@careevolution/mydatahelps-js 5.2.1 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/MyDataHelps.js CHANGED
@@ -59,6 +59,9 @@ class MyDataHelps {
59
59
  if (queryParameters.hasOwnProperty("after")) {
60
60
  queryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);
61
61
  }
62
+ if (queryParameters.hasOwnProperty("event")) {
63
+ queryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);
64
+ }
62
65
  const queryString = new URLSearchParams(queryParameters).toString();
63
66
  const endpoint = 'surveyanswers?' + queryString;
64
67
  const mdh = this;
@@ -124,6 +127,9 @@ class MyDataHelps {
124
127
  if (queryParameters.hasOwnProperty("surveyName")) {
125
128
  queryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);
126
129
  }
130
+ if (queryParameters.hasOwnProperty("event")) {
131
+ queryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);
132
+ }
127
133
  const queryString = new URLSearchParams(queryParameters).toString();
128
134
  const endpoint = 'surveytasks?' + queryString;
129
135
  const mdh = this;
@@ -1,2 +1,2 @@
1
- class e{startSurvey(e,t){if(this.isStandaloneMode()){const n=new URLSearchParams;n.set("surveyName",e),t?.editResultID&&n.set("editResultID",t.editResultID),t?.event&&n.set("event",t.event),this.startDelegatedSurvey(`${this.baseUrl}/survey?${n.toString()}`)}else if(window.webkit.messageHandlers.StartParticipantSurvey){let n=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:n,surveyName:e,options:t})}}completeStep(e){if(null==e&&(e=""),"string"!=typeof e&&(e=JSON.stringify(e)),window.webkit.messageHandlers.ResearchKit)window.webkit.messageHandlers.ResearchKit.postMessage(e);else if(window.webkit.messageHandlers.CompleteStep){let t=this.nextMessageID();window.webkit.messageHandlers.CompleteStep.postMessage({messageID:t,answer:e})}}querySurveyAnswers(t){(t=Object.assign({},t)).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("stepIdentifier")&&(t.stepIdentifier=e.reduceArrayAndEscape(t.stepIdentifier)),t.hasOwnProperty("resultIdentifier")&&(t.resultIdentifier=e.reduceArrayAndEscape(t.resultIdentifier)),t.hasOwnProperty("answer")&&(t.answer=e.reduceArrayAndEscape(t.answer)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after));const n="surveyanswers?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}querySurveyResults(t){(t={...t}).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter));const n="surveyresults?"+new URLSearchParams(t).toString();return this.connect().then((()=>this.makeRequest(n,"GET",null))).then(e.validateResponse).then((e=>e.json()))}deleteSurveyResult(t){const n="surveyresults/"+encodeURIComponent(t),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}querySurveyTasks(t){(t=Object.assign({},t)).hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status)),t.hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName));const n="surveytasks?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryInboxItems(t){(t=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status));const n="inbox?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getInboxItem(t){const n=`inbox/${t}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}updateInboxItem(t,n){const s=`inbox/${t}/${n}`,a=this;return this.connect().then((function(){return a.makeRequest(s,"PUT",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}startEmbeddedSurvey(e,t,n){n||(n=this.getCurrentLanguage());let s=this.baseUrl+"mydatahelps/"+e+"/surveylink/"+t+"?lang="+n;return this.startEmbeddedSurveyInternal(s)}openExternalUrl(e){window.webkit.messageHandlers.OpenExternalLink&&window.webkit.messageHandlers.OpenExternalLink.postMessage(e)}openEmbeddedUrl(e){window.webkit.messageHandlers.OpenEmbeddedLink&&window.webkit.messageHandlers.OpenEmbeddedLink.postMessage(e)}showTab(e){window.webkit.messageHandlers.ShowTab&&window.webkit.messageHandlers.ShowTab.postMessage(e)}openApplication(e,t){if(window.webkit.messageHandlers.OpenExternalApplication){let n=this.nextMessageID();window.webkit.messageHandlers.OpenExternalApplication.postMessage({messageID:n,url:e,modal:!(!t||!t.modal)})}}openSecondaryView(e,t,n){this.lookupSecondaryView(e,t).then((e=>this.openApplication(e.url,n)))}lookupSecondaryView(e,t){let n=this.baseUrl;n.endsWith("/")||(n+="/");return fetch(`${n}api/v1/public/projects/${e}/views/${t}`,{method:"GET",headers:{Accept:"application/json"}}).then((e=>e.ok?e.json():e.text().then((t=>{throw new Error(`Failed to fetch secondary view: ${e.status} ${e.statusText}${t?" - "+t:""}`)}))))}dismiss(){window.webkit.messageHandlers.Dismiss&&window.webkit.messageHandlers.Dismiss.postMessage({})}back(){window.webkit.messageHandlers.PopNavigation&&window.webkit.messageHandlers.PopNavigation.postMessage({})}showDashboard(e,t){window.webkit.messageHandlers.ShowParticipantDashboard&&window.webkit.messageHandlers.ShowParticipantDashboard.postMessage({dashboardKey:e,modal:!(!t||!t.modal),title:t&&t.title?t.title:void 0})}showWebVisualization(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualization&&window.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({visualizationKey:e,parameters:t,modal:!(!n||!n.modal),title:n&&n.title?n.title:void 0})}showWebVisualizationPdf(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF&&window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({visualizationKey:e,parameters:t,landscape:!(!n||!n.landscape),htmlViewerZoom:n&&n.htmlViewerZoom})}showProject(e){window.webkit.messageHandlers.ShowProject&&window.webkit.messageHandlers.ShowProject.postMessage({code:e})}joinProject(e){window.webkit.messageHandlers.JoinProject&&window.webkit.messageHandlers.JoinProject.postMessage({code:e})}on(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");this.registeredEventHandlers[e]||(this.registeredEventHandlers[e]=[]),this.registeredEventHandlers[e].push(t)}off(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");if(!this.registeredEventHandlers[e])return;let n=this.registeredEventHandlers[e].indexOf(t);-1!==n&&this.registeredEventHandlers[e].splice(n,1)}triggerEvent(e){let t=e.type;this.supportedEvents.includes(t)&&this.registeredEventHandlers[t]&&this.registeredEventHandlers[t].forEach((function(t){t(e)}))}setActionResult(e){Object.prototype.hasOwnProperty.call(this.messageHandlers,e.messageID)&&"function"==typeof this.messageHandlers[e.messageID]?this.messageHandlers[e.messageID](e):console.error(`Invalid messageID: ${e.messageID}`)}getParticipantInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("participant","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistParticipantInfo(e,t){const n=this;return this.connect().then((function(){return n.makeRequest("participant","PUT",{demographics:e,customFields:t})})).then((async function(e){if(!e.ok)throw(await e.json()).message;return e.json()})).catch((function(e){console.log("Unable to persist participant: "+e)}))}getProjectInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("project","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceData(t){(t=Object.assign({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter));const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistDeviceData(t){const n=this;return this.connect().then((function(){return n.makeRequest("devicedata","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDeviceDataAllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`;return this.connect().then((()=>this.makeRequest(a,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryDeviceDataV2(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(t){(t=Object.assign({},t)).hasOwnProperty("aggregateFunctions")&&(t.aggregateFunctions=e.reduceArrayAndEscape(t.aggregateFunctions)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(a,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,a){let r={};t&&(r.search=t),n&&(r.category=n),s&&(r.pageSize=s),a&&(r.pageNumber=a);const o="externalaccountproviders?"+new URLSearchParams(r).toString(),i=this;return this.connect().then((function(){return i.makeRequest(o,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}connectExternalAccount(n,s){return new Promise(((a,r)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?a():r(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const a=this;let i;if(s?.openNewWindow){t=`${t.split("?")[0]}?connectExternalAccount=true&messageID=${o}&success=%SUCCESSVALUE%`;let e=null;if(s?.width&&s?.height){const t=s?.width,n=s?.height;e="width="+t+",height="+n+",top="+(window.outerHeight/2+window.screenY-n/2)+",left="+(window.outerWidth/2+window.screenX-t/2)}i=window.open(`${this.baseUrl}home/loading`,"providerauth",e)}const d=new URLSearchParams({finalRedirectPath:t}).toString(),c="externalaccountproviders/"+n+"/connect?"+d;this.connect().then((function(){return a.makeRequest(c,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.text()})).then((function(e){i?i.location=e.replace(/['"]+/g,""):window.top.location=e.replace(/['"]+/g,"")})).catch((function(e){r(e)}))}else window.webkit.messageHandlers.ConnectExternalAccount&&window.webkit.messageHandlers.ConnectExternalAccount.postMessage({externalAccountProviderID:n,messageID:o,...s})}))}getExternalAccounts(){const t=this;return this.connect().then((function(){return t.makeRequest("externalaccounts","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}refreshExternalAccount(t){const n="externalaccounts/refresh/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}deleteExternalAccount(t){const n="externalaccounts/delete/"+encodeURIComponent(t),s=this;return this.isStandaloneMode()?this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})):new Promise((function(e,n){if(window.webkit.messageHandlers.DeleteProviderAccount){const a=s.nextMessageID();s.messageHandlers[a]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:a,accountID:t})}else n()}))}getFeaturedProviders(t){const n={};t&&(n.featuredProvidersContext=t);const s=`featuredexternalaccountproviders?${new URLSearchParams(n).toString()}`;return this.connect().then((()=>this.makeRequest(s,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryNotifications(t){(t=Object.assign({},t)).hasOwnProperty("sentBefore")&&(t.sentBefore=e.convertDateToIsoString(t.sentBefore)),t.hasOwnProperty("sentAfter")&&(t.sentAfter=e.convertDateToIsoString(t.sentAfter));const n="notifications?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitDailySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/dailySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitSleepLogs(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/sleepLogs?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthActivitySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/activitySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthWorkouts(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/workouts?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}uploadFile(t,n,s){if(t.size>209715200)throw new Error("File size exceeds the maximum allowed size of 200MB.");const a=this,r="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return a.makeRequest(r,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()})).then((function(e){return fetch(e.preSignedUrl,{method:"PUT",body:t,headers:{"Content-Type":t.type,"x-amz-server-side-encryption":"AES256"}})})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryFiles(t){const n="files?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getFileDownloadUrl(t){if(!t)throw new Error("Please specify the key of the file to download.");const n="files/download?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteFile(t){if(!t)throw new Error("Please specify the key of the file to delete.");const n="files?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}connect(){const e=this;let t=function(){e.token=null,e.refreshTokenPromise=new Promise((function(n,s){let a=e.nextMessageID();e.messageHandlers[a]=function(r){r.success?(e.tokenExpires=Date.now()+1e3*r.data.expires_in,e.token=r.data,e.baseUrl=r.baseUrl,setTimeout(t,1e3*(r.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(r.message)),e.messageHandlers[a]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:a})}))};if(this.token&&Date.now()<this.tokenExpires)return Promise.resolve();if(this.isStandaloneMode()&&!this.isEmbeddedMode()){let e=this.token?"access token is expired or invalid":"access token must be explicitly provided using the setParticipantAccess method";return console.log(e),Promise.reject(e)}return this.refreshTokenPromise||t(),this.refreshTokenPromise}setParticipantAccessToken(e,t){this.enableStandaloneMode(),this.token=e,t&&(this.baseUrl=t),this.tokenExpires=Date.now()+1e3*this.token.expires_in;const n=this;setTimeout((function(){n.triggerEvent({type:"tokenWillExpire"})}),1e3*(this.token.expires_in-this.accessTokenRenewalBufferSeconds))}isStandaloneMode(){return this.standaloneMode}isEmbeddedMode(){return this.embeddedMode}enableStandaloneMode(e=!1,t){this.standaloneMode=!0,this.embeddedMode=e,t&&(this.baseUrl=t),window.webkit&&(window.webkit.messageHandlers=e?{GetDelegatedAccessToken:window.webkit.messageHandlers.GetDelegatedAccessToken,OpenExternalLink:window.webkit.messageHandlers.OpenExternalLink,OpenEmbeddedLink:window.webkit.messageHandlers.OpenEmbeddedLink,OpenExternalApplication:window.webkit.messageHandlers.OpenExternalApplication,PopNavigation:window.webkit.messageHandlers.PopNavigation,Dismiss:window.webkit.messageHandlers.Dismiss}:{})}setStatusBarStyle(e){window.webkit.messageHandlers.SetStatusBarStyle&&window.webkit.messageHandlers.SetStatusBarStyle.postMessage({style:e})}getDeviceInfo(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetDeviceInfo){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetDeviceInfo.postMessage({messageID:n})}else n()}))}setSupportedLanguages(e){this.supportedLanguages.length=0;for(let t=0;t<e.length;t++)this.supportedLanguages.push(e[t].replace("_","-"))}getStepConfiguration(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetStepConfiguration){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetStepConfiguration.postMessage({messageID:n})}else n()}))}getSurveyContext(){let e=this;return new Promise((function(t,n){e.isStandaloneMode()&&t(null),e.getDeviceInfo().then((function(s){if("Web"!==s.platform)t({surveyMode:"Survey"});else if(window.webkit.messageHandlers.GetSurveyContext){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetSurveyContext.postMessage({messageID:n})}else n()})).catch((function(e){n()}))}))}getCurrentSurveyAnswers(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetCurrentSurveyAnswers){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({messageID:n})}else n()}))}setCurrentLanguage(e){if(e){let t=this.getSupportedLanguage(e);t?this.language=t:console.warn(`language ${e} not supported`)}else this.language=e}getCurrentLanguage(){let e,t=new URLSearchParams(window.location.search);if(t.has("lang")){if(e=this.getSupportedLanguage(t.get("lang")),e)return e;console.warn(`language ${t.get("lang")} not supported`)}return this.language||navigator.language}showGoogleFitSettings(){window.webkit.messageHandlers.ShowGoogleFitSettings&&window.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({})}showHealthConnectSettings(){window.webkit.messageHandlers.HealthConnectSettings&&window.webkit.messageHandlers.HealthConnectSettings.postMessage({})}showHealthConnectPrompt(){window.webkit.messageHandlers.HealthConnectPrompt&&window.webkit.messageHandlers.HealthConnectPrompt.postMessage({})}getHealthConnectStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectStatus.postMessage({messageID:n})}else n()}))}showHealthConnectPhrPrompt(){window.webkit.messageHandlers.HealthConnectPhrPrompt&&window.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({})}getHealthConnectPhrStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectPhrStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({messageID:n})}else n()}))}requestReview(e){window.webkit.messageHandlers.RequestReview&&window.webkit.messageHandlers.RequestReview.postMessage({cooldownDays:e})}trackCustomEvent(t){const n=this;return this.connect().then((function(){return n.makeRequest("customevents","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDataCollectionSettings(){const t=this;return this.connect().then((function(){return t.makeRequest("datacollectionsettings","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDataAvailability(){const t=this;return this.connect().then((function(){return t.makeRequest("dataavailability","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}invokeCustomApi(t,n,s,a){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let r="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();r+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(r,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return a?e.json():void 0}))}constructor(){if(this.baseUrl="https://mydatahelps.org/",this.acceptableParentDomains=["localhost","careevolution.com","internal","b3-deploys.com","mydatahelps.org","platform.joinallofus.org","careevolution.dev","ce.dev","mydatahelps.dev"],this.accessTokenRenewalBufferSeconds=120,this.unsupportedActions=["SetHeight","ResearchKit"],this.supportedEvents=["surveyDidFinish","applicationDidBecomeVisible","externalAccountSyncComplete","tokenWillExpire","healthConnectSyncComplete","healthConnectPhrSyncComplete"],this.supportedLanguages=[],this.currentMessageID=1,this.messageHandlers=[],this.registeredEventHandlers={},this.refreshTokenPromise=null,this.standaloneMode=!1,this.embeddedMode=!1,this.handleConnectExternalAccountResponse())return;let e,t=this,n=function(){let e=document.location.ancestorOrigins;if(e&&e[0])return e[0];return"*"}();function s(e){if("*"===e)return!0;let n=new URL(e);for(let e=0;e<t.acceptableParentDomains.length;e++)if(n.hostname===t.acceptableParentDomains[e]||n.hostname.endsWith("."+t.acceptableParentDomains[e]))return!0;return!1}s(n)||console.log("Detected unsupported parent origin domain."),e=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.ResearchKit?{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},GetSurveyContext:function(e){window.parent.postMessage({name:"GetSurveyContext",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}}:{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},GetDeviceInfo:function(e){window.parent.postMessage({name:"GetDeviceInfo",messageID:e.messageID},n)},StartParticipantSurvey:function(e){window.parent.postMessage({name:"StartParticipantSurvey",messageID:e.messageID,surveyName:e.surveyName,options:e.options},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},OpenExternalApplication:function(e){window.parent.postMessage({name:"OpenApplication",messageID:e.messageID,url:e.url,modal:e.modal},n)},Dismiss:function(){window.parent.postMessage({name:"Dismiss"},n)},PopNavigation:function(){window.parent.postMessage({name:"Back"},n)},ShowTab:function(e){window.parent.postMessage({name:"ShowTab",tabKey:e},n)},ShowParticipantDashboard:function(e){window.parent.postMessage({name:"ShowParticipantDashboard",dashboardKey:e.dashboardKey,modal:e.modal},n)},ShowParticipantWebVisualization:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualization",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal},n)},ShowParticipantWebVisualizationPDF:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualizationPDF",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal,landscape:e.landscape,htmlViewerZoom:e.htmlViewerZoom},n)},DeleteProviderAccount:function(e){window.parent.postMessage({name:"DeleteProviderAccount",messageID:e.messageID,accountID:e.accountID},n)},ConnectExternalAccount:function(e){window.parent.postMessage({name:"ConnectExternalAccount",externalAccountProviderID:e.externalAccountProviderID,messageID:e.messageID,openNewWindow:e.openNewWindow,width:e.width,height:e.height},n)},ShowProject:function(e){window.parent.postMessage({name:"ShowProject",code:e.code},n)},JoinProject:function(e){window.parent.postMessage({name:"JoinProject",code:e.code},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}},window.webkit&&window.webkit.messageHandlers&&function(){for(let t in e)if(window.webkit.messageHandlers[t])return!0;for(let e in t.unsupportedActions)if(window.webkit.messageHandlers[t.unsupportedActions[e]])return!0;return!1}()||(window.webkit={messageHandlers:{}}),function(e){for(let t in e)if(!window.webkit.messageHandlers[t])try{window.webkit.messageHandlers[t]={postMessage:e[t]}}catch(e){return void console.log("Unable to add missing actions on this platform: "+e)}}(e),window.addEventListener("message",(function(e){if(!function(e){return!(!t.isStandaloneMode()||e.origin!==window.location.origin)||("*"===n?s(e.origin):e.origin===n)}(e))throw console.error("message.origin '"+e.origin+"' is not allowed."),"message.origin '"+e.origin+"' is not allowed.";e.data.messageID?t.setActionResult(e.data):t.triggerEvent(e.data)}),!1),this.hasEmbeddedModeUrlParameter()&&t.enableStandaloneMode(!0)}nextMessageID(){return this.currentMessageID++}makeUrl(e,t){if(!this.baseUrl)throw console.error("Cannot use makeUrl without MyDataHelps.baseUrl."),"Cannot use makeUrl without MyDataHelps.baseUrl.";return this.baseUrl+"api/"+t+"/delegated/"+e}makeRequest(e,t,n,s="v1"){if(!this.token||!this.token.access_token)throw"No access_token available for request authorization.";let a=this.makeUrl(e,s),r=new Headers;r.append("Authorization","Bearer "+this.token.access_token),r.append("Accept","application/json, text/javascript, */*; q=0.01"),r.append("Accept-Language",this.getCurrentLanguage()),n&&r.append("Content-Type","application/json");let o={method:t,headers:r};return n&&(o.body=JSON.stringify(n)),fetch(a,o)}getSupportedLanguage(e){return e=e.replace("_","-"),0===this.supportedLanguages.length||this.supportedLanguages.find((t=>t===e))||e.indexOf("-")>0&&(e=e.substring(0,e.indexOf("-")),this.supportedLanguages.find((t=>t===e)))?e:void 0}static validateResponse(e){if(!e.ok)throw e.statusText;return e}static escapeParam(e){return String(e).replaceAll("\\","\\\\").replaceAll(",","\\,")}static reduceArrayAndEscape(t){if(Array.isArray(t)){return t.map((function(t){return e.escapeParam(t)})).join(",")}return this.escapeParam(t)}static convertDateToIsoString(e){let t=new Date(e);if(isNaN(t.getTime()))throw"Cannot interpret parameter as Date";return t.toISOString()}static flattenPropertyShallow(t,n){if(void 0!==t[n]&&null!==t[n]){for(var s in t[n])t[n].hasOwnProperty(s)&&(t[`${n}.${s}`]=e.escapeParam(t[n][s]));delete t[n]}}startEmbeddedSurveyInternal(e){let t="mydatahelps-survey-modal",n=this;return new Promise((function(s,a){if(document.getElementById(t))return void a("Survey already in progress");window.addEventListener("message",(function e(a){if(a.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;a.source===r&&("SurveyWindowInitialized"===a.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===a.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(a.data)))}),!0);let r=document.createElement("div");r.className="mydatahelps-survey-modal",r.id=t,r.innerHTML="<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='"+e+"'></iframe></div>",document.body.append(r),document.body.className+=" no-scroll"}))}startDelegatedSurvey(e){let t="mydatahelps-survey-modal",n=this;if(document.getElementById(t))return;window.addEventListener("message",(function e(s){if(s.origin!==new URL(n.baseUrl).origin)return;let a=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===a&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{a.postMessage({name:"DelegatedAccessTokenResponse",accessToken:n.token,baseUrl:n.baseUrl,participantID:e.participantID},"*")})):"SurveyWindowInitialized"===s.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===s.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s.data.type="surveyDidFinish",n.triggerEvent(s.data)))}),!0);let s=document.createElement("div");s.className="mydatahelps-survey-modal",s.id=t,s.innerHTML=`<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${e}&lang=${n.getCurrentLanguage()}'></iframe></div>`,document.body.append(s),document.body.className+=" no-scroll"}handleConnectExternalAccountResponse(){const e=new URLSearchParams(window.location.search);if(window.opener&&e.get("connectExternalAccount")&&e.get("messageID")&&e.get("success"))return window.opener.postMessage({name:"ConnectExternalAccountResponse",messageID:parseInt(e.get("messageID")),success:"true"===e.get("success")},window.location.origin),window.close(),!0}hasEmbeddedModeUrlParameter(){const e=new URLSearchParams(window.location.search);if(e.has("_e")&&"false"!==e.get("_e"))return!0}}const t=new e;window.MyDataHelps=t,window.RKStudioClient={},window.RKStudioClient.setActionResult=function(e){window.MyDataHelps.setActionResult(e)};export{e as MyDataHelps,t as default};
1
+ class e{startSurvey(e,t){if(this.isStandaloneMode()){const n=new URLSearchParams;n.set("surveyName",e),t?.editResultID&&n.set("editResultID",t.editResultID),t?.event&&n.set("event",t.event),this.startDelegatedSurvey(`${this.baseUrl}/survey?${n.toString()}`)}else if(window.webkit.messageHandlers.StartParticipantSurvey){let n=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:n,surveyName:e,options:t})}}completeStep(e){if(null==e&&(e=""),"string"!=typeof e&&(e=JSON.stringify(e)),window.webkit.messageHandlers.ResearchKit)window.webkit.messageHandlers.ResearchKit.postMessage(e);else if(window.webkit.messageHandlers.CompleteStep){let t=this.nextMessageID();window.webkit.messageHandlers.CompleteStep.postMessage({messageID:t,answer:e})}}querySurveyAnswers(t){(t=Object.assign({},t)).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("stepIdentifier")&&(t.stepIdentifier=e.reduceArrayAndEscape(t.stepIdentifier)),t.hasOwnProperty("resultIdentifier")&&(t.resultIdentifier=e.reduceArrayAndEscape(t.resultIdentifier)),t.hasOwnProperty("answer")&&(t.answer=e.reduceArrayAndEscape(t.answer)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event));const n="surveyanswers?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}querySurveyResults(t){(t={...t}).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter));const n="surveyresults?"+new URLSearchParams(t).toString();return this.connect().then((()=>this.makeRequest(n,"GET",null))).then(e.validateResponse).then((e=>e.json()))}deleteSurveyResult(t){const n="surveyresults/"+encodeURIComponent(t),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}querySurveyTasks(t){(t=Object.assign({},t)).hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status)),t.hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event));const n="surveytasks?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryInboxItems(t){(t=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status));const n="inbox?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getInboxItem(t){const n=`inbox/${t}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}updateInboxItem(t,n){const s=`inbox/${t}/${n}`,a=this;return this.connect().then((function(){return a.makeRequest(s,"PUT",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}startEmbeddedSurvey(e,t,n){n||(n=this.getCurrentLanguage());let s=this.baseUrl+"mydatahelps/"+e+"/surveylink/"+t+"?lang="+n;return this.startEmbeddedSurveyInternal(s)}openExternalUrl(e){window.webkit.messageHandlers.OpenExternalLink&&window.webkit.messageHandlers.OpenExternalLink.postMessage(e)}openEmbeddedUrl(e){window.webkit.messageHandlers.OpenEmbeddedLink&&window.webkit.messageHandlers.OpenEmbeddedLink.postMessage(e)}showTab(e){window.webkit.messageHandlers.ShowTab&&window.webkit.messageHandlers.ShowTab.postMessage(e)}openApplication(e,t){if(window.webkit.messageHandlers.OpenExternalApplication){let n=this.nextMessageID();window.webkit.messageHandlers.OpenExternalApplication.postMessage({messageID:n,url:e,modal:!(!t||!t.modal)})}}openSecondaryView(e,t,n){this.lookupSecondaryView(e,t).then((e=>this.openApplication(e.url,n)))}lookupSecondaryView(e,t){let n=this.baseUrl;n.endsWith("/")||(n+="/");return fetch(`${n}api/v1/public/projects/${e}/views/${t}`,{method:"GET",headers:{Accept:"application/json"}}).then((e=>e.ok?e.json():e.text().then((t=>{throw new Error(`Failed to fetch secondary view: ${e.status} ${e.statusText}${t?" - "+t:""}`)}))))}dismiss(){window.webkit.messageHandlers.Dismiss&&window.webkit.messageHandlers.Dismiss.postMessage({})}back(){window.webkit.messageHandlers.PopNavigation&&window.webkit.messageHandlers.PopNavigation.postMessage({})}showDashboard(e,t){window.webkit.messageHandlers.ShowParticipantDashboard&&window.webkit.messageHandlers.ShowParticipantDashboard.postMessage({dashboardKey:e,modal:!(!t||!t.modal),title:t&&t.title?t.title:void 0})}showWebVisualization(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualization&&window.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({visualizationKey:e,parameters:t,modal:!(!n||!n.modal),title:n&&n.title?n.title:void 0})}showWebVisualizationPdf(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF&&window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({visualizationKey:e,parameters:t,landscape:!(!n||!n.landscape),htmlViewerZoom:n&&n.htmlViewerZoom})}showProject(e){window.webkit.messageHandlers.ShowProject&&window.webkit.messageHandlers.ShowProject.postMessage({code:e})}joinProject(e){window.webkit.messageHandlers.JoinProject&&window.webkit.messageHandlers.JoinProject.postMessage({code:e})}on(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");this.registeredEventHandlers[e]||(this.registeredEventHandlers[e]=[]),this.registeredEventHandlers[e].push(t)}off(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");if(!this.registeredEventHandlers[e])return;let n=this.registeredEventHandlers[e].indexOf(t);-1!==n&&this.registeredEventHandlers[e].splice(n,1)}triggerEvent(e){let t=e.type;this.supportedEvents.includes(t)&&this.registeredEventHandlers[t]&&this.registeredEventHandlers[t].forEach((function(t){t(e)}))}setActionResult(e){Object.prototype.hasOwnProperty.call(this.messageHandlers,e.messageID)&&"function"==typeof this.messageHandlers[e.messageID]?this.messageHandlers[e.messageID](e):console.error(`Invalid messageID: ${e.messageID}`)}getParticipantInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("participant","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistParticipantInfo(e,t){const n=this;return this.connect().then((function(){return n.makeRequest("participant","PUT",{demographics:e,customFields:t})})).then((async function(e){if(!e.ok)throw(await e.json()).message;return e.json()})).catch((function(e){console.log("Unable to persist participant: "+e)}))}getProjectInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("project","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceData(t){(t=Object.assign({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter));const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistDeviceData(t){const n=this;return this.connect().then((function(){return n.makeRequest("devicedata","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDeviceDataAllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`;return this.connect().then((()=>this.makeRequest(a,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryDeviceDataV2(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(t){(t=Object.assign({},t)).hasOwnProperty("aggregateFunctions")&&(t.aggregateFunctions=e.reduceArrayAndEscape(t.aggregateFunctions)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(a,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,a){let r={};t&&(r.search=t),n&&(r.category=n),s&&(r.pageSize=s),a&&(r.pageNumber=a);const o="externalaccountproviders?"+new URLSearchParams(r).toString(),i=this;return this.connect().then((function(){return i.makeRequest(o,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}connectExternalAccount(n,s){return new Promise(((a,r)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?a():r(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const a=this;let i;if(s?.openNewWindow){t=`${t.split("?")[0]}?connectExternalAccount=true&messageID=${o}&success=%SUCCESSVALUE%`;let e=null;if(s?.width&&s?.height){const t=s?.width,n=s?.height;e="width="+t+",height="+n+",top="+(window.outerHeight/2+window.screenY-n/2)+",left="+(window.outerWidth/2+window.screenX-t/2)}i=window.open(`${this.baseUrl}home/loading`,"providerauth",e)}const d=new URLSearchParams({finalRedirectPath:t}).toString(),c="externalaccountproviders/"+n+"/connect?"+d;this.connect().then((function(){return a.makeRequest(c,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.text()})).then((function(e){i?i.location=e.replace(/['"]+/g,""):window.top.location=e.replace(/['"]+/g,"")})).catch((function(e){r(e)}))}else window.webkit.messageHandlers.ConnectExternalAccount&&window.webkit.messageHandlers.ConnectExternalAccount.postMessage({externalAccountProviderID:n,messageID:o,...s})}))}getExternalAccounts(){const t=this;return this.connect().then((function(){return t.makeRequest("externalaccounts","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}refreshExternalAccount(t){const n="externalaccounts/refresh/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}deleteExternalAccount(t){const n="externalaccounts/delete/"+encodeURIComponent(t),s=this;return this.isStandaloneMode()?this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})):new Promise((function(e,n){if(window.webkit.messageHandlers.DeleteProviderAccount){const a=s.nextMessageID();s.messageHandlers[a]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:a,accountID:t})}else n()}))}getFeaturedProviders(t){const n={};t&&(n.featuredProvidersContext=t);const s=`featuredexternalaccountproviders?${new URLSearchParams(n).toString()}`;return this.connect().then((()=>this.makeRequest(s,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryNotifications(t){(t=Object.assign({},t)).hasOwnProperty("sentBefore")&&(t.sentBefore=e.convertDateToIsoString(t.sentBefore)),t.hasOwnProperty("sentAfter")&&(t.sentAfter=e.convertDateToIsoString(t.sentAfter));const n="notifications?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitDailySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/dailySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitSleepLogs(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/sleepLogs?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthActivitySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/activitySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthWorkouts(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/workouts?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}uploadFile(t,n,s){if(t.size>209715200)throw new Error("File size exceeds the maximum allowed size of 200MB.");const a=this,r="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return a.makeRequest(r,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()})).then((function(e){return fetch(e.preSignedUrl,{method:"PUT",body:t,headers:{"Content-Type":t.type,"x-amz-server-side-encryption":"AES256"}})})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryFiles(t){const n="files?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getFileDownloadUrl(t){if(!t)throw new Error("Please specify the key of the file to download.");const n="files/download?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteFile(t){if(!t)throw new Error("Please specify the key of the file to delete.");const n="files?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}connect(){const e=this;let t=function(){e.token=null,e.refreshTokenPromise=new Promise((function(n,s){let a=e.nextMessageID();e.messageHandlers[a]=function(r){r.success?(e.tokenExpires=Date.now()+1e3*r.data.expires_in,e.token=r.data,e.baseUrl=r.baseUrl,setTimeout(t,1e3*(r.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(r.message)),e.messageHandlers[a]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:a})}))};if(this.token&&Date.now()<this.tokenExpires)return Promise.resolve();if(this.isStandaloneMode()&&!this.isEmbeddedMode()){let e=this.token?"access token is expired or invalid":"access token must be explicitly provided using the setParticipantAccess method";return console.log(e),Promise.reject(e)}return this.refreshTokenPromise||t(),this.refreshTokenPromise}setParticipantAccessToken(e,t){this.enableStandaloneMode(),this.token=e,t&&(this.baseUrl=t),this.tokenExpires=Date.now()+1e3*this.token.expires_in;const n=this;setTimeout((function(){n.triggerEvent({type:"tokenWillExpire"})}),1e3*(this.token.expires_in-this.accessTokenRenewalBufferSeconds))}isStandaloneMode(){return this.standaloneMode}isEmbeddedMode(){return this.embeddedMode}enableStandaloneMode(e=!1,t){this.standaloneMode=!0,this.embeddedMode=e,t&&(this.baseUrl=t),window.webkit&&(window.webkit.messageHandlers=e?{GetDelegatedAccessToken:window.webkit.messageHandlers.GetDelegatedAccessToken,OpenExternalLink:window.webkit.messageHandlers.OpenExternalLink,OpenEmbeddedLink:window.webkit.messageHandlers.OpenEmbeddedLink,OpenExternalApplication:window.webkit.messageHandlers.OpenExternalApplication,PopNavigation:window.webkit.messageHandlers.PopNavigation,Dismiss:window.webkit.messageHandlers.Dismiss}:{})}setStatusBarStyle(e){window.webkit.messageHandlers.SetStatusBarStyle&&window.webkit.messageHandlers.SetStatusBarStyle.postMessage({style:e})}getDeviceInfo(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetDeviceInfo){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetDeviceInfo.postMessage({messageID:n})}else n()}))}setSupportedLanguages(e){this.supportedLanguages.length=0;for(let t=0;t<e.length;t++)this.supportedLanguages.push(e[t].replace("_","-"))}getStepConfiguration(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetStepConfiguration){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetStepConfiguration.postMessage({messageID:n})}else n()}))}getSurveyContext(){let e=this;return new Promise((function(t,n){e.isStandaloneMode()&&t(null),e.getDeviceInfo().then((function(s){if("Web"!==s.platform)t({surveyMode:"Survey"});else if(window.webkit.messageHandlers.GetSurveyContext){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetSurveyContext.postMessage({messageID:n})}else n()})).catch((function(e){n()}))}))}getCurrentSurveyAnswers(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetCurrentSurveyAnswers){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({messageID:n})}else n()}))}setCurrentLanguage(e){if(e){let t=this.getSupportedLanguage(e);t?this.language=t:console.warn(`language ${e} not supported`)}else this.language=e}getCurrentLanguage(){let e,t=new URLSearchParams(window.location.search);if(t.has("lang")){if(e=this.getSupportedLanguage(t.get("lang")),e)return e;console.warn(`language ${t.get("lang")} not supported`)}return this.language||navigator.language}showGoogleFitSettings(){window.webkit.messageHandlers.ShowGoogleFitSettings&&window.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({})}showHealthConnectSettings(){window.webkit.messageHandlers.HealthConnectSettings&&window.webkit.messageHandlers.HealthConnectSettings.postMessage({})}showHealthConnectPrompt(){window.webkit.messageHandlers.HealthConnectPrompt&&window.webkit.messageHandlers.HealthConnectPrompt.postMessage({})}getHealthConnectStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectStatus.postMessage({messageID:n})}else n()}))}showHealthConnectPhrPrompt(){window.webkit.messageHandlers.HealthConnectPhrPrompt&&window.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({})}getHealthConnectPhrStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectPhrStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({messageID:n})}else n()}))}requestReview(e){window.webkit.messageHandlers.RequestReview&&window.webkit.messageHandlers.RequestReview.postMessage({cooldownDays:e})}trackCustomEvent(t){const n=this;return this.connect().then((function(){return n.makeRequest("customevents","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDataCollectionSettings(){const t=this;return this.connect().then((function(){return t.makeRequest("datacollectionsettings","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDataAvailability(){const t=this;return this.connect().then((function(){return t.makeRequest("dataavailability","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}invokeCustomApi(t,n,s,a){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let r="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();r+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(r,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return a?e.json():void 0}))}constructor(){if(this.baseUrl="https://mydatahelps.org/",this.acceptableParentDomains=["localhost","careevolution.com","internal","b3-deploys.com","mydatahelps.org","platform.joinallofus.org","careevolution.dev","ce.dev","mydatahelps.dev"],this.accessTokenRenewalBufferSeconds=120,this.unsupportedActions=["SetHeight","ResearchKit"],this.supportedEvents=["surveyDidFinish","applicationDidBecomeVisible","externalAccountSyncComplete","tokenWillExpire","healthConnectSyncComplete","healthConnectPhrSyncComplete"],this.supportedLanguages=[],this.currentMessageID=1,this.messageHandlers=[],this.registeredEventHandlers={},this.refreshTokenPromise=null,this.standaloneMode=!1,this.embeddedMode=!1,this.handleConnectExternalAccountResponse())return;let e,t=this,n=function(){let e=document.location.ancestorOrigins;if(e&&e[0])return e[0];return"*"}();function s(e){if("*"===e)return!0;let n=new URL(e);for(let e=0;e<t.acceptableParentDomains.length;e++)if(n.hostname===t.acceptableParentDomains[e]||n.hostname.endsWith("."+t.acceptableParentDomains[e]))return!0;return!1}s(n)||console.log("Detected unsupported parent origin domain."),e=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.ResearchKit?{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},GetSurveyContext:function(e){window.parent.postMessage({name:"GetSurveyContext",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}}:{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},GetDeviceInfo:function(e){window.parent.postMessage({name:"GetDeviceInfo",messageID:e.messageID},n)},StartParticipantSurvey:function(e){window.parent.postMessage({name:"StartParticipantSurvey",messageID:e.messageID,surveyName:e.surveyName,options:e.options},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},OpenExternalApplication:function(e){window.parent.postMessage({name:"OpenApplication",messageID:e.messageID,url:e.url,modal:e.modal},n)},Dismiss:function(){window.parent.postMessage({name:"Dismiss"},n)},PopNavigation:function(){window.parent.postMessage({name:"Back"},n)},ShowTab:function(e){window.parent.postMessage({name:"ShowTab",tabKey:e},n)},ShowParticipantDashboard:function(e){window.parent.postMessage({name:"ShowParticipantDashboard",dashboardKey:e.dashboardKey,modal:e.modal},n)},ShowParticipantWebVisualization:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualization",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal},n)},ShowParticipantWebVisualizationPDF:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualizationPDF",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal,landscape:e.landscape,htmlViewerZoom:e.htmlViewerZoom},n)},DeleteProviderAccount:function(e){window.parent.postMessage({name:"DeleteProviderAccount",messageID:e.messageID,accountID:e.accountID},n)},ConnectExternalAccount:function(e){window.parent.postMessage({name:"ConnectExternalAccount",externalAccountProviderID:e.externalAccountProviderID,messageID:e.messageID,openNewWindow:e.openNewWindow,width:e.width,height:e.height},n)},ShowProject:function(e){window.parent.postMessage({name:"ShowProject",code:e.code},n)},JoinProject:function(e){window.parent.postMessage({name:"JoinProject",code:e.code},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}},window.webkit&&window.webkit.messageHandlers&&function(){for(let t in e)if(window.webkit.messageHandlers[t])return!0;for(let e in t.unsupportedActions)if(window.webkit.messageHandlers[t.unsupportedActions[e]])return!0;return!1}()||(window.webkit={messageHandlers:{}}),function(e){for(let t in e)if(!window.webkit.messageHandlers[t])try{window.webkit.messageHandlers[t]={postMessage:e[t]}}catch(e){return void console.log("Unable to add missing actions on this platform: "+e)}}(e),window.addEventListener("message",(function(e){if(!function(e){return!(!t.isStandaloneMode()||e.origin!==window.location.origin)||("*"===n?s(e.origin):e.origin===n)}(e))throw console.error("message.origin '"+e.origin+"' is not allowed."),"message.origin '"+e.origin+"' is not allowed.";e.data.messageID?t.setActionResult(e.data):t.triggerEvent(e.data)}),!1),this.hasEmbeddedModeUrlParameter()&&t.enableStandaloneMode(!0)}nextMessageID(){return this.currentMessageID++}makeUrl(e,t){if(!this.baseUrl)throw console.error("Cannot use makeUrl without MyDataHelps.baseUrl."),"Cannot use makeUrl without MyDataHelps.baseUrl.";return this.baseUrl+"api/"+t+"/delegated/"+e}makeRequest(e,t,n,s="v1"){if(!this.token||!this.token.access_token)throw"No access_token available for request authorization.";let a=this.makeUrl(e,s),r=new Headers;r.append("Authorization","Bearer "+this.token.access_token),r.append("Accept","application/json, text/javascript, */*; q=0.01"),r.append("Accept-Language",this.getCurrentLanguage()),n&&r.append("Content-Type","application/json");let o={method:t,headers:r};return n&&(o.body=JSON.stringify(n)),fetch(a,o)}getSupportedLanguage(e){return e=e.replace("_","-"),0===this.supportedLanguages.length||this.supportedLanguages.find((t=>t===e))||e.indexOf("-")>0&&(e=e.substring(0,e.indexOf("-")),this.supportedLanguages.find((t=>t===e)))?e:void 0}static validateResponse(e){if(!e.ok)throw e.statusText;return e}static escapeParam(e){return String(e).replaceAll("\\","\\\\").replaceAll(",","\\,")}static reduceArrayAndEscape(t){if(Array.isArray(t)){return t.map((function(t){return e.escapeParam(t)})).join(",")}return this.escapeParam(t)}static convertDateToIsoString(e){let t=new Date(e);if(isNaN(t.getTime()))throw"Cannot interpret parameter as Date";return t.toISOString()}static flattenPropertyShallow(t,n){if(void 0!==t[n]&&null!==t[n]){for(var s in t[n])t[n].hasOwnProperty(s)&&(t[`${n}.${s}`]=e.escapeParam(t[n][s]));delete t[n]}}startEmbeddedSurveyInternal(e){let t="mydatahelps-survey-modal",n=this;return new Promise((function(s,a){if(document.getElementById(t))return void a("Survey already in progress");window.addEventListener("message",(function e(a){if(a.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;a.source===r&&("SurveyWindowInitialized"===a.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===a.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(a.data)))}),!0);let r=document.createElement("div");r.className="mydatahelps-survey-modal",r.id=t,r.innerHTML="<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='"+e+"'></iframe></div>",document.body.append(r),document.body.className+=" no-scroll"}))}startDelegatedSurvey(e){let t="mydatahelps-survey-modal",n=this;if(document.getElementById(t))return;window.addEventListener("message",(function e(s){if(s.origin!==new URL(n.baseUrl).origin)return;let a=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===a&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{a.postMessage({name:"DelegatedAccessTokenResponse",accessToken:n.token,baseUrl:n.baseUrl,participantID:e.participantID},"*")})):"SurveyWindowInitialized"===s.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===s.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s.data.type="surveyDidFinish",n.triggerEvent(s.data)))}),!0);let s=document.createElement("div");s.className="mydatahelps-survey-modal",s.id=t,s.innerHTML=`<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${e}&lang=${n.getCurrentLanguage()}'></iframe></div>`,document.body.append(s),document.body.className+=" no-scroll"}handleConnectExternalAccountResponse(){const e=new URLSearchParams(window.location.search);if(window.opener&&e.get("connectExternalAccount")&&e.get("messageID")&&e.get("success"))return window.opener.postMessage({name:"ConnectExternalAccountResponse",messageID:parseInt(e.get("messageID")),success:"true"===e.get("success")},window.location.origin),window.close(),!0}hasEmbeddedModeUrlParameter(){const e=new URLSearchParams(window.location.search);if(e.has("_e")&&"false"!==e.get("_e"))return!0}}const t=new e;window.MyDataHelps=t,window.RKStudioClient={},window.RKStudioClient.setActionResult=function(e){window.MyDataHelps.setActionResult(e)};export{e as MyDataHelps,t as default};
2
2
  //# sourceMappingURL=MyDataHelps.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MyDataHelps.min.js","sources":["../../src/MyDataHelps.ts"],"sourcesContent":["// @ts-ignore : let rollup handle CSS injection\nimport \"../MyDataHelps.css\";\n\nimport * as Model from \"./types\";\nimport { StringMap } from \"./types\";\n\nexport class MyDataHelps {\n\n\tbaseUrl: string = 'https://mydatahelps.org/';\n\tlanguage: string;\n\ttoken: Model.Token;\n\ttokenExpires: number;\n\n\t// Surveys\n\n\tstartSurvey(surveyName: string, options?: Model.StartSurveyOptions): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tconst params = new URLSearchParams();\n\t\t\tparams.set('surveyName', surveyName);\n\t\t\tif (options?.editResultID) {\n\t\t\t\tparams.set('editResultID', options.editResultID);\n\t\t\t}\n\t\t\tif (options?.event) {\n\t\t\t\tparams.set('event', options.event);\n\t\t\t}\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?${params.toString()}`);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.StartParticipantSurvey) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.StartParticipantSurvey.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tsurveyName: surveyName,\n\t\t\t\toptions: options\n\t\t\t});\n\t\t}\n\t}\n\n\tcompleteStep(answer: any): void {\n\t\tif (answer === undefined || answer === null) answer = '';\n\t\tif (typeof answer !== 'string') {\n\t\t\tanswer = JSON.stringify(answer);\n\t\t}\n\t\tif (window.webkit.messageHandlers.ResearchKit) {\n\t\t\twindow.webkit.messageHandlers.ResearchKit.postMessage(answer);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.CompleteStep) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.CompleteStep.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tanswer: answer\n\t\t\t});\n\t\t}\n\t}\n\n\tquerySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"stepIdentifier\")) {\n\t\t\tqueryParameters.stepIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.stepIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"resultIdentifier\")) {\n\t\t\tqueryParameters.resultIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.resultIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"answer\")) {\n\t\t\tqueryParameters.answer = MyDataHelps.reduceArrayAndEscape(queryParameters.answer);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyanswers?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tquerySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage> {\n\t\tqueryParameters = { ...queryParameters }\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyresults?' + queryString;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\topenSecondaryView(projectId: string, viewKey: string, options?: Model.OpenApplicationOptions): void {\n\t\tthis.lookupSecondaryView(projectId, viewKey).then(secondaryView => {\n\t\t\treturn this.openApplication(secondaryView.url, options);\n\t\t});\n\t};\n\n\tlookupSecondaryView(projectId: string, viewKey: string): Promise<Model.SecondaryView> {\n\t\tlet baseUrl = this.baseUrl;\n\t\tif (!baseUrl.endsWith(\"/\")) {\n\t\t\tbaseUrl += \"/\";\n\t\t}\n\t\tconst viewLookupUrl = `${baseUrl}api/v1/public/projects/${projectId}/views/${viewKey}`;\n\t\treturn fetch(viewLookupUrl, { method: 'GET', headers: { 'Accept': 'application/json' } })\n\t\t\t.then(response => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\treturn response.text().then(text => {\n\t\t\t\t\t\tthrow new Error(`Failed to fetch secondary view: ${response.status} ${response.statusText}${text ? ' - ' + text : ''}`);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDeviceDataAllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetFeaturedProviders(context?: string): Promise<Model.ExternalAccountProvider[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (context) {\n\t\t\tqueryParameters['featuredProvidersContext'] = context;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `featuredexternalaccountproviders?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Notifications\n\n\tqueryNotifications(queryParameters: Model.NotificationQueryParameters): Promise<Model.NotificationsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"sentBefore\")) {\n\t\t\tqueryParameters.sentBefore = MyDataHelps.convertDateToIsoString(queryParameters.sentBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"sentAfter\")) {\n\t\t\tqueryParameters.sentAfter = MyDataHelps.convertDateToIsoString(queryParameters.sentAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'notifications?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Fitbit\n\n\tqueryFitbitDailySummaries(queryParameters: Model.FitbitQuery): Promise<Model.FitbitDailySummariesPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/dailySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryFitbitSleepLogs(queryParameters: Model.FitbitQuery): Promise<Model.FitbitSleepLogsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/sleepLogs?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// AppleHealth\n\n\tqueryAppleHealthActivitySummaries(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthActivitySummaryPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/activitySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryAppleHealthWorkouts(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthWorkoutPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/workouts?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Files\n\n\tuploadFile(file: File, category: string, fileName?: string): Promise<void> {\n\n\t\tif (file.size > 200 * 1024 * 1024) {\n\t\t\tthrow new Error(\"File size exceeds the maximum allowed size of 200MB.\");\n\t\t}\n\n\t\tconst mdh = this;\n\t\tconst endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.then(function (json) {\n\t\t\t\treturn fetch(json.preSignedUrl, {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\tbody: file,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t\t'x-amz-server-side-encryption': 'AES256'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryFiles(queryParameters: Model.UploadedFileQuery): Promise<Model.UploadedFilesPage> {\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'files?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetFileDownloadUrl(key: string): Promise<Model.DownloadedFile> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to download.\");\n\n\t\tconst endpoint = 'files/download?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteFile(key: string): Promise<void> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to delete.\");\n\n\t\tconst endpoint = 'files?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Authorization\n\n\tconnect(): Promise<void> {\n\t\tconst mdh = this;\n\t\tlet refreshDelegatedAccessToken = function () {\n\t\t\tmdh.token = null;\n\n\t\t\tmdh.refreshTokenPromise = new Promise(function (resolve, reject) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (tokenResponse) {\n\t\t\t\t\tif (tokenResponse.success) {\n\t\t\t\t\t\tmdh.tokenExpires = Date.now() + (tokenResponse.data.expires_in * 1000);\n\t\t\t\t\t\tmdh.token = tokenResponse.data;\n\t\t\t\t\t\tmdh.baseUrl = tokenResponse.baseUrl;\n\t\t\t\t\t\tsetTimeout(refreshDelegatedAccessToken, ((tokenResponse.data.expires_in - mdh.accessTokenRenewalBufferSeconds) * 1000));\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmdh.token = null;\n\t\t\t\t\t\treject(tokenResponse.message);\n\t\t\t\t\t}\n\t\t\t\t\tmdh.messageHandlers[messageID] = null;\n\t\t\t\t\tmdh.refreshTokenPromise = null;\n\t\t\t\t};\n\n\t\t\t\twindow.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({ messageID: messageID });\n\t\t\t});\n\t\t};\n\n\t\tif (this.token && Date.now() < this.tokenExpires) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tif (this.isStandaloneMode() && !this.isEmbeddedMode()) {\n\t\t\tlet error = this.token ? \"access token is expired or invalid\" : \"access token must be explicitly provided using the setParticipantAccess method\";\n\t\t\tconsole.log(error);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\n\t\tif (!this.refreshTokenPromise) {\n\t\t\trefreshDelegatedAccessToken();\n\t\t}\n\n\t\t// Re-use promise if refresh already in progress\n\t\treturn this.refreshTokenPromise;\n\t}\n\n\tsetParticipantAccessToken(token: Model.Token, baseUrl?: string): void {\n\t\tthis.enableStandaloneMode();\n\t\tthis.token = token;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tthis.tokenExpires = Date.now() + (this.token.expires_in * 1000);\n\t\tconst mdh = this;\n\t\tsetTimeout(function () {\n\t\t\tmdh.triggerEvent({ type: \"tokenWillExpire\" });\n\t\t}, ((this.token.expires_in - this.accessTokenRenewalBufferSeconds) * 1000));\n\t}\n\n\t// Miscellaneous\n\n\tisStandaloneMode() {\n\t\treturn this.standaloneMode;\n\t}\n\n\tisEmbeddedMode() {\n\t\treturn this.embeddedMode;\n\t}\n\n\tenableStandaloneMode(embeddedMode: boolean = false, baseUrl?: string) {\n\t\tthis.standaloneMode = true;\n\t\tthis.embeddedMode = embeddedMode;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tif (window.webkit) {\n\t\t\twindow.webkit.messageHandlers = embeddedMode ? {\n\t\t\t\tGetDelegatedAccessToken: window.webkit.messageHandlers.GetDelegatedAccessToken,\n\t\t\t\tOpenExternalLink: window.webkit.messageHandlers.OpenExternalLink,\n\t\t\t\tOpenEmbeddedLink: window.webkit.messageHandlers.OpenEmbeddedLink,\n\t\t\t\tOpenExternalApplication: window.webkit.messageHandlers.OpenExternalApplication,\n\t\t\t\tPopNavigation: window.webkit.messageHandlers.PopNavigation,\n\t\t\t\tDismiss: window.webkit.messageHandlers.Dismiss,\n\t\t\t} : {};\n\t\t}\n\t}\n\n\tsetStatusBarStyle(style: Model.StatusBarStyle): void {\n\t\tif (window.webkit.messageHandlers.SetStatusBarStyle) {\n\t\t\twindow.webkit.messageHandlers.SetStatusBarStyle.postMessage({ style: style });\n\t\t}\n\t}\n\n\tgetDeviceInfo(): Promise<Model.DeviceInfo> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.DeviceInfo>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetDeviceInfo) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deviceInfoResponse) {\n\t\t\t\t\tresolve(deviceInfoResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetDeviceInfo.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSupportedLanguages(languages: string[]) {\n\t\tthis.supportedLanguages.length = 0;\n\t\tfor (let i = 0; i < languages.length; i++) {\n\t\t\tthis.supportedLanguages.push(languages[i].replace(\"_\", \"-\"));\n\t\t}\n\t}\n\n\tgetStepConfiguration(): Promise<Model.StepConfiguration> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.StepConfiguration>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetStepConfiguration) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (stepConfigurationResponse) {\n\t\t\t\t\tresolve(stepConfigurationResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetStepConfiguration.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSurveyContext(): Promise<Model.SurveyContext> {\n\t\tlet mdh = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t\tmdh.getDeviceInfo().then(function (deviceInfo) {\n\t\t\t\tif (deviceInfo.platform !== \"Web\") {\n\t\t\t\t\tresolve({ surveyMode: \"Survey\" });\n\t\t\t\t}\n\t\t\t\telse if (window.webkit.messageHandlers.GetSurveyContext) {\n\t\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\t\tmdh.messageHandlers[messageID] = function (surveyContextResponse) {\n\t\t\t\t\t\tresolve(surveyContextResponse.data);\n\t\t\t\t\t};\n\t\t\t\t\twindow.webkit.messageHandlers.GetSurveyContext.postMessage({ messageID: messageID });\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t}).catch(function (error) {\n\t\t\t\treject();\n\t\t\t});\n\t\t});\n\t}\n\n\tgetCurrentSurveyAnswers(): Promise<Model.CurrentSurveyAnswer[]> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.CurrentSurveyAnswer[]>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetCurrentSurveyAnswers) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (currentSurveyAnswersResponse) {\n\t\t\t\t\tresolve(currentSurveyAnswersResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetCurrentLanguage(language: string) {\n\t\tif (language) {\n\t\t\tlet supportedLanguage = this.getSupportedLanguage(language);\n\t\t\tif (supportedLanguage) {\n\t\t\t\tthis.language = supportedLanguage;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${language} not supported`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.language = language;\n\t\t}\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\tlet searchParams = new URLSearchParams(window.location.search);\n\t\tlet lang;\n\t\tif (searchParams.has(\"lang\")) {\n\t\t\tlang = this.getSupportedLanguage(searchParams.get(\"lang\"));\n\t\t\tif (lang) {\n\t\t\t\treturn lang;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${searchParams.get(\"lang\")} not supported`);\n\t\t\t}\n\t\t}\n\t\treturn this.language || navigator.language;\n\t}\n\n\tshowGoogleFitSettings(): void {\n\t\tif (window.webkit.messageHandlers.ShowGoogleFitSettings) {\n\t\t\twindow.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectSettings(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectSettings) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectStatus(): Promise<Model.HealthConnectStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tshowHealthConnectPhrPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPhrPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectPhrStatus(): Promise<Model.HealthConnectPhrStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectPhrStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectPhrStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\trequestReview(cooldownDays?: number): void {\n\t\tif (window.webkit.messageHandlers.RequestReview) {\n\t\t\twindow.webkit.messageHandlers.RequestReview.postMessage({ cooldownDays: cooldownDays });\n\t\t}\n\t}\n\n\ttrackCustomEvent(event: Model.CustomEventInfo): Promise<void> {\n\t\tconst endpoint = 'customevents';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', event);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDataCollectionSettings(): Promise<Model.DataCollectionSettings> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'datacollectionsettings';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDataAvailability(): Promise<Model.DataAvailability> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'dataavailability';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tinvokeCustomApi(customApi: string, method: string, queryParameters: string | string[][] | Record<string, string> | URLSearchParams | null | undefined, jsonResponse: boolean): Promise<any> {\n\t\tif (customApi.includes('?')) {\n\t\t\tthrow new Error(\"Cannot include query parameters directly in the \\\"customApi\\\" string. Provide as an argument for \\\"queryParameters\\\" instead.\");\n\t\t}\n\n\t\tlet endpoint = 'custom/' + customApi;\n\t\tmethod = method.toUpperCase();\n\t\tif (queryParameters !== null && queryParameters !== undefined && (method === 'GET' || method === 'DELETE')) {\n\t\t\tlet parameterString = new URLSearchParams(queryParameters).toString();\n\t\t\tendpoint += \"?\" + parameterString;\n\t\t\tqueryParameters = null;\n\t\t}\n\n\t\tconst mdh = this;\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, method, queryParameters);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn jsonResponse ? response.json() : undefined;\n\t\t\t});\n\t}\n\n\tconstructor() {\n\t\tif (this.handleConnectExternalAccountResponse()) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet mdh = this;\n\t\tlet applicationHost = getParentOrigin();\n\t\tlet supportedActions;\n\n\t\tfunction getParentOrigin(): string {\n\t\t\tlet ancestorOrigins = document.location.ancestorOrigins;\n\t\t\tif (ancestorOrigins && ancestorOrigins[0]) {\n\t\t\t\treturn ancestorOrigins[0];\n\t\t\t}\n\n\t\t\treturn '*';\n\t\t}\n\n\t\tfunction acceptableOrigin(origin) {\n\t\t\tif (origin === '*') return true;\n\n\t\t\tlet sourceURL = new URL(origin);\n\t\t\tfor (let k = 0; k < mdh.acceptableParentDomains.length; k++) {\n\t\t\t\tif (sourceURL.hostname === mdh.acceptableParentDomains[k] || sourceURL.hostname.endsWith(\".\" + mdh.acceptableParentDomains[k])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction validateWindowMessageOrigin(message) {\n\t\t\tif (mdh.isStandaloneMode() && message.origin === window.location.origin) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (applicationHost === \"*\") {\n\t\t\t\treturn acceptableOrigin(message.origin);\n\t\t\t}\n\n\t\t\treturn message.origin === applicationHost;\n\t\t}\n\n\t\tfunction addActions(actions) {\n\t\t\tfor (let action in actions) {\n\t\t\t\tif (!window.webkit.messageHandlers[action]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twindow.webkit.messageHandlers[action] = { postMessage: actions[action] };\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.log(\"Unable to add missing actions on this platform: \" + error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction receiveWindowMessage(message) {\n\t\t\tif (!validateWindowMessageOrigin(message)) {\n\t\t\t\t// todo: this can generate tons of console errors when hosting some apps within webappstep (youtube content, for example )\n\t\t\t\tconsole.error(\"message.origin '\" + message.origin + \"' is not allowed.\");\n\t\t\t\tthrow \"message.origin '\" + message.origin + \"' is not allowed.\";\n\t\t\t}\n\n\t\t\tif (message.data.messageID) {\n\t\t\t\tmdh.setActionResult(message.data);\n\t\t\t} else {\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}\n\n\t\tfunction windowHasAnyActions() {\n\t\t\tfor (let action in supportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[action]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let action in mdh.unsupportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[mdh.unsupportedActions[action]]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!acceptableOrigin(applicationHost)) {\n\t\t\tconsole.log(\"Detected unsupported parent origin domain.\");\n\t\t}\n\n\t\tif (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ResearchKit) {\n\t\t\t// Presence of ResearchKit handler indicates the SDK is being used from within a WebViewStep. For pre-SDK backwards compatiblity,\n\t\t\t// WebViewStep setup registers the following handlers: GetDeviceInfo, DeleteProviderAccount, ConnectExternalAccount\n\t\t\t// ShowParticipantWebVisualizationPDF, ResearchKit\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenExternalUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenEmbeddedUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetSurveyContext\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetSurveyContext',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost);\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetDeviceInfo\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'GetDeviceInfo', messageID: data.messageID }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"StartParticipantSurvey\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'StartParticipantSurvey',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tsurveyName: data.surveyName,\n\t\t\t\t\t\toptions: data.options\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenExternalUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenEmbeddedUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalApplication\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenApplication',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"Dismiss\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Dismiss' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"PopNavigation\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Back' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowTab\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowTab', tabKey: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantDashboard\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantDashboard',\n\t\t\t\t\t\tdashboardKey: data.dashboardKey,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualization\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualization',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualizationPDF\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualizationPDF',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal,\n\t\t\t\t\t\tlandscape: data.landscape,\n\t\t\t\t\t\thtmlViewerZoom: data.htmlViewerZoom\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"DeleteProviderAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'DeleteProviderAccount',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\taccountID: data.accountID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ConnectExternalAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ConnectExternalAccount',\n\t\t\t\t\t\texternalAccountProviderID: data.externalAccountProviderID,\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\topenNewWindow: data.openNewWindow,\n\t\t\t\t\t\twidth: data.width,\n\t\t\t\t\t\theight: data.height\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"JoinProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'JoinProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!window.webkit || !window.webkit.messageHandlers || !windowHasAnyActions()) {\n\t\t\twindow.webkit = {\n\t\t\t\tmessageHandlers: {}\n\t\t\t};\n\t\t}\n\n\t\taddActions(supportedActions);\n\n\t\twindow.addEventListener(\"message\", receiveWindowMessage, false);\n\n\t\tif (this.hasEmbeddedModeUrlParameter()) {\n\t\t\tmdh.enableStandaloneMode(true);\n\t\t}\n\t}\n\n\tprivate readonly acceptableParentDomains = [\n\t\t'localhost',\n\t\t'careevolution.com',\n\t\t'internal',\n\t\t'b3-deploys.com',\n\t\t'mydatahelps.org',\n\t\t'platform.joinallofus.org',\n\t\t'careevolution.dev',\n\t\t'ce.dev',\n\t\t'mydatahelps.dev'\n\t];\n\n\tprivate readonly accessTokenRenewalBufferSeconds = 120;\n\tprivate readonly unsupportedActions = [\"SetHeight\", \"ResearchKit\"];\n\tprivate readonly supportedEvents = [\"surveyDidFinish\", \"applicationDidBecomeVisible\", \"externalAccountSyncComplete\", \"tokenWillExpire\", \"healthConnectSyncComplete\", \"healthConnectPhrSyncComplete\"];\n\tprivate readonly supportedLanguages = [];\n\n\tprivate currentMessageID = 1;\n\tprivate messageHandlers = [];\n\tprivate registeredEventHandlers = {};\n\tprivate refreshTokenPromise = null;\n\tprivate standaloneMode = false;\n\tprivate embeddedMode = false;\n\n\tprivate nextMessageID() {\n\t\treturn this.currentMessageID++;\n\t}\n\n\tprivate makeUrl(endpoint, apiVersion) {\n\t\tif (!this.baseUrl) {\n\t\t\tconsole.error(\"Cannot use makeUrl without MyDataHelps.baseUrl.\");\n\t\t\tthrow \"Cannot use makeUrl without MyDataHelps.baseUrl.\";\n\t\t}\n\n\t\treturn this.baseUrl + 'api/' + apiVersion + '/delegated/' + endpoint;\n\t}\n\n\tprivate makeRequest(endpoint, method, body, apiVersion = \"v1\") {\n\t\tif (!this.token || !this.token.access_token) {\n\t\t\tthrow \"No access_token available for request authorization.\";\n\t\t}\n\n\t\tlet url = this.makeUrl(endpoint, apiVersion);\n\n\t\tlet headers = new Headers();\n\t\theaders.append('Authorization', 'Bearer ' + this.token.access_token);\n\t\theaders.append('Accept', 'application/json, text/javascript, */*; q=0.01');\n\t\theaders.append('Accept-Language', this.getCurrentLanguage());\n\t\tif (!!body) {\n\t\t\theaders.append('Content-Type', 'application/json');\n\t\t}\n\n\t\tlet init: any = {\n\t\t\tmethod: method,\n\t\t\theaders: headers\n\t\t};\n\t\tif (!!body) {\n\t\t\tinit.body = JSON.stringify(body);\n\t\t}\n\n\t\treturn fetch(url, init);\n\t}\n\n\tprivate getSupportedLanguage(language: string): string {\n\t\tlanguage = language.replace(\"_\", \"-\");\n\t\tif (this.supportedLanguages.length === 0) {\n\t\t\treturn language;\n\t\t} else {\n\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\treturn language;\n\t\t\t} else if (language.indexOf(\"-\") > 0) {\n\t\t\t\tlanguage = language.substring(0, language.indexOf(\"-\"));\n\t\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\t\treturn language;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static validateResponse(response) {\n\t\tif (!response.ok) {\n\t\t\tthrow response.statusText;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprivate static escapeParam(param) {\n\t\treturn String(param)\n\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t.replaceAll(\",\", \"\\\\,\");\n\t}\n\n\tprivate static reduceArrayAndEscape(param) {\n\t\tif (Array.isArray(param)) {\n\t\t\tlet escapedParams = param.map(function (elem) {\n\t\t\t\treturn MyDataHelps.escapeParam(elem);\n\t\t\t});\n\t\t\treturn escapedParams.join(\",\");\n\t\t}\n\n\t\treturn this.escapeParam(param);\n\t}\n\n\tprivate static convertDateToIsoString(date) {\n\t\tlet paramAsDate = new Date(date);\n\t\tif (isNaN(paramAsDate.getTime())) {\n\t\t\tthrow \"Cannot interpret parameter as Date\";\n\t\t}\n\n\t\treturn paramAsDate.toISOString();\n\t}\n\n\tprivate static flattenPropertyShallow(params, property) {\n\t\tif (params[property] === undefined || params[property] === null) return;\n\n\t\tfor (var key in params[property]) {\n\t\t\tif (params[property].hasOwnProperty(key)) {\n\t\t\t\tparams[`${property}.${key}`] = MyDataHelps.escapeParam(params[property][key]);\n\t\t\t}\n\t\t}\n\n\t\tdelete params[property];\n\t}\n\n\tprivate startEmbeddedSurveyInternal(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\t\treject(\"Survey already in progress\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\t\tif (message.source !== frame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t\t} else if (message.data.name === 'SurveyFinished') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\t\tresolve(message.data);\n\t\t\t\t}\n\t\t\t}, true);\n\n\t\t\tlet surveyModal = document.createElement('div');\n\t\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\t\tsurveyModal.id = mdhSurveyModalId;\n\t\t\tsurveyModal.innerHTML = \"<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='\" + surveyUrl + \"'></iframe></div>\";\n\t\t\tdocument.body.append(surveyModal);\n\t\t\tdocument.body.className += ' no-scroll';\n\t\t});\n\t}\n\n\tprivate startDelegatedSurvey(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\treturn;\n\t\t}\n\n\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\tif (message.source !== frame) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.data.name === 'GetDelegatedAccessToken') {\n\t\t\t\tmdh.getParticipantInfo().then((participant) => {\n\t\t\t\t\tframe.postMessage({ name: \"DelegatedAccessTokenResponse\", accessToken: mdh.token, baseUrl: mdh.baseUrl, participantID: participant.participantID }, '*');\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyFinished') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\tmessage.data.type = 'surveyDidFinish';\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}, true);\n\n\t\tlet surveyModal = document.createElement('div');\n\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\tsurveyModal.id = mdhSurveyModalId;\n\t\tsurveyModal.innerHTML = `<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${surveyUrl}&lang=${mdh.getCurrentLanguage()}'></iframe></div>`;\n\t\tdocument.body.append(surveyModal);\n\t\tdocument.body.className += ' no-scroll';\n\t}\n\n\tprivate handleConnectExternalAccountResponse() {\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (window.opener && params.get('connectExternalAccount') && params.get('messageID') && params.get('success')) {\n\t\t\twindow.opener.postMessage({\n\t\t\t\tname: 'ConnectExternalAccountResponse',\n\t\t\t\tmessageID: parseInt(params.get('messageID')),\n\t\t\t\tsuccess: params.get('success') === 'true'\n\t\t\t}, window.location.origin);\n\t\t\twindow.close();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate hasEmbeddedModeUrlParameter() {\n\t\tconst embeddedModeKey = '_e';\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.has(embeddedModeKey) && params.get(embeddedModeKey) !== 'false') {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n//iOS/Android directly invoke window.MyDataHelps and window.RKStudioClient\n//so it's necessary to explicitly ensure they are present on the window\nconst mdh = new MyDataHelps();\n\nwindow.MyDataHelps = mdh;\n\n// For backwards compatibility\nwindow.RKStudioClient = {};\nwindow.RKStudioClient.setActionResult = function (data) {\n\twindow.MyDataHelps.setActionResult(data);\n};\n\nexport default mdh;\nexport * from './types';\n"],"names":["MyDataHelps","startSurvey","surveyName","options","this","isStandaloneMode","params","URLSearchParams","set","editResultID","event","startDelegatedSurvey","baseUrl","toString","window","webkit","messageHandlers","StartParticipantSurvey","messageID","nextMessageID","postMessage","completeStep","answer","JSON","stringify","ResearchKit","CompleteStep","querySurveyAnswers","queryParameters","Object","assign","hasOwnProperty","reduceArrayAndEscape","stepIdentifier","resultIdentifier","before","convertDateToIsoString","after","endpoint","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","insertedBefore","insertedAfter","deleteSurveyResult","resultID","encodeURIComponent","querySurveyTasks","status","queryInboxItems","target","source","key","keys","value","undefined","assignDefined","type","getInboxItem","id","updateInboxItem","update","startEmbeddedSurvey","linkIdentifier","language","getCurrentLanguage","surveyUrl","startEmbeddedSurveyInternal","openExternalUrl","url","OpenExternalLink","openEmbeddedUrl","OpenEmbeddedLink","showTab","tabKey","ShowTab","openApplication","OpenExternalApplication","modal","openSecondaryView","projectId","viewKey","lookupSecondaryView","secondaryView","endsWith","fetch","method","headers","Accept","ok","text","Error","statusText","dismiss","Dismiss","back","PopNavigation","showDashboard","dashboardKey","ShowParticipantDashboard","title","showWebVisualization","visualizationKey","parameters","ShowParticipantWebVisualization","showWebVisualizationPdf","ShowParticipantWebVisualizationPDF","landscape","htmlViewerZoom","showProject","projectCode","ShowProject","code","joinProject","JoinProject","on","eventName","callback","supportedEvents","includes","registeredEventHandlers","push","off","eventHandlerIndex","indexOf","splice","triggerEvent","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","async","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","getDeviceDataAllDataTypes","enabled","namespace","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","Promise","resolve","reject","connectProviderAccountResponse","success","errorMessage","standaloneMode","standaloneModeFinalRedirectPath","location","href","providerAuthWindow","openNewWindow","split","windowFeatures","width","height","w","h","outerHeight","screenY","outerWidth","screenX","open","queryString","finalRedirectPath","redirectUrl","replace","top","ConnectExternalAccount","getExternalAccounts","refreshExternalAccount","accountID","deleteExternalAccount","DeleteProviderAccount","deleteProviderAccountResponse","getFeaturedProviders","context","queryNotifications","sentBefore","sentAfter","queryFitbitDailySummaries","startDate","endDate","queryFitbitSleepLogs","queryAppleHealthActivitySummaries","queryAppleHealthWorkouts","uploadFile","file","fileName","size","name","preSignedUrl","body","queryFiles","getFileDownloadUrl","deleteFile","refreshDelegatedAccessToken","token","refreshTokenPromise","tokenResponse","tokenExpires","Date","now","expires_in","setTimeout","accessTokenRenewalBufferSeconds","GetDelegatedAccessToken","isEmbeddedMode","setParticipantAccessToken","enableStandaloneMode","embeddedMode","setStatusBarStyle","style","SetStatusBarStyle","getDeviceInfo","GetDeviceInfo","deviceInfoResponse","setSupportedLanguages","languages","supportedLanguages","length","i","getStepConfiguration","GetStepConfiguration","stepConfigurationResponse","getSurveyContext","deviceInfo","platform","surveyMode","GetSurveyContext","surveyContextResponse","getCurrentSurveyAnswers","GetCurrentSurveyAnswers","currentSurveyAnswersResponse","setCurrentLanguage","supportedLanguage","getSupportedLanguage","warn","lang","searchParams","has","get","navigator","showGoogleFitSettings","ShowGoogleFitSettings","showHealthConnectSettings","HealthConnectSettings","showHealthConnectPrompt","HealthConnectPrompt","getHealthConnectStatus","HealthConnectStatus","statusResponse","showHealthConnectPhrPrompt","HealthConnectPhrPrompt","getHealthConnectPhrStatus","HealthConnectPhrStatus","requestReview","cooldownDays","RequestReview","trackCustomEvent","getDataCollectionSettings","getDataAvailability","invokeCustomApi","customApi","jsonResponse","toUpperCase","parameterString","constructor","acceptableParentDomains","unsupportedActions","currentMessageID","handleConnectExternalAccountResponse","supportedActions","applicationHost","ancestorOrigins","document","getParentOrigin","acceptableOrigin","origin","sourceURL","URL","k","hostname","parent","action","windowHasAnyActions","actions","addActions","addEventListener","validateWindowMessageOrigin","hasEmbeddedModeUrlParameter","makeUrl","apiVersion","access_token","Headers","append","init","find","l","substring","escapeParam","param","String","replaceAll","Array","isArray","map","elem","join","date","paramAsDate","isNaN","getTime","toISOString","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseInt","close","RKStudioClient"],"mappings":"MAMaA,EASZ,WAAAC,CAAYC,EAAoBC,GAC/B,GAAIC,KAAKC,mBAAoB,CAC5B,MAAMC,EAAS,IAAIC,gBACnBD,EAAOE,IAAI,aAAcN,GACrBC,GAASM,cACZH,EAAOE,IAAI,eAAgBL,EAAQM,cAEhCN,GAASO,OACZJ,EAAOE,IAAI,QAASL,EAAQO,OAE7BN,KAAKO,qBAAqB,GAAGP,KAAKQ,kBAAkBN,EAAOO,aAC3D,MACI,GAAIC,OAAOC,OAAOC,gBAAgBC,uBAAwB,CAC9D,IAAIC,EAAYd,KAAKe,gBACrBL,OAAOC,OAAOC,gBAAgBC,uBAAuBG,YAAY,CAChEF,UAAWA,EACXhB,WAAYA,EACZC,QAASA,GAEV,CACD,CAED,YAAAkB,CAAaC,GAKZ,GAJIA,UAAyCA,EAAS,IAChC,iBAAXA,IACVA,EAASC,KAAKC,UAAUF,IAErBR,OAAOC,OAAOC,gBAAgBS,YACjCX,OAAOC,OAAOC,gBAAgBS,YAAYL,YAAYE,QAElD,GAAIR,OAAOC,OAAOC,gBAAgBU,aAAc,CACpD,IAAIR,EAAYd,KAAKe,gBACrBL,OAAOC,OAAOC,gBAAgBU,a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YAAY,CACzB6M,KAAM,iCACN/M,UAAW2V,SAASvW,EAAO8Q,IAAI,cAC/BjG,QAAmC,SAA1B7K,EAAO8Q,IAAI,YAClBtQ,OAAOyK,SAASkI,QACnB3S,OAAOgW,SACA,CAER,CAEO,2BAAAzC,GACP,MACM/T,EAAS,IAAIC,gBAAgBO,OAAOyK,SAASf,QACnD,GAAIlK,EAAO6Q,IAFa,OAE2C,UAAhC7Q,EAAO8Q,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAM7O,EAAM,IAAIvC,EAEhBc,OAAOd,YAAcuC,EAGrBzB,OAAOiW,eAAiB,CAAA,EACxBjW,OAAOiW,eAAezO,gBAAkB,SAAUC,GACjDzH,OAAOd,YAAYsI,gBAAgBC,EACpC"}
1
+ {"version":3,"file":"MyDataHelps.min.js","sources":["../../src/MyDataHelps.ts"],"sourcesContent":["// @ts-ignore : let rollup handle CSS injection\nimport \"../MyDataHelps.css\";\n\nimport * as Model from \"./types\";\nimport { StringMap } from \"./types\";\n\nexport class MyDataHelps {\n\n\tbaseUrl: string = 'https://mydatahelps.org/';\n\tlanguage: string;\n\ttoken: Model.Token;\n\ttokenExpires: number;\n\n\t// Surveys\n\n\tstartSurvey(surveyName: string, options?: Model.StartSurveyOptions): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tconst params = new URLSearchParams();\n\t\t\tparams.set('surveyName', surveyName);\n\t\t\tif (options?.editResultID) {\n\t\t\t\tparams.set('editResultID', options.editResultID);\n\t\t\t}\n\t\t\tif (options?.event) {\n\t\t\t\tparams.set('event', options.event);\n\t\t\t}\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?${params.toString()}`);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.StartParticipantSurvey) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.StartParticipantSurvey.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tsurveyName: surveyName,\n\t\t\t\toptions: options\n\t\t\t});\n\t\t}\n\t}\n\n\tcompleteStep(answer: any): void {\n\t\tif (answer === undefined || answer === null) answer = '';\n\t\tif (typeof answer !== 'string') {\n\t\t\tanswer = JSON.stringify(answer);\n\t\t}\n\t\tif (window.webkit.messageHandlers.ResearchKit) {\n\t\t\twindow.webkit.messageHandlers.ResearchKit.postMessage(answer);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.CompleteStep) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.CompleteStep.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tanswer: answer\n\t\t\t});\n\t\t}\n\t}\n\n\tquerySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"stepIdentifier\")) {\n\t\t\tqueryParameters.stepIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.stepIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"resultIdentifier\")) {\n\t\t\tqueryParameters.resultIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.resultIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"answer\")) {\n\t\t\tqueryParameters.answer = MyDataHelps.reduceArrayAndEscape(queryParameters.answer);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyanswers?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tquerySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage> {\n\t\tqueryParameters = { ...queryParameters }\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyresults?' + queryString;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\topenSecondaryView(projectId: string, viewKey: string, options?: Model.OpenApplicationOptions): void {\n\t\tthis.lookupSecondaryView(projectId, viewKey).then(secondaryView => {\n\t\t\treturn this.openApplication(secondaryView.url, options);\n\t\t});\n\t};\n\n\tlookupSecondaryView(projectId: string, viewKey: string): Promise<Model.SecondaryView> {\n\t\tlet baseUrl = this.baseUrl;\n\t\tif (!baseUrl.endsWith(\"/\")) {\n\t\t\tbaseUrl += \"/\";\n\t\t}\n\t\tconst viewLookupUrl = `${baseUrl}api/v1/public/projects/${projectId}/views/${viewKey}`;\n\t\treturn fetch(viewLookupUrl, { method: 'GET', headers: { 'Accept': 'application/json' } })\n\t\t\t.then(response => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\treturn response.text().then(text => {\n\t\t\t\t\t\tthrow new Error(`Failed to fetch secondary view: ${response.status} ${response.statusText}${text ? ' - ' + text : ''}`);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDeviceDataAllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetFeaturedProviders(context?: string): Promise<Model.ExternalAccountProvider[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (context) {\n\t\t\tqueryParameters['featuredProvidersContext'] = context;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `featuredexternalaccountproviders?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Notifications\n\n\tqueryNotifications(queryParameters: Model.NotificationQueryParameters): Promise<Model.NotificationsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"sentBefore\")) {\n\t\t\tqueryParameters.sentBefore = MyDataHelps.convertDateToIsoString(queryParameters.sentBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"sentAfter\")) {\n\t\t\tqueryParameters.sentAfter = MyDataHelps.convertDateToIsoString(queryParameters.sentAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'notifications?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Fitbit\n\n\tqueryFitbitDailySummaries(queryParameters: Model.FitbitQuery): Promise<Model.FitbitDailySummariesPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/dailySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryFitbitSleepLogs(queryParameters: Model.FitbitQuery): Promise<Model.FitbitSleepLogsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/sleepLogs?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// AppleHealth\n\n\tqueryAppleHealthActivitySummaries(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthActivitySummaryPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/activitySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryAppleHealthWorkouts(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthWorkoutPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/workouts?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Files\n\n\tuploadFile(file: File, category: string, fileName?: string): Promise<void> {\n\n\t\tif (file.size > 200 * 1024 * 1024) {\n\t\t\tthrow new Error(\"File size exceeds the maximum allowed size of 200MB.\");\n\t\t}\n\n\t\tconst mdh = this;\n\t\tconst endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.then(function (json) {\n\t\t\t\treturn fetch(json.preSignedUrl, {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\tbody: file,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t\t'x-amz-server-side-encryption': 'AES256'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryFiles(queryParameters: Model.UploadedFileQuery): Promise<Model.UploadedFilesPage> {\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'files?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetFileDownloadUrl(key: string): Promise<Model.DownloadedFile> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to download.\");\n\n\t\tconst endpoint = 'files/download?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteFile(key: string): Promise<void> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to delete.\");\n\n\t\tconst endpoint = 'files?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Authorization\n\n\tconnect(): Promise<void> {\n\t\tconst mdh = this;\n\t\tlet refreshDelegatedAccessToken = function () {\n\t\t\tmdh.token = null;\n\n\t\t\tmdh.refreshTokenPromise = new Promise(function (resolve, reject) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (tokenResponse) {\n\t\t\t\t\tif (tokenResponse.success) {\n\t\t\t\t\t\tmdh.tokenExpires = Date.now() + (tokenResponse.data.expires_in * 1000);\n\t\t\t\t\t\tmdh.token = tokenResponse.data;\n\t\t\t\t\t\tmdh.baseUrl = tokenResponse.baseUrl;\n\t\t\t\t\t\tsetTimeout(refreshDelegatedAccessToken, ((tokenResponse.data.expires_in - mdh.accessTokenRenewalBufferSeconds) * 1000));\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmdh.token = null;\n\t\t\t\t\t\treject(tokenResponse.message);\n\t\t\t\t\t}\n\t\t\t\t\tmdh.messageHandlers[messageID] = null;\n\t\t\t\t\tmdh.refreshTokenPromise = null;\n\t\t\t\t};\n\n\t\t\t\twindow.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({ messageID: messageID });\n\t\t\t});\n\t\t};\n\n\t\tif (this.token && Date.now() < this.tokenExpires) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tif (this.isStandaloneMode() && !this.isEmbeddedMode()) {\n\t\t\tlet error = this.token ? \"access token is expired or invalid\" : \"access token must be explicitly provided using the setParticipantAccess method\";\n\t\t\tconsole.log(error);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\n\t\tif (!this.refreshTokenPromise) {\n\t\t\trefreshDelegatedAccessToken();\n\t\t}\n\n\t\t// Re-use promise if refresh already in progress\n\t\treturn this.refreshTokenPromise;\n\t}\n\n\tsetParticipantAccessToken(token: Model.Token, baseUrl?: string): void {\n\t\tthis.enableStandaloneMode();\n\t\tthis.token = token;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tthis.tokenExpires = Date.now() + (this.token.expires_in * 1000);\n\t\tconst mdh = this;\n\t\tsetTimeout(function () {\n\t\t\tmdh.triggerEvent({ type: \"tokenWillExpire\" });\n\t\t}, ((this.token.expires_in - this.accessTokenRenewalBufferSeconds) * 1000));\n\t}\n\n\t// Miscellaneous\n\n\tisStandaloneMode() {\n\t\treturn this.standaloneMode;\n\t}\n\n\tisEmbeddedMode() {\n\t\treturn this.embeddedMode;\n\t}\n\n\tenableStandaloneMode(embeddedMode: boolean = false, baseUrl?: string) {\n\t\tthis.standaloneMode = true;\n\t\tthis.embeddedMode = embeddedMode;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tif (window.webkit) {\n\t\t\twindow.webkit.messageHandlers = embeddedMode ? {\n\t\t\t\tGetDelegatedAccessToken: window.webkit.messageHandlers.GetDelegatedAccessToken,\n\t\t\t\tOpenExternalLink: window.webkit.messageHandlers.OpenExternalLink,\n\t\t\t\tOpenEmbeddedLink: window.webkit.messageHandlers.OpenEmbeddedLink,\n\t\t\t\tOpenExternalApplication: window.webkit.messageHandlers.OpenExternalApplication,\n\t\t\t\tPopNavigation: window.webkit.messageHandlers.PopNavigation,\n\t\t\t\tDismiss: window.webkit.messageHandlers.Dismiss,\n\t\t\t} : {};\n\t\t}\n\t}\n\n\tsetStatusBarStyle(style: Model.StatusBarStyle): void {\n\t\tif (window.webkit.messageHandlers.SetStatusBarStyle) {\n\t\t\twindow.webkit.messageHandlers.SetStatusBarStyle.postMessage({ style: style });\n\t\t}\n\t}\n\n\tgetDeviceInfo(): Promise<Model.DeviceInfo> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.DeviceInfo>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetDeviceInfo) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deviceInfoResponse) {\n\t\t\t\t\tresolve(deviceInfoResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetDeviceInfo.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSupportedLanguages(languages: string[]) {\n\t\tthis.supportedLanguages.length = 0;\n\t\tfor (let i = 0; i < languages.length; i++) {\n\t\t\tthis.supportedLanguages.push(languages[i].replace(\"_\", \"-\"));\n\t\t}\n\t}\n\n\tgetStepConfiguration(): Promise<Model.StepConfiguration> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.StepConfiguration>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetStepConfiguration) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (stepConfigurationResponse) {\n\t\t\t\t\tresolve(stepConfigurationResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetStepConfiguration.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSurveyContext(): Promise<Model.SurveyContext> {\n\t\tlet mdh = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t\tmdh.getDeviceInfo().then(function (deviceInfo) {\n\t\t\t\tif (deviceInfo.platform !== \"Web\") {\n\t\t\t\t\tresolve({ surveyMode: \"Survey\" });\n\t\t\t\t}\n\t\t\t\telse if (window.webkit.messageHandlers.GetSurveyContext) {\n\t\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\t\tmdh.messageHandlers[messageID] = function (surveyContextResponse) {\n\t\t\t\t\t\tresolve(surveyContextResponse.data);\n\t\t\t\t\t};\n\t\t\t\t\twindow.webkit.messageHandlers.GetSurveyContext.postMessage({ messageID: messageID });\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t}).catch(function (error) {\n\t\t\t\treject();\n\t\t\t});\n\t\t});\n\t}\n\n\tgetCurrentSurveyAnswers(): Promise<Model.CurrentSurveyAnswer[]> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.CurrentSurveyAnswer[]>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetCurrentSurveyAnswers) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (currentSurveyAnswersResponse) {\n\t\t\t\t\tresolve(currentSurveyAnswersResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetCurrentLanguage(language: string) {\n\t\tif (language) {\n\t\t\tlet supportedLanguage = this.getSupportedLanguage(language);\n\t\t\tif (supportedLanguage) {\n\t\t\t\tthis.language = supportedLanguage;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${language} not supported`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.language = language;\n\t\t}\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\tlet searchParams = new URLSearchParams(window.location.search);\n\t\tlet lang;\n\t\tif (searchParams.has(\"lang\")) {\n\t\t\tlang = this.getSupportedLanguage(searchParams.get(\"lang\"));\n\t\t\tif (lang) {\n\t\t\t\treturn lang;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${searchParams.get(\"lang\")} not supported`);\n\t\t\t}\n\t\t}\n\t\treturn this.language || navigator.language;\n\t}\n\n\tshowGoogleFitSettings(): void {\n\t\tif (window.webkit.messageHandlers.ShowGoogleFitSettings) {\n\t\t\twindow.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectSettings(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectSettings) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectStatus(): Promise<Model.HealthConnectStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tshowHealthConnectPhrPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPhrPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectPhrStatus(): Promise<Model.HealthConnectPhrStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectPhrStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectPhrStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\trequestReview(cooldownDays?: number): void {\n\t\tif (window.webkit.messageHandlers.RequestReview) {\n\t\t\twindow.webkit.messageHandlers.RequestReview.postMessage({ cooldownDays: cooldownDays });\n\t\t}\n\t}\n\n\ttrackCustomEvent(event: Model.CustomEventInfo): Promise<void> {\n\t\tconst endpoint = 'customevents';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', event);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDataCollectionSettings(): Promise<Model.DataCollectionSettings> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'datacollectionsettings';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDataAvailability(): Promise<Model.DataAvailability> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'dataavailability';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tinvokeCustomApi(customApi: string, method: string, queryParameters: string | string[][] | Record<string, string> | URLSearchParams | null | undefined, jsonResponse: boolean): Promise<any> {\n\t\tif (customApi.includes('?')) {\n\t\t\tthrow new Error(\"Cannot include query parameters directly in the \\\"customApi\\\" string. Provide as an argument for \\\"queryParameters\\\" instead.\");\n\t\t}\n\n\t\tlet endpoint = 'custom/' + customApi;\n\t\tmethod = method.toUpperCase();\n\t\tif (queryParameters !== null && queryParameters !== undefined && (method === 'GET' || method === 'DELETE')) {\n\t\t\tlet parameterString = new URLSearchParams(queryParameters).toString();\n\t\t\tendpoint += \"?\" + parameterString;\n\t\t\tqueryParameters = null;\n\t\t}\n\n\t\tconst mdh = this;\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, method, queryParameters);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn jsonResponse ? response.json() : undefined;\n\t\t\t});\n\t}\n\n\tconstructor() {\n\t\tif (this.handleConnectExternalAccountResponse()) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet mdh = this;\n\t\tlet applicationHost = getParentOrigin();\n\t\tlet supportedActions;\n\n\t\tfunction getParentOrigin(): string {\n\t\t\tlet ancestorOrigins = document.location.ancestorOrigins;\n\t\t\tif (ancestorOrigins && ancestorOrigins[0]) {\n\t\t\t\treturn ancestorOrigins[0];\n\t\t\t}\n\n\t\t\treturn '*';\n\t\t}\n\n\t\tfunction acceptableOrigin(origin) {\n\t\t\tif (origin === '*') return true;\n\n\t\t\tlet sourceURL = new URL(origin);\n\t\t\tfor (let k = 0; k < mdh.acceptableParentDomains.length; k++) {\n\t\t\t\tif (sourceURL.hostname === mdh.acceptableParentDomains[k] || sourceURL.hostname.endsWith(\".\" + mdh.acceptableParentDomains[k])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction validateWindowMessageOrigin(message) {\n\t\t\tif (mdh.isStandaloneMode() && message.origin === window.location.origin) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (applicationHost === \"*\") {\n\t\t\t\treturn acceptableOrigin(message.origin);\n\t\t\t}\n\n\t\t\treturn message.origin === applicationHost;\n\t\t}\n\n\t\tfunction addActions(actions) {\n\t\t\tfor (let action in actions) {\n\t\t\t\tif (!window.webkit.messageHandlers[action]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twindow.webkit.messageHandlers[action] = { postMessage: actions[action] };\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.log(\"Unable to add missing actions on this platform: \" + error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction receiveWindowMessage(message) {\n\t\t\tif (!validateWindowMessageOrigin(message)) {\n\t\t\t\t// todo: this can generate tons of console errors when hosting some apps within webappstep (youtube content, for example )\n\t\t\t\tconsole.error(\"message.origin '\" + message.origin + \"' is not allowed.\");\n\t\t\t\tthrow \"message.origin '\" + message.origin + \"' is not allowed.\";\n\t\t\t}\n\n\t\t\tif (message.data.messageID) {\n\t\t\t\tmdh.setActionResult(message.data);\n\t\t\t} else {\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}\n\n\t\tfunction windowHasAnyActions() {\n\t\t\tfor (let action in supportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[action]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let action in mdh.unsupportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[mdh.unsupportedActions[action]]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!acceptableOrigin(applicationHost)) {\n\t\t\tconsole.log(\"Detected unsupported parent origin domain.\");\n\t\t}\n\n\t\tif (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ResearchKit) {\n\t\t\t// Presence of ResearchKit handler indicates the SDK is being used from within a WebViewStep. For pre-SDK backwards compatiblity,\n\t\t\t// WebViewStep setup registers the following handlers: GetDeviceInfo, DeleteProviderAccount, ConnectExternalAccount\n\t\t\t// ShowParticipantWebVisualizationPDF, ResearchKit\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenExternalUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenEmbeddedUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetSurveyContext\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetSurveyContext',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost);\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetDeviceInfo\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'GetDeviceInfo', messageID: data.messageID }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"StartParticipantSurvey\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'StartParticipantSurvey',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tsurveyName: data.surveyName,\n\t\t\t\t\t\toptions: data.options\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenExternalUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenEmbeddedUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalApplication\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenApplication',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"Dismiss\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Dismiss' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"PopNavigation\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Back' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowTab\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowTab', tabKey: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantDashboard\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantDashboard',\n\t\t\t\t\t\tdashboardKey: data.dashboardKey,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualization\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualization',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualizationPDF\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualizationPDF',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal,\n\t\t\t\t\t\tlandscape: data.landscape,\n\t\t\t\t\t\thtmlViewerZoom: data.htmlViewerZoom\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"DeleteProviderAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'DeleteProviderAccount',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\taccountID: data.accountID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ConnectExternalAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ConnectExternalAccount',\n\t\t\t\t\t\texternalAccountProviderID: data.externalAccountProviderID,\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\topenNewWindow: data.openNewWindow,\n\t\t\t\t\t\twidth: data.width,\n\t\t\t\t\t\theight: data.height\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"JoinProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'JoinProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!window.webkit || !window.webkit.messageHandlers || !windowHasAnyActions()) {\n\t\t\twindow.webkit = {\n\t\t\t\tmessageHandlers: {}\n\t\t\t};\n\t\t}\n\n\t\taddActions(supportedActions);\n\n\t\twindow.addEventListener(\"message\", receiveWindowMessage, false);\n\n\t\tif (this.hasEmbeddedModeUrlParameter()) {\n\t\t\tmdh.enableStandaloneMode(true);\n\t\t}\n\t}\n\n\tprivate readonly acceptableParentDomains = [\n\t\t'localhost',\n\t\t'careevolution.com',\n\t\t'internal',\n\t\t'b3-deploys.com',\n\t\t'mydatahelps.org',\n\t\t'platform.joinallofus.org',\n\t\t'careevolution.dev',\n\t\t'ce.dev',\n\t\t'mydatahelps.dev'\n\t];\n\n\tprivate readonly accessTokenRenewalBufferSeconds = 120;\n\tprivate readonly unsupportedActions = [\"SetHeight\", \"ResearchKit\"];\n\tprivate readonly supportedEvents = [\"surveyDidFinish\", \"applicationDidBecomeVisible\", \"externalAccountSyncComplete\", \"tokenWillExpire\", \"healthConnectSyncComplete\", \"healthConnectPhrSyncComplete\"];\n\tprivate readonly supportedLanguages = [];\n\n\tprivate currentMessageID = 1;\n\tprivate messageHandlers = [];\n\tprivate registeredEventHandlers = {};\n\tprivate refreshTokenPromise = null;\n\tprivate standaloneMode = false;\n\tprivate embeddedMode = false;\n\n\tprivate nextMessageID() {\n\t\treturn this.currentMessageID++;\n\t}\n\n\tprivate makeUrl(endpoint, apiVersion) {\n\t\tif (!this.baseUrl) {\n\t\t\tconsole.error(\"Cannot use makeUrl without MyDataHelps.baseUrl.\");\n\t\t\tthrow \"Cannot use makeUrl without MyDataHelps.baseUrl.\";\n\t\t}\n\n\t\treturn this.baseUrl + 'api/' + apiVersion + '/delegated/' + endpoint;\n\t}\n\n\tprivate makeRequest(endpoint, method, body, apiVersion = \"v1\") {\n\t\tif (!this.token || !this.token.access_token) {\n\t\t\tthrow \"No access_token available for request authorization.\";\n\t\t}\n\n\t\tlet url = this.makeUrl(endpoint, apiVersion);\n\n\t\tlet headers = new Headers();\n\t\theaders.append('Authorization', 'Bearer ' + this.token.access_token);\n\t\theaders.append('Accept', 'application/json, text/javascript, */*; q=0.01');\n\t\theaders.append('Accept-Language', this.getCurrentLanguage());\n\t\tif (!!body) {\n\t\t\theaders.append('Content-Type', 'application/json');\n\t\t}\n\n\t\tlet init: any = {\n\t\t\tmethod: method,\n\t\t\theaders: headers\n\t\t};\n\t\tif (!!body) {\n\t\t\tinit.body = JSON.stringify(body);\n\t\t}\n\n\t\treturn fetch(url, init);\n\t}\n\n\tprivate getSupportedLanguage(language: string): string {\n\t\tlanguage = language.replace(\"_\", \"-\");\n\t\tif (this.supportedLanguages.length === 0) {\n\t\t\treturn language;\n\t\t} else {\n\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\treturn language;\n\t\t\t} else if (language.indexOf(\"-\") > 0) {\n\t\t\t\tlanguage = language.substring(0, language.indexOf(\"-\"));\n\t\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\t\treturn language;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static validateResponse(response) {\n\t\tif (!response.ok) {\n\t\t\tthrow response.statusText;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprivate static escapeParam(param) {\n\t\treturn String(param)\n\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t.replaceAll(\",\", \"\\\\,\");\n\t}\n\n\tprivate static reduceArrayAndEscape(param) {\n\t\tif (Array.isArray(param)) {\n\t\t\tlet escapedParams = param.map(function (elem) {\n\t\t\t\treturn MyDataHelps.escapeParam(elem);\n\t\t\t});\n\t\t\treturn escapedParams.join(\",\");\n\t\t}\n\n\t\treturn this.escapeParam(param);\n\t}\n\n\tprivate static convertDateToIsoString(date) {\n\t\tlet paramAsDate = new Date(date);\n\t\tif (isNaN(paramAsDate.getTime())) {\n\t\t\tthrow \"Cannot interpret parameter as Date\";\n\t\t}\n\n\t\treturn paramAsDate.toISOString();\n\t}\n\n\tprivate static flattenPropertyShallow(params, property) {\n\t\tif (params[property] === undefined || params[property] === null) return;\n\n\t\tfor (var key in params[property]) {\n\t\t\tif (params[property].hasOwnProperty(key)) {\n\t\t\t\tparams[`${property}.${key}`] = MyDataHelps.escapeParam(params[property][key]);\n\t\t\t}\n\t\t}\n\n\t\tdelete params[property];\n\t}\n\n\tprivate startEmbeddedSurveyInternal(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\t\treject(\"Survey already in progress\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\t\tif (message.source !== frame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t\t} else if (message.data.name === 'SurveyFinished') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\t\tresolve(message.data);\n\t\t\t\t}\n\t\t\t}, true);\n\n\t\t\tlet surveyModal = document.createElement('div');\n\t\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\t\tsurveyModal.id = mdhSurveyModalId;\n\t\t\tsurveyModal.innerHTML = \"<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='\" + surveyUrl + \"'></iframe></div>\";\n\t\t\tdocument.body.append(surveyModal);\n\t\t\tdocument.body.className += ' no-scroll';\n\t\t});\n\t}\n\n\tprivate startDelegatedSurvey(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\treturn;\n\t\t}\n\n\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\tif (message.source !== frame) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.data.name === 'GetDelegatedAccessToken') {\n\t\t\t\tmdh.getParticipantInfo().then((participant) => {\n\t\t\t\t\tframe.postMessage({ name: \"DelegatedAccessTokenResponse\", accessToken: mdh.token, baseUrl: mdh.baseUrl, participantID: participant.participantID }, '*');\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyFinished') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\tmessage.data.type = 'surveyDidFinish';\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}, true);\n\n\t\tlet surveyModal = document.createElement('div');\n\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\tsurveyModal.id = mdhSurveyModalId;\n\t\tsurveyModal.innerHTML = `<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${surveyUrl}&lang=${mdh.getCurrentLanguage()}'></iframe></div>`;\n\t\tdocument.body.append(surveyModal);\n\t\tdocument.body.className += ' no-scroll';\n\t}\n\n\tprivate handleConnectExternalAccountResponse() {\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (window.opener && params.get('connectExternalAccount') && params.get('messageID') && params.get('success')) {\n\t\t\twindow.opener.postMessage({\n\t\t\t\tname: 'ConnectExternalAccountResponse',\n\t\t\t\tmessageID: parseInt(params.get('messageID')),\n\t\t\t\tsuccess: params.get('success') === 'true'\n\t\t\t}, window.location.origin);\n\t\t\twindow.close();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate hasEmbeddedModeUrlParameter() {\n\t\tconst embeddedModeKey = '_e';\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.has(embeddedModeKey) && params.get(embeddedModeKey) !== 'false') {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n//iOS/Android directly invoke window.MyDataHelps and window.RKStudioClient\n//so it's necessary to explicitly ensure they are present on the window\nconst mdh = new MyDataHelps();\n\nwindow.MyDataHelps = mdh;\n\n// For backwards compatibility\nwindow.RKStudioClient = {};\nwindow.RKStudioClient.setActionResult = function (data) {\n\twindow.MyDataHelps.setActionResult(data);\n};\n\nexport default mdh;\nexport * from './types';\n"],"names":["MyDataHelps","startSurvey","surveyName","options","this","isStandaloneMode","params","URLSearchParams","set","editResultID","event","startDelegatedSurvey","baseUrl","toString","window","webkit","messageHandlers","StartParticipantSurvey","messageID","nextMessageID","postMessage","completeStep","answer","JSON","stringify","ResearchKit","CompleteStep","querySurveyAnswers","queryParameters","Object","assign","hasOwnProperty","reduceArrayAndEscape","stepIdentifier","resultIdentifier","before","convertDateToIsoString","after","endpoint","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","insertedBefore","insertedAfter","deleteSurveyResult","resultID","encodeURIComponent","querySurveyTasks","status","queryInboxItems","target","source","key","keys","value","undefined","assignDefined","type","getInboxItem","id","updateInboxItem","update","startEmbeddedSurvey","linkIdentifier","language","getCurrentLanguage","surveyUrl","startEmbeddedSurveyInternal","openExternalUrl","url","OpenExternalLink","openEmbeddedUrl","OpenEmbeddedLink","showTab","tabKey","ShowTab","openApplication","OpenExternalApplication","modal","openSecondaryView","projectId","viewKey","lookupSecondaryView","secondaryView","endsWith","fetch","method","headers","Accept","ok","text","Error","statusText","dismiss","Dismiss","back","PopNavigation","showDashboard","dashboardKey","ShowParticipantDashboard","title","showWebVisualization","visualizationKey","parameters","ShowParticipantWebVisualization","showWebVisualizationPdf","ShowParticipantWebVisualizationPDF","landscape","htmlViewerZoom","showProject","projectCode","ShowProject","code","joinProject","JoinProject","on","eventName","callback","supportedEvents","includes","registeredEventHandlers","push","off","eventHandlerIndex","indexOf","splice","triggerEvent","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","async","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","getDeviceDataAllDataTypes","enabled","namespace","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","Promise","resolve","reject","connectProviderAccountResponse","success","errorMessage","standaloneMode","standaloneModeFinalRedirectPath","location","href","providerAuthWindow","openNewWindow","split","windowFeatures","width","height","w","h","outerHeight","screenY","outerWidth","screenX","open","queryString","finalRedirectPath","redirectUrl","replace","top","ConnectExternalAccount","getExternalAccounts","refreshExternalAccount","accountID","deleteExternalAccount","DeleteProviderAccount","deleteProviderAccountResponse","getFeaturedProviders","context","queryNotifications","sentBefore","sentAfter","queryFitbitDailySummaries","startDate","endDate","queryFitbitSleepLogs","queryAppleHealthActivitySummaries","queryAppleHealthWorkouts","uploadFile","file","fileName","size","name","preSignedUrl","body","queryFiles","getFileDownloadUrl","deleteFile","refreshDelegatedAccessToken","token","refreshTokenPromise","tokenResponse","tokenExpires","Date","now","expires_in","setTimeout","accessTokenRenewalBufferSeconds","GetDelegatedAccessToken","isEmbeddedMode","setParticipantAccessToken","enableStandaloneMode","embeddedMode","setStatusBarStyle","style","SetStatusBarStyle","getDeviceInfo","GetDeviceInfo","deviceInfoResponse","setSupportedLanguages","languages","supportedLanguages","length","i","getStepConfiguration","GetStepConfiguration","stepConfigurationResponse","getSurveyContext","deviceInfo","platform","surveyMode","GetSurveyContext","surveyContextResponse","getCurrentSurveyAnswers","GetCurrentSurveyAnswers","currentSurveyAnswersResponse","setCurrentLanguage","supportedLanguage","getSupportedLanguage","warn","lang","searchParams","has","get","navigator","showGoogleFitSettings","ShowGoogleFitSettings","showHealthConnectSettings","HealthConnectSettings","showHealthConnectPrompt","HealthConnectPrompt","getHealthConnectStatus","HealthConnectStatus","statusResponse","showHealthConnectPhrPrompt","HealthConnectPhrPrompt","getHealthConnectPhrStatus","HealthConnectPhrStatus","requestReview","cooldownDays","RequestReview","trackCustomEvent","getDataCollectionSettings","getDataAvailability","invokeCustomApi","customApi","jsonResponse","toUpperCase","parameterString","constructor","acceptableParentDomains","unsupportedActions","currentMessageID","handleConnectExternalAccountResponse","supportedActions","applicationHost","ancestorOrigins","document","getParentOrigin","acceptableOrigin","origin","sourceURL","URL","k","hostname","parent","action","windowHasAnyActions","actions","addActions","addEventListener","validateWindowMessageOrigin","hasEmbeddedModeUrlParameter","makeUrl","apiVersion","access_token","Headers","append","init","find","l","substring","escapeParam","param","String","replaceAll","Array","isArray","map","elem","join","date","paramAsDate","isNaN","getTime","toISOString","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseInt","close","RKStudioClient"],"mappings":"MAMaA,EASZ,WAAAC,CAAYC,EAAoBC,GAC/B,GAAIC,KAAKC,mBAAoB,CAC5B,MAAMC,EAAS,IAAIC,gBACnBD,EAAOE,IAAI,aAAcN,GACrBC,GAASM,cACZH,EAAOE,IAAI,eAAgBL,EAAQM,cAEhCN,GAASO,OACZJ,EAAOE,IAAI,QAASL,EAAQO,OAE7BN,KAAKO,qBAAqB,GAAGP,KAAKQ,kBAAkBN,EAAOO,aAC3D,MACI,GAAIC,OAAOC,OAAOC,gBAAgBC,uBAAwB,CAC9D,IAAIC,EAAYd,KAAKe,gBACrBL,OAAOC,OAAOC,gBAAgBC,uBAAuBG,YAAY,CAChEF,UAAWA,EACXhB,WAAYA,EACZC,QAASA,GAEV,CACD,CAED,YAAAkB,CAAaC,GAKZ,GAJIA,UAAyCA,EAAS,IAChC,iBAAXA,IACVA,EAASC,KAAKC,UAAUF,IAErBR,OAAOC,OAAOC,gBAAgBS,YACjCX,OAAOC,OAAOC,gBAAgBS,YAAYL,YAAYE,QAElD,GAAIR,OAAOC,OAAOC,gBAAgBU,aAAc,CACpD,IAAIR,EAAYd,KAAKe,gBACrBL,OAAOC,OAAOC,gBAAgBU,aAAaN,YAAY,CACtDF,UAAWA,EACXI,OAAQA,GAET,CACD,CAED,kBAAAK,CAAmBC,IAClBA,EAAkBC,OAAOC,OAAO,CAAE,EAAEF,IAEhBG,eAAe,gB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,OAAO8V,OAAOxV,YAAY,CACzB6M,KAAM,iCACN/M,UAAW2V,SAASvW,EAAO8Q,IAAI,cAC/BjG,QAAmC,SAA1B7K,EAAO8Q,IAAI,YAClBtQ,OAAOyK,SAASkI,QACnB3S,OAAOgW,SACA,CAER,CAEO,2BAAAzC,GACP,MACM/T,EAAS,IAAIC,gBAAgBO,OAAOyK,SAASf,QACnD,GAAIlK,EAAO6Q,IAFa,OAE2C,UAAhC7Q,EAAO8Q,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAM7O,EAAM,IAAIvC,EAEhBc,OAAOd,YAAcuC,EAGrBzB,OAAOiW,eAAiB,CAAA,EACxBjW,OAAOiW,eAAezO,gBAAkB,SAAUC,GACjDzH,OAAOd,YAAYsI,gBAAgBC,EACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careevolution/mydatahelps-js",
3
- "version": "5.2.1",
3
+ "version": "5.3.1",
4
4
  "description": "MyDataHelps client to be used by external applications for integrations inside the MyDataHelps platform",
5
5
  "type": "module",
6
6
  "types": "MyDataHelps.d.ts",
package/types.d.ts CHANGED
@@ -165,6 +165,7 @@ export interface SurveyTaskQueryParameters extends QueryParameters {
165
165
  surveyCategory?: string;
166
166
  linkIdentifier?: string;
167
167
  sortOrder?: SortOrder;
168
+ event?: string | string[];
168
169
  }
169
170
  export interface SurveyTasksPage {
170
171
  surveyTasks: SurveyTask[];
@@ -188,6 +189,7 @@ export interface SurveyTask {
188
189
  insertedDate: string;
189
190
  modifiedDate: string;
190
191
  schedule?: ScheduleMetadata;
192
+ event?: string;
191
193
  }
192
194
  export interface ScheduleMetadata {
193
195
  id: Guid;
@@ -400,6 +402,7 @@ export interface SurveyAnswersQuery extends QueryParameters {
400
402
  answer?: string | string[];
401
403
  insertedAfter?: string;
402
404
  insertedBefore?: string;
405
+ event?: string | string[];
403
406
  }
404
407
  export interface SurveyAnswersPage {
405
408
  surveyAnswers: SurveyAnswer[];
@@ -431,7 +434,7 @@ export interface SurveyResultsQuery extends QueryParameters {
431
434
  before?: string;
432
435
  insertedAfter?: string;
433
436
  insertedBefore?: string;
434
- event?: string;
437
+ event?: string | string[];
435
438
  }
436
439
  export interface SurveyResultsPage {
437
440
  surveyResults: SurveyResult[];