@hiver/connector-agent 0.0.0 → 0.0.1-beta.0

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/index.es.js CHANGED
@@ -26025,8 +26025,10 @@ function Um() {
26025
26025
  }();
26026
26026
  e.Bifrost = c;
26027
26027
  })(G0);
26028
- const JM = new G0.Bifrost(), ZM = ({ rootUrl: e, configHiver: t, withCredentials: n }) => async (o) => {
26029
- const { appEnv: i, tier: a } = F_(), l = S_(), u = T_(), { url: c, method: f } = o, y = {
26028
+ const JM = new G0.Bifrost(), ZM = ({ rootUrl: e, configHiver: t, withCredentials: n }) => (console.log("NOW App Env1111++++++"), async (o) => {
26029
+ const { appEnv: i, tier: a } = F_();
26030
+ console.log("NOW App Env++++++", i, a);
26031
+ const l = S_(), u = T_(), { url: c, method: f } = o, y = {
26030
26032
  root_url: (e || O_()) + ((o == null ? void 0 : o.prefix) || ""),
26031
26033
  url: c,
26032
26034
  method: f,
@@ -26058,7 +26060,7 @@ const JM = new G0.Bifrost(), ZM = ({ rootUrl: e, configHiver: t, withCredentials
26058
26060
  } catch (E) {
26059
26061
  throw console.error("API call failed with error: ", E), E;
26060
26062
  }
26061
- }, eR = ZM({
26063
+ }), eR = ZM({
26062
26064
  configHiver: {
26063
26065
  getToken: !0,
26064
26066
  fetchCsrfToken: () => "",
package/index.umd.js CHANGED
@@ -1999,7 +1999,7 @@ Take a look at the reducer(s) handling this action type: ${E.type}.
1999
1999
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[W0]=this[W0]={accessors:{}}).accessors,o=this.prototype;function i(a){const l=ui(a);r[l]||(DU(o,a),r[l]=!0)}return I.isArray(t)?t.forEach(i):i(t),this}}oa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),I.reduceDescriptors(oa.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),I.freezeMethods(oa);var mn=oa;function Bc(e,t){const n=this||Ic,r=t||n,o=mn.from(r.headers);let i=r.data;return I.forEach(e,function(l){i=l.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function q0(e){return!!(e&&e.__CANCEL__)}function lo(e,t,n){be.call(this,e??"canceled",be.ERR_CANCELED,t,n),this.name="CanceledError"}I.inherits(lo,be,{__CANCEL__:!0});function H0(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new be("Request failed with status code "+n.status,[be.ERR_BAD_REQUEST,be.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function IU(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function NU(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,a;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),f=r[i];a||(a=c),n[o]=u,r[o]=c;let b=i,y=0;for(;b!==o;)y+=n[b++],b=b%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-a<t)return;const E=f&&c-f;return E?Math.round(y*1e3/E):void 0}}function BU(e,t){let n=0,r=1e3/t,o,i;const a=(c,f=Date.now())=>{n=f,o=null,i&&(clearTimeout(i),i=null),e.apply(null,c)};return[(...c)=>{const f=Date.now(),b=f-n;b>=r?a(c,f):(o=c,i||(i=setTimeout(()=>{i=null,a(o)},r-b)))},()=>o&&a(o)]}const ia=(e,t,n=3)=>{let r=0;const o=NU(50,250);return BU(i=>{const a=i.loaded,l=i.lengthComputable?i.total:void 0,u=a-r,c=o(u),f=a<=l;r=a;const b={loaded:a,total:l,progress:l?a/l:void 0,bytes:u,rate:c||void 0,estimated:c&&l&&f?(l-a)/c:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(b)},n)},K0=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},G0=e=>(...t)=>I.asap(()=>e(...t));var $U=Nt.hasStandardBrowserEnv?function(){const t=Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent),n=document.createElement("a");let r;function o(i){let a=i;return t&&(n.setAttribute("href",a),a=n.href),n.setAttribute("href",a),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=o(window.location.href),function(a){const l=I.isString(a)?o(a):a;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}(),jU=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const a=[e+"="+encodeURIComponent(t)];I.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),I.isString(r)&&a.push("path="+r),I.isString(o)&&a.push("domain="+o),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function LU(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zU(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function X0(e,t){return e&&!LU(t)?zU(e,t):t}const Q0=e=>e instanceof mn?{...e}:e;function Sr(e,t){t=t||{};const n={};function r(c,f,b){return I.isPlainObject(c)&&I.isPlainObject(f)?I.merge.call({caseless:b},c,f):I.isPlainObject(f)?I.merge({},f):I.isArray(f)?f.slice():f}function o(c,f,b){if(I.isUndefined(f)){if(!I.isUndefined(c))return r(void 0,c,b)}else return r(c,f,b)}function i(c,f){if(!I.isUndefined(f))return r(void 0,f)}function a(c,f){if(I.isUndefined(f)){if(!I.isUndefined(c))return r(void 0,c)}else return r(void 0,f)}function l(c,f,b){if(b in t)return r(c,f);if(b in e)return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l,headers:(c,f)=>o(Q0(c),Q0(f),!0)};return I.forEach(Object.keys(Object.assign({},e,t)),function(f){const b=u[f]||o,y=b(e[f],t[f],f);I.isUndefined(y)&&b!==l||(n[f]=y)}),n}var J0=e=>{const t=Sr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:a,auth:l}=t;t.headers=a=mn.from(a),t.url=L0(X0(t.baseURL,t.url),e.params,e.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let u;if(I.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((u=a.getContentType())!==!1){const[c,...f]=u?u.split(";").map(b=>b.trim()).filter(Boolean):[];a.setContentType([c||"multipart/form-data",...f].join("; "))}}if(Nt.hasStandardBrowserEnv&&(r&&I.isFunction(r)&&(r=r(t)),r||r!==!1&&$U(t.url))){const c=o&&i&&jU.read(i);c&&a.set(o,c)}return t},VU=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=J0(e);let i=o.data;const a=mn.from(o.headers).normalize();let{responseType:l,onUploadProgress:u,onDownloadProgress:c}=o,f,b,y,E,m;function h(){E&&E(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let d=new XMLHttpRequest;d.open(o.method.toUpperCase(),o.url,!0),d.timeout=o.timeout;function g(){if(!d)return;const v=mn.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),p={data:!l||l==="text"||l==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:v,config:e,request:d};H0(function(S){n(S),h()},function(S){r(S),h()},p),d=null}"onloadend"in d?d.onloadend=g:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(g)},d.onabort=function(){d&&(r(new be("Request aborted",be.ECONNABORTED,e,d)),d=null)},d.onerror=function(){r(new be("Network Error",be.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const p=o.transitional||V0;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),r(new be(x,p.clarifyTimeoutError?be.ETIMEDOUT:be.ECONNABORTED,e,d)),d=null},i===void 0&&a.setContentType(null),"setRequestHeader"in d&&I.forEach(a.toJSON(),function(x,p){d.setRequestHeader(p,x)}),I.isUndefined(o.withCredentials)||(d.withCredentials=!!o.withCredentials),l&&l!=="json"&&(d.responseType=o.responseType),c&&([y,m]=ia(c,!0),d.addEventListener("progress",y)),u&&d.upload&&([b,E]=ia(u),d.upload.addEventListener("progress",b),d.upload.addEventListener("loadend",E)),(o.cancelToken||o.signal)&&(f=v=>{d&&(r(!v||v.type?new lo(null,e,d):v),d.abort(),d=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const C=IU(o.url);if(C&&Nt.protocols.indexOf(C)===-1){r(new be("Unsupported protocol "+C+":",be.ERR_BAD_REQUEST,e));return}d.send(i||null)})},YU=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const i=function(c){if(!o){o=!0,l();const f=c instanceof Error?c:this.reason;r.abort(f instanceof be?f:new lo(f instanceof Error?f.message:f))}};let a=t&&setTimeout(()=>{a=null,i(new be(`timeout ${t} of ms exceeded`,be.ETIMEDOUT))},t);const l=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),e=null)};e.forEach(c=>c.addEventListener("abort",i));const{signal:u}=r;return u.unsubscribe=()=>I.asap(l),u}};const WU=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qU=async function*(e,t){for await(const n of HU(e))yield*WU(n,t)},HU=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Z0=(e,t,n,r)=>{const o=qU(e,t);let i=0,a,l=u=>{a||(a=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:c,value:f}=await o.next();if(c){l(),u.close();return}let b=f.byteLength;if(n){let y=i+=b;n(y)}u.enqueue(new Uint8Array(f))}catch(c){throw l(c),c}},cancel(u){return l(u),o.return()}},{highWaterMark:2})},sa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",em=sa&&typeof ReadableStream=="function",KU=sa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tm=(e,...t)=>{try{return!!e(...t)}catch{return!1}},GU=em&&tm(()=>{let e=!1;const t=new Request(Nt.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),nm=64*1024,$c=em&&tm(()=>I.isReadableStream(new Response("").body)),aa={stream:$c&&(e=>e.body)};sa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!aa[t]&&(aa[t]=I.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new be(`Response type '${t}' is not supported`,be.ERR_NOT_SUPPORT,r)})})})(new Response);const XU=async e=>{if(e==null)return 0;if(I.isBlob(e))return e.size;if(I.isSpecCompliantForm(e))return(await new Request(Nt.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(I.isArrayBufferView(e)||I.isArrayBuffer(e))return e.byteLength;if(I.isURLSearchParams(e)&&(e=e+""),I.isString(e))return(await KU(e)).byteLength},QU=async(e,t)=>{const n=I.toFiniteNumber(e.getContentLength());return n??XU(t)};var JU=sa&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:a,onDownloadProgress:l,onUploadProgress:u,responseType:c,headers:f,withCredentials:b="same-origin",fetchOptions:y}=J0(e);c=c?(c+"").toLowerCase():"text";let E=YU([o,i&&i.toAbortSignal()],a),m;const h=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let d;try{if(u&&GU&&n!=="get"&&n!=="head"&&(d=await QU(f,r))!==0){let p=new Request(t,{method:"POST",body:r,duplex:"half"}),w;if(I.isFormData(r)&&(w=p.headers.get("content-type"))&&f.setContentType(w),p.body){const[S,F]=K0(d,ia(G0(u)));r=Z0(p.body,nm,S,F)}}I.isString(b)||(b=b?"include":"omit");const g="credentials"in Request.prototype;m=new Request(t,{...y,signal:E,method:n.toUpperCase(),headers:f.normalize().toJSON(),body:r,duplex:"half",credentials:g?b:void 0});let C=await fetch(m);const v=$c&&(c==="stream"||c==="response");if($c&&(l||v&&h)){const p={};["status","statusText","headers"].forEach(U=>{p[U]=C[U]});const w=I.toFiniteNumber(C.headers.get("content-length")),[S,F]=l&&K0(w,ia(G0(l),!0))||[];C=new Response(Z0(C.body,nm,S,()=>{F&&F(),h&&h()}),p)}c=c||"text";let x=await aa[I.findKey(aa,c)||"text"](C,e);return!v&&h&&h(),await new Promise((p,w)=>{H0(p,w,{data:x,headers:mn.from(C.headers),status:C.status,statusText:C.statusText,config:e,request:m})})}catch(g){throw h&&h(),g&&g.name==="TypeError"&&/fetch/i.test(g.message)?Object.assign(new be("Network Error",be.ERR_NETWORK,e,m),{cause:g.cause||g}):be.from(g,g&&g.code,e,m)}});const jc={http:pU,xhr:VU,fetch:JU};I.forEach(jc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const rm=e=>`- ${e}`,ZU=e=>I.isFunction(e)||e===null||e===!1;var om={getAdapter:e=>{e=I.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){n=e[i];let a;if(r=n,!ZU(n)&&(r=jc[(a=String(n)).toLowerCase()],r===void 0))throw new be(`Unknown adapter '${a}'`);if(r)break;o[a||"#"+i]=r}if(!r){const i=Object.entries(o).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
2000
2000
  `+i.map(rm).join(`
2001
2001
  `):" "+rm(i[0]):"as no adapter specified";throw new be("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return r},adapters:jc};function Lc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lo(null,e)}function im(e){return Lc(e),e.headers=mn.from(e.headers),e.data=Bc.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),om.getAdapter(e.adapter||Ic.adapter)(e).then(function(r){return Lc(e),r.data=Bc.call(e,e.transformResponse,r),r.headers=mn.from(r.headers),r},function(r){return q0(r)||(Lc(e),r&&r.response&&(r.response.data=Bc.call(e,e.transformResponse,r.response),r.response.headers=mn.from(r.response.headers))),Promise.reject(r)})}const sm="1.7.7",zc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{zc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const am={};zc.transitional=function(t,n,r){function o(i,a){return"[Axios v"+sm+"] Transitional option '"+i+"'"+a+(r?". "+r:"")}return(i,a,l)=>{if(t===!1)throw new be(o(a," has been removed"+(n?" in "+n:"")),be.ERR_DEPRECATED);return n&&!am[a]&&(am[a]=!0,console.warn(o(a," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,a,l):!0}};function eM(e,t,n){if(typeof e!="object")throw new be("options must be an object",be.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],a=t[i];if(a){const l=e[i],u=l===void 0||a(l,i,e);if(u!==!0)throw new be("option "+i+" must be "+u,be.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new be("Unknown option "+i,be.ERR_BAD_OPTION)}}var Vc={assertOptions:eM,validators:zc};const Zn=Vc.validators;let la=class{constructor(t){this.defaults=t,this.interceptors={request:new z0,response:new z0}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
2002
- `+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Sr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Vc.assertOptions(r,{silentJSONParsing:Zn.transitional(Zn.boolean),forcedJSONParsing:Zn.transitional(Zn.boolean),clarifyTimeoutError:Zn.transitional(Zn.boolean)},!1),o!=null&&(I.isFunction(o)?n.paramsSerializer={serialize:o}:Vc.assertOptions(o,{encode:Zn.function,serialize:Zn.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=i&&I.merge(i.common,i[n.method]);i&&I.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),n.headers=mn.concat(a,i);const l=[];let u=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(u=u&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let f,b=0,y;if(!u){const m=[im.bind(this),void 0];for(m.unshift.apply(m,l),m.push.apply(m,c),y=m.length,f=Promise.resolve(n);b<y;)f=f.then(m[b++],m[b++]);return f}y=l.length;let E=n;for(b=0;b<y;){const m=l[b++],h=l[b++];try{E=m(E)}catch(d){h.call(this,d);break}}try{f=im.call(this,E)}catch(m){return Promise.reject(m)}for(b=0,y=c.length;b<y;)f=f.then(c[b++],c[b++]);return f}getUri(t){t=Sr(this.defaults,t);const n=X0(t.baseURL,t.url);return L0(n,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){la.prototype[t]=function(n,r){return this.request(Sr(r||{},{method:t,url:n,data:(r||{}).data}))}}),I.forEach(["post","put","patch"],function(t){function n(r){return function(i,a,l){return this.request(Sr(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}la.prototype[t]=n(),la.prototype[t+"Form"]=n(!0)});var ca=la;class Yc{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const a=new Promise(l=>{r.subscribe(l),i=l}).then(o);return a.cancel=function(){r.unsubscribe(i)},a},t(function(i,a,l){r.reason||(r.reason=new lo(i,a,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Yc(function(o){t=o}),cancel:t}}}var tM=Yc;function nM(e){return function(n){return e.apply(null,n)}}function rM(e){return I.isObject(e)&&e.isAxiosError===!0}const Wc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wc).forEach(([e,t])=>{Wc[t]=e});var oM=Wc;function lm(e){const t=new ca(e),n=T0(ca.prototype.request,t);return I.extend(n,ca.prototype,t,{allOwnKeys:!0}),I.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return lm(Sr(e,o))},n}const ht=lm(Ic);ht.Axios=ca,ht.CanceledError=lo,ht.CancelToken=tM,ht.isCancel=q0,ht.VERSION=sm,ht.toFormData=na,ht.AxiosError=be,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=nM,ht.isAxiosError=rM,ht.mergeConfig=Sr,ht.AxiosHeaders=mn,ht.formToJSON=e=>Y0(I.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=om.getAdapter,ht.HttpStatusCode=oM,ht.default=ht;var cm=ht,Ge={},Tr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM=e.API_CALL_ORIGIN=e.TIERS=e.APP_UI=e.CONFIG_HIVER=e.REFETCH_CHECK_DELAY=e.INITIAL_RETRY_DELAY=e.MAX_BACKOFF_LIMIT=e.MAX_CONFLICT_RETRY_DELAY=e.MAX_RETRY_DELAY=e.GET_METHOD=void 0,e.GET_METHOD="GET",e.MAX_RETRY_DELAY=18e4,e.MAX_CONFLICT_RETRY_DELAY=63e3,e.MAX_BACKOFF_LIMIT=8e3,e.INITIAL_RETRY_DELAY=1e3,e.REFETCH_CHECK_DELAY=168e4,e.CONFIG_HIVER={getToken:!1,fetchCsrfToken:function(){return""},isHiverApiDomain:!0},e.APP_UI={COLLAB_SPACE:"collab-space",DEFAULT:"default"},e.TIERS={DEV:"dev",SIT:"sit",PROD:"production"},e.API_CALL_ORIGIN={API_RETRY:"Api Retry"},function(t){t[t.WEB=0]="WEB",t[t.MOBILE=1]="MOBILE"}(e.PLATFORM||(e.PLATFORM={}))})(Tr);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.getProdHqConfig=Bt.getProdApiConfig=Bt.getSitHqConfig=Bt.getSitApiConfig=Bt.getDevHqConfig=Bt.getDevApiConfig=void 0;var co={heimdallTokenFetch:"/v1/token/get",heimdallLogin:"/v1/login/code",v2Login:"/api/auth/login/code"},iM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api",apiEndpoints:co}};Bt.getDevApiConfig=iM;var sM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api2",apiEndpoints:co}};Bt.getDevHqConfig=sM;var aM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api"),apiEndpoints:co}};Bt.getSitApiConfig=aM;var lM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api2"),apiEndpoints:co}};Bt.getSitHqConfig=lM;var cM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall.hiverapi.com",apiEndpoints:co}};Bt.getProdApiConfig=cM;var uM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall2.hiverhq.com",apiEndpoints:co}};Bt.getProdHqConfig=uM;var Fr={},er={};Object.defineProperty(er,"__esModule",{value:!0}),er.getValue=er.setValue=void 0;var um={};function fM(e,t){um[e]=t}er.setValue=fM;function dM(e){return um[e]}er.getValue=dM,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.setItemInStorage=Fr.getItemFromStorage=void 0;var ua=Tr,fa=er,pM=function(e,t){switch(t===void 0&&(t=(0,fa.getValue)("PLATFORM")),t){case ua.PLATFORM.WEB:return sessionStorage.getItem(e);case ua.PLATFORM.MOBILE:return(0,fa.getValue)(e);default:throw Error("Invalid PLATFORM ".concat(t))}};Fr.getItemFromStorage=pM;var hM=function(e,t,n){switch(n===void 0&&(n=(0,fa.getValue)("PLATFORM")),n){case ua.PLATFORM.WEB:return sessionStorage.setItem(e,t);case ua.PLATFORM.MOBILE:return(0,fa.setValue)(e,t);default:throw Error("Invalid PLATFORM ".concat(n))}};Fr.setItemInStorage=hM;var mM=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},yM=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.expireToken=Ge.invalidateToken=Ge.validateToken=Ge.validateAccount=Ge.getConfig=Ge.introduceDelay=Ge.isTokenInExpiryWindow=Ge.getStoredAuthData=Ge.setUserDetails=Ge.setTokenAndExpiry=Ge.getRandomDelay=Ge.hasValidToken=void 0;var qc=Tr,uo=Bt,an=Fr,fm=function(){var e=new Date,t=new Date(e.getTime()+e.getTimezoneOffset()*6e4);return t},Hc=function(e){var t=parseInt((0,an.getItemFromStorage)("hiverAuthUserId")||"0"),n=parseInt((0,an.getItemFromStorage)("hiverAuthUserGroupId")||"0"),r=e.userId,o=e.usergroupId;return t===r&&o===n};Ge.validateAccount=Hc;var gM=function(e){var t=Hc(e);return!dm()&&t};Ge.validateToken=gM;var bM=function(e){return e.apiRetry?e.apiRetry>0:!1};Ge.invalidateToken=bM;var vM=function(){try{sessionStorage.removeItem("hiverAuthTokenExpiry")}catch{console.log("Heimdall: Unable to Remove token.")}};Ge.expireToken=vM;var wM=function(e){var t=(0,an.getItemFromStorage)("hiverAuthTokenExpiry")||"",n=new Date(t),r=fm(),o=Hc(e);return console.log("Heimdall: checking if there is a valid token",r<n&&o),r<n&&o};Ge.hasValidToken=wM;var EM=function(){return Math.floor(Math.random()*6e4)+6e4};Ge.getRandomDelay=EM;var CM=function(e,t){if(!e||!t)throw new Error("User Id or user group Id not found in the response");(0,an.setItemInStorage)("hiverAuthUserId",e),(0,an.setItemInStorage)("hiverAuthUserGroupId",t)};Ge.setUserDetails=CM;var xM=function(e,t){if(!e)throw new Error("Token not found in the response");(0,an.setItemInStorage)("hiverAuthToken",e),(0,an.setItemInStorage)("hiverAuthTokenExpiry",t)};Ge.setTokenAndExpiry=xM;var SM=function(){var e=(0,an.getItemFromStorage)("hiverAuthTokenExpiry"),t=(0,an.getItemFromStorage)("hiverAuthToken"),n=(0,an.getItemFromStorage)("hiverAuthUserId"),r=(0,an.getItemFromStorage)("hiverAuthUserGroupId");return{token:t,expiryTime:e,userId:n,usergroupId:r}};Ge.getStoredAuthData=SM;var dm=function(){var e=(0,an.getItemFromStorage)("hiverAuthTokenExpiry")||"";if(!e)return!0;var t=fm(),n=new Date(e),r=4*60*1e3,o=n.getTime()-t.getTime()<r;return console.log({currentTime:t,expiry:n,isInExpiryWindow:o}),o};Ge.isTokenInExpiryWindow=dm;var TM=function(e){return mM(void 0,void 0,void 0,function(){return yM(this,function(t){switch(t.label){case 0:return[4,new Promise(function(n){return setTimeout(n,e)})];case 1:return t.sent(),[2]}})})};Ge.introduceDelay=TM;var FM=function(e,t,n){switch(t){case qc.TIERS.SIT:return n?(0,uo.getSitApiConfig)(e):(0,uo.getSitHqConfig)(e);case qc.TIERS.PROD:return n?(0,uo.getProdApiConfig)():(0,uo.getProdHqConfig)();case qc.TIERS.DEV:default:return n?(0,uo.getDevApiConfig)():(0,uo.getDevHqConfig)()}};Ge.getConfig=FM;var fi={},jn={},pm;function OM(){if(pm)return jn;pm=1;var e=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},t=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(jn,"__esModule",{value:!0}),jn.getV2LoginCode=jn.getLoginToken=jn.getAccessToken=void 0;var n=Tr,r=bm(),o=Ge,i=function(y,E,m){var h=(0,o.getStoredAuthData)();return{root_url:y.heimdallUrl,url:y.apiEndpoints.heimdallTokenFetch,method:n.GET_METHOD,data:{user_id:E.userId,usergroup_id:E.usergroupId,access_token:(h==null?void 0:h.token)||"",source:m},withCredentials:!0}},a=function(y,E){return{root_url:E.heimdallUrl,url:E.apiEndpoints.heimdallLogin,method:n.GET_METHOD,data:{code:y},withCredentials:!0}},l=function(y){return parseInt(y,10)},u=function(y,E,m){return{root_url:y.v2Url,url:y.apiEndpoints.v2Login,method:n.GET_METHOD,withCredentials:!0,data:{usersession:l(E.userId),app:m||n.APP_UI.DEFAULT}}},c=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),!(0,o.validateToken)(m)||(0,o.invalidateToken)(m)?(console.log("HEIMDALL: No valid token, fetching token"),d=i(E,m,h),[4,(0,r.performAxiosCall)(d)]):[3,2];case 1:return g=S.sent(),[2,{atToken:(v=g==null?void 0:g.data.at)===null||v===void 0?void 0:v.token,expiryTime:(x=g==null?void 0:g.data.at)===null||x===void 0?void 0:x.expires_at,userId:(p=g==null?void 0:g.data)===null||p===void 0?void 0:p.user_id,userGroupId:(w=g==null?void 0:g.data)===null||w===void 0?void 0:w.usergroup_id}];case 2:return console.log("Heimdall: Valid token already exists"),[2,{}];case 3:return[3,5];case 4:throw C=S.sent(),C;case 5:return[2]}})})};jn.getAccessToken=c;var f=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g,C,v,x,p;return t(this,function(w){switch(w.label){case 0:h=a(y,m),w.label=1;case 1:return w.trys.push([1,3,,4]),[4,(0,r.performAxiosCall)(h)];case 2:return d=w.sent(),[2,{userId:(C=d==null?void 0:d.data)===null||C===void 0?void 0:C.user_id,userGroupId:(v=d==null?void 0:d.data)===null||v===void 0?void 0:v.usergroup_id,atToken:(x=d==null?void 0:d.data.at)===null||x===void 0?void 0:x.token,expiryTime:(p=d==null?void 0:d.data.at)===null||p===void 0?void 0:p.expires_at}];case 3:throw g=w.sent(),g;case 4:return[2]}})})};jn.getLoginToken=f;var b=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C;return t(this,function(v){switch(v.label){case 0:return v.trys.push([0,2,,3]),console.log("ERROR debug: in getV2loginCode:",h),d=u(E,m,h),[4,(0,r.performAxiosCall)(d)];case 1:return g=v.sent(),console.log("DEBUG HEIMDALL: local storage:",g==null?void 0:g.data),[2,g==null?void 0:g.data.code];case 2:throw C=v.sent(),C;case 3:return[2]}})})};return jn.getV2LoginCode=b,jn}var da={},_M=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},UM=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(da,"__esModule",{value:!0}),da.subscribeToOnlineEvent=void 0;var hm=Tr,MM=er,kM=function(e,t){switch(t===void 0&&(t=(0,MM.getValue)("PLATFORM")),console.log("Online status detected. Fetching token..."),t){case hm.PLATFORM.WEB:return window.addEventListener("online",function(){return _M(void 0,void 0,void 0,function(){return UM(this,function(n){switch(n.label){case 0:return console.log("Online status detected. Fetching token..."),[4,e()];case 1:return n.sent(),[2]}})})});case hm.PLATFORM.MOBILE:e();return;default:throw Error("Invalid PLATFORM ".concat(t))}};da.subscribeToOnlineEvent=kM;var mm;function ym(){if(mm)return fi;mm=1;var e=ge&&ge.__awaiter||function(m,h,d,g){function C(v){return v instanceof d?v:new d(function(x){x(v)})}return new(d||(d=Promise))(function(v,x){function p(F){try{S(g.next(F))}catch(U){x(U)}}function w(F){try{S(g.throw(F))}catch(U){x(U)}}function S(F){F.done?v(F.value):C(F.value).then(p,w)}S((g=g.apply(m,h||[])).next())})},t=ge&&ge.__generator||function(m,h){var d={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},g,C,v,x;return x={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function p(S){return function(F){return w([S,F])}}function w(S){if(g)throw new TypeError("Generator is already executing.");for(;x&&(x=0,S[0]&&(d=0)),d;)try{if(g=1,C&&(v=S[0]&2?C.return:S[0]?C.throw||((v=C.return)&&v.call(C),0):C.next)&&!(v=v.call(C,S[1])).done)return v;switch(C=0,v&&(S=[S[0]&2,v.value]),S[0]){case 0:case 1:v=S;break;case 4:return d.label++,{value:S[1],done:!1};case 5:d.label++,C=S[1],S=[0];continue;case 7:S=d.ops.pop(),d.trys.pop();continue;default:if(v=d.trys,!(v=v.length>0&&v[v.length-1])&&(S[0]===6||S[0]===2)){d=0;continue}if(S[0]===3&&(!v||S[1]>v[0]&&S[1]<v[3])){d.label=S[1];break}if(S[0]===6&&d.label<v[1]){d.label=v[1],v=S;break}if(v&&d.label<v[2]){d.label=v[2],d.ops.push(S);break}v[2]&&d.ops.pop(),d.trys.pop();continue}S=h.call(m,d)}catch(F){S=[6,F],C=0}finally{g=v=0}if(S[0]&5)throw S[1];return{value:S[0]?S[1]:void 0,done:!0}}};Object.defineProperty(fi,"__esModule",{value:!0}),fi.fetchAccessToken=void 0;var n=OM(),r=Tr,o=Ge,i=da,a,l,u,c=function(m,h,d,g){return g===void 0&&(g=r.APP_UI.DEFAULT),e(void 0,void 0,void 0,function(){var C,v,x,p,w,S,F,U,A;return t(this,function(D){switch(D.label){case 0:C=2,D.label=1;case 1:return D.trys.push([1,4,,9]),console.log("ERROR debug: in login:",g),[4,(0,n.getV2LoginCode)(r.CONFIG_HIVER,m,h,g)];case 2:return v=D.sent(),[4,(0,n.getLoginToken)(v,r.CONFIG_HIVER,m)];case 3:return x=D.sent(),p=x.userId,w=x.userGroupId,S=x.atToken,F=x.expiryTime,(0,o.setTokenAndExpiry)(S,F),(0,o.setUserDetails)(p,w),[3,9];case 4:U=D.sent(),console.log("ERROR debug: in error login:",U,g),A=d,D.label=5;case 5:return A<C?[4,c(m,h,A+1,g)]:[3,8];case 6:D.sent(),D.label=7;case 7:return A++,[3,5];case 8:throw U;case 9:return[2]}})})},f=function(m,h,d){return e(void 0,void 0,void 0,function(){var g,C,v,x;return t(this,function(p){switch(p.label){case 0:return h<r.MAX_CONFLICT_RETRY_DELAY?[4,new Promise(function(w){return setTimeout(w,m)})]:[3,3];case 1:return p.sent(),h+=m,m*2<=r.MAX_BACKOFF_LIMIT?m*=2:m=r.MAX_BACKOFF_LIMIT,console.log("Heimdall: Fetch token post doubling conflict retry delay",m),g=d.retryDelay,C=d.configs,v=d.apiParams,x=d.appUI,[4,b(g,m,h,C,v,x)];case 2:p.sent(),p.label=3;case 3:return[2]}})})},b=function(m,h,d,g,C,v,x){return v===void 0&&(v="default"),e(void 0,void 0,void 0,function(){var p,w,S,F,U,A,D,B,N,k,$,j,q,L;return t(this,function(le){switch(le.label){case 0:return le.trys.push([0,2,,12]),console.log("Heimdall: Interval Set on fetch token in fetchAndSaveToken:",u),[4,(0,n.getAccessToken)(r.CONFIG_HIVER,g,C,v)];case 1:return p=le.sent(),w=p.atToken,S=p.expiryTime,F=p.userId,U=p.userGroupId,w&&S&&(0,o.setTokenAndExpiry)(w,S),F&&U&&(0,o.setUserDetails)(F,U),m=r.INITIAL_RETRY_DELAY,h=r.INITIAL_RETRY_DELAY,d=0,[3,12];case 2:return A=le.sent(),console.log("ERROR: Heimdall fetch token",A),((N=A.response)===null||N===void 0?void 0:N.status)===401||((k=A.request)===null||k===void 0?void 0:k.status)===401?(D=1,[4,c(g,C,D,x)]):[3,4];case 3:return le.sent(),[3,11];case 4:return(($=A.response)===null||$===void 0?void 0:$.status)===409||((j=A.request)===null||j===void 0?void 0:j.status)===409?(console.log("Heimdall: Fetching token post 409 in fetch And Save Token"),B={retryDelay:m,configs:g,apiParams:C,appUI:x},[4,f(h,d,B)]):[3,6];case 5:if(le.sent(),d>=r.MAX_CONFLICT_RETRY_DELAY)throw A;return[3,11];case 6:if(!(((q=A.response)===null||q===void 0?void 0:q.status)===422||((L=A.request)===null||L===void 0?void 0:L.status)===422))return[3,7];throw console.log("ERROR: Throwing error",A.response.status),A;case 7:return m<=r.MAX_RETRY_DELAY?[4,new Promise(function(R){return setTimeout(R,m)})]:[3,10];case 8:return le.sent(),m*=2,console.log("Heimdall: Fetch token post doubling retry delay",m),[4,b(m,h,d,g,C,x)];case 9:return le.sent(),[3,11];case 10:throw A;case 11:return[3,12];case 12:return[2]}})})},y=function(m,h,d,g,C,v){return d===void 0&&(d=r.INITIAL_RETRY_DELAY),g===void 0&&(g=r.INITIAL_RETRY_DELAY),C===void 0&&(C=0),e(void 0,void 0,void 0,function(){var x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),x=(0,o.isTokenInExpiryWindow)(),x?(p=(0,o.getRandomDelay)(),[4,(0,o.introduceDelay)(p)]):[3,3];case 1:return S.sent(),console.log("Heimdall: Fetching token - in expiry window"),[4,b(d,g,C,m,h,v)];case 2:S.sent(),S.label=3;case 3:return[3,5];case 4:throw w=S.sent(),w;case 5:return[2]}})})},E=function(m,h,d,g,C,v){return e(void 0,void 0,void 0,function(){var x,p,w,S,F,U;return t(this,function(A){switch(A.label){case 0:a=m,l=h,x=r.INITIAL_RETRY_DELAY,p=r.INITIAL_RETRY_DELAY,w=0,S=(0,o.getConfig)(a,l,g),console.log("Instance: Fetch Call"),A.label=1;case 1:return A.trys.push([1,3,,4]),[4,b(x,p,w,S,d,C,v)];case 2:return A.sent(),console.log("Heimdall: Interval Set on fetch token when fetch token is called:",u),clearInterval(u),u=setInterval(function(){return y(S,d)},r.REFETCH_CHECK_DELAY),F=function(){return e(void 0,void 0,void 0,function(){return t(this,function(D){switch(D.label){case 0:return[4,y(S,d)];case 1:return D.sent(),[2]}})})},console.log("Heimdall: Interval Set on fetch token:",u),(0,i.subscribeToOnlineEvent)(F),[3,4];case 3:return U=A.sent(),console.log("ERROR: Fetching token failed",U),[3,4];case 4:return[2]}})})};return fi.fetchAccessToken=E,fi}var gm;function bm(){if(gm)return Cr;gm=1;var e=ge&&ge.__assign||function(){return e=Object.assign||function(m){for(var h,d=1,g=arguments.length;d<g;d++){h=arguments[d];for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(m[C]=h[C])}return m},e.apply(this,arguments)},t=ge&&ge.__awaiter||function(m,h,d,g){function C(v){return v instanceof d?v:new d(function(x){x(v)})}return new(d||(d=Promise))(function(v,x){function p(F){try{S(g.next(F))}catch(U){x(U)}}function w(F){try{S(g.throw(F))}catch(U){x(U)}}function S(F){F.done?v(F.value):C(F.value).then(p,w)}S((g=g.apply(m,h||[])).next())})},n=ge&&ge.__generator||function(m,h){var d={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},g,C,v,x;return x={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function p(S){return function(F){return w([S,F])}}function w(S){if(g)throw new TypeError("Generator is already executing.");for(;x&&(x=0,S[0]&&(d=0)),d;)try{if(g=1,C&&(v=S[0]&2?C.return:S[0]?C.throw||((v=C.return)&&v.call(C),0):C.next)&&!(v=v.call(C,S[1])).done)return v;switch(C=0,v&&(S=[S[0]&2,v.value]),S[0]){case 0:case 1:v=S;break;case 4:return d.label++,{value:S[1],done:!1};case 5:d.label++,C=S[1],S=[0];continue;case 7:S=d.ops.pop(),d.trys.pop();continue;default:if(v=d.trys,!(v=v.length>0&&v[v.length-1])&&(S[0]===6||S[0]===2)){d=0;continue}if(S[0]===3&&(!v||S[1]>v[0]&&S[1]<v[3])){d.label=S[1];break}if(S[0]===6&&d.label<v[1]){d.label=v[1],v=S;break}if(v&&d.label<v[2]){d.label=v[2],d.ops.push(S);break}v[2]&&d.ops.pop(),d.trys.pop();continue}S=h.call(m,d)}catch(F){S=[6,F],C=0}finally{g=v=0}if(S[0]&5)throw S[1];return{value:S[0]?S[1]:void 0,done:!0}}};Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.hiverAxiosCall=Cr.performAxiosCall=void 0;var r=cm,o=Ge,i=ym(),a=Fr,l,u=2,c=function(m,h){var d=h.fetchCsrfToken();m.formData?m.formData.append("_csrf_token",d):(m.data=m.data||{},m.data._csrf_token=d)},f=function(m){var h=!m.method||m.method.toLowerCase()==="get"?{params:m.data}:{data:m.data},d=e(e({method:m.method,url:"".concat(m.root_url).concat(m.url),headers:m.headers},h),{withCredentials:m.withCredentials,responseType:(m==null?void 0:m.responseType)||""});return d};function b(m){return t(this,void 0,void 0,function(){var h;return n(this,function(d){return h=f(m),[2,(0,r.default)(h).then(function(g){return g}).catch(function(g){throw g})]})})}Cr.performAxiosCall=b;function y(m,h,d,g,C,v){return t(this,void 0,void 0,function(){var x;return n(this,function(p){switch(p.label){case 0:return p.trys.push([0,6,,8]),m.authTokenFetchingInProgress?[3,2]:(m.authTokenFetchingInProgress=!0,[4,(0,i.fetchAccessToken)(h,d,g,C,v)]);case 1:return p.sent(),m.authTokenFetchingInProgress=!1,[3,5];case 2:return[4,new Promise(function(w){return setTimeout(w,100)})];case 3:return p.sent(),console.log("Heimdall: Retrying fetchAccessToken after 100ms..."),[4,y(m,h,d,g,C,v)];case 4:p.sent(),p.label=5;case 5:return[3,8];case 6:return x=p.sent(),console.log("Error while fetching Auth Token :",x),m.authTokenFetchingInProgress=!1,[4,y(m,h,d,g,C,v)];case 7:return p.sent(),[3,8];case 8:return[2]}})})}function E(m,h,d,g,C){var v,x;return C===void 0&&(C=0),t(this,void 0,void 0,function(){var p,w,S,F,U,A;return n(this,function(D){switch(D.label){case 0:if(D.trys.push([0,4,,5]),!(d.getToken&&!(0,o.hasValidToken)(h)))return[3,2];if(p=h.appEnv,w=h.tier,!p||!w)throw Error("appEnv or tier missing : ".concat(p,"/").concat(w));return"userId"in h&&"usergroupId"in h?(S={userId:h.userId,usergroupId:h.usergroupId},typeof d.isHiverApiDomain!="boolean"&&(d.isHiverApiDomain=!0),[4,y(m,p,w,S,d.isHiverApiDomain,g)]):[3,2];case 1:D.sent(),D.label=2;case 2:return h.csrfToken&&c(h,d),d.getToken&&(l=(0,a.getItemFromStorage)("hiverAuthToken")||"",h.headers=e(e({},h.headers),{Authorization:"Bearer ".concat(l)})),console.log("Performing axios call for:",h),[4,b(h)];case 3:return F=D.sent(),h.onSuccess&&h.onSuccess(F),[2,F];case 4:if(U=D.sent(),A=((v=U.response)===null||v===void 0?void 0:v.status)===403||((x=U.request)===null||x===void 0?void 0:x.status)===403,C<u&&A)return(0,o.expireToken)(),[2,E(m,h,d,g,C+1)];if(C>=u&&A||!A)throw h.onFail&&h.onFail(U),console.log("ERROR: Reached make Axios",U),U;return[3,5];case 5:return[2]}})})}return Cr.hiverAxiosCall=E,Cr}var di={},Je={},lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.TIERS=lt.APP_UI=lt.CONFIG_HIVER=lt.REFETCH_CHECK_DELAY=lt.INITIAL_RETRY_DELAY=lt.MAX_BACKOFF_LIMIT=lt.MAX_CONFLICT_RETRY_DELAY=lt.MAX_RETRY_DELAY=lt.GET_METHOD=void 0,lt.GET_METHOD="GET",lt.MAX_RETRY_DELAY=18e4,lt.MAX_CONFLICT_RETRY_DELAY=63e3,lt.MAX_BACKOFF_LIMIT=8e3,lt.INITIAL_RETRY_DELAY=1e3,lt.REFETCH_CHECK_DELAY=168e4,lt.CONFIG_HIVER={getToken:!1,fetchCsrfToken:function(){return""},isHiverApiDomain:!0},lt.APP_UI={COLLAB_SPACE:"collab-space",DEFAULT:"default"},lt.TIERS={DEV:"dev",SIT:"sit",PROD:"production"};var $t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.getProdHqConfig=$t.getProdApiConfig=$t.getSitHqConfig=$t.getSitApiConfig=$t.getDevHqConfig=$t.getDevApiConfig=void 0;var fo={heimdallTokenFetch:"/v1/token/get",heimdallLogin:"/v1/login/code",v2Login:"/api/auth/login/code"},RM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api",apiEndpoints:fo}};$t.getDevApiConfig=RM;var AM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api2",apiEndpoints:fo}};$t.getDevHqConfig=AM;var PM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api"),apiEndpoints:fo}};$t.getSitApiConfig=PM;var DM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api2"),apiEndpoints:fo}};$t.getSitHqConfig=DM;var IM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall.hiverapi.com",apiEndpoints:fo}};$t.getProdApiConfig=IM;var NM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall2.hiverhq.com",apiEndpoints:fo}};$t.getProdHqConfig=NM;var BM=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},$M=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(Je,"__esModule",{value:!0}),Je.expireToken=Je.validateToken=Je.validateAccount=Je.getConfig=Je.introduceDelay=Je.isTokenInExpiryWindow=Je.getStoredAuthData=Je.setUserDetails=Je.setTokenAndExpiry=Je.getRandomDelay=Je.hasValidToken=void 0;var Kc=lt,Or=$t,vm=function(){var e=new Date,t=new Date(e.getTime()+e.getTimezoneOffset()*6e4);return t},Gc=function(e){var t=parseInt(sessionStorage.getItem("hiverAuthUserId")||"0"),n=parseInt(sessionStorage.getItem("hiverAuthUserGroupId")||"0"),r=e.userId,o=e.usergroupId;return t===r&&o===n};Je.validateAccount=Gc;var jM=function(e){var t=Gc(e);return!wm()&&t};Je.validateToken=jM;var LM=function(){try{sessionStorage.removeItem("hiverAuthTokenExpiry")}catch{console.log("Heimdall: Unable to Remove token.")}};Je.expireToken=LM;var zM=function(e){console.log("Heimdall: checking if there is a valid token");var t=sessionStorage.getItem("hiverAuthTokenExpiry")||"",n=new Date(t),r=vm(),o=Gc(e);return r<n&&o};Je.hasValidToken=zM;var VM=function(){return Math.floor(Math.random()*6e4)+6e4};Je.getRandomDelay=VM;var YM=function(e,t){if(!e||!t)throw new Error("User Id or user group Id not found in the response");sessionStorage.setItem("hiverAuthUserId",e),sessionStorage.setItem("hiverAuthUserGroupId",t)};Je.setUserDetails=YM;var WM=function(e,t){if(!e)throw new Error("Token not found in the response");sessionStorage.setItem("hiverAuthToken",e),sessionStorage.setItem("hiverAuthTokenExpiry",t)};Je.setTokenAndExpiry=WM;var qM=function(){var e=sessionStorage.getItem("hiverAuthTokenExpiry"),t=sessionStorage.getItem("hiverAuthToken"),n=sessionStorage.getItem("hiverAuthUserId"),r=sessionStorage.getItem("hiverAuthUserGroupId");return{token:t,expiryTime:e,userId:n,usergroupId:r}};Je.getStoredAuthData=qM;var wm=function(){var e=sessionStorage.getItem("hiverAuthTokenExpiry")||"";if(!e)return!0;var t=vm(),n=new Date(e),r=4*60*1e3,o=n.getTime()-t.getTime()<r;return console.log({currentTime:t,expiry:n,isInExpiryWindow:o}),o};Je.isTokenInExpiryWindow=wm;var HM=function(e){return BM(void 0,void 0,void 0,function(){return $M(this,function(t){switch(t.label){case 0:return[4,new Promise(function(n){return setTimeout(n,e)})];case 1:return t.sent(),[2]}})})};Je.introduceDelay=HM;var KM=function(e,t,n){switch(t){case Kc.TIERS.SIT:return console.log("ISHIVERAPIDOMAIN:",n,(0,Or.getSitHqConfig)(e)),n?(0,Or.getSitApiConfig)(e):(0,Or.getSitHqConfig)(e);case Kc.TIERS.PROD:return n?(0,Or.getProdApiConfig)():(0,Or.getProdHqConfig)();case Kc.TIERS.DEV:default:return n?(0,Or.getDevApiConfig)():(0,Or.getDevHqConfig)()}};Je.getConfig=KM;var pi={},Ln={},Em;function GM(){if(Em)return Ln;Em=1;var e=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},t=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.getV2LoginCode=Ln.getLoginToken=Ln.getAccessToken=void 0;var n=lt,r=Tm(),o=Je,i=function(y,E,m){var h=(0,o.getStoredAuthData)();return{root_url:y.heimdallUrl,url:y.apiEndpoints.heimdallTokenFetch,method:n.GET_METHOD,data:{user_id:E.userId,usergroup_id:E.usergroupId,access_token:(h==null?void 0:h.token)||"",source:m},withCredentials:!0}},a=function(y,E){return{root_url:E.heimdallUrl,url:E.apiEndpoints.heimdallLogin,method:n.GET_METHOD,data:{code:y},withCredentials:!0}},l=function(y){return parseInt(y,10)},u=function(y,E){return{root_url:y.v2Url,url:y.apiEndpoints.v2Login,method:n.GET_METHOD,withCredentials:!0,data:{usersession:l(localStorage.getItem("hiver-config.usersession")),app:E||n.APP_UI.DEFAULT}}},c=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),(0,o.validateToken)(m)?[3,2]:(console.log("HEIMDALL: No valid token, fetching token"),d=i(E,m,h),[4,(0,r.makeAxiosCall)(d,y)]);case 1:return g=S.sent(),[2,{atToken:(v=g==null?void 0:g.data.at)===null||v===void 0?void 0:v.token,expiryTime:(x=g==null?void 0:g.data.at)===null||x===void 0?void 0:x.expires_at,userId:(p=g==null?void 0:g.data)===null||p===void 0?void 0:p.user_id,userGroupId:(w=g==null?void 0:g.data)===null||w===void 0?void 0:w.usergroup_id}];case 2:return console.log("Heimdall: Valid token already exists"),[2,{}];case 3:return[3,5];case 4:throw C=S.sent(),C;case 5:return[2]}})})};Ln.getAccessToken=c;var f=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g,C,v,x,p;return t(this,function(w){switch(w.label){case 0:h=a(y,m),w.label=1;case 1:return w.trys.push([1,3,,4]),[4,(0,r.makeAxiosCall)(h,E)];case 2:return d=w.sent(),[2,{userId:(C=d==null?void 0:d.data)===null||C===void 0?void 0:C.user_id,userGroupId:(v=d==null?void 0:d.data)===null||v===void 0?void 0:v.usergroup_id,atToken:(x=d==null?void 0:d.data.at)===null||x===void 0?void 0:x.token,expiryTime:(p=d==null?void 0:d.data.at)===null||p===void 0?void 0:p.expires_at}];case 3:throw g=w.sent(),g;case 4:return[2]}})})};Ln.getLoginToken=f;var b=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g;return t(this,function(C){switch(C.label){case 0:return C.trys.push([0,2,,3]),console.log("ERROR debug: in getV2loginCode:",m),h=u(E,m),[4,(0,r.makeAxiosCall)(h,y)];case 1:return d=C.sent(),console.log("DEBUG HEIMDALL: local storage:",d==null?void 0:d.data),[2,d==null?void 0:d.data.code];case 2:throw g=C.sent(),g;case 3:return[2]}})})};return Ln.getV2LoginCode=b,Ln}var Cm;function xm(){if(Cm)return pi;Cm=1;var e=ge&&ge.__awaiter||function(E,m,h,d){function g(C){return C instanceof h?C:new h(function(v){v(C)})}return new(h||(h=Promise))(function(C,v){function x(S){try{w(d.next(S))}catch(F){v(F)}}function p(S){try{w(d.throw(S))}catch(F){v(F)}}function w(S){S.done?C(S.value):g(S.value).then(x,p)}w((d=d.apply(E,m||[])).next())})},t=ge&&ge.__generator||function(E,m){var h={label:0,sent:function(){if(C[0]&1)throw C[1];return C[1]},trys:[],ops:[]},d,g,C,v;return v={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function x(w){return function(S){return p([w,S])}}function p(w){if(d)throw new TypeError("Generator is already executing.");for(;v&&(v=0,w[0]&&(h=0)),h;)try{if(d=1,g&&(C=w[0]&2?g.return:w[0]?g.throw||((C=g.return)&&C.call(g),0):g.next)&&!(C=C.call(g,w[1])).done)return C;switch(g=0,C&&(w=[w[0]&2,C.value]),w[0]){case 0:case 1:C=w;break;case 4:return h.label++,{value:w[1],done:!1};case 5:h.label++,g=w[1],w=[0];continue;case 7:w=h.ops.pop(),h.trys.pop();continue;default:if(C=h.trys,!(C=C.length>0&&C[C.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!C||w[1]>C[0]&&w[1]<C[3])){h.label=w[1];break}if(w[0]===6&&h.label<C[1]){h.label=C[1],C=w;break}if(C&&h.label<C[2]){h.label=C[2],h.ops.push(w);break}C[2]&&h.ops.pop(),h.trys.pop();continue}w=m.call(E,h)}catch(S){w=[6,S],g=0}finally{d=C=0}if(w[0]&5)throw w[1];return{value:w[0]?w[1]:void 0,done:!0}}};Object.defineProperty(pi,"__esModule",{value:!0}),pi.fetchToken=void 0;var n=GM(),r=lt,o=Je,i,a,l,u=function(E,m,h){return h===void 0&&(h=r.APP_UI.DEFAULT),e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w,S,F;return t(this,function(U){switch(U.label){case 0:d=2,U.label=1;case 1:return U.trys.push([1,4,,9]),console.log("ERROR debug: in login:",h),[4,(0,n.getV2LoginCode)(r.CONFIG_HIVER,E,h)];case 2:return g=U.sent(),[4,(0,n.getLoginToken)(g,r.CONFIG_HIVER,E)];case 3:return C=U.sent(),v=C.userId,x=C.userGroupId,p=C.atToken,w=C.expiryTime,(0,o.setTokenAndExpiry)(p,w),(0,o.setUserDetails)(v,x),[3,9];case 4:S=U.sent(),console.log("ERROR debug: in error login:",S,h),F=m,U.label=5;case 5:return F<d?[4,u(E,F+1,h)]:[3,8];case 6:U.sent(),U.label=7;case 7:return F++,[3,5];case 8:throw S;case 9:return[2]}})})},c=function(E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v;return t(this,function(x){switch(x.label){case 0:return m<r.MAX_CONFLICT_RETRY_DELAY?[4,new Promise(function(p){return setTimeout(p,E)})]:[3,3];case 1:return x.sent(),m+=E,E*2<=r.MAX_BACKOFF_LIMIT?E*=2:E=r.MAX_BACKOFF_LIMIT,console.log("Heimdall: Fetch token post doubling conflict retry delay",E),d=h.retryDelay,g=h.configs,C=h.api_params,v=h.appUI,[4,f(d,E,m,g,C,v)];case 2:x.sent(),x.label=3;case 3:return[2]}})})},f=function(E,m,h,d,g,C,v){return C===void 0&&(C="default"),e(void 0,void 0,void 0,function(){var x,p,w,S,F,U,A,D,B,N,k,$,j,q;return t(this,function(L){switch(L.label){case 0:return L.trys.push([0,2,,12]),console.log("Heimdall: Interval Set on fetch token in fetchAndSaveToken:",l),[4,(0,n.getAccessToken)(r.CONFIG_HIVER,d,g,C)];case 1:return x=L.sent(),p=x.atToken,w=x.expiryTime,S=x.userId,F=x.userGroupId,p&&w&&(0,o.setTokenAndExpiry)(p,w),S&&F&&(0,o.setUserDetails)(S,F),E=r.INITIAL_RETRY_DELAY,m=r.INITIAL_RETRY_DELAY,h=0,[3,12];case 2:return U=L.sent(),console.log("ERROR: Heimdall fetch token",U),((B=U.response)===null||B===void 0?void 0:B.status)===401||((N=U.request)===null||N===void 0?void 0:N.status)===401?(A=1,[4,u(d,A,v)]):[3,4];case 3:return L.sent(),[3,11];case 4:return((k=U.response)===null||k===void 0?void 0:k.status)===409||(($=U.request)===null||$===void 0?void 0:$.status)===409?(console.log("Heimdall: Fetching token post 409 in fetch And Save Token"),D={retryDelay:E,configs:d,api_params:g,appUI:v},[4,c(m,h,D)]):[3,6];case 5:if(L.sent(),h>=r.MAX_CONFLICT_RETRY_DELAY)throw U;return[3,11];case 6:if(!(((j=U.response)===null||j===void 0?void 0:j.status)===422||((q=U.request)===null||q===void 0?void 0:q.status)===422))return[3,7];throw console.log("ERROR: Throwing error",U.response.status),U;case 7:return E<=r.MAX_RETRY_DELAY?[4,new Promise(function(le){return setTimeout(le,E)})]:[3,10];case 8:return L.sent(),E*=2,console.log("Heimdall: Fetch token post doubling retry delay",E),[4,f(E,m,h,d,g,v)];case 9:return L.sent(),[3,11];case 10:throw U;case 11:return[3,12];case 12:return[2]}})})},b=function(E,m,h,d,g,C){return h===void 0&&(h=r.INITIAL_RETRY_DELAY),d===void 0&&(d=r.INITIAL_RETRY_DELAY),g===void 0&&(g=0),e(void 0,void 0,void 0,function(){var v,x,p;return t(this,function(w){switch(w.label){case 0:return w.trys.push([0,4,,5]),v=(0,o.isTokenInExpiryWindow)(),v?(x=(0,o.getRandomDelay)(),[4,(0,o.introduceDelay)(x)]):[3,3];case 1:return w.sent(),console.log("Heimdall: Fetching token - in expiry window"),[4,f(h,d,g,E,m,C)];case 2:w.sent(),w.label=3;case 3:return[3,5];case 4:throw p=w.sent(),p;case 5:return[2]}})})},y=function(E,m,h,d,g,C){return e(void 0,void 0,void 0,function(){var v,x,p,w,S;return t(this,function(F){switch(F.label){case 0:i=E,a=m,v=r.INITIAL_RETRY_DELAY,x=r.INITIAL_RETRY_DELAY,p=0,w=(0,o.getConfig)(i,a,d),F.label=1;case 1:return F.trys.push([1,3,,4]),[4,f(v,x,p,w,h,g,C)];case 2:return F.sent(),console.log("Heimdall: Interval Set on fetch token when fetch token is called:",l),clearInterval(l),l=setInterval(function(){return b(w,h)},r.REFETCH_CHECK_DELAY),console.log("Heimdall: Interval Set on fetch token:",l),window.addEventListener("online",function(){return e(void 0,void 0,void 0,function(){return t(this,function(U){switch(U.label){case 0:return console.log("Online status detected. Fetching token..."),[4,b(w,h)];case 1:return U.sent(),[2]}})})}),[3,4];case 3:throw S=F.sent(),S;case 4:return[2]}})})};return pi.fetchToken=y,pi}var Sm;function Tm(){if(Sm)return di;Sm=1;var e=ge&&ge.__assign||function(){return e=Object.assign||function(y){for(var E,m=1,h=arguments.length;m<h;m++){E=arguments[m];for(var d in E)Object.prototype.hasOwnProperty.call(E,d)&&(y[d]=E[d])}return y},e.apply(this,arguments)},t=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},n=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(di,"__esModule",{value:!0}),di.makeAxiosCall=void 0;var r=cm,o=Je,i=xm(),a,l=2,u=function(y,E){var m=E.fetchCsrfToken();y.formData?y.formData.append("_csrf_token",m):(y.data=y.data||{},y.data._csrf_token=m)},c=function(y){var E=!y.method||y.method.toLowerCase()==="get"?{params:y.data}:{data:y.data},m=e(e({method:y.method,url:"".concat(y.root_url).concat(y.url),headers:y.headers},E),{withCredentials:y.withCredentials,responseType:(y==null?void 0:y.responseType)||""});return m};function f(y){return t(this,void 0,void 0,function(){var E;return n(this,function(m){return E=c(y),[2,(0,r.default)(E).then(function(h){return h}).catch(function(h){throw h})]})})}function b(y,E,m,h){var d,g;return h===void 0&&(h=0),t(this,void 0,void 0,function(){var C,v,x,p,w,S;return n(this,function(F){switch(F.label){case 0:if(F.trys.push([0,4,,5]),!(E.getToken&&!(0,o.hasValidToken)(y)))return[3,2];if(C=y.app_env,v=y.tier,!C||!v)throw Error("app_env or tier missing : ".concat(C,"/").concat(v));return"userId"in y&&"usergroupId"in y?(x={userId:y.userId,usergroupId:y.usergroupId},typeof E.isHiverApiDomain!="boolean"&&(E.isHiverApiDomain=!0),[4,(0,i.fetchToken)(C,v,x,E.isHiverApiDomain,m)]):[3,2];case 1:F.sent(),F.label=2;case 2:return y.csrfToken&&u(y,E),E.getToken&&(a=sessionStorage.getItem("hiverAuthToken")||"",y.headers=e(e({},y.headers),{Authorization:"Bearer ".concat(a)})),[4,f(y)];case 3:return p=F.sent(),y.onSuccess&&y.onSuccess(p),[2,p];case 4:if(w=F.sent(),S=((d=w.response)===null||d===void 0?void 0:d.status)===403||((g=w.request)===null||g===void 0?void 0:g.status)===403,h<l&&S)return(0,o.expireToken)(),[2,b(y,E,m,h+1)];if(h>=l&&S||!S)throw y.onFail&&y.onFail(w),console.log("ERROR: Reached make Axios",w),w;return[3,5];case 5:return[2]}})})}return di.makeAxiosCall=b,di}(function(e){var t=ge&&ge.__awaiter||function(f,b,y,E){function m(h){return h instanceof y?h:new y(function(d){d(h)})}return new(y||(y=Promise))(function(h,d){function g(x){try{v(E.next(x))}catch(p){d(p)}}function C(x){try{v(E.throw(x))}catch(p){d(p)}}function v(x){x.done?h(x.value):m(x.value).then(g,C)}v((E=E.apply(f,b||[])).next())})},n=ge&&ge.__generator||function(f,b){var y={label:0,sent:function(){if(h[0]&1)throw h[1];return h[1]},trys:[],ops:[]},E,m,h,d;return d={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function g(v){return function(x){return C([v,x])}}function C(v){if(E)throw new TypeError("Generator is already executing.");for(;d&&(d=0,v[0]&&(y=0)),y;)try{if(E=1,m&&(h=v[0]&2?m.return:v[0]?m.throw||((h=m.return)&&h.call(m),0):m.next)&&!(h=h.call(m,v[1])).done)return h;switch(m=0,h&&(v=[v[0]&2,h.value]),v[0]){case 0:case 1:h=v;break;case 4:return y.label++,{value:v[1],done:!1};case 5:y.label++,m=v[1],v=[0];continue;case 7:v=y.ops.pop(),y.trys.pop();continue;default:if(h=y.trys,!(h=h.length>0&&h[h.length-1])&&(v[0]===6||v[0]===2)){y=0;continue}if(v[0]===3&&(!h||v[1]>h[0]&&v[1]<h[3])){y.label=v[1];break}if(v[0]===6&&y.label<h[1]){y.label=h[1],h=v;break}if(h&&y.label<h[2]){y.label=h[2],y.ops.push(v);break}h[2]&&y.ops.pop(),y.trys.pop();continue}v=b.call(f,y)}catch(x){v=[6,x],m=0}finally{E=h=0}if(v[0]&5)throw v[1];return{value:v[0]?v[1]:void 0,done:!0}}};Object.defineProperty(e,"__esModule",{value:!0}),e.fetchToken=e.makeAxiosCall=e.Bifrost=void 0;var r=bm(),o=ym(),i=Tr,a=Tm();Object.defineProperty(e,"makeAxiosCall",{enumerable:!0,get:function(){return a.makeAxiosCall}});var l=xm();Object.defineProperty(e,"fetchToken",{enumerable:!0,get:function(){return l.fetchToken}});var u=er,c=function(){function f(){this.setEnvironment(),this.authTokenFetchingInProgress=!1}return f.prototype.setEnvironment=function(){typeof window<"u"&&window.document?(0,u.setValue)("PLATFORM",i.PLATFORM.WEB):(0,u.setValue)("PLATFORM",i.PLATFORM.MOBILE)},f.prototype.hiverAxios=function(b,y,E,m){return t(this,void 0,void 0,function(){var h,d;return n(this,function(g){switch(g.label){case 0:return g.trys.push([0,4,,5]),m&&m<2?(h={userId:b.userId,usergroupId:b.usergroupId,apiRetry:m},[4,(0,o.fetchAccessToken)(b.appEnv,b.tier,h,!0,i.API_CALL_ORIGIN.API_RETRY)]):[3,2];case 1:g.sent(),g.label=2;case 2:return[4,(0,r.hiverAxiosCall)(this,b,y,E)];case 3:return[2,g.sent()];case 4:throw d=g.sent(),console.log("ERROR: Axios call failed",d),d;case 5:return[2]}})})},f.prototype.fetchAuthToken=function(b,y,E,m,h,d){return t(this,void 0,void 0,function(){var g;return n(this,function(C){switch(C.label){case 0:return C.trys.push([0,4,7,8]),this.authTokenFetchingInProgress?[3,2]:(this.authTokenFetchingInProgress=!0,[4,(0,o.fetchAccessToken)(b,y,E,m,h,d)]);case 1:return C.sent(),[3,3];case 2:console.log("Heimdall: AuthToken Fetching InProgress",this.authTokenFetchingInProgress),C.label=3;case 3:return[3,8];case 4:return g=C.sent(),console.log("ERROR: Fetching token failed",g),this.authTokenFetchingInProgress=!1,[4,new Promise(function(v){return setTimeout(v,100)})];case 5:return C.sent(),console.log("Heimdall: Retrying fetchAccessToken after 100ms..."),[4,this.fetchAuthToken(b,y,E,m,h,d)];case 6:return C.sent(),[3,8];case 7:return this.authTokenFetchingInProgress=!1,[7];case 8:return[2]}})})},f.prototype.isTokenFetchingInProgress=function(){return this.authTokenFetchingInProgress},f}();e.Bifrost=c})(S0);const XM=new S0.Bifrost,QM=(({rootUrl:e,configHiver:t,withCredentials:n})=>async o=>{const{appEnv:i,tier:a}=F_(),l=x_(),u=T_(),{url:c,method:f}=o,y={root_url:(e||O_())+((o==null?void 0:o.prefix)||""),url:c,method:f,withCredentials:n,appEnv:i,tier:a,headers:o==null?void 0:o.headers,csrfToken:o==null?void 0:o.csrfToken,onSuccess:o==null?void 0:o.onSuccess,onFail:o==null?void 0:o.onFail,data:o==null?void 0:o.data,params:o==null?void 0:o.params,timeout:o==null?void 0:o.timeout,formData:o==null?void 0:o.formData,userId:Number(l),usergroupId:Number(u)};try{console.log("--- requestParams - ",y," --- configHiver - ",t," --- isHiverApiDomain - ",!0);const E=await XM.hiverAxios(y,{...t,isHiverApiDomain:!0});return console.log("--- response - ",E),E}catch(E){throw console.error("API call failed with error: ",E),E}})({configHiver:{getToken:!0,fetchCsrfToken:()=>"",isHiverApiDomain:!0},withCredentials:!0}),JM="/v1/api/connectors/cards/",ZM=()=>QM({url:JM,method:v_.GET}),ek=e=>e.cardList.connectorCards,tk=p_({name:"connectorCardLibrary",initialState:w_,reducers:{},extraReducers:e=>{e.addCase(pa.pending,t=>{t.connectorApiStatus=Qs.LOADING}).addCase(pa.fulfilled,(t,n)=>{t.connectorApiStatus=Qs.IDLE,t.connectorCards=n.payload.cards}).addCase(pa.rejected,t=>{t.connectorApiStatus=Qs.FAILED})}}),pa=s_("connectorCardLibrary/fetchAllCard",async()=>{const e=await ZM();return!e||!e.data||!Array.isArray(e.data.cards)?{cards:[]}:e.data}),nk=tk.reducer,rk=Hh({cardList:nk}),ok=QO({reducer:rk,devTools:!0}),ik=({children:e})=>M.jsx(ey,{store:ok,children:M.jsx(ZF,{custom:!0,children:M.jsx(tO,{children:M.jsx(re.Suspense,{fallback:M.jsx(M.Fragment,{}),children:e})})})}),sk=ry.withTypes(),ak=qm.withTypes(),lk=G(Vo)`
2002
+ `+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Sr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Vc.assertOptions(r,{silentJSONParsing:Zn.transitional(Zn.boolean),forcedJSONParsing:Zn.transitional(Zn.boolean),clarifyTimeoutError:Zn.transitional(Zn.boolean)},!1),o!=null&&(I.isFunction(o)?n.paramsSerializer={serialize:o}:Vc.assertOptions(o,{encode:Zn.function,serialize:Zn.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=i&&I.merge(i.common,i[n.method]);i&&I.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),n.headers=mn.concat(a,i);const l=[];let u=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(u=u&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let f,b=0,y;if(!u){const m=[im.bind(this),void 0];for(m.unshift.apply(m,l),m.push.apply(m,c),y=m.length,f=Promise.resolve(n);b<y;)f=f.then(m[b++],m[b++]);return f}y=l.length;let E=n;for(b=0;b<y;){const m=l[b++],h=l[b++];try{E=m(E)}catch(d){h.call(this,d);break}}try{f=im.call(this,E)}catch(m){return Promise.reject(m)}for(b=0,y=c.length;b<y;)f=f.then(c[b++],c[b++]);return f}getUri(t){t=Sr(this.defaults,t);const n=X0(t.baseURL,t.url);return L0(n,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){la.prototype[t]=function(n,r){return this.request(Sr(r||{},{method:t,url:n,data:(r||{}).data}))}}),I.forEach(["post","put","patch"],function(t){function n(r){return function(i,a,l){return this.request(Sr(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}la.prototype[t]=n(),la.prototype[t+"Form"]=n(!0)});var ca=la;class Yc{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const a=new Promise(l=>{r.subscribe(l),i=l}).then(o);return a.cancel=function(){r.unsubscribe(i)},a},t(function(i,a,l){r.reason||(r.reason=new lo(i,a,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Yc(function(o){t=o}),cancel:t}}}var tM=Yc;function nM(e){return function(n){return e.apply(null,n)}}function rM(e){return I.isObject(e)&&e.isAxiosError===!0}const Wc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wc).forEach(([e,t])=>{Wc[t]=e});var oM=Wc;function lm(e){const t=new ca(e),n=T0(ca.prototype.request,t);return I.extend(n,ca.prototype,t,{allOwnKeys:!0}),I.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return lm(Sr(e,o))},n}const ht=lm(Ic);ht.Axios=ca,ht.CanceledError=lo,ht.CancelToken=tM,ht.isCancel=q0,ht.VERSION=sm,ht.toFormData=na,ht.AxiosError=be,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=nM,ht.isAxiosError=rM,ht.mergeConfig=Sr,ht.AxiosHeaders=mn,ht.formToJSON=e=>Y0(I.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=om.getAdapter,ht.HttpStatusCode=oM,ht.default=ht;var cm=ht,Ge={},Tr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM=e.API_CALL_ORIGIN=e.TIERS=e.APP_UI=e.CONFIG_HIVER=e.REFETCH_CHECK_DELAY=e.INITIAL_RETRY_DELAY=e.MAX_BACKOFF_LIMIT=e.MAX_CONFLICT_RETRY_DELAY=e.MAX_RETRY_DELAY=e.GET_METHOD=void 0,e.GET_METHOD="GET",e.MAX_RETRY_DELAY=18e4,e.MAX_CONFLICT_RETRY_DELAY=63e3,e.MAX_BACKOFF_LIMIT=8e3,e.INITIAL_RETRY_DELAY=1e3,e.REFETCH_CHECK_DELAY=168e4,e.CONFIG_HIVER={getToken:!1,fetchCsrfToken:function(){return""},isHiverApiDomain:!0},e.APP_UI={COLLAB_SPACE:"collab-space",DEFAULT:"default"},e.TIERS={DEV:"dev",SIT:"sit",PROD:"production"},e.API_CALL_ORIGIN={API_RETRY:"Api Retry"},function(t){t[t.WEB=0]="WEB",t[t.MOBILE=1]="MOBILE"}(e.PLATFORM||(e.PLATFORM={}))})(Tr);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.getProdHqConfig=Bt.getProdApiConfig=Bt.getSitHqConfig=Bt.getSitApiConfig=Bt.getDevHqConfig=Bt.getDevApiConfig=void 0;var co={heimdallTokenFetch:"/v1/token/get",heimdallLogin:"/v1/login/code",v2Login:"/api/auth/login/code"},iM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api",apiEndpoints:co}};Bt.getDevApiConfig=iM;var sM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api2",apiEndpoints:co}};Bt.getDevHqConfig=sM;var aM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api"),apiEndpoints:co}};Bt.getSitApiConfig=aM;var lM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api2"),apiEndpoints:co}};Bt.getSitHqConfig=lM;var cM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall.hiverapi.com",apiEndpoints:co}};Bt.getProdApiConfig=cM;var uM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall2.hiverhq.com",apiEndpoints:co}};Bt.getProdHqConfig=uM;var Fr={},er={};Object.defineProperty(er,"__esModule",{value:!0}),er.getValue=er.setValue=void 0;var um={};function fM(e,t){um[e]=t}er.setValue=fM;function dM(e){return um[e]}er.getValue=dM,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.setItemInStorage=Fr.getItemFromStorage=void 0;var ua=Tr,fa=er,pM=function(e,t){switch(t===void 0&&(t=(0,fa.getValue)("PLATFORM")),t){case ua.PLATFORM.WEB:return sessionStorage.getItem(e);case ua.PLATFORM.MOBILE:return(0,fa.getValue)(e);default:throw Error("Invalid PLATFORM ".concat(t))}};Fr.getItemFromStorage=pM;var hM=function(e,t,n){switch(n===void 0&&(n=(0,fa.getValue)("PLATFORM")),n){case ua.PLATFORM.WEB:return sessionStorage.setItem(e,t);case ua.PLATFORM.MOBILE:return(0,fa.setValue)(e,t);default:throw Error("Invalid PLATFORM ".concat(n))}};Fr.setItemInStorage=hM;var mM=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},yM=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.expireToken=Ge.invalidateToken=Ge.validateToken=Ge.validateAccount=Ge.getConfig=Ge.introduceDelay=Ge.isTokenInExpiryWindow=Ge.getStoredAuthData=Ge.setUserDetails=Ge.setTokenAndExpiry=Ge.getRandomDelay=Ge.hasValidToken=void 0;var qc=Tr,uo=Bt,an=Fr,fm=function(){var e=new Date,t=new Date(e.getTime()+e.getTimezoneOffset()*6e4);return t},Hc=function(e){var t=parseInt((0,an.getItemFromStorage)("hiverAuthUserId")||"0"),n=parseInt((0,an.getItemFromStorage)("hiverAuthUserGroupId")||"0"),r=e.userId,o=e.usergroupId;return t===r&&o===n};Ge.validateAccount=Hc;var gM=function(e){var t=Hc(e);return!dm()&&t};Ge.validateToken=gM;var bM=function(e){return e.apiRetry?e.apiRetry>0:!1};Ge.invalidateToken=bM;var vM=function(){try{sessionStorage.removeItem("hiverAuthTokenExpiry")}catch{console.log("Heimdall: Unable to Remove token.")}};Ge.expireToken=vM;var wM=function(e){var t=(0,an.getItemFromStorage)("hiverAuthTokenExpiry")||"",n=new Date(t),r=fm(),o=Hc(e);return console.log("Heimdall: checking if there is a valid token",r<n&&o),r<n&&o};Ge.hasValidToken=wM;var EM=function(){return Math.floor(Math.random()*6e4)+6e4};Ge.getRandomDelay=EM;var CM=function(e,t){if(!e||!t)throw new Error("User Id or user group Id not found in the response");(0,an.setItemInStorage)("hiverAuthUserId",e),(0,an.setItemInStorage)("hiverAuthUserGroupId",t)};Ge.setUserDetails=CM;var xM=function(e,t){if(!e)throw new Error("Token not found in the response");(0,an.setItemInStorage)("hiverAuthToken",e),(0,an.setItemInStorage)("hiverAuthTokenExpiry",t)};Ge.setTokenAndExpiry=xM;var SM=function(){var e=(0,an.getItemFromStorage)("hiverAuthTokenExpiry"),t=(0,an.getItemFromStorage)("hiverAuthToken"),n=(0,an.getItemFromStorage)("hiverAuthUserId"),r=(0,an.getItemFromStorage)("hiverAuthUserGroupId");return{token:t,expiryTime:e,userId:n,usergroupId:r}};Ge.getStoredAuthData=SM;var dm=function(){var e=(0,an.getItemFromStorage)("hiverAuthTokenExpiry")||"";if(!e)return!0;var t=fm(),n=new Date(e),r=4*60*1e3,o=n.getTime()-t.getTime()<r;return console.log({currentTime:t,expiry:n,isInExpiryWindow:o}),o};Ge.isTokenInExpiryWindow=dm;var TM=function(e){return mM(void 0,void 0,void 0,function(){return yM(this,function(t){switch(t.label){case 0:return[4,new Promise(function(n){return setTimeout(n,e)})];case 1:return t.sent(),[2]}})})};Ge.introduceDelay=TM;var FM=function(e,t,n){switch(t){case qc.TIERS.SIT:return n?(0,uo.getSitApiConfig)(e):(0,uo.getSitHqConfig)(e);case qc.TIERS.PROD:return n?(0,uo.getProdApiConfig)():(0,uo.getProdHqConfig)();case qc.TIERS.DEV:default:return n?(0,uo.getDevApiConfig)():(0,uo.getDevHqConfig)()}};Ge.getConfig=FM;var fi={},jn={},pm;function OM(){if(pm)return jn;pm=1;var e=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},t=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(jn,"__esModule",{value:!0}),jn.getV2LoginCode=jn.getLoginToken=jn.getAccessToken=void 0;var n=Tr,r=bm(),o=Ge,i=function(y,E,m){var h=(0,o.getStoredAuthData)();return{root_url:y.heimdallUrl,url:y.apiEndpoints.heimdallTokenFetch,method:n.GET_METHOD,data:{user_id:E.userId,usergroup_id:E.usergroupId,access_token:(h==null?void 0:h.token)||"",source:m},withCredentials:!0}},a=function(y,E){return{root_url:E.heimdallUrl,url:E.apiEndpoints.heimdallLogin,method:n.GET_METHOD,data:{code:y},withCredentials:!0}},l=function(y){return parseInt(y,10)},u=function(y,E,m){return{root_url:y.v2Url,url:y.apiEndpoints.v2Login,method:n.GET_METHOD,withCredentials:!0,data:{usersession:l(E.userId),app:m||n.APP_UI.DEFAULT}}},c=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),!(0,o.validateToken)(m)||(0,o.invalidateToken)(m)?(console.log("HEIMDALL: No valid token, fetching token"),d=i(E,m,h),[4,(0,r.performAxiosCall)(d)]):[3,2];case 1:return g=S.sent(),[2,{atToken:(v=g==null?void 0:g.data.at)===null||v===void 0?void 0:v.token,expiryTime:(x=g==null?void 0:g.data.at)===null||x===void 0?void 0:x.expires_at,userId:(p=g==null?void 0:g.data)===null||p===void 0?void 0:p.user_id,userGroupId:(w=g==null?void 0:g.data)===null||w===void 0?void 0:w.usergroup_id}];case 2:return console.log("Heimdall: Valid token already exists"),[2,{}];case 3:return[3,5];case 4:throw C=S.sent(),C;case 5:return[2]}})})};jn.getAccessToken=c;var f=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g,C,v,x,p;return t(this,function(w){switch(w.label){case 0:h=a(y,m),w.label=1;case 1:return w.trys.push([1,3,,4]),[4,(0,r.performAxiosCall)(h)];case 2:return d=w.sent(),[2,{userId:(C=d==null?void 0:d.data)===null||C===void 0?void 0:C.user_id,userGroupId:(v=d==null?void 0:d.data)===null||v===void 0?void 0:v.usergroup_id,atToken:(x=d==null?void 0:d.data.at)===null||x===void 0?void 0:x.token,expiryTime:(p=d==null?void 0:d.data.at)===null||p===void 0?void 0:p.expires_at}];case 3:throw g=w.sent(),g;case 4:return[2]}})})};jn.getLoginToken=f;var b=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C;return t(this,function(v){switch(v.label){case 0:return v.trys.push([0,2,,3]),console.log("ERROR debug: in getV2loginCode:",h),d=u(E,m,h),[4,(0,r.performAxiosCall)(d)];case 1:return g=v.sent(),console.log("DEBUG HEIMDALL: local storage:",g==null?void 0:g.data),[2,g==null?void 0:g.data.code];case 2:throw C=v.sent(),C;case 3:return[2]}})})};return jn.getV2LoginCode=b,jn}var da={},_M=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},UM=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(da,"__esModule",{value:!0}),da.subscribeToOnlineEvent=void 0;var hm=Tr,MM=er,kM=function(e,t){switch(t===void 0&&(t=(0,MM.getValue)("PLATFORM")),console.log("Online status detected. Fetching token..."),t){case hm.PLATFORM.WEB:return window.addEventListener("online",function(){return _M(void 0,void 0,void 0,function(){return UM(this,function(n){switch(n.label){case 0:return console.log("Online status detected. Fetching token..."),[4,e()];case 1:return n.sent(),[2]}})})});case hm.PLATFORM.MOBILE:e();return;default:throw Error("Invalid PLATFORM ".concat(t))}};da.subscribeToOnlineEvent=kM;var mm;function ym(){if(mm)return fi;mm=1;var e=ge&&ge.__awaiter||function(m,h,d,g){function C(v){return v instanceof d?v:new d(function(x){x(v)})}return new(d||(d=Promise))(function(v,x){function p(F){try{S(g.next(F))}catch(U){x(U)}}function w(F){try{S(g.throw(F))}catch(U){x(U)}}function S(F){F.done?v(F.value):C(F.value).then(p,w)}S((g=g.apply(m,h||[])).next())})},t=ge&&ge.__generator||function(m,h){var d={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},g,C,v,x;return x={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function p(S){return function(F){return w([S,F])}}function w(S){if(g)throw new TypeError("Generator is already executing.");for(;x&&(x=0,S[0]&&(d=0)),d;)try{if(g=1,C&&(v=S[0]&2?C.return:S[0]?C.throw||((v=C.return)&&v.call(C),0):C.next)&&!(v=v.call(C,S[1])).done)return v;switch(C=0,v&&(S=[S[0]&2,v.value]),S[0]){case 0:case 1:v=S;break;case 4:return d.label++,{value:S[1],done:!1};case 5:d.label++,C=S[1],S=[0];continue;case 7:S=d.ops.pop(),d.trys.pop();continue;default:if(v=d.trys,!(v=v.length>0&&v[v.length-1])&&(S[0]===6||S[0]===2)){d=0;continue}if(S[0]===3&&(!v||S[1]>v[0]&&S[1]<v[3])){d.label=S[1];break}if(S[0]===6&&d.label<v[1]){d.label=v[1],v=S;break}if(v&&d.label<v[2]){d.label=v[2],d.ops.push(S);break}v[2]&&d.ops.pop(),d.trys.pop();continue}S=h.call(m,d)}catch(F){S=[6,F],C=0}finally{g=v=0}if(S[0]&5)throw S[1];return{value:S[0]?S[1]:void 0,done:!0}}};Object.defineProperty(fi,"__esModule",{value:!0}),fi.fetchAccessToken=void 0;var n=OM(),r=Tr,o=Ge,i=da,a,l,u,c=function(m,h,d,g){return g===void 0&&(g=r.APP_UI.DEFAULT),e(void 0,void 0,void 0,function(){var C,v,x,p,w,S,F,U,A;return t(this,function(D){switch(D.label){case 0:C=2,D.label=1;case 1:return D.trys.push([1,4,,9]),console.log("ERROR debug: in login:",g),[4,(0,n.getV2LoginCode)(r.CONFIG_HIVER,m,h,g)];case 2:return v=D.sent(),[4,(0,n.getLoginToken)(v,r.CONFIG_HIVER,m)];case 3:return x=D.sent(),p=x.userId,w=x.userGroupId,S=x.atToken,F=x.expiryTime,(0,o.setTokenAndExpiry)(S,F),(0,o.setUserDetails)(p,w),[3,9];case 4:U=D.sent(),console.log("ERROR debug: in error login:",U,g),A=d,D.label=5;case 5:return A<C?[4,c(m,h,A+1,g)]:[3,8];case 6:D.sent(),D.label=7;case 7:return A++,[3,5];case 8:throw U;case 9:return[2]}})})},f=function(m,h,d){return e(void 0,void 0,void 0,function(){var g,C,v,x;return t(this,function(p){switch(p.label){case 0:return h<r.MAX_CONFLICT_RETRY_DELAY?[4,new Promise(function(w){return setTimeout(w,m)})]:[3,3];case 1:return p.sent(),h+=m,m*2<=r.MAX_BACKOFF_LIMIT?m*=2:m=r.MAX_BACKOFF_LIMIT,console.log("Heimdall: Fetch token post doubling conflict retry delay",m),g=d.retryDelay,C=d.configs,v=d.apiParams,x=d.appUI,[4,b(g,m,h,C,v,x)];case 2:p.sent(),p.label=3;case 3:return[2]}})})},b=function(m,h,d,g,C,v,x){return v===void 0&&(v="default"),e(void 0,void 0,void 0,function(){var p,w,S,F,U,A,D,B,N,k,$,j,q,L;return t(this,function(le){switch(le.label){case 0:return le.trys.push([0,2,,12]),console.log("Heimdall: Interval Set on fetch token in fetchAndSaveToken:",u),[4,(0,n.getAccessToken)(r.CONFIG_HIVER,g,C,v)];case 1:return p=le.sent(),w=p.atToken,S=p.expiryTime,F=p.userId,U=p.userGroupId,w&&S&&(0,o.setTokenAndExpiry)(w,S),F&&U&&(0,o.setUserDetails)(F,U),m=r.INITIAL_RETRY_DELAY,h=r.INITIAL_RETRY_DELAY,d=0,[3,12];case 2:return A=le.sent(),console.log("ERROR: Heimdall fetch token",A),((N=A.response)===null||N===void 0?void 0:N.status)===401||((k=A.request)===null||k===void 0?void 0:k.status)===401?(D=1,[4,c(g,C,D,x)]):[3,4];case 3:return le.sent(),[3,11];case 4:return(($=A.response)===null||$===void 0?void 0:$.status)===409||((j=A.request)===null||j===void 0?void 0:j.status)===409?(console.log("Heimdall: Fetching token post 409 in fetch And Save Token"),B={retryDelay:m,configs:g,apiParams:C,appUI:x},[4,f(h,d,B)]):[3,6];case 5:if(le.sent(),d>=r.MAX_CONFLICT_RETRY_DELAY)throw A;return[3,11];case 6:if(!(((q=A.response)===null||q===void 0?void 0:q.status)===422||((L=A.request)===null||L===void 0?void 0:L.status)===422))return[3,7];throw console.log("ERROR: Throwing error",A.response.status),A;case 7:return m<=r.MAX_RETRY_DELAY?[4,new Promise(function(R){return setTimeout(R,m)})]:[3,10];case 8:return le.sent(),m*=2,console.log("Heimdall: Fetch token post doubling retry delay",m),[4,b(m,h,d,g,C,x)];case 9:return le.sent(),[3,11];case 10:throw A;case 11:return[3,12];case 12:return[2]}})})},y=function(m,h,d,g,C,v){return d===void 0&&(d=r.INITIAL_RETRY_DELAY),g===void 0&&(g=r.INITIAL_RETRY_DELAY),C===void 0&&(C=0),e(void 0,void 0,void 0,function(){var x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),x=(0,o.isTokenInExpiryWindow)(),x?(p=(0,o.getRandomDelay)(),[4,(0,o.introduceDelay)(p)]):[3,3];case 1:return S.sent(),console.log("Heimdall: Fetching token - in expiry window"),[4,b(d,g,C,m,h,v)];case 2:S.sent(),S.label=3;case 3:return[3,5];case 4:throw w=S.sent(),w;case 5:return[2]}})})},E=function(m,h,d,g,C,v){return e(void 0,void 0,void 0,function(){var x,p,w,S,F,U;return t(this,function(A){switch(A.label){case 0:a=m,l=h,x=r.INITIAL_RETRY_DELAY,p=r.INITIAL_RETRY_DELAY,w=0,S=(0,o.getConfig)(a,l,g),console.log("Instance: Fetch Call"),A.label=1;case 1:return A.trys.push([1,3,,4]),[4,b(x,p,w,S,d,C,v)];case 2:return A.sent(),console.log("Heimdall: Interval Set on fetch token when fetch token is called:",u),clearInterval(u),u=setInterval(function(){return y(S,d)},r.REFETCH_CHECK_DELAY),F=function(){return e(void 0,void 0,void 0,function(){return t(this,function(D){switch(D.label){case 0:return[4,y(S,d)];case 1:return D.sent(),[2]}})})},console.log("Heimdall: Interval Set on fetch token:",u),(0,i.subscribeToOnlineEvent)(F),[3,4];case 3:return U=A.sent(),console.log("ERROR: Fetching token failed",U),[3,4];case 4:return[2]}})})};return fi.fetchAccessToken=E,fi}var gm;function bm(){if(gm)return Cr;gm=1;var e=ge&&ge.__assign||function(){return e=Object.assign||function(m){for(var h,d=1,g=arguments.length;d<g;d++){h=arguments[d];for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(m[C]=h[C])}return m},e.apply(this,arguments)},t=ge&&ge.__awaiter||function(m,h,d,g){function C(v){return v instanceof d?v:new d(function(x){x(v)})}return new(d||(d=Promise))(function(v,x){function p(F){try{S(g.next(F))}catch(U){x(U)}}function w(F){try{S(g.throw(F))}catch(U){x(U)}}function S(F){F.done?v(F.value):C(F.value).then(p,w)}S((g=g.apply(m,h||[])).next())})},n=ge&&ge.__generator||function(m,h){var d={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},g,C,v,x;return x={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function p(S){return function(F){return w([S,F])}}function w(S){if(g)throw new TypeError("Generator is already executing.");for(;x&&(x=0,S[0]&&(d=0)),d;)try{if(g=1,C&&(v=S[0]&2?C.return:S[0]?C.throw||((v=C.return)&&v.call(C),0):C.next)&&!(v=v.call(C,S[1])).done)return v;switch(C=0,v&&(S=[S[0]&2,v.value]),S[0]){case 0:case 1:v=S;break;case 4:return d.label++,{value:S[1],done:!1};case 5:d.label++,C=S[1],S=[0];continue;case 7:S=d.ops.pop(),d.trys.pop();continue;default:if(v=d.trys,!(v=v.length>0&&v[v.length-1])&&(S[0]===6||S[0]===2)){d=0;continue}if(S[0]===3&&(!v||S[1]>v[0]&&S[1]<v[3])){d.label=S[1];break}if(S[0]===6&&d.label<v[1]){d.label=v[1],v=S;break}if(v&&d.label<v[2]){d.label=v[2],d.ops.push(S);break}v[2]&&d.ops.pop(),d.trys.pop();continue}S=h.call(m,d)}catch(F){S=[6,F],C=0}finally{g=v=0}if(S[0]&5)throw S[1];return{value:S[0]?S[1]:void 0,done:!0}}};Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.hiverAxiosCall=Cr.performAxiosCall=void 0;var r=cm,o=Ge,i=ym(),a=Fr,l,u=2,c=function(m,h){var d=h.fetchCsrfToken();m.formData?m.formData.append("_csrf_token",d):(m.data=m.data||{},m.data._csrf_token=d)},f=function(m){var h=!m.method||m.method.toLowerCase()==="get"?{params:m.data}:{data:m.data},d=e(e({method:m.method,url:"".concat(m.root_url).concat(m.url),headers:m.headers},h),{withCredentials:m.withCredentials,responseType:(m==null?void 0:m.responseType)||""});return d};function b(m){return t(this,void 0,void 0,function(){var h;return n(this,function(d){return h=f(m),[2,(0,r.default)(h).then(function(g){return g}).catch(function(g){throw g})]})})}Cr.performAxiosCall=b;function y(m,h,d,g,C,v){return t(this,void 0,void 0,function(){var x;return n(this,function(p){switch(p.label){case 0:return p.trys.push([0,6,,8]),m.authTokenFetchingInProgress?[3,2]:(m.authTokenFetchingInProgress=!0,[4,(0,i.fetchAccessToken)(h,d,g,C,v)]);case 1:return p.sent(),m.authTokenFetchingInProgress=!1,[3,5];case 2:return[4,new Promise(function(w){return setTimeout(w,100)})];case 3:return p.sent(),console.log("Heimdall: Retrying fetchAccessToken after 100ms..."),[4,y(m,h,d,g,C,v)];case 4:p.sent(),p.label=5;case 5:return[3,8];case 6:return x=p.sent(),console.log("Error while fetching Auth Token :",x),m.authTokenFetchingInProgress=!1,[4,y(m,h,d,g,C,v)];case 7:return p.sent(),[3,8];case 8:return[2]}})})}function E(m,h,d,g,C){var v,x;return C===void 0&&(C=0),t(this,void 0,void 0,function(){var p,w,S,F,U,A;return n(this,function(D){switch(D.label){case 0:if(D.trys.push([0,4,,5]),!(d.getToken&&!(0,o.hasValidToken)(h)))return[3,2];if(p=h.appEnv,w=h.tier,!p||!w)throw Error("appEnv or tier missing : ".concat(p,"/").concat(w));return"userId"in h&&"usergroupId"in h?(S={userId:h.userId,usergroupId:h.usergroupId},typeof d.isHiverApiDomain!="boolean"&&(d.isHiverApiDomain=!0),[4,y(m,p,w,S,d.isHiverApiDomain,g)]):[3,2];case 1:D.sent(),D.label=2;case 2:return h.csrfToken&&c(h,d),d.getToken&&(l=(0,a.getItemFromStorage)("hiverAuthToken")||"",h.headers=e(e({},h.headers),{Authorization:"Bearer ".concat(l)})),console.log("Performing axios call for:",h),[4,b(h)];case 3:return F=D.sent(),h.onSuccess&&h.onSuccess(F),[2,F];case 4:if(U=D.sent(),A=((v=U.response)===null||v===void 0?void 0:v.status)===403||((x=U.request)===null||x===void 0?void 0:x.status)===403,C<u&&A)return(0,o.expireToken)(),[2,E(m,h,d,g,C+1)];if(C>=u&&A||!A)throw h.onFail&&h.onFail(U),console.log("ERROR: Reached make Axios",U),U;return[3,5];case 5:return[2]}})})}return Cr.hiverAxiosCall=E,Cr}var di={},Je={},lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.TIERS=lt.APP_UI=lt.CONFIG_HIVER=lt.REFETCH_CHECK_DELAY=lt.INITIAL_RETRY_DELAY=lt.MAX_BACKOFF_LIMIT=lt.MAX_CONFLICT_RETRY_DELAY=lt.MAX_RETRY_DELAY=lt.GET_METHOD=void 0,lt.GET_METHOD="GET",lt.MAX_RETRY_DELAY=18e4,lt.MAX_CONFLICT_RETRY_DELAY=63e3,lt.MAX_BACKOFF_LIMIT=8e3,lt.INITIAL_RETRY_DELAY=1e3,lt.REFETCH_CHECK_DELAY=168e4,lt.CONFIG_HIVER={getToken:!1,fetchCsrfToken:function(){return""},isHiverApiDomain:!0},lt.APP_UI={COLLAB_SPACE:"collab-space",DEFAULT:"default"},lt.TIERS={DEV:"dev",SIT:"sit",PROD:"production"};var $t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.getProdHqConfig=$t.getProdApiConfig=$t.getSitHqConfig=$t.getSitApiConfig=$t.getDevHqConfig=$t.getDevApiConfig=void 0;var fo={heimdallTokenFetch:"/v1/token/get",heimdallLogin:"/v1/login/code",v2Login:"/api/auth/login/code"},RM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api",apiEndpoints:fo}};$t.getDevApiConfig=RM;var AM=function(){return{v2Url:"https://v2dev.hiver.space",heimdallUrl:"https://dev.hiver.space/api/heimdall-api2",apiEndpoints:fo}};$t.getDevHqConfig=AM;var PM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api"),apiEndpoints:fo}};$t.getSitApiConfig=PM;var DM=function(e){return{v2Url:"https://v2".concat(e,".hiver.space"),heimdallUrl:"https://".concat(e,".hiver.space/api/heimdall-api2"),apiEndpoints:fo}};$t.getSitHqConfig=DM;var IM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall.hiverapi.com",apiEndpoints:fo}};$t.getProdApiConfig=IM;var NM=function(){return{v2Url:"https://v2.hiverhq.com",heimdallUrl:"https://heimdall2.hiverhq.com",apiEndpoints:fo}};$t.getProdHqConfig=NM;var BM=ge&&ge.__awaiter||function(e,t,n,r){function o(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(f){try{c(r.next(f))}catch(b){a(b)}}function u(f){try{c(r.throw(f))}catch(b){a(b)}}function c(f){f.done?i(f.value):o(f.value).then(l,u)}c((r=r.apply(e,t||[])).next())})},$M=ge&&ge.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(c){return function(f){return u([c,f])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(f){c=[6,f],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(Je,"__esModule",{value:!0}),Je.expireToken=Je.validateToken=Je.validateAccount=Je.getConfig=Je.introduceDelay=Je.isTokenInExpiryWindow=Je.getStoredAuthData=Je.setUserDetails=Je.setTokenAndExpiry=Je.getRandomDelay=Je.hasValidToken=void 0;var Kc=lt,Or=$t,vm=function(){var e=new Date,t=new Date(e.getTime()+e.getTimezoneOffset()*6e4);return t},Gc=function(e){var t=parseInt(sessionStorage.getItem("hiverAuthUserId")||"0"),n=parseInt(sessionStorage.getItem("hiverAuthUserGroupId")||"0"),r=e.userId,o=e.usergroupId;return t===r&&o===n};Je.validateAccount=Gc;var jM=function(e){var t=Gc(e);return!wm()&&t};Je.validateToken=jM;var LM=function(){try{sessionStorage.removeItem("hiverAuthTokenExpiry")}catch{console.log("Heimdall: Unable to Remove token.")}};Je.expireToken=LM;var zM=function(e){console.log("Heimdall: checking if there is a valid token");var t=sessionStorage.getItem("hiverAuthTokenExpiry")||"",n=new Date(t),r=vm(),o=Gc(e);return r<n&&o};Je.hasValidToken=zM;var VM=function(){return Math.floor(Math.random()*6e4)+6e4};Je.getRandomDelay=VM;var YM=function(e,t){if(!e||!t)throw new Error("User Id or user group Id not found in the response");sessionStorage.setItem("hiverAuthUserId",e),sessionStorage.setItem("hiverAuthUserGroupId",t)};Je.setUserDetails=YM;var WM=function(e,t){if(!e)throw new Error("Token not found in the response");sessionStorage.setItem("hiverAuthToken",e),sessionStorage.setItem("hiverAuthTokenExpiry",t)};Je.setTokenAndExpiry=WM;var qM=function(){var e=sessionStorage.getItem("hiverAuthTokenExpiry"),t=sessionStorage.getItem("hiverAuthToken"),n=sessionStorage.getItem("hiverAuthUserId"),r=sessionStorage.getItem("hiverAuthUserGroupId");return{token:t,expiryTime:e,userId:n,usergroupId:r}};Je.getStoredAuthData=qM;var wm=function(){var e=sessionStorage.getItem("hiverAuthTokenExpiry")||"";if(!e)return!0;var t=vm(),n=new Date(e),r=4*60*1e3,o=n.getTime()-t.getTime()<r;return console.log({currentTime:t,expiry:n,isInExpiryWindow:o}),o};Je.isTokenInExpiryWindow=wm;var HM=function(e){return BM(void 0,void 0,void 0,function(){return $M(this,function(t){switch(t.label){case 0:return[4,new Promise(function(n){return setTimeout(n,e)})];case 1:return t.sent(),[2]}})})};Je.introduceDelay=HM;var KM=function(e,t,n){switch(t){case Kc.TIERS.SIT:return console.log("ISHIVERAPIDOMAIN:",n,(0,Or.getSitHqConfig)(e)),n?(0,Or.getSitApiConfig)(e):(0,Or.getSitHqConfig)(e);case Kc.TIERS.PROD:return n?(0,Or.getProdApiConfig)():(0,Or.getProdHqConfig)();case Kc.TIERS.DEV:default:return n?(0,Or.getDevApiConfig)():(0,Or.getDevHqConfig)()}};Je.getConfig=KM;var pi={},Ln={},Em;function GM(){if(Em)return Ln;Em=1;var e=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},t=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.getV2LoginCode=Ln.getLoginToken=Ln.getAccessToken=void 0;var n=lt,r=Tm(),o=Je,i=function(y,E,m){var h=(0,o.getStoredAuthData)();return{root_url:y.heimdallUrl,url:y.apiEndpoints.heimdallTokenFetch,method:n.GET_METHOD,data:{user_id:E.userId,usergroup_id:E.usergroupId,access_token:(h==null?void 0:h.token)||"",source:m},withCredentials:!0}},a=function(y,E){return{root_url:E.heimdallUrl,url:E.apiEndpoints.heimdallLogin,method:n.GET_METHOD,data:{code:y},withCredentials:!0}},l=function(y){return parseInt(y,10)},u=function(y,E){return{root_url:y.v2Url,url:y.apiEndpoints.v2Login,method:n.GET_METHOD,withCredentials:!0,data:{usersession:l(localStorage.getItem("hiver-config.usersession")),app:E||n.APP_UI.DEFAULT}}},c=function(y,E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w;return t(this,function(S){switch(S.label){case 0:return S.trys.push([0,4,,5]),(0,o.validateToken)(m)?[3,2]:(console.log("HEIMDALL: No valid token, fetching token"),d=i(E,m,h),[4,(0,r.makeAxiosCall)(d,y)]);case 1:return g=S.sent(),[2,{atToken:(v=g==null?void 0:g.data.at)===null||v===void 0?void 0:v.token,expiryTime:(x=g==null?void 0:g.data.at)===null||x===void 0?void 0:x.expires_at,userId:(p=g==null?void 0:g.data)===null||p===void 0?void 0:p.user_id,userGroupId:(w=g==null?void 0:g.data)===null||w===void 0?void 0:w.usergroup_id}];case 2:return console.log("Heimdall: Valid token already exists"),[2,{}];case 3:return[3,5];case 4:throw C=S.sent(),C;case 5:return[2]}})})};Ln.getAccessToken=c;var f=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g,C,v,x,p;return t(this,function(w){switch(w.label){case 0:h=a(y,m),w.label=1;case 1:return w.trys.push([1,3,,4]),[4,(0,r.makeAxiosCall)(h,E)];case 2:return d=w.sent(),[2,{userId:(C=d==null?void 0:d.data)===null||C===void 0?void 0:C.user_id,userGroupId:(v=d==null?void 0:d.data)===null||v===void 0?void 0:v.usergroup_id,atToken:(x=d==null?void 0:d.data.at)===null||x===void 0?void 0:x.token,expiryTime:(p=d==null?void 0:d.data.at)===null||p===void 0?void 0:p.expires_at}];case 3:throw g=w.sent(),g;case 4:return[2]}})})};Ln.getLoginToken=f;var b=function(y,E,m){return e(void 0,void 0,void 0,function(){var h,d,g;return t(this,function(C){switch(C.label){case 0:return C.trys.push([0,2,,3]),console.log("ERROR debug: in getV2loginCode:",m),h=u(E,m),[4,(0,r.makeAxiosCall)(h,y)];case 1:return d=C.sent(),console.log("DEBUG HEIMDALL: local storage:",d==null?void 0:d.data),[2,d==null?void 0:d.data.code];case 2:throw g=C.sent(),g;case 3:return[2]}})})};return Ln.getV2LoginCode=b,Ln}var Cm;function xm(){if(Cm)return pi;Cm=1;var e=ge&&ge.__awaiter||function(E,m,h,d){function g(C){return C instanceof h?C:new h(function(v){v(C)})}return new(h||(h=Promise))(function(C,v){function x(S){try{w(d.next(S))}catch(F){v(F)}}function p(S){try{w(d.throw(S))}catch(F){v(F)}}function w(S){S.done?C(S.value):g(S.value).then(x,p)}w((d=d.apply(E,m||[])).next())})},t=ge&&ge.__generator||function(E,m){var h={label:0,sent:function(){if(C[0]&1)throw C[1];return C[1]},trys:[],ops:[]},d,g,C,v;return v={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function x(w){return function(S){return p([w,S])}}function p(w){if(d)throw new TypeError("Generator is already executing.");for(;v&&(v=0,w[0]&&(h=0)),h;)try{if(d=1,g&&(C=w[0]&2?g.return:w[0]?g.throw||((C=g.return)&&C.call(g),0):g.next)&&!(C=C.call(g,w[1])).done)return C;switch(g=0,C&&(w=[w[0]&2,C.value]),w[0]){case 0:case 1:C=w;break;case 4:return h.label++,{value:w[1],done:!1};case 5:h.label++,g=w[1],w=[0];continue;case 7:w=h.ops.pop(),h.trys.pop();continue;default:if(C=h.trys,!(C=C.length>0&&C[C.length-1])&&(w[0]===6||w[0]===2)){h=0;continue}if(w[0]===3&&(!C||w[1]>C[0]&&w[1]<C[3])){h.label=w[1];break}if(w[0]===6&&h.label<C[1]){h.label=C[1],C=w;break}if(C&&h.label<C[2]){h.label=C[2],h.ops.push(w);break}C[2]&&h.ops.pop(),h.trys.pop();continue}w=m.call(E,h)}catch(S){w=[6,S],g=0}finally{d=C=0}if(w[0]&5)throw w[1];return{value:w[0]?w[1]:void 0,done:!0}}};Object.defineProperty(pi,"__esModule",{value:!0}),pi.fetchToken=void 0;var n=GM(),r=lt,o=Je,i,a,l,u=function(E,m,h){return h===void 0&&(h=r.APP_UI.DEFAULT),e(void 0,void 0,void 0,function(){var d,g,C,v,x,p,w,S,F;return t(this,function(U){switch(U.label){case 0:d=2,U.label=1;case 1:return U.trys.push([1,4,,9]),console.log("ERROR debug: in login:",h),[4,(0,n.getV2LoginCode)(r.CONFIG_HIVER,E,h)];case 2:return g=U.sent(),[4,(0,n.getLoginToken)(g,r.CONFIG_HIVER,E)];case 3:return C=U.sent(),v=C.userId,x=C.userGroupId,p=C.atToken,w=C.expiryTime,(0,o.setTokenAndExpiry)(p,w),(0,o.setUserDetails)(v,x),[3,9];case 4:S=U.sent(),console.log("ERROR debug: in error login:",S,h),F=m,U.label=5;case 5:return F<d?[4,u(E,F+1,h)]:[3,8];case 6:U.sent(),U.label=7;case 7:return F++,[3,5];case 8:throw S;case 9:return[2]}})})},c=function(E,m,h){return e(void 0,void 0,void 0,function(){var d,g,C,v;return t(this,function(x){switch(x.label){case 0:return m<r.MAX_CONFLICT_RETRY_DELAY?[4,new Promise(function(p){return setTimeout(p,E)})]:[3,3];case 1:return x.sent(),m+=E,E*2<=r.MAX_BACKOFF_LIMIT?E*=2:E=r.MAX_BACKOFF_LIMIT,console.log("Heimdall: Fetch token post doubling conflict retry delay",E),d=h.retryDelay,g=h.configs,C=h.api_params,v=h.appUI,[4,f(d,E,m,g,C,v)];case 2:x.sent(),x.label=3;case 3:return[2]}})})},f=function(E,m,h,d,g,C,v){return C===void 0&&(C="default"),e(void 0,void 0,void 0,function(){var x,p,w,S,F,U,A,D,B,N,k,$,j,q;return t(this,function(L){switch(L.label){case 0:return L.trys.push([0,2,,12]),console.log("Heimdall: Interval Set on fetch token in fetchAndSaveToken:",l),[4,(0,n.getAccessToken)(r.CONFIG_HIVER,d,g,C)];case 1:return x=L.sent(),p=x.atToken,w=x.expiryTime,S=x.userId,F=x.userGroupId,p&&w&&(0,o.setTokenAndExpiry)(p,w),S&&F&&(0,o.setUserDetails)(S,F),E=r.INITIAL_RETRY_DELAY,m=r.INITIAL_RETRY_DELAY,h=0,[3,12];case 2:return U=L.sent(),console.log("ERROR: Heimdall fetch token",U),((B=U.response)===null||B===void 0?void 0:B.status)===401||((N=U.request)===null||N===void 0?void 0:N.status)===401?(A=1,[4,u(d,A,v)]):[3,4];case 3:return L.sent(),[3,11];case 4:return((k=U.response)===null||k===void 0?void 0:k.status)===409||(($=U.request)===null||$===void 0?void 0:$.status)===409?(console.log("Heimdall: Fetching token post 409 in fetch And Save Token"),D={retryDelay:E,configs:d,api_params:g,appUI:v},[4,c(m,h,D)]):[3,6];case 5:if(L.sent(),h>=r.MAX_CONFLICT_RETRY_DELAY)throw U;return[3,11];case 6:if(!(((j=U.response)===null||j===void 0?void 0:j.status)===422||((q=U.request)===null||q===void 0?void 0:q.status)===422))return[3,7];throw console.log("ERROR: Throwing error",U.response.status),U;case 7:return E<=r.MAX_RETRY_DELAY?[4,new Promise(function(le){return setTimeout(le,E)})]:[3,10];case 8:return L.sent(),E*=2,console.log("Heimdall: Fetch token post doubling retry delay",E),[4,f(E,m,h,d,g,v)];case 9:return L.sent(),[3,11];case 10:throw U;case 11:return[3,12];case 12:return[2]}})})},b=function(E,m,h,d,g,C){return h===void 0&&(h=r.INITIAL_RETRY_DELAY),d===void 0&&(d=r.INITIAL_RETRY_DELAY),g===void 0&&(g=0),e(void 0,void 0,void 0,function(){var v,x,p;return t(this,function(w){switch(w.label){case 0:return w.trys.push([0,4,,5]),v=(0,o.isTokenInExpiryWindow)(),v?(x=(0,o.getRandomDelay)(),[4,(0,o.introduceDelay)(x)]):[3,3];case 1:return w.sent(),console.log("Heimdall: Fetching token - in expiry window"),[4,f(h,d,g,E,m,C)];case 2:w.sent(),w.label=3;case 3:return[3,5];case 4:throw p=w.sent(),p;case 5:return[2]}})})},y=function(E,m,h,d,g,C){return e(void 0,void 0,void 0,function(){var v,x,p,w,S;return t(this,function(F){switch(F.label){case 0:i=E,a=m,v=r.INITIAL_RETRY_DELAY,x=r.INITIAL_RETRY_DELAY,p=0,w=(0,o.getConfig)(i,a,d),F.label=1;case 1:return F.trys.push([1,3,,4]),[4,f(v,x,p,w,h,g,C)];case 2:return F.sent(),console.log("Heimdall: Interval Set on fetch token when fetch token is called:",l),clearInterval(l),l=setInterval(function(){return b(w,h)},r.REFETCH_CHECK_DELAY),console.log("Heimdall: Interval Set on fetch token:",l),window.addEventListener("online",function(){return e(void 0,void 0,void 0,function(){return t(this,function(U){switch(U.label){case 0:return console.log("Online status detected. Fetching token..."),[4,b(w,h)];case 1:return U.sent(),[2]}})})}),[3,4];case 3:throw S=F.sent(),S;case 4:return[2]}})})};return pi.fetchToken=y,pi}var Sm;function Tm(){if(Sm)return di;Sm=1;var e=ge&&ge.__assign||function(){return e=Object.assign||function(y){for(var E,m=1,h=arguments.length;m<h;m++){E=arguments[m];for(var d in E)Object.prototype.hasOwnProperty.call(E,d)&&(y[d]=E[d])}return y},e.apply(this,arguments)},t=ge&&ge.__awaiter||function(y,E,m,h){function d(g){return g instanceof m?g:new m(function(C){C(g)})}return new(m||(m=Promise))(function(g,C){function v(w){try{p(h.next(w))}catch(S){C(S)}}function x(w){try{p(h.throw(w))}catch(S){C(S)}}function p(w){w.done?g(w.value):d(w.value).then(v,x)}p((h=h.apply(y,E||[])).next())})},n=ge&&ge.__generator||function(y,E){var m={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},h,d,g,C;return C={next:v(0),throw:v(1),return:v(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function v(p){return function(w){return x([p,w])}}function x(p){if(h)throw new TypeError("Generator is already executing.");for(;C&&(C=0,p[0]&&(m=0)),m;)try{if(h=1,d&&(g=p[0]&2?d.return:p[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,p[1])).done)return g;switch(d=0,g&&(p=[p[0]&2,g.value]),p[0]){case 0:case 1:g=p;break;case 4:return m.label++,{value:p[1],done:!1};case 5:m.label++,d=p[1],p=[0];continue;case 7:p=m.ops.pop(),m.trys.pop();continue;default:if(g=m.trys,!(g=g.length>0&&g[g.length-1])&&(p[0]===6||p[0]===2)){m=0;continue}if(p[0]===3&&(!g||p[1]>g[0]&&p[1]<g[3])){m.label=p[1];break}if(p[0]===6&&m.label<g[1]){m.label=g[1],g=p;break}if(g&&m.label<g[2]){m.label=g[2],m.ops.push(p);break}g[2]&&m.ops.pop(),m.trys.pop();continue}p=E.call(y,m)}catch(w){p=[6,w],d=0}finally{h=g=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(di,"__esModule",{value:!0}),di.makeAxiosCall=void 0;var r=cm,o=Je,i=xm(),a,l=2,u=function(y,E){var m=E.fetchCsrfToken();y.formData?y.formData.append("_csrf_token",m):(y.data=y.data||{},y.data._csrf_token=m)},c=function(y){var E=!y.method||y.method.toLowerCase()==="get"?{params:y.data}:{data:y.data},m=e(e({method:y.method,url:"".concat(y.root_url).concat(y.url),headers:y.headers},E),{withCredentials:y.withCredentials,responseType:(y==null?void 0:y.responseType)||""});return m};function f(y){return t(this,void 0,void 0,function(){var E;return n(this,function(m){return E=c(y),[2,(0,r.default)(E).then(function(h){return h}).catch(function(h){throw h})]})})}function b(y,E,m,h){var d,g;return h===void 0&&(h=0),t(this,void 0,void 0,function(){var C,v,x,p,w,S;return n(this,function(F){switch(F.label){case 0:if(F.trys.push([0,4,,5]),!(E.getToken&&!(0,o.hasValidToken)(y)))return[3,2];if(C=y.app_env,v=y.tier,!C||!v)throw Error("app_env or tier missing : ".concat(C,"/").concat(v));return"userId"in y&&"usergroupId"in y?(x={userId:y.userId,usergroupId:y.usergroupId},typeof E.isHiverApiDomain!="boolean"&&(E.isHiverApiDomain=!0),[4,(0,i.fetchToken)(C,v,x,E.isHiverApiDomain,m)]):[3,2];case 1:F.sent(),F.label=2;case 2:return y.csrfToken&&u(y,E),E.getToken&&(a=sessionStorage.getItem("hiverAuthToken")||"",y.headers=e(e({},y.headers),{Authorization:"Bearer ".concat(a)})),[4,f(y)];case 3:return p=F.sent(),y.onSuccess&&y.onSuccess(p),[2,p];case 4:if(w=F.sent(),S=((d=w.response)===null||d===void 0?void 0:d.status)===403||((g=w.request)===null||g===void 0?void 0:g.status)===403,h<l&&S)return(0,o.expireToken)(),[2,b(y,E,m,h+1)];if(h>=l&&S||!S)throw y.onFail&&y.onFail(w),console.log("ERROR: Reached make Axios",w),w;return[3,5];case 5:return[2]}})})}return di.makeAxiosCall=b,di}(function(e){var t=ge&&ge.__awaiter||function(f,b,y,E){function m(h){return h instanceof y?h:new y(function(d){d(h)})}return new(y||(y=Promise))(function(h,d){function g(x){try{v(E.next(x))}catch(p){d(p)}}function C(x){try{v(E.throw(x))}catch(p){d(p)}}function v(x){x.done?h(x.value):m(x.value).then(g,C)}v((E=E.apply(f,b||[])).next())})},n=ge&&ge.__generator||function(f,b){var y={label:0,sent:function(){if(h[0]&1)throw h[1];return h[1]},trys:[],ops:[]},E,m,h,d;return d={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function g(v){return function(x){return C([v,x])}}function C(v){if(E)throw new TypeError("Generator is already executing.");for(;d&&(d=0,v[0]&&(y=0)),y;)try{if(E=1,m&&(h=v[0]&2?m.return:v[0]?m.throw||((h=m.return)&&h.call(m),0):m.next)&&!(h=h.call(m,v[1])).done)return h;switch(m=0,h&&(v=[v[0]&2,h.value]),v[0]){case 0:case 1:h=v;break;case 4:return y.label++,{value:v[1],done:!1};case 5:y.label++,m=v[1],v=[0];continue;case 7:v=y.ops.pop(),y.trys.pop();continue;default:if(h=y.trys,!(h=h.length>0&&h[h.length-1])&&(v[0]===6||v[0]===2)){y=0;continue}if(v[0]===3&&(!h||v[1]>h[0]&&v[1]<h[3])){y.label=v[1];break}if(v[0]===6&&y.label<h[1]){y.label=h[1],h=v;break}if(h&&y.label<h[2]){y.label=h[2],y.ops.push(v);break}h[2]&&y.ops.pop(),y.trys.pop();continue}v=b.call(f,y)}catch(x){v=[6,x],m=0}finally{E=h=0}if(v[0]&5)throw v[1];return{value:v[0]?v[1]:void 0,done:!0}}};Object.defineProperty(e,"__esModule",{value:!0}),e.fetchToken=e.makeAxiosCall=e.Bifrost=void 0;var r=bm(),o=ym(),i=Tr,a=Tm();Object.defineProperty(e,"makeAxiosCall",{enumerable:!0,get:function(){return a.makeAxiosCall}});var l=xm();Object.defineProperty(e,"fetchToken",{enumerable:!0,get:function(){return l.fetchToken}});var u=er,c=function(){function f(){this.setEnvironment(),this.authTokenFetchingInProgress=!1}return f.prototype.setEnvironment=function(){typeof window<"u"&&window.document?(0,u.setValue)("PLATFORM",i.PLATFORM.WEB):(0,u.setValue)("PLATFORM",i.PLATFORM.MOBILE)},f.prototype.hiverAxios=function(b,y,E,m){return t(this,void 0,void 0,function(){var h,d;return n(this,function(g){switch(g.label){case 0:return g.trys.push([0,4,,5]),m&&m<2?(h={userId:b.userId,usergroupId:b.usergroupId,apiRetry:m},[4,(0,o.fetchAccessToken)(b.appEnv,b.tier,h,!0,i.API_CALL_ORIGIN.API_RETRY)]):[3,2];case 1:g.sent(),g.label=2;case 2:return[4,(0,r.hiverAxiosCall)(this,b,y,E)];case 3:return[2,g.sent()];case 4:throw d=g.sent(),console.log("ERROR: Axios call failed",d),d;case 5:return[2]}})})},f.prototype.fetchAuthToken=function(b,y,E,m,h,d){return t(this,void 0,void 0,function(){var g;return n(this,function(C){switch(C.label){case 0:return C.trys.push([0,4,7,8]),this.authTokenFetchingInProgress?[3,2]:(this.authTokenFetchingInProgress=!0,[4,(0,o.fetchAccessToken)(b,y,E,m,h,d)]);case 1:return C.sent(),[3,3];case 2:console.log("Heimdall: AuthToken Fetching InProgress",this.authTokenFetchingInProgress),C.label=3;case 3:return[3,8];case 4:return g=C.sent(),console.log("ERROR: Fetching token failed",g),this.authTokenFetchingInProgress=!1,[4,new Promise(function(v){return setTimeout(v,100)})];case 5:return C.sent(),console.log("Heimdall: Retrying fetchAccessToken after 100ms..."),[4,this.fetchAuthToken(b,y,E,m,h,d)];case 6:return C.sent(),[3,8];case 7:return this.authTokenFetchingInProgress=!1,[7];case 8:return[2]}})})},f.prototype.isTokenFetchingInProgress=function(){return this.authTokenFetchingInProgress},f}();e.Bifrost=c})(S0);const XM=new S0.Bifrost,QM=(({rootUrl:e,configHiver:t,withCredentials:n})=>(console.log("NOW App Env1111++++++"),async o=>{const{appEnv:i,tier:a}=F_();console.log("NOW App Env++++++",i,a);const l=x_(),u=T_(),{url:c,method:f}=o,y={root_url:(e||O_())+((o==null?void 0:o.prefix)||""),url:c,method:f,withCredentials:n,appEnv:i,tier:a,headers:o==null?void 0:o.headers,csrfToken:o==null?void 0:o.csrfToken,onSuccess:o==null?void 0:o.onSuccess,onFail:o==null?void 0:o.onFail,data:o==null?void 0:o.data,params:o==null?void 0:o.params,timeout:o==null?void 0:o.timeout,formData:o==null?void 0:o.formData,userId:Number(l),usergroupId:Number(u)};try{console.log("--- requestParams - ",y," --- configHiver - ",t," --- isHiverApiDomain - ",!0);const E=await XM.hiverAxios(y,{...t,isHiverApiDomain:!0});return console.log("--- response - ",E),E}catch(E){throw console.error("API call failed with error: ",E),E}}))({configHiver:{getToken:!0,fetchCsrfToken:()=>"",isHiverApiDomain:!0},withCredentials:!0}),JM="/v1/api/connectors/cards/",ZM=()=>QM({url:JM,method:v_.GET}),ek=e=>e.cardList.connectorCards,tk=p_({name:"connectorCardLibrary",initialState:w_,reducers:{},extraReducers:e=>{e.addCase(pa.pending,t=>{t.connectorApiStatus=Qs.LOADING}).addCase(pa.fulfilled,(t,n)=>{t.connectorApiStatus=Qs.IDLE,t.connectorCards=n.payload.cards}).addCase(pa.rejected,t=>{t.connectorApiStatus=Qs.FAILED})}}),pa=s_("connectorCardLibrary/fetchAllCard",async()=>{const e=await ZM();return!e||!e.data||!Array.isArray(e.data.cards)?{cards:[]}:e.data}),nk=tk.reducer,rk=Hh({cardList:nk}),ok=QO({reducer:rk,devTools:!0}),ik=({children:e})=>M.jsx(ey,{store:ok,children:M.jsx(ZF,{custom:!0,children:M.jsx(tO,{children:M.jsx(re.Suspense,{fallback:M.jsx(M.Fragment,{}),children:e})})})}),sk=ry.withTypes(),ak=qm.withTypes(),lk=G(Vo)`
2003
2003
  max-width: 255px;
2004
2004
  width: 255px;
2005
2005
  margin-top: 22px;
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@hiver/connector-agent",
3
- "version": "0.0.0",
3
+ "version": "0.0.1-beta.0",
4
4
  "main": "index.es.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
8
8
  "*"
9
9
  ],
10
- "dependencies": {
11
- "@connector/bifrost": "*"
12
- },
10
+ "dependencies": {},
13
11
  "devDependencies": {
14
12
  "msw": "^2.4.4",
15
13
  "react": "^18.3.1",