@story-health/fhirclient
Version:
JavaScript client for Fast Healthcare Interoperability Resources
1 lines • 69.7 kB
JavaScript
(()=>{var e={6486:(e,t,r)=>{var n;void 0===(n=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?i(e):t}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(n,arguments,s)}else r=n.apply(this,arguments);return a(this,r)}}function u(e,t,r){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(n){var s=Object.getOwnPropertyDescriptor(n,t);return s.get?s.get.call(r):s.value}},u(e,t,r||e)}var l=function(){function t(){e(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return n(t,[{key:"addEventListener",value:function(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var r=this.listeners[e],n=0,o=r.length;n<o;n++)if(r[n].callback===t)return void r.splice(n,1)}},{key:"dispatchEvent",value:function(e){if(e.type in this.listeners){for(var t=this.listeners[e.type].slice(),r=0,n=t.length;r<n;r++){var o=t[r];try{o.callback.call(this,e)}catch(e){Promise.resolve().then((function(){throw e}))}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}}}]),t}(),f=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(a,t);var r=c(a);function a(){var t;return e(this,a),(t=r.call(this)).listeners||l.call(i(t)),Object.defineProperty(i(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(i(t),"onabort",{value:null,writable:!0,configurable:!0}),t}return n(a,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(e){"abort"===e.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,e)),u(o(a.prototype),"dispatchEvent",this).call(this,e)}}]),a}(l),h=function(){function t(){e(this,t),Object.defineProperty(this,"signal",{value:new f,writable:!0,configurable:!0})}return n(t,[{key:"abort",value:function(){var e;try{e=new Event("abort")}catch(t){"undefined"!=typeof document?document.createEvent?(e=document.createEvent("Event")).initEvent("abort",!1,!1):(e=document.createEventObject()).type="abort":e={type:"abort",bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(h.prototype[Symbol.toStringTag]="AbortController",f.prototype[Symbol.toStringTag]="AbortSignal"),function(e){(function(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):"function"==typeof e.Request&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController})(e)&&(e.AbortController=h,e.AbortSignal=f)}("undefined"!=typeof self?self:r.g)}.call(t,r,t,e))||(e.exports=n)},866:(e,t,r)=>{"use strict";t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(9956)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},9956:(e,t,r)=>{"use strict";e.exports=function(e){function t(e){let r,o,s,i=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),s=o-(r||o);n.diff=s,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];r=s.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(7824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},9071:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6966),o=r(2088),s=r(7691),{Response:i}="undefined"!=typeof FHIRCLIENT_PURE?window:r(4098),a=n.debug.extend("client");function c(e,t,r,o,s){let i=(0,n.makeArray)(t.resolveReferences).filter(Boolean).map((e=>String(e).trim())).filter(Boolean);if(i=i.filter(((e,t)=>!(i.indexOf(e,t+1)>-1&&(a('Duplicated reference path "%s"',e),1)))),!i.length)return Promise.resolve();const c={};i.forEach((e=>{const t=e.split(".").length;c[t]||(c[t]=[]),c[t].push(e)}));let u=Promise.resolve();return Object.keys(c).sort().forEach((i=>{const a=c[i];u=u.then((()=>Promise.all(a.map((i=>function(e,t,r,o,s,i){const a=(0,n.getPath)(e,t);if(a){const c=Array.isArray(a);return Promise.all((0,n.makeArray)(a).filter(Boolean).map(((a,u)=>{const l=a.reference;if(l)return function(e,t,r,n){return t[e]||(t[e]=r.request({url:e,signal:n}).then((r=>(t[e]=r,r)),(r=>{throw delete t[e],r}))),Promise.resolve(t[e])}(l,o,s,i).then((o=>{r&&(c?t.indexOf("..")>-1?(0,n.setPath)(e,`${t.replace("..",`.${u}.`)}`,o):(0,n.setPath)(e,`${t}.${u}`,o):(0,n.setPath)(e,t,o))})).catch((e=>{if(404!==e.status)throw e}))})))}}(e,i,!!t.graph,r,o,s))))))})),u}t.default=class{constructor(e,t){this.units=n.units;const r="string"==typeof t?{serverUrl:t}:t;(0,n.assert)(r.serverUrl&&r.serverUrl.match(/https?:\/\/.+/),'A "serverUrl" option is required and must begin with "http(s)"'),this.state=r,this.environment=e,this._refreshTask=null;const o=this;this.patient={get id(){return o.getPatientId()},read:e=>{const t=this.patient.id;return t?this.request({...e,url:`Patient/${t}`}):Promise.reject(new Error("Patient is not available"))},request:(e,t={})=>this.patient.id?(async()=>{const r=await async function(e,t){const r=(0,n.absolute)("/",t.state.serverUrl);async function o(e){const r=e.pathname.split("/").pop();(0,n.assert)(r,`Invalid url "${e}"`),(0,n.assert)(s.patientCompartment.indexOf(r)>-1,`Cannot filter "${r}" resources by patient`);const o=await(0,n.fetchConformanceStatement)(t.state.serverUrl),i=(0,n.getPatientParam)(o,r);return e.searchParams.set(i,t.patient.id),e.href}return"string"==typeof e||e instanceof URL?{url:await o(new URL(e+"",r))}:(e.url=await o(new URL(e.url+"",r)),e)}(e,this);return this.request(r,t)})():Promise.reject(new Error("Patient is not available"))},this.encounter={get id(){return o.getEncounterId()},read:e=>{const t=this.encounter.id;return t?this.request({...e,url:`Encounter/${t}`}):Promise.reject(new Error("Encounter is not available"))}},this.user={get fhirUser(){return o.getFhirUser()},get id(){return o.getUserId()},get resourceType(){return o.getUserType()},read:e=>{const t=this.user.fhirUser;return t?this.request({...e,url:t}):Promise.reject(new Error("User is not available"))}},this.connect(e.fhir)}connect(e){if("function"==typeof e){const t={baseUrl:this.state.serverUrl.replace(/\/$/,"")},r=this.getState("tokenResponse.access_token");if(r)t.auth={token:r};else{const{username:e,password:r}=this.state;e&&r&&(t.auth={user:e,pass:r})}this.api=e(t);const n=this.getState("tokenResponse.patient");n&&(this.patient.api=e({...t,patient:n}))}return this}getPatientId(){const e=this.state.tokenResponse;return e?e.patient?e.patient:((this.state.scope||"").match(/\blaunch(\/patient)?\b/)?a("The ID of the selected patient is not available. Please check if your server supports that."):a(o.default.noScopeForId,"patient","patient"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected patient"):a(o.default.noFreeContext,"selected patient"),null)}getEncounterId(){const e=this.state.tokenResponse;return e?e.encounter?e.encounter:((this.state.scope||"").match(/\blaunch(\/encounter)?\b/)?a("The ID of the selected encounter is not available. Please check if your server supports that, and that the selected patient has any recorded encounters."):a(o.default.noScopeForId,"encounter","encounter"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected encounter"):a(o.default.noFreeContext,"selected encounter"),null)}getIdToken(){const e=this.state.tokenResponse;if(e){const t=e.id_token,r=this.state.scope||"";if(!t){const e=r.match(/\bopenid\b/),t=r.match(/\bprofile\b/),n=r.match(/\bfhirUser\b/);return a(e&&(n||t)?"The id_token is not available. Please check if your server supports that.":"You are trying to get the id_token but you are not using the right scopes. Please add 'openid' and 'fhirUser' or 'profile' to the scopes you are requesting."),null}return(0,n.jwtDecode)(t,this.environment)}return this.state.authorizeUri?a(o.default.noIfNoAuth,"the id_token"):a(o.default.noFreeContext,"id_token"),null}getFhirUser(){const e=this.getIdToken();return e?e.fhirUser?e.fhirUser.split("/").slice(-2).join("/"):e.profile:null}getUserId(){const e=this.getFhirUser();return e?e.split("/")[1]:null}getUserType(){const e=this.getFhirUser();return e?e.split("/")[0]:null}getAuthorizationHeader(){const e=this.getState("tokenResponse.access_token");if(e)return"Bearer "+e;const{username:t,password:r}=this.state;return t&&r?"Basic "+this.environment.btoa(t+":"+r):null}async _clearState(){const e=this.environment.getStorage(),t=await e.get(s.SMART_KEY);t&&await e.unset(t),await e.unset(s.SMART_KEY),this.state.tokenResponse={}}create(e,t){return this.request({...t,url:`${e.resourceType}`,method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json",...(t||{}).headers}})}update(e,t){return this.request({...t,url:`${e.resourceType}/${e.id}`,method:"PUT",body:JSON.stringify(e),headers:{"content-type":"application/json",...(t||{}).headers}})}delete(e,t={}){return this.request({...t,url:e,method:"DELETE"})}async patch(e,t,r={}){return(0,n.assertJsonPatch)(t),this.request({...r,url:e,method:"PATCH",body:JSON.stringify(t),headers:{prefer:"return=presentation","content-type":"application/json-patch+json; charset=UTF-8",...r.headers}})}async request(e,t={},r={}){var s;const a=n.debug.extend("client:request");let u;(0,n.assert)(e,"request requires an url or request options as argument"),"string"==typeof e||e instanceof URL?(u=String(e),e={}):u=String(e.url),u=(0,n.absolute)(u,this.state.serverUrl);const l={graph:!1!==t.graph,flat:!!t.flat,pageLimit:null!==(s=t.pageLimit)&&void 0!==s?s:1,resolveReferences:t.resolveReferences||[],useRefreshToken:!1!==t.useRefreshToken,onPage:"function"==typeof t.onPage?t.onPage:void 0},f=e.signal||void 0;let h;return(l.useRefreshToken?this.refreshIfNeeded({signal:f}).then((()=>e)):Promise.resolve(e)).then((e=>{const t=this.getAuthorizationHeader();return t&&(e.headers={...e.headers,authorization:t}),e})).then((e=>(a("%s, options: %O, fhirOptions: %O",u,e,l),(0,n.request)(u,e).then((t=>e.includeResponse?(h=t.response,t.body):t))))).catch((async e=>{if(401==e.status){if(!this.getState("tokenResponse.access_token"))throw e.message+="\nThis app cannot be accessed directly. Please launch it as SMART app!",e;if(!l.useRefreshToken)throw a("Your session has expired and the useRefreshToken option is set to false. Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e;throw a("Auto-refresh failed! Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e}throw e})).catch((e=>{throw 403==e.status&&a("Permission denied! Please make sure that you have requested the proper scopes."),e})).then((t=>t?"string"==typeof t||t instanceof i?t:(async e=>("Bundle"==e.resourceType?await Promise.all((e.entry||[]).map((e=>c(e.resource,l,r,this,f)))):await c(e,l,r,this,f),e))(t).then((async e=>{if(e&&"Bundle"==e.resourceType){const t=e.link||[];if(l.flat&&(e=(e.entry||[]).map((e=>e.resource))),l.onPage&&await l.onPage(e,{...r}),--l.pageLimit){const o=t.find((e=>"next"==e.relation));if(e=(0,n.makeArray)(e),o&&o.url){const t=await this.request({url:o.url,signal:f},l,r);return l.onPage?null:l.resolveReferences.length?(Object.assign(r,t.references),e.concat((0,n.makeArray)(t.data||t))):e.concat((0,n.makeArray)(t))}}}return e})).then((e=>{if(l.graph)r={};else if(!l.onPage&&l.resolveReferences.length)return{data:e,references:r};return e})).then((t=>e.includeResponse?{body:t,response:h}:t)):t))}refreshIfNeeded(e={}){const t=this.getState("tokenResponse.access_token"),r=this.getState("tokenResponse.refresh_token"),n=this.state.expiresAt||0;return t&&r&&n-10<Date.now()/1e3?this.refresh(e):Promise.resolve(this.state)}refresh(e={}){var t,r;const o=n.debug.extend("client:refresh");o("Attempting to refresh with refresh_token...");const s=null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token;(0,n.assert)(s,"Unable to refresh. No refresh_token found.");const i=this.state.tokenUri;(0,n.assert)(i,"Unable to refresh. No tokenUri found.");const a=this.getState("tokenResponse.scope")||"",c=a.search(/\boffline_access\b/)>-1,u=a.search(/\bonline_access\b/)>-1;if((0,n.assert)(c||u,"Unable to refresh. No offline_access or online_access scope found."),!this._refreshTask){const t={credentials:this.environment.options.refreshTokenWithCredentials||"same-origin",...e,method:"POST",mode:"cors",headers:{...e.headers||{},"content-type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(s)}`};if(!("authorization"in t.headers)){const{clientSecret:e,clientId:r}=this.state;e&&(t.headers.authorization="Basic "+this.environment.btoa(r+":"+e))}this._refreshTask=(0,n.request)(i,t).then((e=>((0,n.assert)(e.access_token,"No access token received"),o("Received new access token response %O",e),this.state.tokenResponse={...this.state.tokenResponse,...e},this.state.expiresAt=(0,n.getAccessTokenExpiration)(e,this.environment),this.state))).catch((e=>{var t,r;throw(null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token)&&(o("Deleting the expired or invalid refresh token."),delete this.state.tokenResponse.refresh_token),e})).finally((()=>{this._refreshTask=null;const e=this.state.key;e?this.environment.getStorage().set(e,this.state):o("No 'key' found in Clint.state. Cannot persist the instance.")}))}return this._refreshTask}byCode(e,t){return(0,n.byCode)(e,t)}byCodes(e,t){return(0,n.byCodes)(e,t)}getPath(e,t=""){return(0,n.getPath)(e,t)}getState(e=""){return(0,n.getPath)({...this.state},e)}getFhirVersion(){return(0,n.fetchConformanceStatement)(this.state.serverUrl).then((e=>e.fhirVersion))}getFhirRelease(){return this.getFhirVersion().then((e=>{var t;return null!==(t=s.fhirVersions[e])&&void 0!==t?t:0}))}}},7998:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(`${e.status} ${e.statusText}\nURL: ${e.url}`),this.name="HttpError",this.response=e,this.statusCode=e.status,this.status=e.status,this.statusText=e.statusText}async parse(){if(!this.response.bodyUsed)try{const e=this.response.headers.get("content-type")||"text/plain";if(e.match(/\bjson\b/i)){let e=await this.response.json();e.error?(this.message+="\n"+e.error,e.error_description&&(this.message+=": "+e.error_description)):this.message+="\n\n"+JSON.stringify(e,null,4)}else if(e.match(/^text\//i)){let e=await this.response.text();e&&(this.message+="\n\n"+e)}}catch{}return this}toJSON(){return{name:this.name,statusCode:this.statusCode,status:this.status,statusText:this.statusText,message:this.message}}}t.default=r},3923:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1074),o=r(9071),s=r(1060),i=r(8366),a=r(9575);t.default=class{constructor(e={}){this._url=null,this._storage=null,this.security=i,this.options={replaceBrowserHistory:!0,fullSessionStorageSupport:!0,refreshTokenWithCredentials:"same-origin",...e}}relative(e){return new URL(e,this.getUrl().href).href}get fhir(){return"function"==typeof fhir?fhir:null}getUrl(){return this._url||(this._url=new URL(location+"")),this._url}redirect(e){location.href=e}getStorage(){return this._storage||(this._storage=new s.default),this._storage}getAbortController(){return AbortController}atob(e){return window.atob(e)}btoa(e){return window.btoa(e)}base64urlencode(e){return"string"==typeof e?(0,a.encodeURL)(e):(0,a.fromUint8Array)(e,!0)}base64urldecode(e){return(0,a.decode)(e)}getSmartApi(){return{ready:(...e)=>(0,n.ready)(this,...e),authorize:e=>(0,n.authorize)(this,e),init:e=>(0,n.init)(this,e),client:e=>new o.default(this,e),options:this.options,utils:{security:i}}}}},4746:(e,t,r)=>{"use strict";const n=new(r(3923).default),{ready:o,authorize:s,init:i,client:a,options:c,utils:u}=n.getSmartApi();if("undefined"==typeof FHIRCLIENT_PURE){const e=r(4098);r(6486),window.fetch||(window.fetch=e.default,window.Headers=e.Headers,window.Request=e.Request,window.Response=e.Response)}const l={AbortController:window.AbortController,client:a,utils:u,oauth2:{settings:c,ready:o,authorize:s,init:i}};e.exports=l},6966:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertJsonPatch=t.assert=t.getTargetWindow=t.getPatientParam=t.byCodes=t.byCode=t.getAccessTokenExpiration=t.getTimeInFuture=t.jwtDecode=t.randomString=t.absolute=t.makeArray=t.setPath=t.getPath=t.fetchConformanceStatement=t.getAndCache=t.request=t.loweCaseKeys=t.responseToJSON=t.checkResponse=t.units=t.debug=void 0;const n=r(7998),o=r(7691),s=r(866),{fetch:i}="undefined"!=typeof FHIRCLIENT_PURE?window:r(4098),a=s("FHIR");t.debug=a;const c={};function u({value:e,code:t}){if("number"!=typeof e)throw new Error("Found a non-numerical unit: "+e+" "+t)}async function l(e){if(!e.ok){const t=new n.default(e);throw await t.parse(),t}return e}function f(e){return e.text().then((e=>e.length?JSON.parse(e):""))}function h(e){if(!e)return e;if(Array.isArray(e))return e.map((e=>e&&"object"==typeof e?h(e):e));let t={};return Object.keys(e).forEach((r=>{const n=r.toLowerCase(),o=e[r];t[n]=o&&"object"==typeof o?h(o):o})),t}function p(e,t={}){const{includeResponse:r,...n}=t;return i(e,{mode:"cors",...n,headers:{accept:"application/json",...h(n.headers)}}).then(l).then((e=>{const t=e.headers.get("content-type")+"";return t.match(/\bjson\b/i)?f(e).then((t=>({res:e,body:t}))):t.match(/^text\//i)?e.text().then((t=>({res:e,body:t}))):{res:e}})).then((({res:e,body:t})=>{if(!t&&201==e.status){const t=e.headers.get("location");if(t)return p(t,{...n,method:"GET",body:null,includeResponse:r})}return r?{body:t,response:e}:void 0===t?e:t}))}function d(e,t,r=!1){return r||!c[e]?(c[e]=p(e,t),c[e]):Promise.resolve(c[e])}function y(e,t=""){if(!(t=t.trim()))return e;let r=t.split("."),n=e;for(;n&&r.length;){const e=r.shift();if(!e&&Array.isArray(n))return n.map((e=>y(e,r.join("."))));n=n[e]}return n}function g(e){return Array.isArray(e)?e:[e]}function m(e,t){const r=e.split(".")[1];return r?JSON.parse(t.atob(r)):null}function b(e,t){const r={};function n(e,t){e&&Array.isArray(e.coding)&&e.coding.forEach((({code:e})=>{e&&(r[e]=r[e]||[],r[e].push(t))}))}return g(e).forEach((e=>{"Observation"===e.resourceType&&e[t]&&(Array.isArray(e[t])?e[t].forEach((t=>n(t,e))):n(e[t],e))})),r}function v(e,t){if(!e)throw new Error(t)}t.units={cm({code:e,value:t}){if(u({code:e,value:t}),"cm"==e)return t;if("m"==e)return 100*t;if("in"==e)return 2.54*t;if("[in_us]"==e)return 2.54*t;if("[in_i]"==e)return 2.54*t;if("ft"==e)return 30.48*t;if("[ft_us]"==e)return 30.48*t;throw new Error("Unrecognized length unit: "+e)},kg({code:e,value:t}){if(u({code:e,value:t}),"kg"==e)return t;if("g"==e)return t/1e3;if(e.match(/lb/))return t/2.20462;if(e.match(/oz/))return t/35.274;throw new Error("Unrecognized weight unit: "+e)},any:e=>(u(e),e.value)},t.checkResponse=l,t.responseToJSON=f,t.loweCaseKeys=h,t.request=p,t.getAndCache=d,t.fetchConformanceStatement=function(e="/",t){const r=String(e).replace(/\/*$/,"/")+"metadata";return d(r,t).catch((e=>{throw new Error(`Failed to fetch the conformance statement from "${r}". ${e}`)}))},t.getPath=y,t.setPath=function(e,t,r,n=!1){return t.trim().split(".").reduce(((e,t,o,s)=>{if(!e||o!==s.length-1)return e&&void 0===e[t]&&n&&(e[t]=s[o+1].match(/^[0-9]+$/)?[]:{}),e?e[t]:void 0;e[t]=r}),e),e},t.makeArray=g,t.absolute=function(e,t){return e.match(/^http/)||e.match(/^urn/)?e:String(t||"").replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")},t.randomString=function(e=8,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){const r=[],n=t.length;for(;e--;)r.push(t.charAt(Math.floor(Math.random()*n)));return r.join("")},t.jwtDecode=m,t.getTimeInFuture=function(e=120,t){return Math.floor(+(t||new Date)/1e3+e)},t.getAccessTokenExpiration=function(e,t){const r=Math.floor(Date.now()/1e3);if(e.expires_in)return r+e.expires_in;if(e.access_token){let r=m(e.access_token,t);if(r&&r.exp)return r.exp}return r+300},t.byCode=b,t.byCodes=function(e,t){const r=b(e,t);return(...e)=>e.filter((e=>e+""in r)).reduce(((e,t)=>e.concat(r[t+""])),[])},t.getPatientParam=function(e,t){const r=(y(e,"rest.0.resource")||[]).find((e=>e.type===t));if(!r)throw new Error(`Resource "${t}" is not supported by this FHIR server`);if(!Array.isArray(r.searchParam))throw new Error(`No search parameters supported for "${t}" on this FHIR server`);if("Patient"==t&&r.searchParam.find((e=>"_id"==e.name)))return"_id";const n=o.patientParams.find((e=>r.searchParam.find((t=>t.name==e))));if(!n)throw new Error("I don't know what param to use for "+t);return n},t.getTargetWindow=async function(e,t=800,r=720){if("function"==typeof e&&(e=await e()),e&&"object"==typeof e)return e;if("string"!=typeof e)return a("Invalid target type '%s'. Failing back to '_self'.",typeof e),self;if("_self"==e)return self;if("_parent"==e)return parent;if("_top"==e)return top||self;if("_blank"==e){let e,t=null;try{if(t=window.open("","SMARTAuthPopup"),!t)throw new Error("Perhaps window.open was blocked")}catch(t){e=t}return t||(a("Cannot open window. Failing back to '_self'. %s",e),self)}if("popup"==e){let e,n=null;try{if(n=window.open("","SMARTAuthPopup",["height="+r,"width="+t,"menubar=0","resizable=1","status=0","top="+(screen.height-r)/2,"left="+(screen.width-t)/2].join(",")),!n)throw new Error("Perhaps the popup window was blocked")}catch(t){e=t}return n||(a("Cannot open window. Failing back to '_self'. %s",e),self)}return frames[e]||(a("Unknown target '%s'. Failing back to '_self'.",e),self)},t.assert=v,t.assertJsonPatch=function(e){v(Array.isArray(e),"The JSON patch must be an array"),v(e.length>0,"The JSON patch array should not be empty"),e.forEach((e=>{v(["add","replace","test","move","copy","remove"].indexOf(e.op)>-1,'Each patch operation must have an "op" property which must be one of: "add", "replace", "test", "move", "copy", "remove"'),v(e.path&&typeof e.path,`Invalid "${e.op}" operation. Missing "path" property`),"add"==e.op||"replace"==e.op||"test"==e.op?(v("value"in e,`Invalid "${e.op}" operation. Missing "value" property`),v(3==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)):"move"==e.op||"copy"==e.op?(v("string"==typeof e.from,`Invalid "${e.op}" operation. Requires a string "from" property`),v(3==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)):v(2==Object.keys(e).length,`Invalid "${e.op}" operation. Contains unknown properties`)}))}},8366:(e,t,r)=>{"use strict";r(6801),Object.defineProperty(t,"__esModule",{value:!0}),t.signCompactJws=t.importJWK=t.generatePKCEChallenge=t.digestSha256=t.randomBytes=void 0;const n=r(9575),o=(()=>{if("object"==typeof globalThis&&globalThis.crypto)return globalThis.crypto;throw new Error("window.crypto does not exist in this browser")})(),s=o.subtle,i={ES384:{name:"ECDSA",namedCurve:"P-384"},RS384:{name:"RSASSA-PKCS1-v1_5",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-384"}}};function a(e){return o.getRandomValues(new Uint8Array(e))}async function c(e){const t=(new TextEncoder).encode(e),r=await s.digest("SHA-256",t);return new Uint8Array(r)}t.randomBytes=a,t.digestSha256=c,t.generatePKCEChallenge=async(e=96)=>{const t=a(e),r=(0,n.fromUint8Array)(t,!0);return{codeChallenge:(0,n.fromUint8Array)(await c(r),!0),codeVerifier:r}},t.importJWK=async function(e){if(!e.alg)throw new Error('The "alg" property of the JWK must be set to "ES384" or "RS384"');if(Array.isArray(e.key_ops)||(e.key_ops=["sign"]),!e.key_ops.includes("sign"))throw new Error('The "key_ops" property of the JWK does not contain "sign"');try{return await s.importKey("jwk",e,i[e.alg],!0===e.ext,e.key_ops)}catch(t){throw new Error(`The ${e.alg} is not supported by this browser: ${t}`)}},t.signCompactJws=async function(e,t,r,o){const i=JSON.stringify({...r,alg:e}),a=JSON.stringify(o),c=`${(0,n.encodeURL)(i)}.${(0,n.encodeURL)(a)}`,u=await s.sign({...t.algorithm,hash:"SHA-384"},t,(new TextEncoder).encode(c));return`${c}.${(0,n.fromUint8Array)(new Uint8Array(u),!0)}`}},7691:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SMART_KEY=t.patientParams=t.fhirVersions=t.patientCompartment=void 0,t.patientCompartment=["Account","AdverseEvent","AllergyIntolerance","Appointment","AppointmentResponse","AuditEvent","Basic","BodySite","BodyStructure","CarePlan","CareTeam","ChargeItem","Claim","ClaimResponse","ClinicalImpression","Communication","CommunicationRequest","Composition","Condition","Consent","Coverage","CoverageEligibilityRequest","CoverageEligibilityResponse","DetectedIssue","DeviceRequest","DeviceUseRequest","DeviceUseStatement","DiagnosticOrder","DiagnosticReport","DocumentManifest","DocumentReference","EligibilityRequest","Encounter","EnrollmentRequest","EpisodeOfCare","ExplanationOfBenefit","FamilyMemberHistory","Flag","Goal","Group","ImagingManifest","ImagingObjectSelection","ImagingStudy","Immunization","ImmunizationEvaluation","ImmunizationRecommendation","Invoice","List","MeasureReport","Media","MedicationAdministration","MedicationDispense","MedicationOrder","MedicationRequest","MedicationStatement","MolecularSequence","NutritionOrder","Observation","Order","Patient","Person","Procedure","ProcedureRequest","Provenance","QuestionnaireResponse","ReferralRequest","RelatedPerson","RequestGroup","ResearchSubject","RiskAssessment","Schedule","ServiceRequest","Specimen","SupplyDelivery","SupplyRequest","VisionPrescription"],t.fhirVersions={"0.4.0":2,"0.5.0":2,"1.0.0":2,"1.0.1":2,"1.0.2":2,"1.1.0":3,"1.4.0":3,"1.6.0":3,"1.8.0":3,"3.0.0":3,"3.0.1":3,"3.3.0":4,"3.5.0":4,"4.0.0":4,"4.0.1":4},t.patientParams=["patient","subject","requester","member","actor","beneficiary"],t.SMART_KEY="SMART_KEY"},1074:(e,t,r)=>{"use strict";r(6801),Object.defineProperty(t,"__esModule",{value:!0}),t.init=t.buildTokenRequest=t.ready=t.onMessage=t.isInPopUp=t.isInFrame=t.authorize=t.getSecurityExtensions=t.fetchWellKnownJson=t.KEY=void 0;const n=r(6966),o=r(9071),s=r(7691);Object.defineProperty(t,"KEY",{enumerable:!0,get:function(){return s.SMART_KEY}});const i=n.debug.extend("oauth2");function a(){return"object"==typeof window}function c(e="/",t){const r=String(e).replace(/\/*$/,"/")+".well-known/smart-configuration";return(0,n.getAndCache)(r,t).catch((e=>{throw new Error(`Failed to fetch the well-known json "${r}". ${e.message}`)}))}function u(e="/"){return function(e="/",t){return c(e,void 0).then((e=>{if(!e.authorization_endpoint||!e.token_endpoint)throw new Error("Invalid wellKnownJson");return{registrationUri:e.registration_endpoint||"",authorizeUri:e.authorization_endpoint,tokenUri:e.token_endpoint,codeChallengeMethods:e.code_challenge_methods_supported||[]}}))}(e).catch((()=>function(e="/",t){return(0,n.fetchConformanceStatement)(e,t).then((e=>{const t=((0,n.getPath)(e||{},"rest.0.security.extension")||[]).filter((e=>"http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris"===e.url)).map((e=>e.extension))[0],r={registrationUri:"",authorizeUri:"",tokenUri:"",codeChallengeMethods:[]};return t&&t.forEach((e=>{"register"===e.url&&(r.registrationUri=e.valueUri),"authorize"===e.url&&(r.authorizeUri=e.valueUri),"token"===e.url&&(r.tokenUri=e.valueUri)})),r}))}(e)))}async function l(e,t={}){const r=e.getUrl();if(Array.isArray(t)){const o=r.searchParams.get("iss")||r.searchParams.get("fhirServiceUrl");if(!o)throw new Error('Passing in an "iss" url parameter is required if authorize uses multiple configurations');const s=t.find((e=>{if(e.issMatch){if("function"==typeof e.issMatch)return!!e.issMatch(o);if("string"==typeof e.issMatch)return e.issMatch===o;if(e.issMatch instanceof RegExp)return e.issMatch.test(o)}return!1}));return(0,n.assert)(s,`No configuration found matching the current "iss" parameter "${o}"`),await l(e,s)}const{redirect_uri:o,clientSecret:c,fakeTokenResponse:d,patientId:y,encounterId:g,client_id:m,target:b,width:v,height:w,pkceMode:C,clientPublicKeySetUrl:S}=t;let{iss:P,launch:x,fhirServiceUrl:A,redirectUri:E,noRedirect:_,scope:k="",clientId:R,completeInTarget:O,clientPrivateJwk:F,stateKey:U}=t;const T=e.getStorage();P=r.searchParams.get("iss")||P,A=r.searchParams.get("fhirServiceUrl")||A,x=r.searchParams.get("launch")||x,R||(R=m),E||(E=o),E?E.match(/^https?\:\/\//)||(E=e.relative(E)):E=e.relative(".");const j=String(P||A||"");if(!j)throw new Error("No server url found. It must be specified as `iss` or as `fhirServiceUrl` parameter");if(P&&i("Making %s launch...",x?"EHR":"standalone"),x&&!k.match(/launch/)&&(k+=" launch"),a()){const e=f(),t=h();(e||t)&&!0!==O&&!1!==O&&(O=e,console.warn('Your app is being authorized from within an iframe or popup window. Please be explicit and provide a "completeInTarget" option. Use "true" to complete the authorization in the same window, or "false" to try to complete it in the parent or the opener window. See http://docs.smarthealthit.org/client-js/api.html'))}const I=await T.get(s.SMART_KEY);await T.unset(I),U=null!=U?U:(0,n.randomString)(16);const M={clientId:R,scope:k,redirectUri:E,serverUrl:j,clientSecret:c,clientPrivateJwk:F,tokenResponse:{},key:U,completeInTarget:O,clientPublicKeySetUrl:S};(!a()||(0,n.getPath)(e,"options.fullSessionStorageSupport"))&&await T.set(s.SMART_KEY,U),d&&Object.assign(M.tokenResponse,d),y&&Object.assign(M.tokenResponse,{patient:y}),g&&Object.assign(M.tokenResponse,{encounter:g});let B=E+"?state="+encodeURIComponent(U);if(A&&!P)return i("Making fake launch..."),await T.set(U,M),_?B:await e.redirect(B);const D=await u(j);if(Object.assign(M,D),await T.set(U,M),!M.authorizeUri)return _?B:await e.redirect(B);const L=["response_type=code","client_id="+encodeURIComponent(R||""),"scope="+encodeURIComponent(k),"redirect_uri="+encodeURIComponent(E),"aud="+encodeURIComponent(j),"state="+encodeURIComponent(U)];if(x&&L.push("launch="+encodeURIComponent(x)),function(e,t){if("disabled"===t)return!1;if("unsafeV1"===t)return!0;if("required"===t){if(!e)throw new Error("Required PKCE code challenge method (`S256`) was not found.");return!0}return e}(D.codeChallengeMethods.includes("S256"),C)){let t=await e.security.generatePKCEChallenge();Object.assign(M,t),await T.set(U,M),L.push("code_challenge="+M.codeChallenge),L.push("code_challenge_method=S256")}if(B=M.authorizeUri+"?"+L.join("&"),_)return B;if(!b||!a())return await e.redirect(B);{let e;if(e=await(0,n.getTargetWindow)(b,v,w),e!==self)try{e.sessionStorage.removeItem(I),e.sessionStorage.setItem(U,JSON.stringify(M))}catch(t){(0,n.debug)('Failed to modify window.sessionStorage. Perhaps it is from different origin?. Failing back to "_self". %s',t),e=self}if(e!==self)try{e.location.href=B,self.addEventListener("message",p)}catch(e){(0,n.debug)('Failed to modify window.location. Perhaps it is from different origin?. Failing back to "_self". %s',e),self.location.href=B}else self.location.href=B}}function f(){try{return self!==top&&parent!==self}catch(e){return!0}}function h(){try{return self===top&&!!opener&&opener!==self&&!!window.name}catch(e){return!1}}function p(e){"completeAuth"==e.data.type&&e.origin===new URL(self.location.href).origin&&(window.removeEventListener("message",p),window.location.href=e.data.url)}async function d(e,t={}){var r,c;const u=e.getUrl(),l=e.getStorage(),p=u.searchParams;let d=p.get("state");const g=p.get("code"),m=p.get("error"),b=p.get("error_description");if(d||(d=await l.get(s.SMART_KEY)),m||b)throw new Error([m,b].filter(Boolean).join(": "));i("key: %s, code: %s",d,g),(0,n.assert)(d,"No 'state' parameter found. Please (re)launch the app.");let v=await l.get(d);const w=!a()||(0,n.getPath)(e,"options.fullSessionStorageSupport");if(a()&&v&&!v.completeInTarget){const e=f(),t=h();if((e||t)&&!u.searchParams.get("complete")){u.searchParams.set("complete","1");const{href:r,origin:n}=u;return e&&parent.postMessage({type:"completeAuth",url:r},n),t&&(opener.postMessage({type:"completeAuth",url:r},n),window.close()),new Promise((()=>{}))}}u.searchParams.delete("complete");const C=p.has("state");if(a()&&(0,n.getPath)(e,"options.replaceBrowserHistory")&&(g||C)&&(g&&(p.delete("code"),i("Removed code parameter from the url.")),C&&w&&(p.delete("state"),i("Removed state parameter from the url.")),window.history.replaceState&&window.history.replaceState({},"",u.href)),(0,n.assert)(v,"No state found! Please (re)launch the app."),g&&!(null===(r=v.tokenResponse)||void 0===r?void 0:r.access_token)&&v.tokenUri){(0,n.assert)(g,"'code' url parameter is required"),i("Preparing to exchange the code for access token...");const r=await y(e,{code:g,state:v,clientPublicKeySetUrl:t.clientPublicKeySetUrl,privateKey:t.privateKey||v.clientPrivateJwk});i("Token request options: %O",r);const o=await(0,n.request)(v.tokenUri,r);i("Token response: %O",o),(0,n.assert)(o.access_token,"Failed to obtain access token."),v.expiresAt=(0,n.getAccessTokenExpiration)(o,e),v={...v,tokenResponse:o},await l.set(d,v),i("Authorization successful!")}else i((null===(c=v.tokenResponse)||void 0===c?void 0:c.access_token)?"Already authorized":"No authorization needed");w&&await l.set(s.SMART_KEY,d);const S=new o.default(e,v);return i("Created client instance: %O",S),S}async function y(e,{code:t,state:r,clientPublicKeySetUrl:o,privateKey:s}){const{redirectUri:a,clientSecret:c,tokenUri:u,clientId:l,codeVerifier:f}=r;(0,n.assert)(a,"Missing state.redirectUri"),(0,n.assert)(u,"Missing state.tokenUri"),(0,n.assert)(l,"Missing state.clientId");const h={method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:`code=${t}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(a)}`};if(c)h.headers.authorization="Basic "+e.btoa(l+":"+c),i("Using state.clientSecret to construct the authorization header: %s",h.headers.authorization);else if(s){const t="key"in s?s.key:await e.security.importJWK(s),a={typ:"JWT",kid:s.kid,jku:o||r.clientPublicKeySetUrl},c={iss:l,sub:l,aud:u,jti:e.base64urlencode(e.security.randomBytes(32)),exp:(0,n.getTimeInFuture)(120)},f=await e.security.signCompactJws(s.alg,t,a,c);h.body+=`&client_assertion_type=${encodeURIComponent("urn:ietf:params:oauth:client-assertion-type:jwt-bearer")}`,h.body+=`&client_assertion=${encodeURIComponent(f)}`,i("Using state.clientPrivateJwk to add a client_assertion to the POST body")}else i("Public client detected; adding state.clientId to the POST body"),h.body+=`&client_id=${encodeURIComponent(l)}`;return f&&(i("Found state.codeVerifier, adding to the POST body"),h.body+="&code_verifier="+f),h}t.fetchWellKnownJson=c,t.getSecurityExtensions=u,t.authorize=l,t.isInFrame=f,t.isInPopUp=h,t.onMessage=p,t.ready=d,t.buildTokenRequest=y,t.init=async function(e,t,r){const n=e.getUrl(),i=n.searchParams.get("code"),a=n.searchParams.get("state");if(i&&a)return d(e,r);const c=e.getStorage(),u=a||await c.get(s.SMART_KEY),f=await c.get(u);return f?new o.default(e,f):l(e,t).then((()=>new Promise((()=>{}))))}},1060:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{async get(e){const t=sessionStorage[e];return t?JSON.parse(t):null}async set(e,t){return sessionStorage[e]=JSON.stringify(t),t}async unset(e){return e in sessionStorage&&(delete sessionStorage[e],!0)}}},2088:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={expired:"Session expired! Please re-launch the app",noScopeForId:"Trying to get the ID of the selected %s. Please add 'launch' or 'launch/%s' to the requested scopes and try again.",noIfNoAuth:"You are trying to get %s but the app is not authorized yet.",noFreeContext:"Please don't use open fhir servers if you need to access launch context items like the %S."}},4098:function(e,t){var r="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in e,i="ArrayBuffer"in e;if(i)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function f(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function d(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=d(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():i&&o&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=d(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=u(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},h.prototype.delete=function(e){delete this.map[u(e)]},h.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},h.prototype.set=function(e,t){this.map[u(e)]=l(t)},h.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},h.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),f(e)},h.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),f(e)},h.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),f(e)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var r,n,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new h(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),b.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}})),t}function C(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},C.error=function(){var e=new C(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];C.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new C(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function P(e,r){return new Promise((function(n,s){var i=new v(e,r);if(i.signal&&i.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new C(o,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},a.open(i.method,i.url,!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),i.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),i.signal&&(i.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",c)}),a.send(void 0===i._bodyInit?null:i._bodyInit)}))}P.polyfill=!0,e.fetch||(e.fetch=P,e.Headers=h,e.Request=v,e.Response=C),t.Headers=h,t.Request=v,t.Response=C,t.fetch=P,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var o=n;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},9575:function(e,t,r){"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r.g&&r.g,e.exports=function(){"use strict";var e,t="3.7.2",r="function"==typeof atob,n="function"==typeof btoa,o="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,i="function"==typeof TextEncoder?new TextEncoder:void 0,a=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(e={},a.forEach((function(t,r){return e[t]=r})),e),u=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,l=String.fromCharCode.bind(String),f="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(e,t){return void 0===t&&(t=function(e){return e}),new Uint8Array(Array.prototype.slice.call(e,0).map(t))},h=function(e){return e.replace(/=/g,"")