work-workflow-test 0.0.1 → 0.0.2
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/dist/workflow.es.js +8 -6
- package/dist/workflow.umd.js +2 -2
- package/package.json +1 -1
package/dist/workflow.es.js
CHANGED
|
@@ -18595,7 +18595,7 @@ const r0 = {
|
|
|
18595
18595
|
if (typeof window < "u") {
|
|
18596
18596
|
const { cookie: t } = document, n = t?.split(";")?.find((o) => o?.includes(e));
|
|
18597
18597
|
if (!n) return ["", ""];
|
|
18598
|
-
const r = n
|
|
18598
|
+
const r = n?.split("=");
|
|
18599
18599
|
return r.length <= 1 ? ["", ""] : r;
|
|
18600
18600
|
}
|
|
18601
18601
|
return ["", ""];
|
|
@@ -18624,7 +18624,7 @@ typeof window < "u" && (bs = window.location.href);
|
|
|
18624
18624
|
bs.includes("invite-user") || bs.includes("mailOpened") || bs.includes("/email?");
|
|
18625
18625
|
je.interceptors.request.use(
|
|
18626
18626
|
async (e) => {
|
|
18627
|
-
const t = window.location.pathname
|
|
18627
|
+
const t = window.location.pathname?.split("/").find((r) => parseInt(r)) ?? li(sy.workspaceId)[1];
|
|
18628
18628
|
e.headers["x-tenant-id"] || (e.headers["x-tenant-id"] = t ? t.toString() : "");
|
|
18629
18629
|
const n = li("accessToken");
|
|
18630
18630
|
return e.headers.authorization = `${n[1]}`, {
|
|
@@ -18704,7 +18704,7 @@ const Kk = () => {
|
|
|
18704
18704
|
}
|
|
18705
18705
|
}
|
|
18706
18706
|
`, Qk = (e, t, n = void 0) => {
|
|
18707
|
-
const r = t
|
|
18707
|
+
const r = t?.split(".");
|
|
18708
18708
|
let o = e;
|
|
18709
18709
|
for (const i of r)
|
|
18710
18710
|
if (o && typeof o == "object" && i in o)
|
|
@@ -18716,7 +18716,7 @@ const Kk = () => {
|
|
|
18716
18716
|
const t = typeof e == "string" ? e : Qk(e, "props.children", "");
|
|
18717
18717
|
let n = RegExp(/\b\w/g).exec(t);
|
|
18718
18718
|
return s0(n) || (n = ((n.shift() || "") + (n.pop() || "")).toUpperCase()), n;
|
|
18719
|
-
}, t2 = (e) => e?.toLowerCase()
|
|
18719
|
+
}, t2 = (e) => e?.toLowerCase()?.split(/[\s\-_]+/).map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), n2 = ({ data: e, value: t }) => /* @__PURE__ */ E.jsxs(
|
|
18720
18720
|
"div",
|
|
18721
18721
|
{
|
|
18722
18722
|
className: "d-flex align-center justify-between flex-1 text-truncate",
|
|
@@ -18775,7 +18775,9 @@ const Kk = () => {
|
|
|
18775
18775
|
},
|
|
18776
18776
|
fetchPolicy: "network-only",
|
|
18777
18777
|
client: i0
|
|
18778
|
-
})
|
|
18778
|
+
});
|
|
18779
|
+
console.log("filteredOptions", h);
|
|
18780
|
+
const p = (y) => {
|
|
18779
18781
|
let v;
|
|
18780
18782
|
o.some((S) => S.id === y.id) ? v = o.filter((S) => S.id !== y.id) : v = [...o, y], i(v), t(v.map((S) => S.id));
|
|
18781
18783
|
}, g = (y) => {
|
|
@@ -20111,7 +20113,7 @@ const w2 = /* @__PURE__ */ Zt(x2), b2 = ({ defaultValue: e, setValue: t }) => {
|
|
|
20111
20113
|
);
|
|
20112
20114
|
d.set(f.internalName, h?.name ?? "");
|
|
20113
20115
|
} else if (f.dataType === "collaborators") {
|
|
20114
|
-
const m = c[f.internalName]
|
|
20116
|
+
const m = c[f.internalName]?.split(",");
|
|
20115
20117
|
let h = [];
|
|
20116
20118
|
m.forEach((p) => {
|
|
20117
20119
|
const g = s.find(
|
package/dist/workflow.umd.js
CHANGED
|
@@ -150,7 +150,7 @@ const theme2 = createTheme({ palette: {
|
|
|
150
150
|
`+l):d.stack=l}catch{}}throw d}}_request(o,e){typeof o=="string"?(e=e||{},e.url=o):e=o||{},e=bd(this.defaults,e);const{transitional:d,paramsSerializer:t,headers:l}=e;d!==void 0&&Ii.assertOptions(d,{silentJSONParsing:te.transitional(te.boolean),forcedJSONParsing:te.transitional(te.boolean),clarifyTimeoutError:te.transitional(te.boolean)},!1),t!=null&&(U.isFunction(t)?e.paramsSerializer={serialize:t}:Ii.assertOptions(t,{encode:te.function,serialize:te.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Ii.assertOptions(e,{baseUrl:te.spelling("baseURL"),withXsrfToken:te.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let i=l&&U.merge(l.common,l[e.method]);l&&U.forEach(["delete","get","head","post","put","patch","common"],h=>{delete l[h]}),e.headers=mo.concat(i,l);const a=[];let w=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(w=w&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});const b=[];this.interceptors.response.forEach(function(f){b.push(f.fulfilled,f.rejected)});let n,s=0,p;if(!w){const h=[qp.bind(this),void 0];for(h.unshift(...a),h.push(...b),p=h.length,n=Promise.resolve(e);s<p;)n=n.then(h[s++],h[s++]);return n}p=a.length;let m=e;for(;s<p;){const h=a[s++],f=a[s++];try{m=h(m)}catch(k){f.call(this,k);break}}try{n=qp.call(this,m)}catch(h){return Promise.reject(h)}for(s=0,p=b.length;s<p;)n=n.then(b[s++],b[s++]);return n}getUri(o){o=bd(this.defaults,o);const e=Pp(o.baseURL,o.url,o.allowAbsoluteUrls);return Dp(e,o.params,o.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(o){nd.prototype[o]=function(e,d){return this.request(bd(d||{},{method:o,url:e,data:(d||{}).data}))}}),U.forEach(["post","put","patch"],function(o){function e(d){return function(l,i,a){return this.request(bd(a||{},{method:o,headers:d?{"Content-Type":"multipart/form-data"}:{},url:l,data:i}))}}nd.prototype[o]=e(),nd.prototype[o+"Form"]=e(!0)});let lA=class qm{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(l){e=l});const d=this;this.promise.then(t=>{if(!d._listeners)return;let l=d._listeners.length;for(;l-- >0;)d._listeners[l](t);d._listeners=null}),this.promise.then=t=>{let l;const i=new Promise(a=>{d.subscribe(a),l=a}).then(t);return i.cancel=function(){d.unsubscribe(l)},i},o(function(l,i,a){d.reason||(d.reason=new Ld(l,i,a),e(d.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const e=this._listeners.indexOf(o);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const o=new AbortController,e=d=>{o.abort(d)};return this.subscribe(e),o.signal.unsubscribe=()=>this.unsubscribe(e),o.signal}static source(){let o;return{token:new qm(function(t){o=t}),cancel:o}}};function iA(r){return function(e){return r.apply(null,e)}}function aA(r){return U.isObject(r)&&r.isAxiosError===!0}const Xw={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(Xw).forEach(([r,o])=>{Xw[o]=r});function Yp(r){const o=new nd(r),e=np(nd.prototype.request,o);return U.extend(e,nd.prototype,o,{allOwnKeys:!0}),U.extend(e,o,null,{allOwnKeys:!0}),e.create=function(t){return Yp(bd(r,t))},e}const Rr=Yp(zt);Rr.Axios=nd,Rr.CanceledError=Ld,Rr.CancelToken=lA,Rr.isCancel=Bp,Rr.VERSION=Wp,Rr.toFormData=vi,Rr.AxiosError=br,Rr.Cancel=Rr.CanceledError,Rr.all=function(o){return Promise.all(o)},Rr.spread=iA,Rr.isAxiosError=aA,Rr.mergeConfig=bd,Rr.AxiosHeaders=mo,Rr.formToJSON=r=>_p(U.isHTMLForm(r)?new FormData(r):r),Rr.getAdapter=Hp.getAdapter,Rr.HttpStatusCode=Xw,Rr.default=Rr;const{Axios:dv,AxiosError:tv,CanceledError:lv,isCancel:iv,CancelToken:av,VERSION:wv,all:bv,Cancel:nv,isAxiosError:sv,spread:pv,toFormData:fv,AxiosHeaders:hv,HttpStatusCode:mv,formToJSON:kv,getAdapter:xv,mergeConfig:gv}=Rr;var Ht={},Gp;function wA(){if(Gp)return Ht;Gp=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.parse=i,Ht.serialize=b;const r=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,o=/^[\u0021-\u003A\u003C-\u007E]*$/,e=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,d=/^[\u0020-\u003A\u003D-\u007E]*$/,t=Object.prototype.toString,l=(()=>{const p=function(){};return p.prototype=Object.create(null),p})();function i(p,m){const h=new l,f=p.length;if(f<2)return h;const k=m?.decode||n;let x=0;do{const c=p.indexOf("=",x);if(c===-1)break;const E=p.indexOf(";",x),y=E===-1?f:E;if(c>y){x=p.lastIndexOf(";",c-1)+1;continue}const F=a(p,x,c),I=w(p,c,F),D=p.slice(F,I);if(h[D]===void 0){let v=a(p,c+1,y),_=w(p,y,v);const T=k(p.slice(v,_));h[D]=T}x=y+1}while(x<f);return h}function a(p,m,h){do{const f=p.charCodeAt(m);if(f!==32&&f!==9)return m}while(++m<h);return h}function w(p,m,h){for(;m>h;){const f=p.charCodeAt(--m);if(f!==32&&f!==9)return m+1}return h}function b(p,m,h){const f=h?.encode||encodeURIComponent;if(!r.test(p))throw new TypeError(`argument name is invalid: ${p}`);const k=f(m);if(!o.test(k))throw new TypeError(`argument val is invalid: ${m}`);let x=p+"="+k;if(!h)return x;if(h.maxAge!==void 0){if(!Number.isInteger(h.maxAge))throw new TypeError(`option maxAge is invalid: ${h.maxAge}`);x+="; Max-Age="+h.maxAge}if(h.domain){if(!e.test(h.domain))throw new TypeError(`option domain is invalid: ${h.domain}`);x+="; Domain="+h.domain}if(h.path){if(!d.test(h.path))throw new TypeError(`option path is invalid: ${h.path}`);x+="; Path="+h.path}if(h.expires){if(!s(h.expires)||!Number.isFinite(h.expires.valueOf()))throw new TypeError(`option expires is invalid: ${h.expires}`);x+="; Expires="+h.expires.toUTCString()}if(h.httpOnly&&(x+="; HttpOnly"),h.secure&&(x+="; Secure"),h.partitioned&&(x+="; Partitioned"),h.priority)switch(typeof h.priority=="string"?h.priority.toLowerCase():void 0){case"low":x+="; Priority=Low";break;case"medium":x+="; Priority=Medium";break;case"high":x+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${h.priority}`)}if(h.sameSite)switch(typeof h.sameSite=="string"?h.sameSite.toLowerCase():h.sameSite){case!0:case"strict":x+="; SameSite=Strict";break;case"lax":x+="; SameSite=Lax";break;case"none":x+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${h.sameSite}`)}return x}function n(p){if(p.indexOf("%")===-1)return p;try{return decodeURIComponent(p)}catch{return p}}function s(p){return t.call(p)==="[object Date]"}return Ht}var Ti=wA();function bA(){const r=typeof global>"u"?void 0:global.TEST_HAS_DOCUMENT_COOKIE;return typeof r=="boolean"?r:typeof document=="object"&&typeof document.cookie=="string"}function nA(r){return typeof r=="string"?Ti.parse(r):typeof r=="object"&&r!==null?r:{}}function Zw(r,o={}){const e=sA(r);if(!o.doNotParse)try{return JSON.parse(e)}catch{}return r}function sA(r){return r&&r[0]==="j"&&r[1]===":"?r.substr(2):r}class pA{constructor(o,e={}){this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.update=()=>{if(!this.HAS_DOCUMENT_COOKIE)return;const t=this.cookies;this.cookies=Ti.parse(document.cookie),this._checkChanges(t)};const d=typeof document>"u"?"":document.cookie;this.cookies=nA(o||d),this.defaultSetOptions=e,this.HAS_DOCUMENT_COOKIE=bA()}_emitChange(o){for(let e=0;e<this.changeListeners.length;++e)this.changeListeners[e](o)}_checkChanges(o){new Set(Object.keys(o).concat(Object.keys(this.cookies))).forEach(d=>{o[d]!==this.cookies[d]&&this._emitChange({name:d,value:Zw(this.cookies[d])})})}_startPolling(){this.pollingInterval=setInterval(this.update,300)}_stopPolling(){this.pollingInterval&&clearInterval(this.pollingInterval)}get(o,e={}){return e.doNotUpdate||this.update(),Zw(this.cookies[o],e)}getAll(o={}){o.doNotUpdate||this.update();const e={};for(let d in this.cookies)e[d]=Zw(this.cookies[d],o);return e}set(o,e,d){d?d=Object.assign(Object.assign({},this.defaultSetOptions),d):d=this.defaultSetOptions;const t=typeof e=="string"?e:JSON.stringify(e);this.cookies=Object.assign(Object.assign({},this.cookies),{[o]:t}),this.HAS_DOCUMENT_COOKIE&&(document.cookie=Ti.serialize(o,t,d)),this._emitChange({name:o,value:e,options:d})}remove(o,e){const d=e=Object.assign(Object.assign(Object.assign({},this.defaultSetOptions),e),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[o],this.HAS_DOCUMENT_COOKIE&&(document.cookie=Ti.serialize(o,"",d)),this._emitChange({name:o,value:void 0,options:e})}addChangeListener(o){this.changeListeners.push(o),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===1&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.addEventListener("change",this.update):this._startPolling())}removeChangeListener(o){const e=this.changeListeners.indexOf(o);e>=0&&this.changeListeners.splice(e,1),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===0&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.removeEventListener("change",this.update):this._stopPolling())}removeAllChangeListeners(){for(;this.changeListeners.length>0;)this.removeChangeListener(this.changeListeners[0])}}const Jw={clientApiUrl:"https://api.testin.doworks.com/api/client/",clientGraphqlUrl:"https://api.testin.doworks.com/api/client/graphql",serverGraphqlUrl:"https://api.testin.doworks.com/api/crm/graphql"},fA=Jw.clientApiUrl,Qw=new pA,ze=Rr.create({baseURL:fA});ze.interceptors.request.use(r=>{const e=(()=>{const l=Object.keys(Qw.getAll()).find(i=>i.endsWith("accessToken"));return l?Qw.get(l):null})(),d=Qw.get("workspaceId");return e&&(r.headers.Authorization=e),d&&(r.headers["x-tenant-id"]=d),r},r=>Promise.reject(r));const hA=async r=>{try{return(await ze.post(`/workspace/${r.workspaceId}/workflow`,{...r})).data}catch(o){throw console.error("Failed to fetch table column data types:",o),o}},mA=async r=>{try{return(await ze.post(`/workspace/${r.workspaceId}/automation`,{...r})).data}catch(o){throw console.error("Failed to fetch table column data types:",o),o}},kA=async r=>{try{return(await ze.put(`/workspace/${r.workspaceId}/automation/automationAction`,{...r})).data}catch(o){throw console.error("Failed to fetch table column data types:",o),o}},xA=async(r,o)=>{try{return(await ze.get(`/workspace/${o}/automation/workflowSeg/${r}`)).data}catch(e){throw console.error("Failed to fetch table column data types:",e),e}},gA=async({id:r,isActive:o,workspaceId:e})=>{try{return(await ze.put(`/workspace/${e}/automation/activetoggle/${r}/${o}`)).data}catch(d){throw console.error("Failed to fetch table column data types:",d),d}},cA=async({id:r,workspaceId:o})=>{try{return(await ze.delete(`/workspace/${o}/automation/${r}`)).data}catch(e){throw console.error("Failed to fetch table column data types:",e),e}},uA=async({fieldId:r,workspaceId:o})=>{try{return(await ze.get(`/workspace/${o}/workflow/${r}`)).data}catch(e){throw console.error("Failed to fetch table column data types:",e),e}},Xp=r=>r?.toLowerCase()?.split(/[\s\-_]+/)?.map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),FA=(r,o,e=void 0)=>{const d=o.split(".");let t=r;for(const l of d)if(t&&typeof t=="object"&&l in t)t=t[l];else return e;return t},Zp=(r,o)=>{const e=r.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(t,l,i,a)=>`#${l}${l}${i}${i}${a}${a}`),d=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return d?`rgba(${parseInt(d[1],16)}, ${parseInt(d[2],16)}, ${parseInt(d[3],16)}, ${o})`:""},Jp=(r,o)=>{const e=r.match(/\d+/g);return e?`rgba(${e.join(", ")}, ${o})`:r},r4=r=>{const o=r||"rgb(154, 173, 189)";return o.startsWith("#")?Zp(o,.2):Jp(o,.2)},Ve=r=>{const o=r||"rgb(154, 173, 189)";return o.startsWith("#")?Zp(o,1):Jp(o,1)},AA=({data:r})=>u.jsxs("div",{style:{backgroundColor:r4(r.color),border:`1px solid ${Ve(r.color)}`},className:"w-264px h-40px radius-8 d-flex align-center justify-center",children:[u.jsx("p",{className:"f-14 f-w-600 ",style:{color:Ve(r.color)},children:r.label}),u.jsx(Ad,{type:"target",position:er.Top,style:{width:6,height:6,background:"#a855f7",borderRadius:"50%",opacity:1,pointerEvents:"auto"}}),u.jsx(Ad,{type:"source",position:er.Bottom,isConnectable:!0,style:{opacity:0}})]}),yA=({id:r,sourceX:o,sourceY:e,targetX:d,targetY:t,data:l})=>{const[i,a,w]=Va({sourceX:o,sourceY:e,targetX:d,targetY:t});return u.jsxs(u.Fragment,{children:[u.jsx(Fd,{id:r,path:i,style:{stroke:"#B475FC",strokeWidth:1}}),u.jsx("foreignObject",{width:18,height:20,x:a-10,y:w-8,color:"#B475FC",children:u.jsx("div",{style:{background:"#fff",border:"1px solid #ccc",borderRadius:"5px",padding:"2px 4px"},className:"d-flex align-center justify-center",children:u.jsx("div",{style:{background:"linear-gradient(163.3deg, #FA5B5B 14.56%, #186EDF 96.43%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:u.jsx("img",{src:"/vector.svg",alt:"vector"})})})})]})},EA={customHandle:AA},DA={custom:yA},vA=({setEdges:r,nodes:o,edges:e,onNodesChange:d,onEdgesChange:t})=>{const l=g.useCallback(i=>{const a=o.find(p=>p.id===i.source),w=o.find(p=>p.id===i.target),b=a?.data?.color||"#000",n=w?.data?.color||"#000",s={...i,id:`reactflow__edge-${i.source}-${i.target}`,type:"custom",source:i.source,target:i.target,data:{sourceLabel:a?.data?.label,targetLabel:w?.data?.label,sourceColor:b,targetColor:n,permission:[],requiredColumns:[],condition:""}};r(p=>Pn(s,p))},[]);return u.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:u.jsxs(Is,{nodes:o,edges:e,nodeTypes:EA,edgeTypes:DA,onNodesChange:d,onEdgesChange:t,onConnect:l,fitView:!0,fitViewOptions:{maxZoom:1},children:[u.jsx(Og,{}),u.jsx(zg,{}),u.jsx(Yg,{})]})})},SA=()=>u.jsx("div",{style:{background:"#fff",border:"1px solid #ccc",borderRadius:"5px",padding:"2px 4px"},className:"d-flex align-center justify-center",children:u.jsx("div",{style:{background:"linear-gradient(163.3deg, #FA5B5B 14.56%, #186EDF 96.43%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:u.jsx("img",{src:"/vector.svg",alt:"vector"})})}),_A=({edges:r,setSelectedId:o,saveToBackend:e})=>u.jsx("div",{style:{top:0,right:0,height:"100%",width:"422px",background:"#fff",borderLeft:"1px solid #ccc"},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:"Configuration"}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsx("div",{className:"flex-1",children:r?.map(d=>u.jsxs("div",{className:"d-flex h-44px mb-12",children:[u.jsxs("div",{style:{backgroundColor:r4(d.data?.sourceColor),border:`1px solid ${Ve(d.data?.sourceColor)}`},className:" flex-1 radius-8 px-12 py-6 d-flex justify-between align-center cursor-pointer",onClick:()=>{o({id:d.id,type:"config"})},children:[u.jsx("div",{className:"f-14 f-w-400 mr-20",style:{color:Ve(d.data?.sourceColor)},children:d?.data?.sourceLabel}),u.jsx("img",{src:"/arrow.svg",alt:"arrow",className:"mr-20"}),u.jsx("div",{className:"f-w-400 f-14",style:{color:Ve(d.data?.targetColor)},children:d?.data?.targetLabel})]}),u.jsx("div",{className:"w-42px d-flex align-center justify-center cursor-pointer",onClick:()=>{o({id:d.id,type:"auto"})},children:u.jsx(SA,{})})]}))}),u.jsxs("div",{className:"d-flex justify-end",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10",onClick:()=>close(),children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",onClick:()=>{e()},children:"Update"})]})]})});var qt={},Qp;function CA(){if(Qp)return qt;Qp=1;var r=Qo();Object.defineProperty(qt,"__esModule",{value:!0}),qt.default=void 0;var o=r(je()),e=he();return qt.default=(0,o.default)((0,e.jsx)("path",{d:"m8.71 11.71 2.59 2.59c.39.39 1.02.39 1.41 0l2.59-2.59c.63-.63.18-1.71-.71-1.71H9.41c-.89 0-1.33 1.08-.7 1.71"}),"ArrowDropDownRounded"),qt}var BA=CA();const rf=zo(BA),Ni={"popper-border":"#eaeff4","success-disabled":"#a6aaaf"};var Wt={},of;function IA(){if(of)return Wt;of=1;var r=Qo();Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.default=void 0;var o=r(je()),e=he();return Wt.default=(0,o.default)((0,e.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),Wt}var TA=IA();const NA=zo(TA);var o4=function(r,o){return o4=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,d){e.__proto__=d}||function(e,d){for(var t in d)Object.prototype.hasOwnProperty.call(d,t)&&(e[t]=d[t])},o4(r,o)};function PA(r,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");o4(r,o);function e(){this.constructor=r}r.prototype=o===null?Object.create(o):(e.prototype=o.prototype,new e)}var He=function(){return He=Object.assign||function(o){for(var e,d=1,t=arguments.length;d<t;d++){e=arguments[d];for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&(o[l]=e[l])}return o},He.apply(this,arguments)};function OA(r,o){var e={};for(var d in r)Object.prototype.hasOwnProperty.call(r,d)&&o.indexOf(d)<0&&(e[d]=r[d]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,d=Object.getOwnPropertySymbols(r);t<d.length;t++)o.indexOf(d[t])<0&&Object.prototype.propertyIsEnumerable.call(r,d[t])&&(e[d[t]]=r[d[t]]);return e}function RA(r,o,e,d){function t(l){return l instanceof e?l:new e(function(i){i(l)})}return new(e||(e=Promise))(function(l,i){function a(n){try{b(d.next(n))}catch(s){i(s)}}function w(n){try{b(d.throw(n))}catch(s){i(s)}}function b(n){n.done?l(n.value):t(n.value).then(a,w)}b((d=d.apply(r,o||[])).next())})}function MA(r,o){var e={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},d,t,l,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(b){return function(n){return w([b,n])}}function w(b){if(d)throw new TypeError("Generator is already executing.");for(;i&&(i=0,b[0]&&(e=0)),e;)try{if(d=1,t&&(l=b[0]&2?t.return:b[0]?t.throw||((l=t.return)&&l.call(t),0):t.next)&&!(l=l.call(t,b[1])).done)return l;switch(t=0,l&&(b=[b[0]&2,l.value]),b[0]){case 0:case 1:l=b;break;case 4:return e.label++,{value:b[1],done:!1};case 5:e.label++,t=b[1],b=[0];continue;case 7:b=e.ops.pop(),e.trys.pop();continue;default:if(l=e.trys,!(l=l.length>0&&l[l.length-1])&&(b[0]===6||b[0]===2)){e=0;continue}if(b[0]===3&&(!l||b[1]>l[0]&&b[1]<l[3])){e.label=b[1];break}if(b[0]===6&&e.label<l[1]){e.label=l[1],l=b;break}if(l&&e.label<l[2]){e.label=l[2],e.ops.push(b);break}l[2]&&e.ops.pop(),e.trys.pop();continue}b=o.call(r,e)}catch(n){b=[6,n],t=0}finally{d=l=0}if(b[0]&5)throw b[1];return{value:b[0]?b[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var e4="Invariant Violation",ef=Object.setPrototypeOf,$A=ef===void 0?function(r,o){return r.__proto__=o,r}:ef,df=function(r){PA(o,r);function o(e){e===void 0&&(e=e4);var d=r.call(this,typeof e=="number"?e4+": "+e+" (see https://github.com/apollographql/invariant-packages)":e)||this;return d.framesToPop=1,d.name=e4,$A(d,o.prototype),d}return o}(Error);function sd(r,o){if(!r)throw new df(o)}var tf=["debug","log","warn","error","silent"],UA=tf.indexOf("log");function Pi(r){return function(){if(tf.indexOf(r)>=UA){var o=console[r]||console.log;return o.apply(console,arguments)}}}(function(r){r.debug=Pi("debug"),r.log=Pi("log"),r.warn=Pi("warn"),r.error=Pi("error")})(sd||(sd={}));var lf="3.14.0";function jd(r){try{return r()}catch{}}const d4=jd(function(){return globalThis})||jd(function(){return window})||jd(function(){return self})||jd(function(){return global})||jd(function(){return jd.constructor("return this")()});var af=new Map;function LA(r){var o=af.get(r)||1;return af.set(r,o+1),"".concat(r,":").concat(o,":").concat(Math.random().toString(36).slice(2))}function jA(r,o){var e=LA("stringifyForDisplay");return JSON.stringify(r,function(d,t){return t===void 0?e:t},o).split(JSON.stringify(e)).join("<undefined>")}function Oi(r){return function(o){for(var e=[],d=1;d<arguments.length;d++)e[d-1]=arguments[d];if(typeof o=="number"){var t=o;o=l4(t),o||(o=i4(t,e),e=[])}r.apply(void 0,[o].concat(e))}}var t4=Object.assign(function(o,e){for(var d=[],t=2;t<arguments.length;t++)d[t-2]=arguments[t];o||sd(o,l4(e,d)||i4(e,d))},{debug:Oi(sd.debug),log:Oi(sd.log),warn:Oi(sd.warn),error:Oi(sd.error)});function wf(r){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return new df(l4(r,o)||i4(r,o))}var bf=Symbol.for("ApolloErrorMessageHandler_"+lf);function nf(r){if(typeof r=="string")return r;try{return jA(r,2).slice(0,1e3)}catch{return"<non-serializable>"}}function l4(r,o){if(o===void 0&&(o=[]),!!r)return d4[bf]&&d4[bf](r,o.map(nf))}function i4(r,o){if(o===void 0&&(o=[]),!!r)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:lf,message:r,args:o.map(nf)})))}function zA(r){return r.definitions.filter(function(o){return o.kind==="OperationDefinition"&&!!o.name}).map(function(o){return o.name.value})[0]||null}let oo=null;const sf={};let VA=1;const HA=()=>class{constructor(){this.id=["slot",VA++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let o=oo;o;o=o.parent)if(this.id in o.slots){const e=o.slots[this.id];if(e===sf)break;return o!==oo&&(oo.slots[this.id]=e),!0}return oo&&(oo.slots[this.id]=sf),!1}getValue(){if(this.hasValue())return oo.slots[this.id]}withValue(o,e,d,t){const l={__proto__:null,[this.id]:o},i=oo;oo={parent:i,slots:l};try{return e.apply(t,d)}finally{oo=i}}static bind(o){const e=oo;return function(){const d=oo;try{return oo=e,o.apply(this,arguments)}finally{oo=d}}}static noContext(o,e,d){if(oo){const t=oo;try{return oo=null,o.apply(d,e)}finally{oo=t}}else return o.apply(d,e)}};function pf(r){try{return r()}catch{}}const a4="@wry/context:Slot",ff=pf(()=>globalThis)||pf(()=>global)||Object.create(null),w4=ff[a4]||Array[a4]||function(r){try{Object.defineProperty(ff,a4,{value:r,enumerable:!1,writable:!1,configurable:!0})}finally{return r}}(HA()),{bind:uv,noContext:Fv}=w4;new w4;function qA(r,o){var e=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(e)return(e=e.call(r)).next.bind(e);if(Array.isArray(r)||(e=WA(r))||o){e&&(r=e);var d=0;return function(){return d>=r.length?{done:!0}:{done:!1,value:r[d++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
151
151
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WA(r,o){if(r){if(typeof r=="string")return hf(r,o);var e=Object.prototype.toString.call(r).slice(8,-1);if(e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set")return Array.from(r);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return hf(r,o)}}function hf(r,o){(o==null||o>r.length)&&(o=r.length);for(var e=0,d=new Array(o);e<o;e++)d[e]=r[e];return d}function mf(r,o){for(var e=0;e<o.length;e++){var d=o[e];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(r,d.key,d)}}function b4(r,o,e){return o&&mf(r.prototype,o),e&&mf(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}var n4=function(){return typeof Symbol=="function"},s4=function(r){return n4()&&!!Symbol[r]},p4=function(r){return s4(r)?Symbol[r]:"@@"+r};n4()&&!s4("observable")&&(Symbol.observable=Symbol("observable"));var KA=p4("iterator"),f4=p4("observable"),kf=p4("species");function Ri(r,o){var e=r[o];if(e!=null){if(typeof e!="function")throw new TypeError(e+" is not a function");return e}}function Kt(r){var o=r.constructor;return o!==void 0&&(o=o[kf],o===null&&(o=void 0)),o!==void 0?o:ao}function YA(r){return r instanceof ao}function zd(r){zd.log?zd.log(r):setTimeout(function(){throw r})}function Mi(r){Promise.resolve().then(function(){try{r()}catch(o){zd(o)}})}function xf(r){var o=r._cleanup;if(o!==void 0&&(r._cleanup=void 0,!!o))try{if(typeof o=="function")o();else{var e=Ri(o,"unsubscribe");e&&e.call(o)}}catch(d){zd(d)}}function h4(r){r._observer=void 0,r._queue=void 0,r._state="closed"}function GA(r){var o=r._queue;if(o){r._queue=void 0,r._state="ready";for(var e=0;e<o.length&&(gf(r,o[e].type,o[e].value),r._state!=="closed");++e);}}function gf(r,o,e){r._state="running";var d=r._observer;try{var t=Ri(d,o);switch(o){case"next":t&&t.call(d,e);break;case"error":if(h4(r),t)t.call(d,e);else throw e;break;case"complete":h4(r),t&&t.call(d);break}}catch(l){zd(l)}r._state==="closed"?xf(r):r._state==="running"&&(r._state="ready")}function m4(r,o,e){if(r._state!=="closed"){if(r._state==="buffering"){r._queue.push({type:o,value:e});return}if(r._state!=="ready"){r._state="buffering",r._queue=[{type:o,value:e}],Mi(function(){return GA(r)});return}gf(r,o,e)}}var XA=function(){function r(e,d){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var t=new ZA(this);try{this._cleanup=d.call(void 0,t)}catch(l){t.error(l)}this._state==="initializing"&&(this._state="ready")}var o=r.prototype;return o.unsubscribe=function(){this._state!=="closed"&&(h4(this),xf(this))},b4(r,[{key:"closed",get:function(){return this._state==="closed"}}]),r}(),ZA=function(){function r(e){this._subscription=e}var o=r.prototype;return o.next=function(d){m4(this._subscription,"next",d)},o.error=function(d){m4(this._subscription,"error",d)},o.complete=function(){m4(this._subscription,"complete")},b4(r,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),r}(),ao=function(){function r(e){if(!(this instanceof r))throw new TypeError("Observable cannot be called as a function");if(typeof e!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=e}var o=r.prototype;return o.subscribe=function(d){return(typeof d!="object"||d===null)&&(d={next:d,error:arguments[1],complete:arguments[2]}),new XA(d,this._subscriber)},o.forEach=function(d){var t=this;return new Promise(function(l,i){if(typeof d!="function"){i(new TypeError(d+" is not a function"));return}function a(){w.unsubscribe(),l()}var w=t.subscribe({next:function(b){try{d(b,a)}catch(n){i(n),w.unsubscribe()}},error:i,complete:l})})},o.map=function(d){var t=this;if(typeof d!="function")throw new TypeError(d+" is not a function");var l=Kt(this);return new l(function(i){return t.subscribe({next:function(a){try{a=d(a)}catch(w){return i.error(w)}i.next(a)},error:function(a){i.error(a)},complete:function(){i.complete()}})})},o.filter=function(d){var t=this;if(typeof d!="function")throw new TypeError(d+" is not a function");var l=Kt(this);return new l(function(i){return t.subscribe({next:function(a){try{if(!d(a))return}catch(w){return i.error(w)}i.next(a)},error:function(a){i.error(a)},complete:function(){i.complete()}})})},o.reduce=function(d){var t=this;if(typeof d!="function")throw new TypeError(d+" is not a function");var l=Kt(this),i=arguments.length>1,a=!1,w=arguments[1],b=w;return new l(function(n){return t.subscribe({next:function(s){var p=!a;if(a=!0,!p||i)try{b=d(b,s)}catch(m){return n.error(m)}else b=s},error:function(s){n.error(s)},complete:function(){if(!a&&!i)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(b),n.complete()}})})},o.concat=function(){for(var d=this,t=arguments.length,l=new Array(t),i=0;i<t;i++)l[i]=arguments[i];var a=Kt(this);return new a(function(w){var b,n=0;function s(p){b=p.subscribe({next:function(m){w.next(m)},error:function(m){w.error(m)},complete:function(){n===l.length?(b=void 0,w.complete()):s(a.from(l[n++]))}})}return s(d),function(){b&&(b.unsubscribe(),b=void 0)}})},o.flatMap=function(d){var t=this;if(typeof d!="function")throw new TypeError(d+" is not a function");var l=Kt(this);return new l(function(i){var a=[],w=t.subscribe({next:function(n){if(d)try{n=d(n)}catch(p){return i.error(p)}var s=l.from(n).subscribe({next:function(p){i.next(p)},error:function(p){i.error(p)},complete:function(){var p=a.indexOf(s);p>=0&&a.splice(p,1),b()}});a.push(s)},error:function(n){i.error(n)},complete:function(){b()}});function b(){w.closed&&a.length===0&&i.complete()}return function(){a.forEach(function(n){return n.unsubscribe()}),w.unsubscribe()}})},o[f4]=function(){return this},r.from=function(d){var t=typeof this=="function"?this:r;if(d==null)throw new TypeError(d+" is not an object");var l=Ri(d,f4);if(l){var i=l.call(d);if(Object(i)!==i)throw new TypeError(i+" is not an object");return YA(i)&&i.constructor===t?i:new t(function(a){return i.subscribe(a)})}if(s4("iterator")&&(l=Ri(d,KA),l))return new t(function(a){Mi(function(){if(!a.closed){for(var w=qA(l.call(d)),b;!(b=w()).done;){var n=b.value;if(a.next(n),a.closed)return}a.complete()}})});if(Array.isArray(d))return new t(function(a){Mi(function(){if(!a.closed){for(var w=0;w<d.length;++w)if(a.next(d[w]),a.closed)return;a.complete()}})});throw new TypeError(d+" is not observable")},r.of=function(){for(var d=arguments.length,t=new Array(d),l=0;l<d;l++)t[l]=arguments[l];var i=typeof this=="function"?this:r;return new i(function(a){Mi(function(){if(!a.closed){for(var w=0;w<t.length;++w)if(a.next(t[w]),a.closed)return;a.complete()}})})},b4(r,null,[{key:kf,get:function(){return this}}]),r}();n4()&&Object.defineProperty(ao,Symbol("extensions"),{value:{symbol:f4,hostReportError:zd},configurable:!0});function JA(r){var o,e=r.Symbol;if(typeof e=="function")if(e.observable)o=e.observable;else{typeof e.for=="function"?o=e.for("https://github.com/benlesh/symbol-observable"):o=e("https://github.com/benlesh/symbol-observable");try{e.observable=o}catch{}}else o="@@observable";return o}var Vd;typeof self<"u"?Vd=self:typeof window<"u"?Vd=window:typeof global<"u"?Vd=global:typeof module<"u"?Vd=module:Vd=Function("return this")(),JA(Vd);var cf=ao.prototype,uf="@@observable";cf[uf]||(cf[uf]=function(){return this});function QA(r){for(var o=["query","operationName","variables","extensions","context"],e=0,d=Object.keys(r);e<d.length;e++){var t=d[e];if(o.indexOf(t)<0)throw wf(58,t)}return r}function ry(r,o){var e=He({},r),d=function(l){typeof l=="function"?e=He(He({},e),l(e)):e=He(He({},e),l)},t=function(){return He({},e)};return Object.defineProperty(o,"setContext",{enumerable:!1,value:d}),Object.defineProperty(o,"getContext",{enumerable:!1,value:t}),o}function oy(r){var o={variables:r.variables||{},extensions:r.extensions||{},operationName:r.operationName,query:r.query};return o.operationName||(o.operationName=typeof o.query!="string"?zA(o.query)||void 0:""),o}var ey=Symbol.for("apollo.deprecations"),dy=d4,ty=new w4;function ly(r){return dy[ey]||(ty.getValue()||[]).includes(r)}function iy(r,o){ly(r)||o()}function Ff(r,o){return o?o(r):ao.of()}function Yt(r){return typeof r=="function"?new Af(r):r}function $i(r){return r.request.length<=1}var Af=function(){function r(o){o&&(this.request=o)}return r.empty=function(){return new r(function(){return ao.of()})},r.from=function(o){return o.length===0?r.empty():o.map(Yt).reduce(function(e,d){return e.concat(d)})},r.split=function(o,e,d){var t=Yt(e),l=Yt(d||new r(Ff)),i;return $i(t)&&$i(l)?i=new r(function(a){return o(a)?t.request(a)||ao.of():l.request(a)||ao.of()}):i=new r(function(a,w){return o(a)?t.request(a,w)||ao.of():l.request(a,w)||ao.of()}),Object.assign(i,{left:t,right:l})},r.execute=function(o,e){return o.request(ry(e.context,oy(QA(e))))||ao.of()},r.concat=function(o,e){var d=Yt(o);if($i(d))return globalThis.__DEV__!==!1&&t4.warn(47,d),d;var t=Yt(e),l;return $i(t)?l=new r(function(i){return d.request(i,function(a){return t.request(a)||ao.of()})||ao.of()}):l=new r(function(i,a){return d.request(i,function(w){return t.request(w,a)||ao.of()})||ao.of()}),Object.assign(l,{left:d,right:t})},r.prototype.split=function(o,e,d){return this.concat(r.split(o,e,d||new r(Ff)))},r.prototype.concat=function(o){return r.concat(this,o)},r.prototype.request=function(o,e){throw wf(48)},r.prototype.onError=function(o,e){if(globalThis.__DEV__!==!1&&iy("onError",function(){globalThis.__DEV__!==!1&&t4.warn(49)}),e&&e.error)return e.error(o),!1;throw o},r.prototype.setOnError=function(o){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&t4.warn(50),this.onError=o,this},r}();function ay(r){return new Af(function(o,e){var d=OA(o,[]);return new ao(function(t){var l,i=!1;return Promise.resolve(d).then(function(a){return r(a,o.getContext())}).then(o.setContext).then(function(){i||(l=e(o).subscribe({next:t.next.bind(t),error:t.error.bind(t),complete:t.complete.bind(t)}))}).catch(t.error.bind(t)),function(){i=!0,l&&l.unsubscribe()}})})}/*! js-cookie v3.0.5 | MIT */function Ui(r){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var d in e)r[d]=e[d]}return r}var wy={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function k4(r,o){function e(t,l,i){if(!(typeof document>"u")){i=Ui({},o,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var w in i)i[w]&&(a+="; "+w,i[w]!==!0&&(a+="="+i[w].split(";")[0]));return document.cookie=t+"="+r.write(l,t)+a}}function d(t){if(!(typeof document>"u"||arguments.length&&!t)){for(var l=document.cookie?document.cookie.split("; "):[],i={},a=0;a<l.length;a++){var w=l[a].split("="),b=w.slice(1).join("=");try{var n=decodeURIComponent(w[0]);if(i[n]=r.read(b,n),t===n)break}catch{}}return t?i[t]:i}}return Object.create({set:e,get:d,remove:function(t,l){e(t,"",Ui({},l,{expires:-1}))},withAttributes:function(t){return k4(this.converter,Ui({},this.attributes,t))},withConverter:function(t){return k4(Ui({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}var Gt=k4(wy,{path:"/"});const Xt={NOTIFY:"notify",UPDATE_FIELD:"update_field",MOVE_RECORD:"move_record",COPY_RECORD_TO_OTHER_WORKSPACE:"copy_record_to_other_workspace"},yf={Config:"config",Auto:"auto"},by={login:"/auth/login"},Ef={workspaceId:"workspaceId"},ny="Logging",sy="NoHubcallbackProvidedException";var yo;(function(r){r.DEBUG="DEBUG",r.ERROR="ERROR",r.INFO="INFO",r.WARN="WARN",r.VERBOSE="VERBOSE",r.NONE="NONE"})(yo||(yo={}));const Df={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};class Eo{constructor(o,e=yo.WARN){this.name=o,this.level=e,this._pluggables=[]}_padding(o){return o<10?"0"+o:""+o}_ts(){const o=new Date;return[this._padding(o.getMinutes()),this._padding(o.getSeconds())].join(":")+"."+o.getMilliseconds()}configure(o){return o?(this._config=o,this._config):this._config}_log(o,...e){let d=this.level;Eo.LOG_LEVEL&&(d=Eo.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(d=window.LOG_LEVEL);const t=Df[d];if(!(Df[o]>=t))return;let i=console.log.bind(console);o===yo.ERROR&&console.error&&(i=console.error.bind(console)),o===yo.WARN&&console.warn&&(i=console.warn.bind(console)),Eo.BIND_ALL_LOG_LEVELS&&(o===yo.INFO&&console.info&&(i=console.info.bind(console)),o===yo.DEBUG&&console.debug&&(i=console.debug.bind(console)));const a=`[${o}] ${this._ts()} ${this.name}`;let w="";if(e.length===1&&typeof e[0]=="string")w=`${a} - ${e[0]}`,i(w);else if(e.length===1)w=`${a} ${e[0]}`,i(a,e[0]);else if(typeof e[0]=="string"){let b=e.slice(1);b.length===1&&(b=b[0]),w=`${a} - ${e[0]} ${b}`,i(`${a} - ${e[0]}`,b)}else w=`${a} ${e}`,i(a,e);for(const b of this._pluggables){const n={message:w,timestamp:Date.now()};b.pushLogs([n])}}log(...o){this._log(yo.INFO,...o)}info(...o){this._log(yo.INFO,...o)}warn(...o){this._log(yo.WARN,...o)}error(...o){this._log(yo.ERROR,...o)}debug(...o){this._log(yo.DEBUG,...o)}verbose(...o){this._log(yo.VERBOSE,...o)}addPluggable(o){o&&o.getCategoryName()===ny&&(this._pluggables.push(o),o.configure(this._config))}listPluggables(){return this._pluggables}}Eo.LOG_LEVEL=null,Eo.BIND_ALL_LOG_LEVELS=!1;class ko extends Error{constructor({message:o,name:e,recoverySuggestion:d,underlyingError:t,metadata:l}){if(super(o),this.name=e,this.underlyingError=t,this.recoverySuggestion=d,l){const{extendedRequestId:i,httpStatusCode:a,requestId:w}=l;this.metadata={extendedRequestId:i,httpStatusCode:a,requestId:w}}this.constructor=ko,Object.setPrototypeOf(this,ko.prototype)}}var qe;(function(r){r.NoEndpointId="NoEndpointId",r.PlatformNotSupported="PlatformNotSupported",r.Unknown="Unknown",r.NetworkError="NetworkError"})(qe||(qe={}));const x4=(r,o=ko)=>(e,d,t)=>{const{message:l,recoverySuggestion:i}=r[d];if(!e)throw new o({name:d,message:t?`${l} ${t}`:l,recoverySuggestion:i})},pd=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",Zt=new Eo("Hub");class vf{constructor(o){this.listeners=new Map,this.protectedChannels=["core","auth","api","analytics","interactions","pubsub","storage","ui","xr"],this.name=o}_remove(o,e){const d=this.listeners.get(o);if(!d){Zt.warn(`No listeners for ${o}`);return}this.listeners.set(o,[...d.filter(({callback:t})=>t!==e)])}dispatch(o,e,d,t){typeof o=="string"&&this.protectedChannels.indexOf(o)>-1&&(t===pd||Zt.warn(`WARNING: ${o} is protected and dispatching on it can have unintended consequences`));const l={channel:o,payload:{...e},source:d,patternInfo:[]};try{this._toListeners(l)}catch(i){Zt.error(i)}}listen(o,e,d="noname"){let t;if(typeof e!="function")throw new ko({name:sy,message:"No callback supplied to Hub"});t=e;let l=this.listeners.get(o);return l||(l=[],this.listeners.set(o,l)),l.push({name:d,callback:t}),()=>{this._remove(o,t)}}_toListeners(o){const{channel:e,payload:d}=o,t=this.listeners.get(e);t&&t.forEach(l=>{Zt.debug(`Dispatching to ${e} with `,d);try{l.callback(o)}catch(i){Zt.error(i)}})}}const Hd=new vf("__default__"),Li=new vf("internal-hub"),py=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new ko({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},fy=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new ko({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},hy=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new ko({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})},g4={convert(r,o){let e=r;return o?.urlSafe&&(e=e.replace(/-/g,"+").replace(/_/g,"/")),hy()(e)}};var le;(function(r){r.AuthTokenConfigException="AuthTokenConfigException",r.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",r.AuthUserPoolException="AuthUserPoolException",r.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",r.OAuthNotConfigureException="OAuthNotConfigureException"})(le||(le={}));const my={[le.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[le.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[le.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[le.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[le.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},c4=x4(my);function Sr(r){let o=!0;r?o=!!r.userPoolId&&!!r.userPoolClientId:o=!1,c4(o,le.AuthUserPoolException)}function Sf(r){const o=!!r?.loginWith?.oauth?.domain&&!!r?.loginWith?.oauth?.redirectSignOut&&!!r?.loginWith?.oauth?.redirectSignIn&&!!r?.loginWith?.oauth?.responseType;c4(o,le.OAuthNotConfigureException)}function ji(r){const o=!!r?.identityPoolId;c4(o,le.InvalidIdentityPoolIdException)}function fd(r){const o=r.split(".");if(o.length!==3)throw new Error("Invalid token");try{const d=o[1].replace(/-/g,"+").replace(/_/g,"/"),t=decodeURIComponent(g4.convert(d).split("").map(i=>`%${`00${i.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")),l=JSON.parse(t);return{toString:()=>r,payload:l}}catch{throw new Error("Invalid token payload")}}const _f=r=>{const o=Reflect.ownKeys(r);for(const e of o){const d=r[e];(d&&typeof d=="object"||typeof d=="function")&&_f(d)}return Object.freeze(r)},ky=new Eo("parseAWSExports"),xy={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},gy=(r={})=>{if(!Object.prototype.hasOwnProperty.call(r,"aws_project_region"))throw new ko({name:"InvalidParameterException",message:"Invalid config parameter.",recoverySuggestion:"Ensure passing the config object imported from `amplifyconfiguration.json`."});const{aws_appsync_apiKey:o,aws_appsync_authenticationType:e,aws_appsync_graphqlEndpoint:d,aws_appsync_region:t,aws_bots_config:l,aws_cognito_identity_pool_id:i,aws_cognito_sign_up_verification_method:a,aws_cognito_mfa_configuration:w,aws_cognito_mfa_types:b,aws_cognito_password_protection_settings:n,aws_cognito_verification_mechanisms:s,aws_cognito_signup_attributes:p,aws_cognito_social_providers:m,aws_cognito_username_attributes:h,aws_mandatory_sign_in:f,aws_mobile_analytics_app_id:k,aws_mobile_analytics_app_region:x,aws_user_files_s3_bucket:c,aws_user_files_s3_bucket_region:E,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:y,aws_user_pools_id:F,aws_user_pools_web_client_id:I,geo:D,oauth:v,predictions:_,aws_cloud_logic_custom:T,Notifications:L,modelIntrospection:q}=r,M={};k&&(M.Analytics={Pinpoint:{appId:k,region:x}});const{InAppMessaging:A,Push:O}=L??{};if(A?.AWSPinpoint||O?.AWSPinpoint){if(A?.AWSPinpoint){const{appId:j,region:W}=A.AWSPinpoint;M.Notifications={InAppMessaging:{Pinpoint:{appId:j,region:W}}}}if(O?.AWSPinpoint){const{appId:j,region:W}=O.AWSPinpoint;M.Notifications={...M.Notifications,PushNotification:{Pinpoint:{appId:j,region:W}}}}}if(Array.isArray(l)&&(M.Interactions={LexV1:Object.fromEntries(l.map(j=>[j.name,j]))}),d){const j=xy[e];j||ky.debug(`Invalid authentication type ${e}. Falling back to IAM.`),M.API={GraphQL:{endpoint:d,apiKey:o,region:t,defaultAuthMode:j??"iam"}},q&&(M.API.GraphQL.modelIntrospection=q)}const C=w?{status:w&&w.toLowerCase(),totpEnabled:b?.includes("TOTP")??!1,smsEnabled:b?.includes("SMS")??!1}:void 0,$=n?{minLength:n.passwordPolicyMinLength,requireLowercase:n.passwordPolicyCharacters?.includes("REQUIRES_LOWERCASE")??!1,requireUppercase:n.passwordPolicyCharacters?.includes("REQUIRES_UPPERCASE")??!1,requireNumbers:n.passwordPolicyCharacters?.includes("REQUIRES_NUMBERS")??!1,requireSpecialCharacters:n.passwordPolicyCharacters?.includes("REQUIRES_SYMBOLS")??!1}:void 0,P=Array.from(new Set([...s??[],...p??[]])).reduce((j,W)=>({...j,[W.toLowerCase()]:{required:!0}}),{}),B=h?.includes("EMAIL")??!1,N=h?.includes("PHONE_NUMBER")??!1;(i||F)&&(M.Auth={Cognito:{identityPoolId:i,allowGuestAccess:f!=="enable",signUpVerificationMethod:a,userAttributes:P,userPoolClientId:I,userPoolId:F,mfa:C,passwordFormat:$,loginWith:{username:!(B||N),email:B,phone:N}}});const z=v?Object.keys(v).length>0:!1,H=m?m.length>0:!1;if(M.Auth&&z&&(M.Auth.Cognito.loginWith={...M.Auth.Cognito.loginWith,oauth:{...cy(v),...H&&{providers:uy(m)}}}),c&&(M.Storage={S3:{bucket:c,region:E,dangerouslyConnectToHttpEndpointForTesting:y}}),D){const{amazon_location_service:j}=D;M.Geo={LocationService:{maps:j.maps,geofenceCollections:j.geofenceCollections,searchIndices:j.search_indices,region:j.region}}}if(T&&(M.API={...M.API,REST:T.reduce((j,W)=>{const{name:Y,endpoint:X,region:Z,service:J}=W;return{...j,[Y]:{endpoint:X,...J?{service:J}:void 0,...Z?{region:Z}:void 0}}},{})}),_){const{VoiceId:j}=_?.convert?.speechGenerator?.defaults??{};M.Predictions=j?{..._,convert:{..._.convert,speechGenerator:{..._.convert.speechGenerator,defaults:{voiceId:j}}}}:_}return M},Cf=r=>r?.split(",")??[],cy=({domain:r,scope:o,redirectSignIn:e,redirectSignOut:d,responseType:t})=>({domain:r,scopes:o,redirectSignIn:Cf(e),redirectSignOut:Cf(d),responseType:t}),uy=r=>r.map(o=>{const e=o.toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}),Fy=Symbol("oauth-listener"),eo=[];for(let r=0;r<256;++r)eo.push((r+256).toString(16).slice(1));function Ay(r,o=0){return(eo[r[o+0]]+eo[r[o+1]]+eo[r[o+2]]+eo[r[o+3]]+"-"+eo[r[o+4]]+eo[r[o+5]]+"-"+eo[r[o+6]]+eo[r[o+7]]+"-"+eo[r[o+8]]+eo[r[o+9]]+"-"+eo[r[o+10]]+eo[r[o+11]]+eo[r[o+12]]+eo[r[o+13]]+eo[r[o+14]]+eo[r[o+15]]).toLowerCase()}let u4;const yy=new Uint8Array(16);function Ey(){if(!u4){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");u4=crypto.getRandomValues.bind(crypto)}return u4(yy)}const Bf={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Dy(r,o,e){if(Bf.randomUUID&&!o&&!r)return Bf.randomUUID();r=r||{};const d=r.random??r.rng?.()??Ey();if(d.length<16)throw new Error("Random bytes length must be >= 16");if(d[6]=d[6]&15|64,d[8]=d[8]&63|128,o){if(e=e||0,e<0||e+16>o.length)throw new RangeError(`UUID byte range ${e}:${e+15} is out of buffer bounds`);for(let t=0;t<16;++t)o[e+t]=d[t];return o}return Ay(d)}function vy(r){const{version:o}=r;return o?o.startsWith("1"):!1}function Sy(r){if(!r)return;const{bucket_name:o,aws_region:e,buckets:d}=r;return{S3:{bucket:o,region:e,buckets:d&&$y(d)}}}function _y(r){if(!r)return;const{user_pool_id:o,user_pool_client_id:e,identity_pool_id:d,password_policy:t,mfa_configuration:l,mfa_methods:i,unauthenticated_identities_enabled:a,oauth:w,username_attributes:b,standard_required_attributes:n,groups:s}=r,p={Cognito:{userPoolId:o,userPoolClientId:e,groups:s}};return d&&(p.Cognito={...p.Cognito,identityPoolId:d}),t&&(p.Cognito.passwordFormat={requireLowercase:t.require_lowercase,requireNumbers:t.require_numbers,requireUppercase:t.require_uppercase,requireSpecialCharacters:t.require_symbols,minLength:t.min_length??6}),l&&(p.Cognito.mfa={status:My(l),smsEnabled:i?.includes("SMS"),totpEnabled:i?.includes("TOTP")}),a&&(p.Cognito.allowGuestAccess=a),w&&(p.Cognito.loginWith={oauth:{domain:w.domain,redirectSignIn:w.redirect_sign_in_uri,redirectSignOut:w.redirect_sign_out_uri,responseType:w.response_type==="token"?"token":"code",scopes:w.scopes,providers:Ry(w.identity_providers)}}),b&&(p.Cognito.loginWith={...p.Cognito.loginWith,email:b.includes("email"),phone:b.includes("phone_number"),username:b.includes("username")}),n&&(p.Cognito.userAttributes=n.reduce((m,h)=>({...m,[h]:{required:!0}}),{})),p}function Cy(r){if(!r?.amazon_pinpoint)return;const{amazon_pinpoint:o}=r;return{Pinpoint:{appId:o.app_id,region:o.aws_region}}}function By(r){if(!r)return;const{aws_region:o,geofence_collections:e,maps:d,search_indices:t}=r;return{LocationService:{region:o,searchIndices:t,geofenceCollections:e,maps:d}}}function Iy(r){if(!r)return;const{aws_region:o,default_authorization_type:e,url:d,api_key:t,model_introspection:l}=r;return{GraphQL:{endpoint:d,defaultAuthMode:If(e),region:o,apiKey:t,modelIntrospection:l}}}function Ty(r){if(!r?.events)return;const{url:o,aws_region:e,api_key:d,default_authorization_type:t}=r.events;return{Events:{endpoint:o,defaultAuthMode:If(t),region:e,apiKey:d}}}function Ny(r){if(!r)return;const{aws_region:o,channels:e,amazon_pinpoint_app_id:d}=r,t=e.includes("IN_APP_MESSAGING"),l=e.includes("APNS")||e.includes("FCM");if(!(t||l))return;const i={};return t&&(i.InAppMessaging={Pinpoint:{appId:d,region:o}}),l&&(i.PushNotification={Pinpoint:{appId:d,region:o}}),i}function Py(r){const o={};if(r.storage&&(o.Storage=Sy(r.storage)),r.auth&&(o.Auth=_y(r.auth)),r.analytics&&(o.Analytics=Cy(r.analytics)),r.geo&&(o.Geo=By(r.geo)),r.data&&(o.API=Iy(r.data)),r.custom){const e=Ty(r.custom);e&&"Events"in e&&(o.API={...o.API,...e})}return r.notifications&&(o.Notifications=Ny(r.notifications)),o}const Oy={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};function If(r){return Oy[r]}const Tf={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"};function Ry(r=[]){return r.reduce((o,e)=>(Tf[e]!==void 0&&o.push(Tf[e]),o),[])}function My(r){return r==="OPTIONAL"?"optional":r==="REQUIRED"?"on":"off"}function $y(r){const o={};return r.forEach(({name:e,bucket_name:d,aws_region:t,paths:l})=>{if(e in o)throw new Error(`Duplicate friendly name found: ${e}. Name must be unique.`);const i=l?Object.entries(l).reduce((a,[w,b])=>(b!==void 0&&(a[w]=b),a),{}):void 0;o[e]={bucketName:d,region:t,paths:i}}),o}const Nf=r=>Object.keys(r).some(o=>o.startsWith("aws_"))?gy(r):vy(r)?Py(r):r;var Oo=64,Uy=32,Ly=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),jy=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],zy=Math.pow(2,53)-1,zi=function(){function r(){this.state=Int32Array.from(jy),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return r.prototype.update=function(o){if(this.finished)throw new Error("Attempted to update an already finished hash.");var e=0,d=o.byteLength;if(this.bytesHashed+=d,this.bytesHashed*8>zy)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;d>0;)this.buffer[this.bufferLength++]=o[e++],d--,this.bufferLength===Oo&&(this.hashBuffer(),this.bufferLength=0)},r.prototype.digest=function(){if(!this.finished){var o=this.bytesHashed*8,e=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),d=this.bufferLength;if(e.setUint8(this.bufferLength++,128),d%Oo>=Oo-8){for(var t=this.bufferLength;t<Oo;t++)e.setUint8(t,0);this.hashBuffer(),this.bufferLength=0}for(var t=this.bufferLength;t<Oo-8;t++)e.setUint8(t,0);e.setUint32(Oo-8,Math.floor(o/4294967296),!0),e.setUint32(Oo-4,o),this.hashBuffer(),this.finished=!0}for(var l=new Uint8Array(Uy),t=0;t<8;t++)l[t*4]=this.state[t]>>>24&255,l[t*4+1]=this.state[t]>>>16&255,l[t*4+2]=this.state[t]>>>8&255,l[t*4+3]=this.state[t]>>>0&255;return l},r.prototype.hashBuffer=function(){for(var o=this,e=o.buffer,d=o.state,t=d[0],l=d[1],i=d[2],a=d[3],w=d[4],b=d[5],n=d[6],s=d[7],p=0;p<Oo;p++){if(p<16)this.temp[p]=(e[p*4]&255)<<24|(e[p*4+1]&255)<<16|(e[p*4+2]&255)<<8|e[p*4+3]&255;else{var m=this.temp[p-2],h=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10;m=this.temp[p-15];var f=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;this.temp[p]=(h+this.temp[p-7]|0)+(f+this.temp[p-16]|0)}var k=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&b^~w&n)|0)+(s+(Ly[p]+this.temp[p]|0)|0)|0,x=((t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10))+(t&l^t&i^l&i)|0;s=n,n=b,b=w,w=a+k|0,a=i,i=l,l=t,t=k+x|0}d[0]+=t,d[1]+=l,d[2]+=i,d[3]+=a,d[4]+=w,d[5]+=b,d[6]+=n,d[7]+=s},r}();const Vy=r=>new TextEncoder().encode(r);var Hy=typeof Buffer<"u"&&Buffer.from?function(r){return Buffer.from(r,"utf8")}:Vy;function Pf(r){return r instanceof Uint8Array?r:typeof r=="string"?Hy(r):ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(r)}function qy(r){return typeof r=="string"?r.length===0:r.byteLength===0}var Vi=function(){function r(o){this.secret=o,this.hash=new zi,this.reset()}return r.prototype.update=function(o){if(!(qy(o)||this.error))try{this.hash.update(Pf(o))}catch(e){this.error=e}},r.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},r.prototype.digest=function(){return RA(this,void 0,void 0,function(){return MA(this,function(o){return[2,this.digestSync()]})})},r.prototype.reset=function(){if(this.hash=new zi,this.secret){this.outer=new zi;var o=Wy(this.secret),e=new Uint8Array(Oo);e.set(o);for(var d=0;d<Oo;d++)o[d]^=54,e[d]^=92;this.hash.update(o),this.outer.update(e);for(var d=0;d<o.byteLength;d++)o[d]=0}},r}();function Wy(r){var o=Pf(r);if(o.byteLength>Oo){var e=new zi;e.update(o),o=e.digest()}var d=new Uint8Array(Oo);return d.set(o),d}for(let r=0;r<256;r++){let o=r.toString(16).toLowerCase();o.length===1&&(o=`0${o}`)}var Wr;(function(r){r.WebUnknown="0",r.React="1",r.NextJs="2",r.Angular="3",r.VueJs="4",r.Nuxt="5",r.Svelte="6",r.ServerSideUnknown="100",r.ReactSSR="101",r.NextJsSSR="102",r.AngularSSR="103",r.VueJsSSR="104",r.NuxtSSR="105",r.SvelteSSR="106",r.ReactNative="201",r.Expo="202"})(Wr||(Wr={}));var F4;(function(r){r.AI="ai",r.API="api",r.Auth="auth",r.Analytics="analytics",r.DataStore="datastore",r.Geo="geo",r.InAppMessaging="inappmessaging",r.Interactions="interactions",r.Predictions="predictions",r.PubSub="pubsub",r.PushNotification="pushnotification",r.Storage="storage"})(F4||(F4={}));var Of;(function(r){r.CreateConversation="1",r.GetConversation="2",r.ListConversations="3",r.DeleteConversation="4",r.SendMessage="5",r.ListMessages="6",r.OnMessage="7",r.Generation="8",r.UpdateConversation="9"})(Of||(Of={}));var Rf;(function(r){r.Record="1",r.IdentifyUser="2"})(Rf||(Rf={}));var Mf;(function(r){r.GraphQl="1",r.Get="2",r.Post="3",r.Put="4",r.Patch="5",r.Del="6",r.Head="7"})(Mf||(Mf={}));var wo;(function(r){r.SignUp="1",r.ConfirmSignUp="2",r.ResendSignUpCode="3",r.SignIn="4",r.FetchMFAPreference="6",r.UpdateMFAPreference="7",r.SetUpTOTP="10",r.VerifyTOTPSetup="11",r.ConfirmSignIn="12",r.DeleteUserAttributes="15",r.DeleteUser="16",r.UpdateUserAttributes="17",r.FetchUserAttributes="18",r.ConfirmUserAttribute="22",r.SignOut="26",r.UpdatePassword="27",r.ResetPassword="28",r.ConfirmResetPassword="29",r.FederatedSignIn="30",r.RememberDevice="32",r.ForgetDevice="33",r.FetchDevices="34",r.SendUserAttributeVerificationCode="35",r.SignInWithRedirect="36",r.StartWebAuthnRegistration="37",r.CompleteWebAuthnRegistration="38",r.ListWebAuthnCredentials="39",r.DeleteWebAuthnCredential="40"})(wo||(wo={}));var $f;(function(r){r.Subscribe="1",r.GraphQl="2"})($f||($f={}));var Uf;(function(r){r.SearchByText="0",r.SearchByCoordinates="1",r.SearchForSuggestions="2",r.SearchByPlaceId="3",r.SaveGeofences="4",r.GetGeofence="5",r.ListGeofences="6",r.DeleteGeofences="7"})(Uf||(Uf={}));var Lf;(function(r){r.SyncMessages="1",r.IdentifyUser="2",r.NotifyMessageInteraction="3"})(Lf||(Lf={}));var jf;(function(r){r.None="0"})(jf||(jf={}));var zf;(function(r){r.Convert="1",r.Identify="2",r.Interpret="3"})(zf||(zf={}));var Vf;(function(r){r.Subscribe="1"})(Vf||(Vf={}));var Hf;(function(r){r.InitializePushNotifications="1",r.IdentifyUser="2"})(Hf||(Hf={}));var qf;(function(r){r.UploadData="1",r.DownloadData="2",r.List="3",r.Copy="4",r.Remove="5",r.GetProperties="6",r.GetUrl="7",r.GetDataAccess="8",r.ListCallerAccessGrants="9"})(qf||(qf={}));const Ky="6.15.5",Hi=()=>typeof global<"u",qd=()=>typeof window<"u",Wf=()=>typeof document<"u",A4=()=>typeof process<"u",Jt=(r,o)=>!!Object.keys(r).find(e=>e.startsWith(o));function Yy(){const r=d=>d.startsWith("_react")||d.startsWith("__react"),o=d=>Object.keys(d).find(r),e=()=>Array.from(document.querySelectorAll("[id]"));return Wf()&&e().some(o)}function Gy(){return A4()&&typeof process.env<"u"&&!!Object.keys(process.env).find(r=>r.includes("react"))}function Xy(){return qd()&&Jt(window,"__VUE")}function Zy(){return Hi()&&Jt(global,"__VUE")}function Jy(){return qd()&&Jt(window,"__SVELTE")}function Qy(){return A4()&&typeof process.env<"u"&&!!Object.keys(process.env).find(r=>r.includes("svelte"))}function r8(){return qd()&&window.next&&typeof window.next=="object"}function o8(){return Hi()&&(Jt(global,"__next")||Jt(global,"__NEXT"))}function e8(){return qd()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function d8(){return Hi()&&typeof global.__NUXT_PATHS__<"u"}function t8(){const r=!!(Wf()&&document.querySelector("[ng-version]")),o=!!(qd()&&typeof window.ng<"u");return r||o}function l8(){return A4()&&typeof process.env=="object"&&process.env.npm_lifecycle_script?.startsWith("ng ")||!1}function i8(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}function a8(){return Hi()&&typeof global.expo<"u"}function w8(){return qd()}const b8=[{platform:Wr.Expo,detectionMethod:a8},{platform:Wr.ReactNative,detectionMethod:i8},{platform:Wr.NextJs,detectionMethod:r8},{platform:Wr.Nuxt,detectionMethod:e8},{platform:Wr.Angular,detectionMethod:t8},{platform:Wr.React,detectionMethod:Yy},{platform:Wr.VueJs,detectionMethod:Xy},{platform:Wr.Svelte,detectionMethod:Jy},{platform:Wr.WebUnknown,detectionMethod:w8},{platform:Wr.NextJsSSR,detectionMethod:o8},{platform:Wr.NuxtSSR,detectionMethod:d8},{platform:Wr.ReactSSR,detectionMethod:Gy},{platform:Wr.VueJsSSR,detectionMethod:Zy},{platform:Wr.AngularSSR,detectionMethod:l8},{platform:Wr.SvelteSSR,detectionMethod:Qy}];function n8(){return b8.find(r=>r.detectionMethod())?.platform||Wr.ServerSideUnknown}let Qt;const y4=[];let E4=!1;const s8=10,p8=10,f8=1e3,Kf=()=>{if(!Qt){if(Qt=n8(),E4)for(;y4.length;)y4.pop()?.();else y4.forEach(r=>{r()});Yf(Wr.ServerSideUnknown,s8),Yf(Wr.WebUnknown,p8)}return Qt};function h8(){Qt=void 0}function Yf(r,o){Qt===r&&!E4&&setTimeout(()=>{h8(),E4=!0,setTimeout(Kf,f8)},o)}const m8={},k8=(r,o)=>m8[r]?.[o]?.additionalDetails,x8="aws-amplify",g8=r=>r.replace(/\+.*/,""),c8=({category:r,action:o}={})=>{const e=[[x8,g8(Ky)]];if(r&&e.push([r,o]),e.push(["framework",Kf()]),r&&o){const d=k8(r,o);d&&d.forEach(t=>{e.push(t)})}return e},qi=r=>c8(r).map(([d,t])=>d&&t?`${d}/${t}`:d).join(" "),Gf=()=>typeof window<"u"&&typeof window.document<"u",Xf=new Eo("Auth");class u8{configure(o,e){this.authConfig=o,this.authOptions=e,o&&o.Cognito?.userPoolEndpoint&&Xf.warn(Zf("Amazon Cognito User Pool")),o&&o.Cognito?.identityPoolEndpoint&&Xf.warn(Zf("Amazon Cognito Identity Pool"))}async fetchAuthSession(o={}){let e,d;const t=await this.getTokens(o);return t?(d=t.accessToken?.payload?.sub,e=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,tokens:t,authenticated:!0,forceRefresh:o.forceRefresh})):e=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,authenticated:!1,forceRefresh:o.forceRefresh}),{tokens:t,credentials:e?.credentials,identityId:e?.identityId,userSub:d}}async clearCredentials(){await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId()}async getTokens(o){return await this.authOptions?.tokenProvider?.getTokens(o)??void 0}}const Zf=r=>`You are using a custom Amazon ${r} endpoint, ensure the endpoint is correct.`;class F8{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new u8}configure(o,e){const d=Nf(o);this.resourcesConfig=d,e&&(this.libraryOptions=e),this.resourcesConfig=_f(this.resourcesConfig),this.Auth.configure(this.resourcesConfig.Auth,this.libraryOptions.Auth),Hd.dispatch("core",{event:"configure",data:this.resourcesConfig},"Configure",pd),this.notifyOAuthListener(),this.isConfigured=!0}getConfig(){return this.isConfigured||console.warn("Amplify has not been configured. Please call Amplify.configure() before using this service."),this.resourcesConfig}[Fy](o){this.resourcesConfig.Auth?.Cognito.loginWith?.oauth?o(this.resourcesConfig.Auth?.Cognito):this.oAuthListener=o}notifyOAuthListener(){!this.resourcesConfig.Auth?.Cognito.loginWith?.oauth||!this.oAuthListener||(this.oAuthListener(this.resourcesConfig.Auth?.Cognito),this.oAuthListener=void 0)}}const Tr=new F8,A8=(r,o)=>r.Auth.fetchAuthSession(o),Jf=r=>A8(Tr,r);function Qf(){return Tr.Auth.clearCredentials()}const Wi=r=>{const{headers:o,statusCode:e}=r;return{...y8(r)?r.$metadata:{},httpStatusCode:e,requestId:o["x-amzn-requestid"]??o["x-amzn-request-id"]??o["x-amz-request-id"],extendedRequestId:o["x-amz-id-2"],cfId:o["x-amz-cf-id"]}},y8=r=>typeof r?.$metadata=="object",Wd=async r=>{if(!r||r.statusCode<300)return;const o=await rl(r),d=(i=>{const[a]=i.toString().split(/[,:]+/);return a.includes("#")?a.split("#")[1]:a})(r.headers["x-amzn-errortype"]??o.code??o.__type??"UnknownError"),t=o.message??o.Message??"Unknown error",l=new Error(t);return Object.assign(l,{name:d,$metadata:Wi(r)})},rl=async r=>{if(!r.body)throw new Error("Missing response payload");const o=await r.body.json();return Object.assign(o,{$metadata:Wi(r)})},no=(r,o,e,d)=>async(t,l)=>{const i={...d,...t},a=await i.endpointResolver(i,l),w=await o(l,a),b=await r(w,{...i});return e(b)},E8=300*1e3;function D8(r=E8){return d=>{const t=2**d*100+100*Math.random();return t>r?!1:t}}const rh=3,oh="amz-sdk-invocation-id",v8="amz-sdk-request",eh=300*1e3,dh=r=>{const e=D8(eh)(r);return e===!1?eh:e},S8=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],_8=r=>!!r&&S8.includes(r),th=r=>async(o,e)=>{const d=e??await r(o)??void 0,t=d?.code||d?.name,l=o?.statusCode;return{retryable:T8(e)||I8(l,t)||_8(t)||N8(l,t)}},C8=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],B8=["TimeoutError","RequestTimeout","RequestTimeoutException"],I8=(r,o)=>r===429||!!o&&C8.includes(o),T8=r=>[qe.NetworkError,"ERR_NETWORK"].includes(r?.name),N8=(r,o)=>!!r&&[500,502,503,504].includes(r)||!!o&&B8.includes(o),lh="cognito-identity",ih={service:lh,retryDecider:th(Wd),computeDelay:dh,cache:"no-store"},P8=({maxAttempts:r=rh,retryDecider:o,computeDelay:e,abortSignal:d})=>{if(r<1)throw new Error("maxAttempts must be greater than 0");return(t,l)=>async function(a){let w,b=l.attemptsCount??0,n;const s=()=>{if(n)return ah(n,b),n;throw ah(w,b),w};for(;!d?.aborted&&b<r;){try{n=await t(a),w=void 0}catch(h){w=h,n=void 0}b=(l.attemptsCount??0)>b?l.attemptsCount??0:b+1,l.attemptsCount=b;const{isCredentialsExpiredError:p,retryable:m}=await o(n,w,l);if(m){if(l.isCredentialsExpired=!!p,!d?.aborted&&b<r){const h=e(b);await O8(h,d)}continue}else return s()}if(d?.aborted)throw new Error("Request aborted.");return s()}},O8=(r,o)=>{if(o?.aborted)return Promise.resolve();let e,d;const t=new Promise(l=>{d=l,e=setTimeout(l,r)});return o?.addEventListener("abort",function l(i){clearTimeout(e),o?.removeEventListener("abort",l),d()}),t},ah=(r,o)=>{Object.prototype.toString.call(r)==="[object Object]"&&(r.$metadata={...r.$metadata??{},attempts:o})},R8=Dy,M8=()=>r=>async function(e){return e.headers[oh]||(e.headers[oh]=R8()),r(e)},$8=({maxAttempts:r=rh})=>(o,e)=>async function(t){const l=e.attemptsCount??0;return t.headers[v8]=`attempt=${l+1}; max=${r}`,o(t)},U8=({userAgentHeader:r="x-amz-user-agent",userAgentValue:o=""})=>e=>async function(t){if(o.trim().length===0)return await e(t);{const l=r.toLowerCase();return t.headers[l]=t.headers[l]?`${t.headers[l]} ${o}`:o,await e(t)}},D4=(r,o)=>(e,d)=>{const t={};let l=i=>r(i,d);for(let i=o.length-1;i>=0;i--){const a=o[i];l=a(d)(l,t)}return l(e)},v4=r=>{let o;return()=>(o||(o=r()),o)},L8=r=>!["HEAD","GET"].includes(r.toUpperCase()),wh=D4(async({url:r,method:o,headers:e,body:d},{abortSignal:t,cache:l,withCrossDomainCredentials:i})=>{let a;try{a=await fetch(r,{method:o,headers:e,body:L8(o)?d:void 0,signal:t,cache:l,credentials:i?"include":"same-origin"})}catch(s){throw s instanceof TypeError?new ko({name:qe.NetworkError,message:"A network error has occurred.",underlyingError:s}):s}const w={};a.headers?.forEach((s,p)=>{w[p.toLowerCase()]=s});const b={statusCode:a.status,headers:w,body:null},n=Object.assign(a.body??{},{text:v4(()=>a.text()),blob:v4(()=>a.blob()),json:v4(()=>a.json())});return{...b,body:n}},[U8,M8,P8,$8]),bh=D4(wh,[()=>r=>async function(e){return e.headers["cache-control"]="no-store",r(e)}]),nh=r=>(o,e)=>{const d=j8(r),t=JSON.stringify(o);return z8(e,d,t)},j8=r=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${r}`}),z8=({url:r},o,e)=>({headers:o,url:r,body:e,method:"POST"}),sh=r=>no(bh,nh("GetCredentialsForIdentity"),V8,{...ih,...r,userAgentValue:qi()}),V8=async r=>{if(r.statusCode>=300)throw await Wd(r);const o=await rl(r);return{IdentityId:o.IdentityId,Credentials:H8(o.Credentials),$metadata:Wi(r)}},H8=({Expiration:r,...o}={})=>({...o,Expiration:r&&new Date(r*1e3)}),q8=r=>no(bh,nh("GetId"),W8,{...ih,...r,userAgentValue:qi()}),W8=async r=>{if(r.statusCode>=300)throw await Wd(r);return{IdentityId:(await rl(r)).IdentityId,$metadata:Wi(r)}},ph={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},K8={partitions:[ph,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]},fh=r=>{const{partitions:o}=K8;for(const{regions:e,outputs:d,regionRegex:t}of o){const l=new RegExp(t);if(e.includes(r)||l.test(r))return d.dnsSuffix}return ph.outputs.dnsSuffix},ol=URL,Y8=({region:r})=>({url:new ol(`https://${lh}.${r}.${fh(r)}`)});class el extends ko{constructor(){super({name:qe.PlatformNotSupported,message:"Function not supported on current platform"})}}class hh{constructor(o){this.storage=o}async setItem(o,e){if(!this.storage)throw new el;this.storage.setItem(o,e)}async getItem(o){if(!this.storage)throw new el;return this.storage.getItem(o)}async removeItem(o){if(!this.storage)throw new el;this.storage.removeItem(o)}async clear(){if(!this.storage)throw new el;this.storage.clear()}}class mh{constructor(){this.storage=new Map}get length(){return this.storage.size}key(o){return o>this.length-1?null:Array.from(this.storage.keys())[o]}setItem(o,e){this.storage.set(o,e)}getItem(o){return this.storage.get(o)??null}removeItem(o){this.storage.delete(o)}clear(){this.storage.clear()}}const kh=new Eo("CoreStorageUtils"),G8=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{kh.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new mh},xh=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return kh.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new mh}};class X8 extends hh{constructor(){super(G8())}}class Z8 extends hh{constructor(){super(xh())}}class J8{constructor(o){this._storage=o}get storage(){if(!this._storage)throw new el;return this._storage}setItem(o,e){this.storage.setItem(o,e)}getItem(o){return this.storage.getItem(o)}removeItem(o){this.storage.removeItem(o)}clear(){this.storage.clear()}}class Q8 extends J8{constructor(){super(xh())}}class gh{constructor(o={}){const{path:e,domain:d,expires:t,sameSite:l,secure:i}=o;if(this.domain=d,this.path=e||"/",this.expires=Object.prototype.hasOwnProperty.call(o,"expires")?t:365,this.secure=Object.prototype.hasOwnProperty.call(o,"secure")?i:!0,Object.prototype.hasOwnProperty.call(o,"sameSite")){if(!l||!["strict","lax","none"].includes(l))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if(l==="none"&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=l}}async setItem(o,e){Gt.set(o,e,this.getData())}async getItem(o){return Gt.get(o)??null}async removeItem(o){Gt.remove(o,this.getData())}async clear(){const o=Gt.get(),e=Object.keys(o).map(d=>this.removeItem(d));await Promise.all(e)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}}const dl=new X8;new Z8;const ue=new Q8,rE=r=>{let o;return async(...e)=>o||(o=new Promise((d,t)=>{r(...e).then(l=>{d(l)}).catch(l=>{t(l)}).finally(()=>{o=void 0})}),o)};function ch({expiresAt:r,clockDrift:o,tolerance:e=5e3}){return Date.now()+o+e>r}const oE=async()=>{const{userAgentData:r}=navigator;if(!r)return navigator.userAgent;const{platform:o="",platformVersion:e="",model:d="",architecture:t="",fullVersionList:l=[]}=await r.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),i=l.map(w=>`${w.brand}/${w.version}`).join(";");return[o,e,t,d,o,i].filter(w=>w).join(" ")||navigator.userAgent};function eE(r){return Array.from(r,o=>String.fromCodePoint(o)).join("")}const tl={convert(r,o={urlSafe:!1,skipPadding:!1}){const e=typeof r=="string"?r:eE(r);let d=fy()(e);return o.urlSafe&&(d=d.replace(/\+/g,"-").replace(/\//g,"_")),o.skipPadding&&(d=d.replace(/=/g,"")),d}};function dE(){return py().getRandomValues(new Uint32Array(1))[0]}function tE(r){const{words:o}=r,{sigBytes:e}=r,d=[];for(let t=0;t<e;t++){const l=o[t>>>2]>>>24-t%4*8&255;d.push((l>>>4).toString(16)),d.push((l&15).toString(16))}return d.join("")}class S4{constructor(o,e){this.words=[];let d=o;d=this.words=d||[],e!==void 0?this.sigBytes=e:this.sigBytes=d.length*4}random(o){const e=[];for(let d=0;d<o;d+=4)e.push(dE());return new S4(e,o)}toString(){return tE(this)}}var sr;(function(r){r.EmptySignInUsername="EmptySignInUsername",r.EmptySignInPassword="EmptySignInPassword",r.CustomAuthSignInPassword="CustomAuthSignInPassword",r.EmptySignUpUsername="EmptySignUpUsername",r.EmptySignUpPassword="EmptySignUpPassword",r.EmptyConfirmSignUpUsername="EmptyConfirmSignUpUsername",r.EmptyConfirmSignUpCode="EmptyConfirmSignUpCode",r.EmptyResendSignUpCodeUsername="EmptyresendSignUpCodeUsername",r.EmptyChallengeResponse="EmptyChallengeResponse",r.EmptyConfirmResetPasswordUsername="EmptyConfirmResetPasswordUsername",r.EmptyConfirmResetPasswordNewPassword="EmptyConfirmResetPasswordNewPassword",r.EmptyConfirmResetPasswordConfirmationCode="EmptyConfirmResetPasswordConfirmationCode",r.EmptyResetPasswordUsername="EmptyResetPasswordUsername",r.EmptyVerifyTOTPSetupCode="EmptyVerifyTOTPSetupCode",r.EmptyConfirmUserAttributeCode="EmptyConfirmUserAttributeCode",r.IncorrectMFAMethod="IncorrectMFAMethod",r.EmptyUpdatePassword="EmptyUpdatePassword"})(sr||(sr={}));const uh={[sr.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[sr.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[sr.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[sr.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[sr.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[sr.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[sr.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[sr.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[sr.EmptySignInPassword]:{message:"password is required to signIn"},[sr.EmptySignInUsername]:{message:"username is required to signIn"},[sr.EmptySignUpPassword]:{message:"password is required to signUp"},[sr.EmptySignUpUsername]:{message:"username is required to signUp"},[sr.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[sr.IncorrectMFAMethod]:{message:"Incorrect MFA method was chosen. It should be either SMS, TOTP, or EMAIL",recoverySuggestion:"Try to pass SMS, TOTP, or EMAIL as the challengeResponse"},[sr.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[sr.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[sr.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"}};var Fh;(function(r){r.DEFAULT_MSG="Authentication Error",r.EMPTY_EMAIL="Email cannot be empty",r.EMPTY_PHONE="Phone number cannot be empty",r.EMPTY_USERNAME="Username cannot be empty",r.INVALID_USERNAME="The username should either be a string or one of the sign in types",r.EMPTY_PASSWORD="Password cannot be empty",r.EMPTY_CODE="Confirmation code cannot be empty",r.SIGN_UP_ERROR="Error creating account",r.NO_MFA="No valid MFA method provided",r.INVALID_MFA="Invalid MFA type",r.EMPTY_CHALLENGE="Challenge response cannot be empty",r.NO_USER_SESSION="Failed to get the session because the user is empty",r.NETWORK_ERROR="Network Error",r.DEVICE_CONFIG="Device tracking has not been configured in this User Pool",r.AUTOSIGNIN_ERROR="Please use your credentials to sign in",r.OAUTH_ERROR="Couldn't finish OAuth flow, check your User Pool HostedUI settings"})(Fh||(Fh={}));var Kd;(function(r){r.SignInException="SignInException",r.OAuthSignInError="OAuthSignInException"})(Kd||(Kd={}));class ar extends ko{constructor(o){super(o),this.constructor=ar,Object.setPrototypeOf(this,ar.prototype)}}function Vr(r,o){const{message:e,recoverySuggestion:d}=uh[o];if(!r)throw new ar({name:o,message:e,recoverySuggestion:d})}function Kr(r){const o=r?.split("_")[0];if(!r||r.indexOf("_")<0||!o||typeof o!="string")throw new ar({name:"InvalidUserPoolId",message:"Invalid user pool id provided."});return o}function _4(r){if(!r||!r.includes(":"))throw new ar({name:"InvalidIdentityPoolIdException",message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."});return r.split(":")[0]}function Ah(r){return Object.entries(r).map(([o,e])=>({Name:o,Value:e}))}var yh;(function(r){r.ConcurrentModificationException="ConcurrentModificationException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(yh||(yh={}));var Eh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.InvalidPasswordException="InvalidPasswordException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Eh||(Eh={}));var Dh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidPasswordException="InvalidPasswordException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UsernameExistsException="UsernameExistsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Dh||(Dh={}));var vh;(function(r){r.CodeMismatchException="CodeMismatchException",r.ExpiredCodeException="ExpiredCodeException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidPasswordException="InvalidPasswordException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyFailedAttemptsException="TooManyFailedAttemptsException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(vh||(vh={}));var Sh;(function(r){r.AliasExistsException="AliasExistsException",r.CodeMismatchException="CodeMismatchException",r.ExpiredCodeException="ExpiredCodeException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyFailedAttemptsException="TooManyFailedAttemptsException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotFoundException="UserNotFoundException"})(Sh||(Sh={}));var _h;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(_h||(_h={}));var Ch;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Ch||(Ch={}));var Bh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Bh||(Bh={}));var Ih;(function(r){r.CodeDeliveryFailureException="CodeDeliveryFailureException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotFoundException="UserNotFoundException"})(Ih||(Ih={}));var Th;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Th||(Th={}));var Nh;(function(r){r.ExternalServiceException="ExternalServiceException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceConflictException="ResourceConflictException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException"})(Nh||(Nh={}));var Ph;(function(r){r.ExternalServiceException="ExternalServiceException",r.InternalErrorException="InternalErrorException",r.InvalidIdentityPoolConfigurationException="InvalidIdentityPoolConfigurationException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceConflictException="ResourceConflictException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException"})(Ph||(Ph={}));var Oh;(function(r){r.CodeDeliveryFailureException="CodeDeliveryFailureException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Oh||(Oh={}));var Rh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException"})(Rh||(Rh={}));var Ki;(function(r){r.PasswordResetRequiredException="PasswordResetRequiredException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Ki||(Ki={}));var Mh;(function(r){r.CodeDeliveryFailureException="CodeDeliveryFailureException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotFoundException="UserNotFoundException"})(Mh||(Mh={}));var $h;(function(r){r.AliasExistsException="AliasExistsException",r.CodeMismatchException="CodeMismatchException",r.ExpiredCodeException="ExpiredCodeException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidPasswordException="InvalidPasswordException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.MFAMethodNotFoundException="MFAMethodNotFoundException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})($h||($h={}));var Uh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Uh||(Uh={}));var C4;(function(r){r.CodeDeliveryFailureException="CodeDeliveryFailureException",r.InternalErrorException="InternalErrorException",r.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidPasswordException="InvalidPasswordException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.NotAuthorizedException="NotAuthorizedException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UsernameExistsException="UsernameExistsException"})(C4||(C4={}));var Lh;(function(r){r.AliasExistsException="AliasExistsException",r.CodeDeliveryFailureException="CodeDeliveryFailureException",r.CodeMismatchException="CodeMismatchException",r.ExpiredCodeException="ExpiredCodeException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",r.InvalidLambdaResponseException="InvalidLambdaResponseException",r.InvalidParameterException="InvalidParameterException",r.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",r.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UnexpectedLambdaException="UnexpectedLambdaException",r.UserLambdaValidationException="UserLambdaValidationException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Lh||(Lh={}));var jh;(function(r){r.CodeMismatchException="CodeMismatchException",r.EnableSoftwareTokenMFAException="EnableSoftwareTokenMFAException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(jh||(jh={}));var zh;(function(r){r.AliasExistsException="AliasExistsException",r.CodeMismatchException="CodeMismatchException",r.ExpiredCodeException="ExpiredCodeException",r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.LimitExceededException="LimitExceededException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(zh||(zh={}));var Vh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Vh||(Vh={}));var Hh;(function(r){r.ForbiddenException="ForbiddenException",r.InternalErrorException="InternalErrorException",r.InvalidParameterException="InvalidParameterException",r.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",r.NotAuthorizedException="NotAuthorizedException",r.PasswordResetRequiredException="PasswordResetRequiredException",r.ResourceNotFoundException="ResourceNotFoundException",r.TooManyRequestsException="TooManyRequestsException",r.UserNotConfirmedException="UserNotConfirmedException",r.UserNotFoundException="UserNotFoundException"})(Hh||(Hh={}));const Yi="UserUnAuthenticatedException",lE="UserAlreadyAuthenticatedException",iE="DeviceMetadataNotFoundException",qh="AutoSignInException",aE="InvalidRedirectException",wE="InvalidAppSchemeException",bE="InvalidPreferredRedirectUrlException",nE=new ar({name:aE,message:"signInRedirect or signOutRedirect had an invalid format or was not found.",recoverySuggestion:"Please make sure the signIn/Out redirect in your oauth config is valid."});new ar({name:wE,message:"A valid non-http app scheme was not found in the config.",recoverySuggestion:"Please make sure a valid custom app scheme is present in the config."});const sE=new ar({name:bE,message:"The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.",recoverySuggestion:"Please make sure a matching preferredRedirectUrl is provided."}),pE="InvalidOriginException",fE=new ar({name:pE,message:"redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin",recoverySuggestion:"Please call signInWithRedirect from the same origin."}),hE="OAuthSignOutException",mE="TokenRefreshException",kE="UnexpectedSignInInterruptionException";function B4(r){if(!r||!r.accessToken)throw new ar({name:Yi,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function xE(r){if(!r||!r.idToken)throw new ar({name:Yi,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}const gE=new ar({name:mE,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow.
|
|
152
152
|
Please change your oauth configuration to use 'code grant' flow.`,recoverySuggestion:`Please logout and change your Amplify configuration to use "code grant" flow.
|
|
153
|
-
E.g { responseType: 'code' }`}),cE=new ar({name:Yi,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function Wh(r){if(AE(r))throw gE;if(!FE(r))throw cE}function Kh(r){if(!r||!r.deviceKey||!r.deviceGroupKey||!r.randomPassword)throw new ar({name:iE,message:"Either deviceKey, deviceGroupKey or secretPassword were not found during the sign-in process.",recoverySuggestion:"Make sure to not clear storage after calling the signIn API."})}const uE={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function Yh(r){return r?.accessToken||r?.idToken}function FE(r){return Yh(r)&&r?.refreshToken}function AE(r){return Yh(r)&&!r?.refreshToken}const yE=async r=>{const o=r.getConfig().Auth?.Cognito;Sr(o);const e=await r.Auth.getTokens({forceRefresh:!1});B4(e);const{"cognito:username":d,sub:t}=e.idToken?.payload??{},l={username:d,userId:t},i=EE(e);return i&&(l.signInDetails=i),l};function EE(r){return r?.signInDetails}const Gh=async()=>yE(Tr),xo=(r,o)=>qi({category:F4.Auth,action:r,...o}),Do=r=>(o,e)=>{const d=DE(r),t=JSON.stringify(o);return vE(e,d,t)},DE=r=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${r}`}),vE=({url:r},o,e)=>({headers:o,url:r,body:e,method:"POST"});function Go(r){if(!r||r.name==="Error"||r instanceof TypeError)throw new ar({name:qe.Unknown,message:"An unknown error has occurred.",underlyingError:r})}const Ro=()=>async r=>{if(r.statusCode>=300){const o=await Wd(r);throw Go(o),new ar({name:o.name,message:o.message,metadata:o.$metadata})}return rl(r)},vo=D4(wh,[()=>(r,o)=>async function(d){return d.headers["cache-control"]="no-store",r(d)}]),Xh="cognito-idp",So={service:Xh,retryDecider:th(Wd),computeDelay:dh,get userAgentValue(){return qi()},cache:"no-store"},ll=r=>no(vo,Do("InitiateAuth"),Ro(),{...So,...r}),Gi=r=>no(vo,Do("RespondToAuthChallenge"),Ro(),{...So,...r}),SE=r=>no(vo,Do("AssociateSoftwareToken"),Ro(),{...So,...r}),_E=({region:r})=>({url:new ol(`https://${Xh}.${r}.${fh(r)}`)}),Yr=({endpointOverride:r})=>o=>r?{url:new ol(r)}:_E(o),CE=r=>no(vo,Do("GetTokensFromRefreshToken"),Ro(),{...So,...r}),BE=rE(async({tokens:r,authConfig:o,username:e})=>{Sr(o?.Cognito);const{userPoolId:d,userPoolClientId:t,userPoolEndpoint:l}=o.Cognito,i=Kr(d);Wh(r);const a=CE({endpointResolver:Yr({endpointOverride:l})}),{AuthenticationResult:w}=await a({region:i},{ClientId:t,RefreshToken:r.refreshToken,DeviceKey:r.deviceMetadata?.deviceKey}),b=fd(w?.AccessToken??""),n=w?.IdToken?fd(w.IdToken):void 0,{iat:s}=b.payload;if(!s)throw new ar({name:"iatNotFoundException",message:"iat not found in access token"});const p=s*1e3-new Date().getTime();return{accessToken:b,idToken:n,clockDrift:p,refreshToken:w?.RefreshToken??r.refreshToken,username:e}}),IE={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var Xi;(function(r){r.InvalidAuthTokens="InvalidAuthTokens"})(Xi||(Xi={}));const TE={[Xi.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},NE=x4(TE),Zh="CognitoIdentityServiceProvider";class PE{getKeyValueStorage(){if(!this.keyValueStorage)throw new ar({name:"KeyValueStorageNotFoundException",message:"KeyValueStorage was not found in TokenStore"});return this.keyValueStorage}setKeyValueStorage(o){this.keyValueStorage=o}setAuthConfig(o){this.authConfig=o}async loadTokens(){try{const o=await this.getAuthKeys(),e=await this.getKeyValueStorage().getItem(o.accessToken);if(!e)throw new ar({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});const d=fd(e),t=await this.getKeyValueStorage().getItem(o.idToken),l=t?fd(t):void 0,i=await this.getKeyValueStorage().getItem(o.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(o.clockDrift)??"0",w=Number.parseInt(a),b=await this.getKeyValueStorage().getItem(o.signInDetails),n={accessToken:d,idToken:l,refreshToken:i,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:w,username:await this.getLastAuthUser()};return b&&(n.signInDetails=JSON.parse(b)),n}catch{return null}}async storeTokens(o){NE(o!==void 0,Xi.InvalidAuthTokens);const e=o.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),e);const d=await this.getAuthKeys();await this.getKeyValueStorage().setItem(d.accessToken,o.accessToken.toString()),o.idToken?await this.getKeyValueStorage().setItem(d.idToken,o.idToken.toString()):await this.getKeyValueStorage().removeItem(d.idToken),o.refreshToken?await this.getKeyValueStorage().setItem(d.refreshToken,o.refreshToken):await this.getKeyValueStorage().removeItem(d.refreshToken),o.deviceMetadata&&(o.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(d.deviceKey,o.deviceMetadata.deviceKey),o.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(d.deviceGroupKey,o.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(d.randomPasswordKey,o.deviceMetadata.randomPassword)),o.signInDetails?await this.getKeyValueStorage().setItem(d.signInDetails,JSON.stringify(o.signInDetails)):await this.getKeyValueStorage().removeItem(d.signInDetails),await this.getKeyValueStorage().setItem(d.clockDrift,`${o.clockDrift}`)}async clearTokens(){const o=await this.getAuthKeys();await Promise.all([this.getKeyValueStorage().removeItem(o.accessToken),this.getKeyValueStorage().removeItem(o.idToken),this.getKeyValueStorage().removeItem(o.clockDrift),this.getKeyValueStorage().removeItem(o.refreshToken),this.getKeyValueStorage().removeItem(o.signInDetails),this.getKeyValueStorage().removeItem(this.getLastAuthUserKey()),this.getKeyValueStorage().removeItem(o.oauthMetadata)])}async getDeviceMetadata(o){const e=await this.getAuthKeys(o),d=await this.getKeyValueStorage().getItem(e.deviceKey),t=await this.getKeyValueStorage().getItem(e.deviceGroupKey),l=await this.getKeyValueStorage().getItem(e.randomPasswordKey);return l&&t&&d?{deviceKey:d,deviceGroupKey:t,randomPassword:l}:null}async clearDeviceMetadata(o){const e=await this.getAuthKeys(o);await Promise.all([this.getKeyValueStorage().removeItem(e.deviceKey),this.getKeyValueStorage().removeItem(e.deviceGroupKey),this.getKeyValueStorage().removeItem(e.randomPasswordKey)])}async getAuthKeys(o){Sr(this.authConfig?.Cognito);const e=o??await this.getLastAuthUser();return OE(Zh,`${this.authConfig.Cognito.userPoolClientId}.${e}`)}getLastAuthUserKey(){Sr(this.authConfig?.Cognito);const o=this.authConfig.Cognito.userPoolClientId;return`${Zh}.${o}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(o){const{oauthMetadata:e}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(e,JSON.stringify(o))}async getOAuthMetadata(){const{oauthMetadata:o}=await this.getAuthKeys(),e=await this.getKeyValueStorage().getItem(o);return e&&JSON.parse(e)}}const OE=(r,o)=>I4(IE)(`${r}`,o);function I4(r){const o=Object.values({...r});return(e,d)=>o.reduce((t,l)=>({...t,[l]:`${e}.${d}.${l}`}),{})}const Jh="amplify-signin-with-hostedUI",ie="CognitoIdentityServiceProvider";class Qh{constructor(o){this.keyValueStorage=o}async clearOAuthInflightData(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(o.inflightOAuth),this.keyValueStorage.removeItem(o.oauthPKCE),this.keyValueStorage.removeItem(o.oauthState)])}async clearOAuthData(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(Jh),this.keyValueStorage.removeItem(o.oauthSignIn)}loadOAuthState(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(o.oauthState)}storeOAuthState(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(e.oauthState,o)}loadPKCE(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(o.oauthPKCE)}storePKCE(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(e.oauthPKCE,o)}setAuthConfig(o){this.cognitoConfig=o}async loadOAuthInFlight(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(o.inflightOAuth)==="true"}async storeOAuthInFlight(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(e.inflightOAuth,`${o}`)}async loadOAuthSignIn(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId),e=await this.keyValueStorage.getItem(Jh),[d,t]=(await this.keyValueStorage.getItem(o.oauthSignIn))?.split(",")??[];return{isOAuthSignIn:d==="true"||e==="true",preferPrivateSession:t==="true"}}async storeOAuthSignIn(o,e=!1){Sr(this.cognitoConfig);const d=ae(ie,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(d.oauthSignIn,`${o},${e}`)}}const ae=(r,o)=>I4(uE)(r,o),rm=new Qh(dl);class RE{constructor(){this.waitForInflightOAuth=Gf()?async()=>{if(await rm.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((o,e)=>{}),this.inflightPromise)}:async()=>{}}setAuthConfig(o){rm.setAuthConfig(o.Cognito),this.authConfig=o}setTokenRefresher(o){this.tokenRefresher=o}setAuthTokenStore(o){this.tokenStore=o}getTokenStore(){if(!this.tokenStore)throw new ar({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new ar({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}async getTokens(o){let e;try{Sr(this.authConfig?.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,e=await this.getTokenStore().loadTokens();const d=await this.getTokenStore().getLastAuthUser();if(e===null)return null;const t=!!e?.idToken&&ch({expiresAt:(e.idToken?.payload?.exp??0)*1e3,clockDrift:e.clockDrift??0}),l=ch({expiresAt:(e.accessToken?.payload?.exp??0)*1e3,clockDrift:e.clockDrift??0});return(o?.forceRefresh||t||l)&&(e=await this.refreshTokens({tokens:e,username:d}),e===null)?null:{accessToken:e?.accessToken,idToken:e?.idToken,signInDetails:e?.signInDetails}}async refreshTokens({tokens:o,username:e}){try{const{signInDetails:d}=o,t=await this.getTokenRefresher()({tokens:o,authConfig:this.authConfig,username:e});return t.signInDetails=d,await this.setTokens({tokens:t}),Hd.dispatch("auth",{event:"tokenRefresh"},"Auth",pd),t}catch(d){return this.handleErrors(d)}}handleErrors(o){if(Go(o),o.name!==qe.NetworkError&&this.clearTokens(),Hd.dispatch("auth",{event:"tokenRefresh_failure",data:{error:o}},"Auth",pd),o.name.startsWith("NotAuthorizedException"))return null;throw o}async setTokens({tokens:o}){return this.getTokenStore().storeTokens(o)}async clearTokens(){return this.getTokenStore().clearTokens()}getDeviceMetadata(o){return this.getTokenStore().getDeviceMetadata(o)}clearDeviceMetadata(o){return this.getTokenStore().clearDeviceMetadata(o)}setOAuthMetadata(o){return this.getTokenStore().setOAuthMetadata(o)}getOAuthMetadata(){return this.getTokenStore().getOAuthMetadata()}}class ME{constructor(){this.authTokenStore=new PE,this.authTokenStore.setKeyValueStorage(dl),this.tokenOrchestrator=new RE,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(BE)}getTokens({forceRefresh:o}={forceRefresh:!1}){return this.tokenOrchestrator.getTokens({forceRefresh:o})}setKeyValueStorage(o){this.authTokenStore.setKeyValueStorage(o)}setAuthConfig(o){this.authTokenStore.setAuthConfig(o),this.tokenOrchestrator.setAuthConfig(o)}}const Yd=new ME,{tokenOrchestrator:_o}=Yd;async function Gd(r){if(r.AccessToken){const o=fd(r.AccessToken),e=(o.payload.iat||0)*1e3,d=new Date().getTime(),t=e>0?e-d:0;let l,i,a;r.RefreshToken&&(i=r.RefreshToken),r.IdToken&&(l=fd(r.IdToken)),r?.NewDeviceMetadata&&(a=r.NewDeviceMetadata);const w={accessToken:o,idToken:l,refreshToken:i,clockDrift:t,deviceMetadata:a,username:r.username};r?.signInDetails&&(w.signInDetails=r.signInDetails),await _o.setTokens({tokens:w})}else throw new ko({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const $E="Unable to get user session following successful sign-in.",Xd=async()=>{try{Hd.dispatch("auth",{event:"signedIn",data:await Gh()},"Auth",pd)}catch(r){throw r.name===Yi?new ar({name:kE,message:$E,recoverySuggestion:"This most likely is due to auth tokens not being persisted. If you are using cookie store, please ensure cookies can be correctly set from your server."}):r}};function om(){return{active:!1}}const We=(r=>{let o=r(om(),{type:"RESET"});return{getState:()=>o,dispatch:e=>{o=r(o,e)}}})((r,o)=>{switch(o.type){case"SET_USERNAME":return{...r,username:o.value};case"SET_SESSION":return{...r,session:o.value};case"START":return{...r,active:!0};case"RESET":return om();default:return r}}),UE=180*1e3,Zi="CognitoSignInState",Fe={username:`${Zi}.username`,challengeName:`${Zi}.challengeName`,signInSession:`${Zi}.signInSession`,expiry:`${Zi}.expiry`},LE=(r,o)=>{switch(o.type){case"SET_SIGN_IN_SESSION":return Ji({signInSession:o.value}),{...r,signInSession:o.value};case"SET_SIGN_IN_STATE":return Ji(o.value),{...o.value};case"SET_CHALLENGE_NAME":return Ji({challengeName:o.value}),{...r,challengeName:o.value};case"SET_USERNAME":return Ji({username:o.value}),{...r,username:o.value};case"SET_INITIAL_STATE":return zE();case"RESET_STATE":return em(),T4();default:return r}},jE=r=>{const o=Number(r),e=Date.now();return o<=e},we=()=>{Ke.dispatch({type:"RESET_STATE"})},em=()=>{for(const r of Object.values(Fe))ue.removeItem(r)},T4=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),zE=()=>{const r=ue.getItem(Fe.expiry);if(!r||jE(r))return em(),T4();const o=ue.getItem(Fe.username)??void 0,e=ue.getItem(Fe.challengeName)??void 0,d=ue.getItem(Fe.signInSession)??void 0;return{username:o,challengeName:e,signInSession:d}},Ke=(r=>{let o=r(T4(),{type:"SET_INITIAL_STATE"});return{getState:()=>o,dispatch:e=>{o=r(o,e)}}})(LE);function Zd(r){Ke.dispatch({type:"SET_SIGN_IN_STATE",value:r})}const Ji=({challengeName:r,signInSession:o,username:e})=>{e&&ue.setItem(Fe.username,e),r&&ue.setItem(Fe.challengeName,r),o&&(ue.setItem(Fe.signInSession,o),ue.setItem(Fe.expiry,String(Date.now()+UE)))};class Ae extends ko{constructor(o){super(o),this.constructor=Ae,Object.setPrototypeOf(this,Ae.prototype)}}var Hr;(function(r){r.PasskeyNotSupported="PasskeyNotSupported",r.PasskeyAlreadyExists="PasskeyAlreadyExists",r.InvalidPasskeyRegistrationOptions="InvalidPasskeyRegistrationOptions",r.InvalidPasskeyAuthenticationOptions="InvalidPasskeyAuthenticationOptions",r.RelyingPartyMismatch="RelyingPartyMismatch",r.PasskeyRegistrationFailed="PasskeyRegistrationFailed",r.PasskeyRetrievalFailed="PasskeyRetrievalFailed",r.PasskeyRegistrationCanceled="PasskeyRegistrationCanceled",r.PasskeyAuthenticationCanceled="PasskeyAuthenticationCanceled",r.PasskeyOperationAborted="PasskeyOperationAborted"})(Hr||(Hr={}));const dm="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.",N4="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",tm="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Qi={[Hr.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:dm},[Hr.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:tm},[Hr.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:tm},[Hr.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:dm},[Hr.PasskeyRetrievalFailed]:{message:"Device failed to retrieve passkey.",recoverySuggestion:"Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP."},[Hr.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[Hr.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:N4},[Hr.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:N4},[Hr.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:N4},[Hr.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},P4=x4(Qi,Ae),VE=r=>{if(r instanceof Ae)return r;if(r instanceof Error&&r.name==="NotAllowedError"){const{message:o,recoverySuggestion:e}=Qi[Hr.PasskeyAuthenticationCanceled];return new Ae({name:Hr.PasskeyAuthenticationCanceled,message:o,recoverySuggestion:e,underlyingError:r})}return HE(r)},HE=r=>{if(r instanceof Error){if(r.name==="AbortError"){const{message:o,recoverySuggestion:e}=Qi[Hr.PasskeyOperationAborted];return new Ae({name:Hr.PasskeyOperationAborted,message:o,recoverySuggestion:e,underlyingError:r})}if(r.name==="SecurityError"){const{message:o,recoverySuggestion:e}=Qi[Hr.RelyingPartyMismatch];return new Ae({name:Hr.RelyingPartyMismatch,message:o,recoverySuggestion:e,underlyingError:r})}}return new Ae({name:qe.Unknown,message:"An unknown error has occurred.",underlyingError:r})},qE=()=>Gf()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",il=r=>tl.convert(new Uint8Array(r),{urlSafe:!0,skipPadding:!0}),lm=r=>Uint8Array.from(g4.convert(r,{urlSafe:!0}),o=>o.charCodeAt(0)).buffer,WE=r=>{const o=lm(r.challenge),e=(r.allowCredentials||[]).map(d=>({...d,id:lm(d.id)}));return{...r,challenge:o,allowCredentials:e}},KE=r=>{const o={clientDataJSON:il(r.response.clientDataJSON),authenticatorData:il(r.response.authenticatorData),signature:il(r.response.signature)};r.response.userHandle&&(o.userHandle=il(r.response.userHandle));const e={id:r.id,rawId:il(r.rawId),type:r.type,clientExtensionResults:r.getClientExtensionResults(),response:o};return r.authenticatorAttachment&&(e.authenticatorAttachment=r.authenticatorAttachment),e};function YE(r){P4(r&&r instanceof PublicKeyCredential&&r.response instanceof AuthenticatorAssertionResponse,Hr.PasskeyRetrievalFailed)}const GE=async r=>{try{const o=qE();P4(o,Hr.PasskeyNotSupported);const e=WE(r),d=await navigator.credentials.get({publicKey:e});return YE(d),KE(d)}catch(o){throw VE(o)}},XE=r=>no(vo,Do("ConfirmDevice"),Ro(),{...So,...r}),ra={convert(r){return new TextEncoder().encode(r)}};function rr(r,o){r!=null&&this.fromString(r,o)}function so(){return new rr(null,null)}let Ye;const im=(0xdeadbeefcafe&16777215)===15715070;function ZE(r,o,e,d,t,l){for(;--l>=0;){const i=o*this[r++]+e[d]+t;t=Math.floor(i/67108864),e[d++]=i&67108863}return t}function JE(r,o,e,d,t,l){const i=o&32767,a=o>>15;for(;--l>=0;){let w=this[r]&32767;const b=this[r++]>>15,n=a*w+b*i;w=i*w+((n&32767)<<15)+e[d]+(t&1073741823),t=(w>>>30)+(n>>>15)+a*b+(t>>>30),e[d++]=w&1073741823}return t}function QE(r,o,e,d,t,l){const i=o&16383,a=o>>14;for(;--l>=0;){let w=this[r]&16383;const b=this[r++]>>14,n=a*w+b*i;w=i*w+((n&16383)<<14)+e[d]+t,t=(w>>28)+(n>>14)+a*b,e[d++]=w&268435455}return t}const am=typeof navigator<"u";am&&im&&navigator.appName==="Microsoft Internet Explorer"?(rr.prototype.am=JE,Ye=30):am&&im&&navigator.appName!=="Netscape"?(rr.prototype.am=ZE,Ye=26):(rr.prototype.am=QE,Ye=28),rr.prototype.DB=Ye,rr.prototype.DM=(1<<Ye)-1,rr.prototype.DV=1<<Ye;const O4=52;rr.prototype.FV=Math.pow(2,O4),rr.prototype.F1=O4-Ye,rr.prototype.F2=2*Ye-O4;const rD="0123456789abcdefghijklmnopqrstuvwxyz",oa=[];let Jd,Mo;for(Jd=48,Mo=0;Mo<=9;++Mo)oa[Jd++]=Mo;for(Jd=97,Mo=10;Mo<36;++Mo)oa[Jd++]=Mo;for(Jd=65,Mo=10;Mo<36;++Mo)oa[Jd++]=Mo;function wm(r){return rD.charAt(r)}function oD(r,o){const e=oa[r.charCodeAt(o)];return e??-1}function eD(r){for(let o=this.t-1;o>=0;--o)r[o]=this[o];r.t=this.t,r.s=this.s}function dD(r){this.t=1,this.s=r<0?-1:0,r>0?this[0]=r:r<-1?this[0]=r+this.DV:this.t=0}function R4(r){const o=so();return o.fromInt(r),o}function tD(r,o){let e;if(o===16)e=4;else if(o===8)e=3;else if(o===2)e=1;else if(o===32)e=5;else if(o===4)e=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let d=r.length,t=!1,l=0;for(;--d>=0;){const i=oD(r,d);if(i<0){r.charAt(d)==="-"&&(t=!0);continue}t=!1,l===0?this[this.t++]=i:l+e>this.DB?(this[this.t-1]|=(i&(1<<this.DB-l)-1)<<l,this[this.t++]=i>>this.DB-l):this[this.t-1]|=i<<l,l+=e,l>=this.DB&&(l-=this.DB)}this.clamp(),t&&rr.ZERO.subTo(this,this)}function lD(){const r=this.s&this.DM;for(;this.t>0&&this[this.t-1]==r;)--this.t}function iD(r){if(this.s<0)return"-"+this.negate().toString(r);let o;if(r==16)o=4;else if(r===8)o=3;else if(r===2)o=1;else if(r===32)o=5;else if(r===4)o=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");const e=(1<<o)-1;let d,t=!1,l="",i=this.t,a=this.DB-i*this.DB%o;if(i-- >0)for(a<this.DB&&(d=this[i]>>a)>0&&(t=!0,l=wm(d));i>=0;)a<o?(d=(this[i]&(1<<a)-1)<<o-a,d|=this[--i]>>(a+=this.DB-o)):(d=this[i]>>(a-=o)&e,a<=0&&(a+=this.DB,--i)),d>0&&(t=!0),t&&(l+=wm(d));return t?l:"0"}function aD(){const r=so();return rr.ZERO.subTo(this,r),r}function wD(){return this.s<0?this.negate():this}function bD(r){let o=this.s-r.s;if(o!=0)return o;let e=this.t;if(o=e-r.t,o!=0)return this.s<0?-o:o;for(;--e>=0;)if((o=this[e]-r[e])!=0)return o;return 0}function M4(r){let o=1,e;return(e=r>>>16)!==0&&(r=e,o+=16),(e=r>>8)!==0&&(r=e,o+=8),(e=r>>4)!==0&&(r=e,o+=4),(e=r>>2)!==0&&(r=e,o+=2),(e=r>>1)!==0&&(r=e,o+=1),o}function nD(){return this.t<=0?0:this.DB*(this.t-1)+M4(this[this.t-1]^this.s&this.DM)}function sD(r,o){let e;for(e=this.t-1;e>=0;--e)o[e+r]=this[e];for(e=r-1;e>=0;--e)o[e]=0;o.t=this.t+r,o.s=this.s}function pD(r,o){for(let e=r;e<this.t;++e)o[e-r]=this[e];o.t=Math.max(this.t-r,0),o.s=this.s}function fD(r,o){const e=r%this.DB,d=this.DB-e,t=(1<<d)-1,l=Math.floor(r/this.DB);let i=this.s<<e&this.DM,a;for(a=this.t-1;a>=0;--a)o[a+l+1]=this[a]>>d|i,i=(this[a]&t)<<e;for(a=l-1;a>=0;--a)o[a]=0;o[l]=i,o.t=this.t+l+1,o.s=this.s,o.clamp()}function hD(r,o){o.s=this.s;const e=Math.floor(r/this.DB);if(e>=this.t){o.t=0;return}const d=r%this.DB,t=this.DB-d,l=(1<<d)-1;o[0]=this[e]>>d;for(let i=e+1;i<this.t;++i)o[i-e-1]|=(this[i]&l)<<t,o[i-e]=this[i]>>d;d>0&&(o[this.t-e-1]|=(this.s&l)<<t),o.t=this.t-e,o.clamp()}function mD(r,o){let e=0,d=0;const t=Math.min(r.t,this.t);for(;e<t;)d+=this[e]-r[e],o[e++]=d&this.DM,d>>=this.DB;if(r.t<this.t){for(d-=r.s;e<this.t;)d+=this[e],o[e++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;e<r.t;)d-=r[e],o[e++]=d&this.DM,d>>=this.DB;d-=r.s}o.s=d<0?-1:0,d<-1?o[e++]=this.DV+d:d>0&&(o[e++]=d),o.t=e,o.clamp()}function kD(r,o){const e=this.abs(),d=r.abs();let t=e.t;for(o.t=t+d.t;--t>=0;)o[t]=0;for(t=0;t<d.t;++t)o[t+e.t]=e.am(0,d[t],o,t,0,e.t);o.s=0,o.clamp(),this.s!==r.s&&rr.ZERO.subTo(o,o)}function xD(r){const o=this.abs();let e=r.t=2*o.t;for(;--e>=0;)r[e]=0;for(e=0;e<o.t-1;++e){const d=o.am(e,o[e],r,2*e,0,1);(r[e+o.t]+=o.am(e+1,2*o[e],r,2*e+1,d,o.t-e-1))>=o.DV&&(r[e+o.t]-=o.DV,r[e+o.t+1]=1)}r.t>0&&(r[r.t-1]+=o.am(e,o[e],r,2*e,0,1)),r.s=0,r.clamp()}function gD(r,o,e){const d=r.abs();if(d.t<=0)return;const t=this.abs();if(t.t<d.t){o?.fromInt(0),e!=null&&this.copyTo(e);return}e===null&&(e=so());const l=so(),i=this.s,a=r.s,w=this.DB-M4(d[d.t-1]);w>0?(d.lShiftTo(w,l),t.lShiftTo(w,e)):(d.copyTo(l),t.copyTo(e));const b=l.t,n=l[b-1];if(n===0)return;const s=n*(1<<this.F1)+(b>1?l[b-2]>>this.F2:0),p=this.FV/s,m=(1<<this.F1)/s,h=1<<this.F2;let f=e.t,k=f-b;const x=o===null?so():o;for(l.dlShiftTo(k,x),e.compareTo(x)>=0&&(e[e.t++]=1,e.subTo(x,e)),rr.ONE.dlShiftTo(b,x),x.subTo(l,l);l.t<b;)l[l.t++]=0;for(;--k>=0;){let c=e[--f]===n?this.DM:Math.floor(e[f]*p+(e[f-1]+h)*m);if((e[f]+=l.am(0,c,e,k,0,b))<c)for(l.dlShiftTo(k,x),e.subTo(x,e);e[f]<--c;)e.subTo(x,e)}o!==null&&(e.drShiftTo(b,o),i!==a&&rr.ZERO.subTo(o,o)),e.t=b,e.clamp(),w>0&&e.rShiftTo(w,e),i<0&&rr.ZERO.subTo(e,e)}function cD(r){const o=so();return this.abs().divRemTo(r,null,o),this.s<0&&o.compareTo(rr.ZERO)>0&&r.subTo(o,o),o}function uD(){if(this.t<1)return 0;const r=this[0];if((r&1)===0)return 0;let o=r&3;return o=o*(2-(r&15)*o)&15,o=o*(2-(r&255)*o)&255,o=o*(2-((r&65535)*o&65535))&65535,o=o*(2-r*o%this.DV)%this.DV,o>0?this.DV-o:-o}function FD(r){return this.compareTo(r)===0}function AD(r,o){let e=0,d=0;const t=Math.min(r.t,this.t);for(;e<t;)d+=this[e]+r[e],o[e++]=d&this.DM,d>>=this.DB;if(r.t<this.t){for(d+=r.s;e<this.t;)d+=this[e],o[e++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;e<r.t;)d+=r[e],o[e++]=d&this.DM,d>>=this.DB;d+=r.s}o.s=d<0?-1:0,d>0?o[e++]=d:d<-1&&(o[e++]=this.DV+d),o.t=e,o.clamp()}function yD(r){const o=so();return this.addTo(r,o),o}function ED(r){const o=so();return this.subTo(r,o),o}function DD(r){const o=so();return this.multiplyTo(r,o),o}function vD(r){const o=so();return this.divRemTo(r,o,null),o}function Qd(r){this.m=r,this.mp=r.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<r.DB-15)-1,this.mt2=2*r.t}function SD(r){const o=so();return r.abs().dlShiftTo(this.m.t,o),o.divRemTo(this.m,null,o),r.s<0&&o.compareTo(rr.ZERO)>0&&this.m.subTo(o,o),o}function _D(r){const o=so();return r.copyTo(o),this.reduce(o),o}function CD(r){for(;r.t<=this.mt2;)r[r.t++]=0;for(let o=0;o<this.m.t;++o){let e=r[o]&32767;const d=e*this.mpl+((e*this.mph+(r[o]>>15)*this.mpl&this.um)<<15)&r.DM;for(e=o+this.m.t,r[e]+=this.m.am(0,d,r,o,0,this.m.t);r[e]>=r.DV;)r[e]-=r.DV,r[++e]++}r.clamp(),r.drShiftTo(this.m.t,r),r.compareTo(this.m)>=0&&r.subTo(this.m,r)}function BD(r,o){r.squareTo(o),this.reduce(o)}function ID(r,o,e){r.multiplyTo(o,e),this.reduce(e)}Qd.prototype.convert=SD,Qd.prototype.revert=_D,Qd.prototype.reduce=CD,Qd.prototype.mulTo=ID,Qd.prototype.sqrTo=BD;function TD(r,o,e){let d=r.bitLength(),t,l=R4(1);const i=new Qd(o);if(d<=0)return l;d<18?t=1:d<48?t=3:d<144?t=4:d<768?t=5:t=6;const a=[];let w=3;const b=t-1,n=(1<<t)-1;if(a[1]=i.convert(this),t>1){const x=so();for(i.sqrTo(a[1],x);w<=n;)a[w]=so(),i.mulTo(x,a[w-2],a[w]),w+=2}let s=r.t-1,p,m=!0,h=so(),f;for(d=M4(r[s])-1;s>=0;){for(d>=b?p=r[s]>>d-b&n:(p=(r[s]&(1<<d+1)-1)<<b-d,s>0&&(p|=r[s-1]>>this.DB+d-b)),w=t;(p&1)===0;)p>>=1,--w;if((d-=w)<0&&(d+=this.DB,--s),m)a[p].copyTo(l),m=!1;else{for(;w>1;)i.sqrTo(l,h),i.sqrTo(h,l),w-=2;w>0?i.sqrTo(l,h):(f=l,l=h,h=f),i.mulTo(h,a[p],l)}for(;s>=0&&(r[s]&1<<d)===0;)i.sqrTo(l,h),f=l,l=h,h=f,--d<0&&(d=this.DB-1,--s)}const k=i.revert(l);return e(null,k),k}rr.prototype.copyTo=eD,rr.prototype.fromInt=dD,rr.prototype.fromString=tD,rr.prototype.clamp=lD,rr.prototype.dlShiftTo=sD,rr.prototype.drShiftTo=pD,rr.prototype.lShiftTo=fD,rr.prototype.rShiftTo=hD,rr.prototype.subTo=mD,rr.prototype.multiplyTo=kD,rr.prototype.squareTo=xD,rr.prototype.divRemTo=gD,rr.prototype.invDigit=uD,rr.prototype.addTo=AD,rr.prototype.toString=iD,rr.prototype.negate=aD,rr.prototype.abs=wD,rr.prototype.compareTo=bD,rr.prototype.bitLength=nD,rr.prototype.mod=cD,rr.prototype.equals=FD,rr.prototype.add=yD,rr.prototype.subtract=ED,rr.prototype.multiply=DD,rr.prototype.divide=vD,rr.prototype.modPow=TD,rr.ZERO=R4(0),rr.ONE=R4(1);const ND=async({a:r,g:o,k:e,x:d,B:t,N:l,U:i})=>new Promise((a,w)=>{o.modPow(d,l,(b,n)=>{if(b){w(b);return}t.subtract(e.multiply(n)).modPow(r.add(i.multiply(d)),l,(s,p)=>{if(s){w(s);return}a(p.mod(l))})})}),PD="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",bm={},$4={};for(let r=0;r<256;r++){let o=r.toString(16).toLowerCase();o.length===1&&(o=`0${o}`),bm[r]=o,$4[o]=r}const rt=r=>{if(r.length%2!==0)throw new Error("Hex encoded strings must have an even number length");const o=new Uint8Array(r.length/2);for(let e=0;e<r.length;e+=2){const d=r.slice(e,e+2).toLowerCase();if(d in $4)o[e/2]=$4[d];else throw new Error(`Cannot decode unrecognized sequence ${d} as hexadecimal`)}return o},U4=r=>{let o="";for(let e=0;e<r.byteLength;e++)o+=bm[r[e]];return o},L4=r=>{const o=new Vi;o.update(r);const e=o.digestSync(),d=U4(e);return new Array(64-d.length).join("0")+d},ea=r=>L4(rt(r)),OD=/^[89a-f]/i,ye=r=>{if(!(r instanceof rr))throw new Error("Not a BigInteger");const o=r.compareTo(rr.ZERO)<0;let e=r.abs().toString(16);if(e=e.length%2!==0?`0${e}`:e,e=OD.test(e)?`00${e}`:e,o){const d=e.split("").map(l=>{const i=~parseInt(l,16)&15;return"0123456789ABCDEF".charAt(i)}).join("");e=new rr(d,16).add(rr.ONE).toString(16),e.toUpperCase().startsWith("FF8")&&(e=e.substring(2))}return e},RD=({A:r,B:o})=>{const e=new rr(ea(ye(r)+ye(o)),16);if(e.equals(rr.ZERO))throw new Error("U cannot be zero.");return e},MD=(r,o,e)=>{const d=new Vi(o);d.update(r);const t=d.digestSync(),l=new Vi(t);return l.update(e),l.digestSync().slice(0,16)},j4=r=>{const o=new S4().random(r).toString();return rt(o)},$D=()=>tl.convert(j4(40));class UD{constructor({userPoolName:o,a:e,g:d,A:t,N:l}){this.encoder=ra,this.userPoolName=o,this.a=e,this.g=d,this.A=t,this.N=l,this.k=new rr(ea(`${ye(l)}${ye(d)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new ar({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new ar({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new ar({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(o,e){this.randomPassword=$D();const d=`${o}${e}:${this.randomPassword}`,t=L4(d),l=U4(j4(16));return this.saltToHashDevices=ye(new rr(l,16)),new Promise((i,a)=>{this.g.modPow(new rr(ea(this.saltToHashDevices+t),16),this.N,(w,b)=>{if(w){a(w);return}this.verifierDevices=ye(b),i()})})}async getPasswordAuthenticationKey({username:o,password:e,serverBValue:d,salt:t}){if(d.mod(this.N).equals(rr.ZERO))throw new Error("B cannot be zero.");const l=RD({A:this.A,B:d}),i=`${this.userPoolName}${o}:${e}`,a=L4(i),w=new rr(ea(ye(t)+a),16),b=await ND({a:this.a,g:this.g,k:this.k,x:w,B:d,N:this.N,U:l}),n=this.encoder.convert("Caldera Derived Key"),s=this.encoder.convert(""),p=new Uint8Array(n.byteLength+s.byteLength);return p.set(n,0),p.set(s,n.byteLength),MD(rt(ye(b)),rt(ye(l)),p)}}const LD=async({a:r,g:o,N:e})=>new Promise((d,t)=>{o.modPow(r,e,(l,i)=>{if(l){t(l);return}if(i.mod(e).equals(rr.ZERO)){t(new Error("Illegal parameter. A mod N cannot be 0."));return}d(i)})}),da=async r=>{const o=new rr(PD,16),e=new rr("2",16),d=jD(),t=await LD({a:d,g:e,N:o});return new UD({userPoolName:r,a:d,g:e,A:t,N:o})},jD=()=>{const r=U4(j4(128));return new rr(r,16)};async function ot({userPoolId:r,userPoolEndpoint:o,newDeviceMetadata:e,accessToken:d}){if(!e)return;const t=r.split("_")[1]||"",l=await da(t),i=e?.DeviceKey,a=e?.DeviceGroupKey;try{await l.generateHashDevice(a??"",i??"")}catch{return}const w={Salt:tl.convert(rt(l.getSaltToHashDevices())),PasswordVerifier:tl.convert(rt(l.getVerifierDevices()))},b=l.getRandomPassword();try{return await XE({endpointResolver:Yr({endpointOverride:o})})({region:Kr(r)},{AccessToken:d,DeviceName:await oE(),DeviceKey:e?.DeviceKey,DeviceSecretVerifierConfig:w}),{deviceKey:i,deviceGroupKey:a,randomPassword:b}}catch{return}}async function zD(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{username:e,signInSession:d,signInDetails:t,challengeName:l}=Ke.getState();if(l!=="WEB_AUTHN"||!e)throw new ar({name:Kd.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:i}=r;P4(!!i,Hr.InvalidPasskeyAuthenticationOptions);const a=await GE(JSON.parse(i)),w=Gi({endpointResolver:Yr({endpointOverride:o.userPoolEndpoint})}),{ChallengeName:b,ChallengeParameters:n,AuthenticationResult:s,Session:p}=await w({region:Kr(o.userPoolId),userAgentValue:xo(wo.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:e,CREDENTIAL:JSON.stringify(a)},ClientId:o.userPoolClientId,Session:d});if(Zd({signInSession:p,username:e,challengeName:b,signInDetails:t}),s)return await Gd({...s,username:e,NewDeviceMetadata:await ot({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:s.NewDeviceMetadata,accessToken:s.AccessToken}),signInDetails:t}),Ke.dispatch({type:"RESET_STATE"}),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(b==="WEB_AUTHN")throw new ar({name:Kd.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:b,challengeParameters:n}}function $o({username:r,userPoolId:o,userPoolClientId:e}){if(typeof window>"u")return;const d=window.AmazonCognitoAdvancedSecurityData;if(typeof d>"u")return;const t=d.getData(r,o,e);return t?{EncodedData:t}:{}}const VD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],HD=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],nm=()=>{const r=new Date,o=HD[r.getUTCDay()],e=VD[r.getUTCMonth()],d=r.getUTCDate();let t=r.getUTCHours();t<10&&(t=`0${t}`);let l=r.getUTCMinutes();l<10&&(l=`0${l}`);let i=r.getUTCSeconds();i<10&&(i=`0${i}`);const a=r.getUTCFullYear();return`${o} ${e} ${d} ${t}:${l}:${i} UTC ${a}`},sm=({userPoolName:r,username:o,challengeParameters:e,dateNow:d,hkdf:t})=>{const l=ra.convert(r),i=ra.convert(o),a=qD(e.SECRET_BLOCK),w=ra.convert(d),b=new Uint8Array(l.byteLength+i.byteLength+a.byteLength+w.byteLength);b.set(l,0),b.set(i,l.byteLength),b.set(a,l.byteLength+i.byteLength),b.set(w,l.byteLength+i.byteLength+a.byteLength);const n=new Vi(t);n.update(b);const s=n.digestSync();return tl.convert(s)},qD=r=>{const o="=".repeat((4-r.length%4)%4),e=(r+o).replace(/-/g,"+").replace(/_/g,"/"),d=g4.convert(e),t=new Uint8Array(d.length);for(let l=0;l<d.length;++l)t[l]=d.charCodeAt(l);return t};async function z4({username:r,config:o,clientMetadata:e,session:d,tokenOrchestrator:t}){const{userPoolId:l,userPoolEndpoint:i}=o,a=o.userPoolClientId,w=await t?.getDeviceMetadata(r);Kh(w);const b=await da(w.deviceGroupKey),n={USERNAME:r,SRP_A:b.A.toString(16),DEVICE_KEY:w.deviceKey},s={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:n,ClientMetadata:e,Session:d},p=Gi({endpointResolver:Yr({endpointOverride:i})}),{ChallengeParameters:m,Session:h}=await p({region:Kr(l)},s);return WD(r,m,e,h,b,o,t)}async function WD(r,o,e,d,t,{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a},w){const b=await w?.getDeviceMetadata(r);Kh(b);const n=new rr(o?.SRP_B,16),s=new rr(o?.SALT,16),{deviceKey:p}=b,{deviceGroupKey:m}=b,h=await t.getPasswordAuthenticationKey({username:b.deviceKey,password:b.randomPassword,serverBValue:n,salt:s}),f=nm(),k={USERNAME:o?.USERNAME??r,PASSWORD_CLAIM_SECRET_BLOCK:o?.SECRET_BLOCK,TIMESTAMP:f,PASSWORD_CLAIM_SIGNATURE:sm({username:p,userPoolName:m,challengeParameters:o,dateNow:f,hkdf:h}),DEVICE_KEY:p},x=$o({username:r,userPoolId:l,userPoolClientId:i}),c={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:i,ChallengeResponses:k,Session:d,ClientMetadata:e,UserContextData:x};return Gi({endpointResolver:Yr({endpointOverride:a})})({region:Kr(l)},c)}async function pm(r,o,e,d,t,l,i){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=l,n=a?.split("_")[1]||"",s=new rr(o?.SRP_B,16),p=new rr(o?.SALT,16),m=o?.USER_ID_FOR_SRP;if(!m)throw new ar({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const h=await t.getPasswordAuthenticationKey({username:m,password:r,serverBValue:s,salt:p}),f=nm(),k={USERNAME:m,PASSWORD_CLAIM_SECRET_BLOCK:o?.SECRET_BLOCK,TIMESTAMP:f,PASSWORD_CLAIM_SIGNATURE:sm({username:m,userPoolName:n,challengeParameters:o,dateNow:f,hkdf:h})},x=await i.getDeviceMetadata(m);x&&x.deviceKey&&(k.DEVICE_KEY=x.deviceKey);const c=$o({username:m,userPoolId:a,userPoolClientId:w}),E={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:k,ClientMetadata:e,Session:d,ClientId:w,UserContextData:c},F=await Gi({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a)},E);return F.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:m,config:l,clientMetadata:e,session:F.Session,tokenOrchestrator:i}):F}async function ta(r,o,e,d){try{return await r(...o)}catch(t){if(t instanceof ar&&t.name==="ResourceNotFoundException"&&t.message.includes("Device does not exist."))return await d.clearDeviceMetadata(e),r(...o);throw t}}function al(r){const{dispatch:o}=Ke;o({type:"SET_USERNAME",value:r})}async function fm({username:r,password:o,clientMetadata:e,config:d,tokenOrchestrator:t,authFlow:l,preferredChallenge:i}){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=d,n=a?.split("_")[1]||"",s=await da(n),p={USERNAME:r,SRP_A:s.A.toString(16)};l==="USER_AUTH"&&i&&(p.PREFERRED_CHALLENGE=i);const m=$o({username:r,userPoolId:a,userPoolClientId:w}),h={AuthFlow:l,AuthParameters:p,ClientMetadata:e,ClientId:w,UserContextData:m},k=await ll({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a),userAgentValue:xo(wo.SignIn)},h),{ChallengeParameters:x,Session:c}=k,E=x?.USERNAME??r;return al(E),k.ChallengeName==="PASSWORD_VERIFIER"?ta(pm,[o,x,e,c,s,d,t],E,t):k}const hm="userAttributes.";function KD(r){return"isSignedIn"in r&&"nextStep"in r}async function YD(r,o,e,d,t){const{userPoolClientId:l,userPoolId:i,userPoolEndpoint:a}=d,w={USERNAME:r,PASSWORD:o},b=await t.getDeviceMetadata(r);b&&b.deviceKey&&(w.DEVICE_KEY=b.deviceKey);const n=$o({username:r,userPoolId:i,userPoolClientId:l}),s={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:w,ClientMetadata:e,ClientId:l,UserContextData:n},m=await ll({endpointResolver:Yr({endpointOverride:a})})({region:Kr(i),userAgentValue:xo(wo.SignIn)},s),h=m.ChallengeParameters?.USERNAME??m.ChallengeParameters?.USER_ID_FOR_SRP??r;return al(h),m.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:h,config:d,clientMetadata:e,session:m.Session,tokenOrchestrator:t}):m}async function GD(r,o,e,d,t){return fm({username:r,password:o,clientMetadata:e,config:d,tokenOrchestrator:t,authFlow:"USER_SRP_AUTH"})}async function XD(r,o,e,d){const{userPoolClientId:t,userPoolId:l,userPoolEndpoint:i}=e,a={USERNAME:r},w=await d.getDeviceMetadata(r);w&&w.deviceKey&&(a.DEVICE_KEY=w.deviceKey);const b=$o({username:r,userPoolId:l,userPoolClientId:t}),n={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:o,ClientId:t,UserContextData:b},p=await ll({endpointResolver:Yr({endpointOverride:i})})({region:Kr(l),userAgentValue:xo(wo.SignIn)},n),m=p.ChallengeParameters?.USERNAME??r;return al(m),p.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:m,config:e,clientMetadata:o,session:p.Session,tokenOrchestrator:d}):p}async function ZD(r,o,e,d,t){Sr(d);const{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a}=d,w=l?.split("_")[1]||"",b=await da(w),n={USERNAME:r,SRP_A:b.A.toString(16),CHALLENGE_NAME:"SRP_A"},s=$o({username:r,userPoolId:l,userPoolClientId:i}),p={AuthFlow:"CUSTOM_AUTH",AuthParameters:n,ClientMetadata:e,ClientId:i,UserContextData:s},m=ll({endpointResolver:Yr({endpointOverride:a})}),{ChallengeParameters:h,Session:f}=await m({region:Kr(l),userAgentValue:xo(wo.SignIn)},p),k=h?.USERNAME??r;return al(k),ta(pm,[o,h,e,f,b,d,t],k,t)}async function et(r){const{challengeName:o,challengeParameters:e,availableChallenges:d}=r,t=Tr.getConfig().Auth?.Cognito;switch(Sr(t),o){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:e}};case"MFA_SETUP":{const{signInSession:l,username:i}=Ke.getState(),a=mm(km(e.MFAS_CAN_SETUP))||[],w=o7(a),b=w.includes("TOTP"),n=w.includes("EMAIL");if(b&&n)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:w}};if(n)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(b){const s=SE({endpointResolver:Yr({endpointOverride:t.userPoolEndpoint})}),{Session:p,SecretCode:m}=await s({region:Kr(t.userPoolId)},{Session:l});return Ke.dispatch({type:"SET_SIGN_IN_SESSION",value:p}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:JD(m,i)}}}throw new ar({name:Kd.SignInException,message:`Cannot initiate MFA setup from available types: ${a}`})}case"NEW_PASSWORD_REQUIRED":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED",missingAttributes:QD(e.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:mm(km(e.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:e.CODE_DELIVERY_DELIVERY_MEDIUM,destination:e.CODE_DELIVERY_DESTINATION}}};case"SOFTWARE_TOKEN_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_TOTP_CODE"}};case"EMAIL_OTP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_EMAIL_CODE",codeDeliveryDetails:{deliveryMedium:e.CODE_DELIVERY_DELIVERY_MEDIUM,destination:e.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{const l=await zD(e);return KD(l)?l:et(l)}case"PASSWORD":case"PASSWORD_SRP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_PASSWORD"}};case"SELECT_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION",availableChallenges:d}}}throw new ar({name:Kd.SignInException,message:`An error occurred during the sign in process. ${o} challengeName returned by the underlying service was not addressed.`})}function JD(r,o){return{sharedSecret:r,getSetupUri:(e,d)=>{const t=`otpauth://totp/${e}:${d??o}?secret=${r}&issuer=${e}`;return new ol(t)}}}function wl(r){if(r===Ki.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(r===Ki.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function QD(r){return r?JSON.parse(r).map(e=>e.includes(hm)?e.replace(hm,""):e):[]}function r7(r){if(r==="SMS_MFA")return"SMS";if(r==="SOFTWARE_TOKEN_MFA")return"TOTP";if(r==="EMAIL_OTP")return"EMAIL"}function mm(r){if(r)return r.map(r7).filter(Boolean)}function km(r){return r?JSON.parse(r):[]}function o7(r){return r.filter(o=>o==="EMAIL"||o==="TOTP")}async function e7(){let r;try{r=await Gh()}catch{}if(r&&r.userId&&r.username)throw new ar({name:lE,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function bl(r){return Ke.getState().username??r}async function d7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{username:e,password:d,options:t}=r,l={loginId:e,authFlowType:"CUSTOM_WITHOUT_SRP"},i=t?.clientMetadata;Vr(!!e,sr.EmptySignInUsername),Vr(!d,sr.CustomAuthSignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ta(XD,[e,i,o,_o],e,_o),s=bl(e);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:l}),b?(await Gd({username:s,...b,NewDeviceMetadata:await ot({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:l}),we(),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),Go(a);const w=wl(a.name);if(w)return w;throw a}}async function t7(r){const{username:o,password:e,options:d}=r,t={loginId:o,authFlowType:"CUSTOM_WITH_SRP"},l=Tr.getConfig().Auth?.Cognito;Sr(l);const i=d?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ZD(o,e,i,l,_o),s=bl(o);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:t}),b?(await Gd({username:s,...b,NewDeviceMetadata:await ot({userPoolId:l.userPoolId,userPoolEndpoint:l.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:t}),we(),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),Go(a);const w=wl(a.name);if(w)return w;throw a}}const xm=async()=>{throw new ar({name:qh,message:"The autoSignIn flow has not started, or has been cancelled/completed.",recoverySuggestion:"Please try to use the signIn API or log out before starting a new autoSignIn flow."})};let V4=xm;function H4(r){V4=r}function go(r=!0){r&&(V4=xm),We.dispatch({type:"RESET"})}async function gm(r){const{username:o,password:e}=r,d=Tr.getConfig().Auth?.Cognito,t={loginId:o,authFlowType:"USER_SRP_AUTH"};Sr(d);const l=r.options?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:i,ChallengeParameters:a,AuthenticationResult:w,Session:b}=await GD(o,e,l,d,_o),n=bl(o);return Zd({signInSession:b,username:n,challengeName:i,signInDetails:t}),w?(await Gd({username:n,...w,NewDeviceMetadata:await ot({userPoolId:d.userPoolId,userPoolEndpoint:d.userPoolEndpoint,newDeviceMetadata:w.NewDeviceMetadata,accessToken:w.AccessToken}),signInDetails:t}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:i,challengeParameters:a})}catch(i){we(),go(),Go(i);const a=wl(i.name);if(a)return a;throw i}}async function l7(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l={loginId:o,authFlowType:"USER_PASSWORD_AUTH"};Sr(t);const i=d?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ta(YD,[o,e,i,t,_o],o,_o),s=bl(o);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:l}),b?(await Gd({...b,username:s,NewDeviceMetadata:await ot({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:l}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),go(),Go(a);const w=wl(a.name);if(w)return w;throw a}}async function i7({username:r,clientMetadata:o,config:e,tokenOrchestrator:d,preferredChallenge:t,password:l,session:i}){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=e,n=$o({username:r,userPoolId:a,userPoolClientId:w}),s={USERNAME:r};if(t){if(t==="PASSWORD_SRP")return Vr(!!l,sr.EmptySignInPassword),fm({username:r,password:l,clientMetadata:o,config:e,tokenOrchestrator:d,authFlow:"USER_AUTH",preferredChallenge:t});t==="PASSWORD"&&(Vr(!!l,sr.EmptySignInPassword),s.PASSWORD=l),s.PREFERRED_CHALLENGE=t}const p={AuthFlow:"USER_AUTH",AuthParameters:s,ClientMetadata:o,ClientId:w,UserContextData:n};i&&(p.Session=i);const h=await ll({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a),userAgentValue:xo(wo.SignIn)},p);return al(r),h}async function cm(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l={loginId:o,authFlowType:"USER_AUTH"};Sr(t);const i=d?.clientMetadata,a=d?.preferredChallenge;Vr(!!o,sr.EmptySignInUsername);try{const w={username:o,config:t,tokenOrchestrator:_o,clientMetadata:i,preferredChallenge:a,password:e},b=We.getState();b.active&&b.username===o&&(w.session=b.session);const n=await i7(w),s=bl(o);return Zd({signInSession:n.Session,username:s,challengeName:n.ChallengeName,signInDetails:l}),n.AuthenticationResult?(await Gd({username:s,...n.AuthenticationResult,NewDeviceMetadata:await ot({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:n.AuthenticationResult.NewDeviceMetadata,accessToken:n.AuthenticationResult.AccessToken}),signInDetails:l}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:n.ChallengeName,challengeParameters:n.ChallengeParameters,availableChallenges:"AvailableChallenges"in n?n.AvailableChallenges:void 0})}catch(w){we(),go(),Go(w);const b=wl(w.name);if(b)return b;throw w}}async function q4(r){go(!1);const o=r.options?.authFlowType;switch(await e7(),o){case"USER_SRP_AUTH":return gm(r);case"USER_PASSWORD_AUTH":return l7(r);case"CUSTOM_WITHOUT_SRP":return d7(r);case"CUSTOM_WITH_SRP":return t7(r);case"USER_AUTH":return cm(r);default:return gm(r)}}const um=180*1e3;function a7(r){const o=Li.listen("auth-internal",async({payload:d})=>{switch(d.event){case"confirmSignUp":d.data?.isSignUpComplete&&(Li.dispatch("auth-internal",{event:"autoSignIn"}),H4(Am(r)),o())}}),e=setTimeout(()=>{o(),clearTimeout(e),go()},um)}function Fm(r,o){let e;return d=>{e||r(...d),clearTimeout(e),e=setTimeout(()=>{e=void 0},o)}}function w7(r,o,e){const d=Date.now(),t=setInterval(async()=>{if(Date.now()-d>um)clearInterval(t),e(new ar({name:qh,message:"The account was not confirmed on time.",recoverySuggestion:"Try to verify your account by clicking the link sent your email or phone and then login manually."})),go();else try{const a=await q4(r);a.nextStep.signInStep!=="CONFIRM_SIGN_UP"&&(o(a),clearInterval(t),go())}catch(a){clearInterval(t),e(a),go()}},5e3)}const b7=Fm(w7,300),n7=Fm(p7,300);function s7(r){return async()=>new Promise((o,e)=>{b7([r,o,e])})}async function p7(r,o,e){try{const d=r?.options?.authFlowType==="USER_AUTH"?await cm(r):await q4(r);o(d),go()}catch(d){e(d),go()}}function Am(r){return async()=>new Promise((o,e)=>{n7([r,o,e])})}const f7=Am,h7=()=>async r=>{if(r.statusCode>=300){const o=await Wd(r);if(Go(o),o.name===C4.InvalidParameterException&&/'password'/.test(o.message)&&/Member must not be null/.test(o.message)){const e=sr.EmptySignUpPassword,{message:d,recoverySuggestion:t}=uh[e];throw new ar({name:e,message:d,recoverySuggestion:t})}throw new ar({name:o.name,message:o.message})}return rl(r)},m7=r=>no(vo,Do("SignUp"),h7(),{...So,...r});async function k7(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l=t?.signUpVerificationMethod??"code",{clientMetadata:i,validationData:a,autoSignIn:w}=r.options??{};Sr(t),Vr(!!o,sr.EmptySignUpUsername);const b=typeof w!="boolean"?w:void 0,n={username:o,options:b};b?.authFlowType!=="CUSTOM_WITHOUT_SRP"&&(n.password=e);const{userPoolId:s,userPoolClientId:p,userPoolEndpoint:m}=t,h=m7({endpointResolver:Yr({endpointOverride:m})}),f={Username:o,Password:void 0,UserAttributes:d?.userAttributes&&Ah(d?.userAttributes),ClientMetadata:i,ValidationData:a&&Ah(a),ClientId:p,UserContextData:$o({username:o,userPoolId:s,userPoolClientId:p})};e&&(f.Password=e);const{UserSub:k,CodeDeliveryDetails:x,UserConfirmed:c,Session:E}=await h({region:Kr(s),userAgentValue:xo(wo.SignUp)},f);(b||w===!0)&&(We.dispatch({type:"START"}),We.dispatch({type:"SET_USERNAME",value:o}),We.dispatch({type:"SET_SESSION",value:E}));const y={destination:x?.Destination,deliveryMedium:x?.DeliveryMedium,attributeName:x?.AttributeName},F=!!c,I=We.getState().active;if(F)return I?(H4(f7(n)),{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:k}):{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:k};if(I){if(l==="link")return H4(s7(n)),{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:y},userId:k};a7(n)}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:y},userId:k}}const x7=r=>no(vo,Do("ForgotPassword"),Ro(),{...So,...r});async function g7(r){const{username:o}=r;Vr(!!o,sr.EmptyResetPasswordUsername);const e=Tr.getConfig().Auth?.Cognito;Sr(e);const{userPoolClientId:d,userPoolId:t,userPoolEndpoint:l}=e,i=r.options?.clientMetadata,a=$o({username:o,userPoolId:t,userPoolClientId:d}),n=(await x7({endpointResolver:Yr({endpointOverride:l})})({region:Kr(t),userAgentValue:xo(wo.ResetPassword)},{Username:o,ClientMetadata:i,ClientId:d,UserContextData:a})).CodeDeliveryDetails;return{isPasswordReset:!1,nextStep:{resetPasswordStep:"CONFIRM_RESET_PASSWORD_WITH_CODE",codeDeliveryDetails:{deliveryMedium:n?.DeliveryMedium,destination:n?.Destination,attributeName:n?.AttributeName}}}}const c7=r=>no(vo,Do("ConfirmForgotPassword"),Ro(),{...So,...r});async function u7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{userPoolClientId:e,userPoolId:d,userPoolEndpoint:t}=o,{username:l,newPassword:i}=r;Vr(!!l,sr.EmptyConfirmResetPasswordUsername),Vr(!!i,sr.EmptyConfirmResetPasswordNewPassword);const a=r.confirmationCode;Vr(!!a,sr.EmptyConfirmResetPasswordConfirmationCode);const w=r.options?.clientMetadata,b=$o({username:l,userPoolId:d,userPoolClientId:e});await c7({endpointResolver:Yr({endpointOverride:t})})({region:Kr(o.userPoolId),userAgentValue:xo(wo.ConfirmResetPassword)},{Username:l,ConfirmationCode:a,Password:i,ClientMetadata:w,ClientId:o.userPoolClientId,UserContextData:b})}const F7=r=>no(vo,Do("ResendConfirmationCode"),Ro(),{...So,...r});async function A7(r){const{username:o}=r;Vr(!!o,sr.EmptySignUpUsername);const e=Tr.getConfig().Auth?.Cognito;Sr(e);const{userPoolClientId:d,userPoolId:t,userPoolEndpoint:l}=e,i=r.options?.clientMetadata,a=$o({username:o,userPoolId:t,userPoolClientId:d}),w=F7({endpointResolver:Yr({endpointOverride:l})}),{CodeDeliveryDetails:b}=await w({region:Kr(e.userPoolId),userAgentValue:xo(wo.ResendSignUpCode)},{Username:o,ClientMetadata:i,ClientId:e.userPoolClientId,UserContextData:a}),{DeliveryMedium:n,AttributeName:s,Destination:p}={...b};return{destination:p,deliveryMedium:n,attributeName:s||void 0}}const y7=r=>no(vo,Do("ConfirmSignUp"),Ro(),{...So,...r});async function E7(r){const{username:o,confirmationCode:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito;Sr(t);const{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a}=t,w=d?.clientMetadata;Vr(!!o,sr.EmptyConfirmSignUpUsername),Vr(!!e,sr.EmptyConfirmSignUpCode);const b=$o({username:o,userPoolId:l,userPoolClientId:i}),n=y7({endpointResolver:Yr({endpointOverride:a})}),{Session:s}=await n({region:Kr(t.userPoolId),userAgentValue:xo(wo.ConfirmSignUp)},{Username:o,ConfirmationCode:e,ClientMetadata:w,ForceAliasCreation:d?.forceAliasCreation,ClientId:t.userPoolClientId,UserContextData:b});return new Promise((p,m)=>{try{const h={isSignUpComplete:!0,nextStep:{signUpStep:"DONE"}},f=We.getState();if(!f.active||f.username!==o){p(h),go();return}We.dispatch({type:"SET_SESSION",value:s});const k=Li.listen("auth-internal",({payload:x})=>{switch(x.event){case"autoSignIn":p({isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"}}),k()}});Li.dispatch("auth-internal",{event:"confirmSignUp",data:h})}catch(h){m(h)}})}const D7=r=>no(vo,Do("ChangePassword"),Ro(),{...So,...r});async function v7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{userPoolEndpoint:e,userPoolId:d}=o,{oldPassword:t,newPassword:l}=r;Vr(!!t,sr.EmptyUpdatePassword),Vr(!!l,sr.EmptyUpdatePassword);const{tokens:i}=await Jf({forceRefresh:!1});B4(i),await D7({endpointResolver:Yr({endpointOverride:e})})({region:Kr(d),userAgentValue:xo(wo.UpdatePassword)},{AccessToken:i.accessToken.toString(),PreviousPassword:t,ProposedPassword:l})}function S7(r,o){if(o){const e=r?.find(d=>d===o);if(!e)throw sE;return e}else{const e=r?.find(_7)??r?.find(C7),d=r?.find(I7)??r?.find(B7);if(e)return e;throw d?fE:nE}}const _7=r=>r.startsWith(String(window.location.origin+(window.location.pathname||"/"))),C7=r=>r.includes(String(window.location.hostname)),B7=r=>r.startsWith("http://"),I7=r=>r.startsWith("https://"),T7=async r=>{window?.location&&(window.location.href=r.replace("http://","https://"))},N7=async r=>{await r.clearOAuthData(),_o.clearTokens(),await Qf(),Hd.dispatch("auth",{event:"signedOut"},"Auth",pd)},P7=async(r,o=!1,e)=>{Sf(r);const{loginWith:d,userPoolClientId:t}=r,{domain:l,redirectSignOut:i}=d.oauth,a=S7(i,e),w=`https://${l}/logout?${Object.entries({client_id:t,logout_uri:encodeURIComponent(a)}).map(([b,n])=>`${b}=${n}`).join("&")}`;return T7(w)},O7=async(r,o,e,d)=>{const{isOAuthSignIn:t}=await o.loadOAuthSignIn(),l=await e.getOAuthMetadata();if(await N7(o),t||l?.oauthSignIn)return P7(r,!1,d)},R7=r=>no(vo,Do("RevokeToken"),Ro(),{...So,...r}),M7=r=>no(vo,Do("GlobalSignOut"),Ro(),{...So,...r}),ym=new Eo("Auth");async function $7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o),r?.global?await L7(o):await U7(o);let e;try{Sf(o),e=!0}catch{e=!1}if(e){const d=new Qh(dl);d.setAuthConfig(o);const{type:t}=await O7(o,d,_o,r?.oauth?.redirectUrl)??{};if(t==="error")throw new ar({name:hE,message:"An error occurred when attempting to log out from OAuth provider."})}else _o.clearTokens(),await Qf(),Hd.dispatch("auth",{event:"signedOut"},"Auth",pd)}async function U7(r){try{const{userPoolEndpoint:o,userPoolId:e,userPoolClientId:d}=r,t=await _o.getTokenStore().loadTokens();Wh(t),j7(t.accessToken)&&await R7({endpointResolver:Yr({endpointOverride:o})})({region:Kr(e),userAgentValue:xo(wo.SignOut)},{ClientId:d,Token:t.refreshToken})}catch{ym.debug("Client signOut error caught but will proceed with token removal")}}async function L7(r){try{const{userPoolEndpoint:o,userPoolId:e}=r,d=await _o.getTokenStore().loadTokens();B4(d),await M7({endpointResolver:Yr({endpointOverride:o})})({region:Kr(e),userAgentValue:xo(wo.SignOut)},{AccessToken:d.accessToken.toString()})}catch{ym.debug("Global signOut error caught but will proceed with token removal")}}const j7=r=>!!r?.payload?.origin_jti,z7={identityId:"identityId"},V7=new Eo("DefaultIdentityIdStore");class Em{setAuthConfig(o){ji(o.Cognito),this.authConfig=o,this._authKeys=H7("Cognito",o.Cognito.identityPoolId)}constructor(o){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=o}async loadIdentityId(){ji(this.authConfig?.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{const o=await this.keyValueStorage.getItem(this._authKeys.identityId);return o?(this._hasGuestIdentityId=!0,{id:o,type:"guest"}):null}}catch(o){return V7.log("Error getting stored IdentityId.",o),null}}async storeIdentityId(o){ji(this.authConfig?.Cognito),o.type==="guest"?(this.keyValueStorage.setItem(this._authKeys.identityId,o.id),this._primaryIdentityId=void 0,this._hasGuestIdentityId=!0):(this._primaryIdentityId=o.id,this._hasGuestIdentityId&&(this.keyValueStorage.removeItem(this._authKeys.identityId),this._hasGuestIdentityId=!1))}async clearIdentityId(){this._primaryIdentityId=void 0,await this.keyValueStorage.removeItem(this._authKeys.identityId)}}const H7=(r,o)=>I4(z7)(`com.amplify.${r}`,o),W4=({endpointOverride:r})=>o=>r?{url:new ol(r)}:Y8(o);function Dm(r){const o=fd(r).payload.iss,e={};if(!o)throw new ar({name:"InvalidIdTokenException",message:"Invalid Idtoken."});const d=o.replace(/(^\w+:|^)\/\//,"");return e[d]=r,e}async function q7({tokens:r,authConfig:o,identityIdStore:e}){e.setAuthConfig({Cognito:o});const d=await e.loadIdentityId();if(d)return d.id;const t=r?.idToken?Dm(r.idToken.toString()):{},l=await W7(t,o);return e.storeIdentityId({id:l,type:r?"primary":"guest"}),l}async function W7(r,o){const e=o?.identityPoolId,d=_4(e),t=q8({endpointResolver:W4({endpointOverride:o.identityPoolEndpoint})});let l;try{l=(await t({region:d},{IdentityPoolId:e,Logins:r})).IdentityId}catch(i){throw Go(i),new ar(i)}if(!l)throw new ar({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return l}const la=new Eo("CognitoCredentialsProvider"),vm=3e3*1e3;class Sm{constructor(o){this._nextCredentialsRefresh=0,this._identityIdStore=o}async clearCredentialsAndIdentityId(){la.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){la.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(o){const e=o.authenticated,{tokens:d}=o,{authConfig:t}=o;try{ji(t?.Cognito)}catch{return}if(!e&&!t.Cognito.allowGuestAccess)return;const{forceRefresh:l}=o,i=this.hasTokenChanged(d),a=await q7({tokens:d,authConfig:t.Cognito,identityIdStore:this._identityIdStore});return(l||i)&&this.clearCredentials(),e?(xE(d),this.credsForOIDCTokens(t.Cognito,d,a)):this.getGuestCredentials(a,t.Cognito)}async getGuestCredentials(o,e){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return la.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const d=_4(e.identityPoolId),t=sh({endpointResolver:W4({endpointOverride:e.identityPoolEndpoint})});let l;try{l=await t({region:d},{IdentityId:o})}catch(i){throw Go(i),new ar(i)}if(l?.Credentials?.AccessKeyId&&l?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+vm;const i={credentials:{accessKeyId:l.Credentials.AccessKeyId,secretAccessKey:l.Credentials.SecretKey,sessionToken:l.Credentials.SessionToken,expiration:l.Credentials.Expiration},identityId:o};return l.IdentityId&&(i.identityId=l.IdentityId,this._identityIdStore.storeIdentityId({id:l.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...i,isAuthenticatedCreds:!1},i}else throw new ar({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(o,e,d){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return la.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const t=e.idToken?Dm(e.idToken.toString()):{},l=_4(o.identityPoolId),i=sh({endpointResolver:W4({endpointOverride:o.identityPoolEndpoint})});let a;try{a=await i({region:l},{IdentityId:d,Logins:t})}catch(w){throw Go(w),new ar(w)}if(a?.Credentials?.AccessKeyId&&a?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+vm;const w={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:d};return a.IdentityId&&(w.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...w,isAuthenticatedCreds:!0,associatedIdToken:e.idToken?.toString()},w}else throw new ar({name:"CredentialsException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}isPastTTL(){return this._nextCredentialsRefresh===void 0?!0:this._nextCredentialsRefresh<=Date.now()}hasTokenChanged(o){return!!o&&!!this._credentialsAndIdentityId?.associatedIdToken&&o.idToken?.toString()!==this._credentialsAndIdentityId.associatedIdToken}}const K7=new Sm(new Em(dl)),Y7={configure(r,o){const e=Nf(r),d=new gh({sameSite:"lax"}),t=o?.ssr?d:dl,l=o?.ssr?new Sm(new Em(d)):K7;if(!e.Auth){Tr.configure(e,o);return}if(o?.Auth){Tr.configure(e,o);return}if(!Tr.libraryOptions.Auth){Yd.setAuthConfig(e.Auth),Yd.setKeyValueStorage(t),Tr.configure(e,{...o,Auth:{tokenProvider:Yd,credentialsProvider:l}});return}if(o){const i=Tr.libraryOptions.Auth;o.ssr!==void 0&&(Yd.setKeyValueStorage(t),i.credentialsProvider=l),Tr.configure(e,{Auth:i,...o});return}Tr.configure(e)},getConfig(){return Tr.getConfig()}},G7={Auth:{Cognito:{userPoolId:"ap-south-1_es4yWY1O9",userPoolClientId:"7hte1nkjug6rqsf9air6021aqr",userPoolEndpoint:"https://cognito-idp.ap-south-1.amazonaws.com/"}}};Y7.configure(G7),Yd.setKeyValueStorage(new gh({domain:"localhost",secure:!0,path:"/",expires:30}));const _m={signIn:q4,autoSignIn:V4,signUp:k7,fetchAuthSession:Jf,resetPassword:g7,confirmResetPassword:u7,resendSignUpCode:A7,confirmSignUp:E7,updatePassword:v7,signOut:$7},nl=r=>{if(typeof window<"u"){const{cookie:o}=document,e=o?.split(";")?.find(t=>t?.includes(r));if(!e)return["",""];const d=e.split("=");return d.length<=1?["",""]:d}return["",""]},Cm=(r,o,e)=>{const d=new Date;d.setTime(d.getTime()+e*24*60*60*1e3);const t="expires="+d.toUTCString();document.cookie=r+"="+o+";"+t+";domain=."+process.env.NEXT_PUBLIC_DOMAIN+";path=/"};async function X7(){try{await _m.signOut()}catch(r){console.log("error signing out: ",r)}}const Bm={jwtExpired:"jwt expired",notLogin:"User must be logged in"},K4=Gt.get();typeof K4=="object"&&Object.entries(K4).length&&Object?.entries(K4)?.forEach(([r,o])=>{r.endsWith("accessToken")});let ia="";typeof window<"u"&&(ia=window.location.href),ia.includes("invite-user")||ia.includes("mailOpened")||ia.includes("/email?"),Rr.interceptors.request.use(async r=>{const o=window.location.pathname.split("/").find(d=>parseInt(d))??nl(Ef.workspaceId)[1];r.headers["x-tenant-id"]||(r.headers["x-tenant-id"]=o?o.toString():"");const e=nl("accessToken");return r.headers.authorization=`${e[1]}`,{...r}},r=>Promise.reject(r)),Rr.interceptors.response.use(r=>r,async r=>{const e=FA(r.config,"url","").split("/");return((r.response?.data?.message??"")===Bm.jwtExpired||(r.response?.data?.message??"")===Bm.notLogin)&&(nl("count")[1]==="1"&&(await X7(),Cm("count","0",0),window.location.href.includes("auth/")||(window.location.pathname=by.login)),await _m.fetchAuthSession(),window.location.href.includes("auth/")||(Cm("count","1",1),window.location.reload())),r.response?.status===401&&!e.includes("validate-user")&&window.location.reload(),Promise.reject(r.response)});const Z7=()=>{const r=window.location.pathname.split("/").find(e=>parseInt(e))??nl(Ef.workspaceId)[1],o=nl("accessToken");return{"x-tenant-id":r?r.toString():"",authorization:`${o[1]}`}},Im=ay((r,{headers:o})=>({headers:{...o,...Z7()}})),J7=Jr.createHttpLink({uri:Jw.clientGraphqlUrl}),Q7=Jr.createHttpLink({uri:Jw.serverGraphqlUrl}),Y4=new Jr.ApolloClient({cache:new Jr.InMemoryCache({}),link:Jr.ApolloLink.from([Im,J7]),queryDeduplication:!1,devtools:{enabled:!0}}),Tm=new Jr.ApolloClient({cache:new Jr.InMemoryCache({}),link:Jr.ApolloLink.from([Im,Q7]),queryDeduplication:!1,devtools:{enabled:!0}}),r9=Jr.gql`
|
|
153
|
+
E.g { responseType: 'code' }`}),cE=new ar({name:Yi,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function Wh(r){if(AE(r))throw gE;if(!FE(r))throw cE}function Kh(r){if(!r||!r.deviceKey||!r.deviceGroupKey||!r.randomPassword)throw new ar({name:iE,message:"Either deviceKey, deviceGroupKey or secretPassword were not found during the sign-in process.",recoverySuggestion:"Make sure to not clear storage after calling the signIn API."})}const uE={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function Yh(r){return r?.accessToken||r?.idToken}function FE(r){return Yh(r)&&r?.refreshToken}function AE(r){return Yh(r)&&!r?.refreshToken}const yE=async r=>{const o=r.getConfig().Auth?.Cognito;Sr(o);const e=await r.Auth.getTokens({forceRefresh:!1});B4(e);const{"cognito:username":d,sub:t}=e.idToken?.payload??{},l={username:d,userId:t},i=EE(e);return i&&(l.signInDetails=i),l};function EE(r){return r?.signInDetails}const Gh=async()=>yE(Tr),xo=(r,o)=>qi({category:F4.Auth,action:r,...o}),Do=r=>(o,e)=>{const d=DE(r),t=JSON.stringify(o);return vE(e,d,t)},DE=r=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${r}`}),vE=({url:r},o,e)=>({headers:o,url:r,body:e,method:"POST"});function Go(r){if(!r||r.name==="Error"||r instanceof TypeError)throw new ar({name:qe.Unknown,message:"An unknown error has occurred.",underlyingError:r})}const Ro=()=>async r=>{if(r.statusCode>=300){const o=await Wd(r);throw Go(o),new ar({name:o.name,message:o.message,metadata:o.$metadata})}return rl(r)},vo=D4(wh,[()=>(r,o)=>async function(d){return d.headers["cache-control"]="no-store",r(d)}]),Xh="cognito-idp",So={service:Xh,retryDecider:th(Wd),computeDelay:dh,get userAgentValue(){return qi()},cache:"no-store"},ll=r=>no(vo,Do("InitiateAuth"),Ro(),{...So,...r}),Gi=r=>no(vo,Do("RespondToAuthChallenge"),Ro(),{...So,...r}),SE=r=>no(vo,Do("AssociateSoftwareToken"),Ro(),{...So,...r}),_E=({region:r})=>({url:new ol(`https://${Xh}.${r}.${fh(r)}`)}),Yr=({endpointOverride:r})=>o=>r?{url:new ol(r)}:_E(o),CE=r=>no(vo,Do("GetTokensFromRefreshToken"),Ro(),{...So,...r}),BE=rE(async({tokens:r,authConfig:o,username:e})=>{Sr(o?.Cognito);const{userPoolId:d,userPoolClientId:t,userPoolEndpoint:l}=o.Cognito,i=Kr(d);Wh(r);const a=CE({endpointResolver:Yr({endpointOverride:l})}),{AuthenticationResult:w}=await a({region:i},{ClientId:t,RefreshToken:r.refreshToken,DeviceKey:r.deviceMetadata?.deviceKey}),b=fd(w?.AccessToken??""),n=w?.IdToken?fd(w.IdToken):void 0,{iat:s}=b.payload;if(!s)throw new ar({name:"iatNotFoundException",message:"iat not found in access token"});const p=s*1e3-new Date().getTime();return{accessToken:b,idToken:n,clockDrift:p,refreshToken:w?.RefreshToken??r.refreshToken,username:e}}),IE={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var Xi;(function(r){r.InvalidAuthTokens="InvalidAuthTokens"})(Xi||(Xi={}));const TE={[Xi.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},NE=x4(TE),Zh="CognitoIdentityServiceProvider";class PE{getKeyValueStorage(){if(!this.keyValueStorage)throw new ar({name:"KeyValueStorageNotFoundException",message:"KeyValueStorage was not found in TokenStore"});return this.keyValueStorage}setKeyValueStorage(o){this.keyValueStorage=o}setAuthConfig(o){this.authConfig=o}async loadTokens(){try{const o=await this.getAuthKeys(),e=await this.getKeyValueStorage().getItem(o.accessToken);if(!e)throw new ar({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});const d=fd(e),t=await this.getKeyValueStorage().getItem(o.idToken),l=t?fd(t):void 0,i=await this.getKeyValueStorage().getItem(o.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(o.clockDrift)??"0",w=Number.parseInt(a),b=await this.getKeyValueStorage().getItem(o.signInDetails),n={accessToken:d,idToken:l,refreshToken:i,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:w,username:await this.getLastAuthUser()};return b&&(n.signInDetails=JSON.parse(b)),n}catch{return null}}async storeTokens(o){NE(o!==void 0,Xi.InvalidAuthTokens);const e=o.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),e);const d=await this.getAuthKeys();await this.getKeyValueStorage().setItem(d.accessToken,o.accessToken.toString()),o.idToken?await this.getKeyValueStorage().setItem(d.idToken,o.idToken.toString()):await this.getKeyValueStorage().removeItem(d.idToken),o.refreshToken?await this.getKeyValueStorage().setItem(d.refreshToken,o.refreshToken):await this.getKeyValueStorage().removeItem(d.refreshToken),o.deviceMetadata&&(o.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(d.deviceKey,o.deviceMetadata.deviceKey),o.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(d.deviceGroupKey,o.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(d.randomPasswordKey,o.deviceMetadata.randomPassword)),o.signInDetails?await this.getKeyValueStorage().setItem(d.signInDetails,JSON.stringify(o.signInDetails)):await this.getKeyValueStorage().removeItem(d.signInDetails),await this.getKeyValueStorage().setItem(d.clockDrift,`${o.clockDrift}`)}async clearTokens(){const o=await this.getAuthKeys();await Promise.all([this.getKeyValueStorage().removeItem(o.accessToken),this.getKeyValueStorage().removeItem(o.idToken),this.getKeyValueStorage().removeItem(o.clockDrift),this.getKeyValueStorage().removeItem(o.refreshToken),this.getKeyValueStorage().removeItem(o.signInDetails),this.getKeyValueStorage().removeItem(this.getLastAuthUserKey()),this.getKeyValueStorage().removeItem(o.oauthMetadata)])}async getDeviceMetadata(o){const e=await this.getAuthKeys(o),d=await this.getKeyValueStorage().getItem(e.deviceKey),t=await this.getKeyValueStorage().getItem(e.deviceGroupKey),l=await this.getKeyValueStorage().getItem(e.randomPasswordKey);return l&&t&&d?{deviceKey:d,deviceGroupKey:t,randomPassword:l}:null}async clearDeviceMetadata(o){const e=await this.getAuthKeys(o);await Promise.all([this.getKeyValueStorage().removeItem(e.deviceKey),this.getKeyValueStorage().removeItem(e.deviceGroupKey),this.getKeyValueStorage().removeItem(e.randomPasswordKey)])}async getAuthKeys(o){Sr(this.authConfig?.Cognito);const e=o??await this.getLastAuthUser();return OE(Zh,`${this.authConfig.Cognito.userPoolClientId}.${e}`)}getLastAuthUserKey(){Sr(this.authConfig?.Cognito);const o=this.authConfig.Cognito.userPoolClientId;return`${Zh}.${o}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(o){const{oauthMetadata:e}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(e,JSON.stringify(o))}async getOAuthMetadata(){const{oauthMetadata:o}=await this.getAuthKeys(),e=await this.getKeyValueStorage().getItem(o);return e&&JSON.parse(e)}}const OE=(r,o)=>I4(IE)(`${r}`,o);function I4(r){const o=Object.values({...r});return(e,d)=>o.reduce((t,l)=>({...t,[l]:`${e}.${d}.${l}`}),{})}const Jh="amplify-signin-with-hostedUI",ie="CognitoIdentityServiceProvider";class Qh{constructor(o){this.keyValueStorage=o}async clearOAuthInflightData(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(o.inflightOAuth),this.keyValueStorage.removeItem(o.oauthPKCE),this.keyValueStorage.removeItem(o.oauthState)])}async clearOAuthData(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(Jh),this.keyValueStorage.removeItem(o.oauthSignIn)}loadOAuthState(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(o.oauthState)}storeOAuthState(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(e.oauthState,o)}loadPKCE(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(o.oauthPKCE)}storePKCE(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(e.oauthPKCE,o)}setAuthConfig(o){this.cognitoConfig=o}async loadOAuthInFlight(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(o.inflightOAuth)==="true"}async storeOAuthInFlight(o){Sr(this.cognitoConfig);const e=ae(ie,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(e.inflightOAuth,`${o}`)}async loadOAuthSignIn(){Sr(this.cognitoConfig);const o=ae(ie,this.cognitoConfig.userPoolClientId),e=await this.keyValueStorage.getItem(Jh),[d,t]=(await this.keyValueStorage.getItem(o.oauthSignIn))?.split(",")??[];return{isOAuthSignIn:d==="true"||e==="true",preferPrivateSession:t==="true"}}async storeOAuthSignIn(o,e=!1){Sr(this.cognitoConfig);const d=ae(ie,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(d.oauthSignIn,`${o},${e}`)}}const ae=(r,o)=>I4(uE)(r,o),rm=new Qh(dl);class RE{constructor(){this.waitForInflightOAuth=Gf()?async()=>{if(await rm.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((o,e)=>{}),this.inflightPromise)}:async()=>{}}setAuthConfig(o){rm.setAuthConfig(o.Cognito),this.authConfig=o}setTokenRefresher(o){this.tokenRefresher=o}setAuthTokenStore(o){this.tokenStore=o}getTokenStore(){if(!this.tokenStore)throw new ar({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new ar({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}async getTokens(o){let e;try{Sr(this.authConfig?.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,e=await this.getTokenStore().loadTokens();const d=await this.getTokenStore().getLastAuthUser();if(e===null)return null;const t=!!e?.idToken&&ch({expiresAt:(e.idToken?.payload?.exp??0)*1e3,clockDrift:e.clockDrift??0}),l=ch({expiresAt:(e.accessToken?.payload?.exp??0)*1e3,clockDrift:e.clockDrift??0});return(o?.forceRefresh||t||l)&&(e=await this.refreshTokens({tokens:e,username:d}),e===null)?null:{accessToken:e?.accessToken,idToken:e?.idToken,signInDetails:e?.signInDetails}}async refreshTokens({tokens:o,username:e}){try{const{signInDetails:d}=o,t=await this.getTokenRefresher()({tokens:o,authConfig:this.authConfig,username:e});return t.signInDetails=d,await this.setTokens({tokens:t}),Hd.dispatch("auth",{event:"tokenRefresh"},"Auth",pd),t}catch(d){return this.handleErrors(d)}}handleErrors(o){if(Go(o),o.name!==qe.NetworkError&&this.clearTokens(),Hd.dispatch("auth",{event:"tokenRefresh_failure",data:{error:o}},"Auth",pd),o.name.startsWith("NotAuthorizedException"))return null;throw o}async setTokens({tokens:o}){return this.getTokenStore().storeTokens(o)}async clearTokens(){return this.getTokenStore().clearTokens()}getDeviceMetadata(o){return this.getTokenStore().getDeviceMetadata(o)}clearDeviceMetadata(o){return this.getTokenStore().clearDeviceMetadata(o)}setOAuthMetadata(o){return this.getTokenStore().setOAuthMetadata(o)}getOAuthMetadata(){return this.getTokenStore().getOAuthMetadata()}}class ME{constructor(){this.authTokenStore=new PE,this.authTokenStore.setKeyValueStorage(dl),this.tokenOrchestrator=new RE,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(BE)}getTokens({forceRefresh:o}={forceRefresh:!1}){return this.tokenOrchestrator.getTokens({forceRefresh:o})}setKeyValueStorage(o){this.authTokenStore.setKeyValueStorage(o)}setAuthConfig(o){this.authTokenStore.setAuthConfig(o),this.tokenOrchestrator.setAuthConfig(o)}}const Yd=new ME,{tokenOrchestrator:_o}=Yd;async function Gd(r){if(r.AccessToken){const o=fd(r.AccessToken),e=(o.payload.iat||0)*1e3,d=new Date().getTime(),t=e>0?e-d:0;let l,i,a;r.RefreshToken&&(i=r.RefreshToken),r.IdToken&&(l=fd(r.IdToken)),r?.NewDeviceMetadata&&(a=r.NewDeviceMetadata);const w={accessToken:o,idToken:l,refreshToken:i,clockDrift:t,deviceMetadata:a,username:r.username};r?.signInDetails&&(w.signInDetails=r.signInDetails),await _o.setTokens({tokens:w})}else throw new ko({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const $E="Unable to get user session following successful sign-in.",Xd=async()=>{try{Hd.dispatch("auth",{event:"signedIn",data:await Gh()},"Auth",pd)}catch(r){throw r.name===Yi?new ar({name:kE,message:$E,recoverySuggestion:"This most likely is due to auth tokens not being persisted. If you are using cookie store, please ensure cookies can be correctly set from your server."}):r}};function om(){return{active:!1}}const We=(r=>{let o=r(om(),{type:"RESET"});return{getState:()=>o,dispatch:e=>{o=r(o,e)}}})((r,o)=>{switch(o.type){case"SET_USERNAME":return{...r,username:o.value};case"SET_SESSION":return{...r,session:o.value};case"START":return{...r,active:!0};case"RESET":return om();default:return r}}),UE=180*1e3,Zi="CognitoSignInState",Fe={username:`${Zi}.username`,challengeName:`${Zi}.challengeName`,signInSession:`${Zi}.signInSession`,expiry:`${Zi}.expiry`},LE=(r,o)=>{switch(o.type){case"SET_SIGN_IN_SESSION":return Ji({signInSession:o.value}),{...r,signInSession:o.value};case"SET_SIGN_IN_STATE":return Ji(o.value),{...o.value};case"SET_CHALLENGE_NAME":return Ji({challengeName:o.value}),{...r,challengeName:o.value};case"SET_USERNAME":return Ji({username:o.value}),{...r,username:o.value};case"SET_INITIAL_STATE":return zE();case"RESET_STATE":return em(),T4();default:return r}},jE=r=>{const o=Number(r),e=Date.now();return o<=e},we=()=>{Ke.dispatch({type:"RESET_STATE"})},em=()=>{for(const r of Object.values(Fe))ue.removeItem(r)},T4=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),zE=()=>{const r=ue.getItem(Fe.expiry);if(!r||jE(r))return em(),T4();const o=ue.getItem(Fe.username)??void 0,e=ue.getItem(Fe.challengeName)??void 0,d=ue.getItem(Fe.signInSession)??void 0;return{username:o,challengeName:e,signInSession:d}},Ke=(r=>{let o=r(T4(),{type:"SET_INITIAL_STATE"});return{getState:()=>o,dispatch:e=>{o=r(o,e)}}})(LE);function Zd(r){Ke.dispatch({type:"SET_SIGN_IN_STATE",value:r})}const Ji=({challengeName:r,signInSession:o,username:e})=>{e&&ue.setItem(Fe.username,e),r&&ue.setItem(Fe.challengeName,r),o&&(ue.setItem(Fe.signInSession,o),ue.setItem(Fe.expiry,String(Date.now()+UE)))};class Ae extends ko{constructor(o){super(o),this.constructor=Ae,Object.setPrototypeOf(this,Ae.prototype)}}var Hr;(function(r){r.PasskeyNotSupported="PasskeyNotSupported",r.PasskeyAlreadyExists="PasskeyAlreadyExists",r.InvalidPasskeyRegistrationOptions="InvalidPasskeyRegistrationOptions",r.InvalidPasskeyAuthenticationOptions="InvalidPasskeyAuthenticationOptions",r.RelyingPartyMismatch="RelyingPartyMismatch",r.PasskeyRegistrationFailed="PasskeyRegistrationFailed",r.PasskeyRetrievalFailed="PasskeyRetrievalFailed",r.PasskeyRegistrationCanceled="PasskeyRegistrationCanceled",r.PasskeyAuthenticationCanceled="PasskeyAuthenticationCanceled",r.PasskeyOperationAborted="PasskeyOperationAborted"})(Hr||(Hr={}));const dm="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.",N4="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",tm="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Qi={[Hr.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:dm},[Hr.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:tm},[Hr.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:tm},[Hr.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:dm},[Hr.PasskeyRetrievalFailed]:{message:"Device failed to retrieve passkey.",recoverySuggestion:"Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP."},[Hr.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[Hr.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:N4},[Hr.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:N4},[Hr.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:N4},[Hr.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},P4=x4(Qi,Ae),VE=r=>{if(r instanceof Ae)return r;if(r instanceof Error&&r.name==="NotAllowedError"){const{message:o,recoverySuggestion:e}=Qi[Hr.PasskeyAuthenticationCanceled];return new Ae({name:Hr.PasskeyAuthenticationCanceled,message:o,recoverySuggestion:e,underlyingError:r})}return HE(r)},HE=r=>{if(r instanceof Error){if(r.name==="AbortError"){const{message:o,recoverySuggestion:e}=Qi[Hr.PasskeyOperationAborted];return new Ae({name:Hr.PasskeyOperationAborted,message:o,recoverySuggestion:e,underlyingError:r})}if(r.name==="SecurityError"){const{message:o,recoverySuggestion:e}=Qi[Hr.RelyingPartyMismatch];return new Ae({name:Hr.RelyingPartyMismatch,message:o,recoverySuggestion:e,underlyingError:r})}}return new Ae({name:qe.Unknown,message:"An unknown error has occurred.",underlyingError:r})},qE=()=>Gf()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",il=r=>tl.convert(new Uint8Array(r),{urlSafe:!0,skipPadding:!0}),lm=r=>Uint8Array.from(g4.convert(r,{urlSafe:!0}),o=>o.charCodeAt(0)).buffer,WE=r=>{const o=lm(r.challenge),e=(r.allowCredentials||[]).map(d=>({...d,id:lm(d.id)}));return{...r,challenge:o,allowCredentials:e}},KE=r=>{const o={clientDataJSON:il(r.response.clientDataJSON),authenticatorData:il(r.response.authenticatorData),signature:il(r.response.signature)};r.response.userHandle&&(o.userHandle=il(r.response.userHandle));const e={id:r.id,rawId:il(r.rawId),type:r.type,clientExtensionResults:r.getClientExtensionResults(),response:o};return r.authenticatorAttachment&&(e.authenticatorAttachment=r.authenticatorAttachment),e};function YE(r){P4(r&&r instanceof PublicKeyCredential&&r.response instanceof AuthenticatorAssertionResponse,Hr.PasskeyRetrievalFailed)}const GE=async r=>{try{const o=qE();P4(o,Hr.PasskeyNotSupported);const e=WE(r),d=await navigator.credentials.get({publicKey:e});return YE(d),KE(d)}catch(o){throw VE(o)}},XE=r=>no(vo,Do("ConfirmDevice"),Ro(),{...So,...r}),ra={convert(r){return new TextEncoder().encode(r)}};function rr(r,o){r!=null&&this.fromString(r,o)}function so(){return new rr(null,null)}let Ye;const im=(0xdeadbeefcafe&16777215)===15715070;function ZE(r,o,e,d,t,l){for(;--l>=0;){const i=o*this[r++]+e[d]+t;t=Math.floor(i/67108864),e[d++]=i&67108863}return t}function JE(r,o,e,d,t,l){const i=o&32767,a=o>>15;for(;--l>=0;){let w=this[r]&32767;const b=this[r++]>>15,n=a*w+b*i;w=i*w+((n&32767)<<15)+e[d]+(t&1073741823),t=(w>>>30)+(n>>>15)+a*b+(t>>>30),e[d++]=w&1073741823}return t}function QE(r,o,e,d,t,l){const i=o&16383,a=o>>14;for(;--l>=0;){let w=this[r]&16383;const b=this[r++]>>14,n=a*w+b*i;w=i*w+((n&16383)<<14)+e[d]+t,t=(w>>28)+(n>>14)+a*b,e[d++]=w&268435455}return t}const am=typeof navigator<"u";am&&im&&navigator.appName==="Microsoft Internet Explorer"?(rr.prototype.am=JE,Ye=30):am&&im&&navigator.appName!=="Netscape"?(rr.prototype.am=ZE,Ye=26):(rr.prototype.am=QE,Ye=28),rr.prototype.DB=Ye,rr.prototype.DM=(1<<Ye)-1,rr.prototype.DV=1<<Ye;const O4=52;rr.prototype.FV=Math.pow(2,O4),rr.prototype.F1=O4-Ye,rr.prototype.F2=2*Ye-O4;const rD="0123456789abcdefghijklmnopqrstuvwxyz",oa=[];let Jd,Mo;for(Jd=48,Mo=0;Mo<=9;++Mo)oa[Jd++]=Mo;for(Jd=97,Mo=10;Mo<36;++Mo)oa[Jd++]=Mo;for(Jd=65,Mo=10;Mo<36;++Mo)oa[Jd++]=Mo;function wm(r){return rD.charAt(r)}function oD(r,o){const e=oa[r.charCodeAt(o)];return e??-1}function eD(r){for(let o=this.t-1;o>=0;--o)r[o]=this[o];r.t=this.t,r.s=this.s}function dD(r){this.t=1,this.s=r<0?-1:0,r>0?this[0]=r:r<-1?this[0]=r+this.DV:this.t=0}function R4(r){const o=so();return o.fromInt(r),o}function tD(r,o){let e;if(o===16)e=4;else if(o===8)e=3;else if(o===2)e=1;else if(o===32)e=5;else if(o===4)e=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let d=r.length,t=!1,l=0;for(;--d>=0;){const i=oD(r,d);if(i<0){r.charAt(d)==="-"&&(t=!0);continue}t=!1,l===0?this[this.t++]=i:l+e>this.DB?(this[this.t-1]|=(i&(1<<this.DB-l)-1)<<l,this[this.t++]=i>>this.DB-l):this[this.t-1]|=i<<l,l+=e,l>=this.DB&&(l-=this.DB)}this.clamp(),t&&rr.ZERO.subTo(this,this)}function lD(){const r=this.s&this.DM;for(;this.t>0&&this[this.t-1]==r;)--this.t}function iD(r){if(this.s<0)return"-"+this.negate().toString(r);let o;if(r==16)o=4;else if(r===8)o=3;else if(r===2)o=1;else if(r===32)o=5;else if(r===4)o=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");const e=(1<<o)-1;let d,t=!1,l="",i=this.t,a=this.DB-i*this.DB%o;if(i-- >0)for(a<this.DB&&(d=this[i]>>a)>0&&(t=!0,l=wm(d));i>=0;)a<o?(d=(this[i]&(1<<a)-1)<<o-a,d|=this[--i]>>(a+=this.DB-o)):(d=this[i]>>(a-=o)&e,a<=0&&(a+=this.DB,--i)),d>0&&(t=!0),t&&(l+=wm(d));return t?l:"0"}function aD(){const r=so();return rr.ZERO.subTo(this,r),r}function wD(){return this.s<0?this.negate():this}function bD(r){let o=this.s-r.s;if(o!=0)return o;let e=this.t;if(o=e-r.t,o!=0)return this.s<0?-o:o;for(;--e>=0;)if((o=this[e]-r[e])!=0)return o;return 0}function M4(r){let o=1,e;return(e=r>>>16)!==0&&(r=e,o+=16),(e=r>>8)!==0&&(r=e,o+=8),(e=r>>4)!==0&&(r=e,o+=4),(e=r>>2)!==0&&(r=e,o+=2),(e=r>>1)!==0&&(r=e,o+=1),o}function nD(){return this.t<=0?0:this.DB*(this.t-1)+M4(this[this.t-1]^this.s&this.DM)}function sD(r,o){let e;for(e=this.t-1;e>=0;--e)o[e+r]=this[e];for(e=r-1;e>=0;--e)o[e]=0;o.t=this.t+r,o.s=this.s}function pD(r,o){for(let e=r;e<this.t;++e)o[e-r]=this[e];o.t=Math.max(this.t-r,0),o.s=this.s}function fD(r,o){const e=r%this.DB,d=this.DB-e,t=(1<<d)-1,l=Math.floor(r/this.DB);let i=this.s<<e&this.DM,a;for(a=this.t-1;a>=0;--a)o[a+l+1]=this[a]>>d|i,i=(this[a]&t)<<e;for(a=l-1;a>=0;--a)o[a]=0;o[l]=i,o.t=this.t+l+1,o.s=this.s,o.clamp()}function hD(r,o){o.s=this.s;const e=Math.floor(r/this.DB);if(e>=this.t){o.t=0;return}const d=r%this.DB,t=this.DB-d,l=(1<<d)-1;o[0]=this[e]>>d;for(let i=e+1;i<this.t;++i)o[i-e-1]|=(this[i]&l)<<t,o[i-e]=this[i]>>d;d>0&&(o[this.t-e-1]|=(this.s&l)<<t),o.t=this.t-e,o.clamp()}function mD(r,o){let e=0,d=0;const t=Math.min(r.t,this.t);for(;e<t;)d+=this[e]-r[e],o[e++]=d&this.DM,d>>=this.DB;if(r.t<this.t){for(d-=r.s;e<this.t;)d+=this[e],o[e++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;e<r.t;)d-=r[e],o[e++]=d&this.DM,d>>=this.DB;d-=r.s}o.s=d<0?-1:0,d<-1?o[e++]=this.DV+d:d>0&&(o[e++]=d),o.t=e,o.clamp()}function kD(r,o){const e=this.abs(),d=r.abs();let t=e.t;for(o.t=t+d.t;--t>=0;)o[t]=0;for(t=0;t<d.t;++t)o[t+e.t]=e.am(0,d[t],o,t,0,e.t);o.s=0,o.clamp(),this.s!==r.s&&rr.ZERO.subTo(o,o)}function xD(r){const o=this.abs();let e=r.t=2*o.t;for(;--e>=0;)r[e]=0;for(e=0;e<o.t-1;++e){const d=o.am(e,o[e],r,2*e,0,1);(r[e+o.t]+=o.am(e+1,2*o[e],r,2*e+1,d,o.t-e-1))>=o.DV&&(r[e+o.t]-=o.DV,r[e+o.t+1]=1)}r.t>0&&(r[r.t-1]+=o.am(e,o[e],r,2*e,0,1)),r.s=0,r.clamp()}function gD(r,o,e){const d=r.abs();if(d.t<=0)return;const t=this.abs();if(t.t<d.t){o?.fromInt(0),e!=null&&this.copyTo(e);return}e===null&&(e=so());const l=so(),i=this.s,a=r.s,w=this.DB-M4(d[d.t-1]);w>0?(d.lShiftTo(w,l),t.lShiftTo(w,e)):(d.copyTo(l),t.copyTo(e));const b=l.t,n=l[b-1];if(n===0)return;const s=n*(1<<this.F1)+(b>1?l[b-2]>>this.F2:0),p=this.FV/s,m=(1<<this.F1)/s,h=1<<this.F2;let f=e.t,k=f-b;const x=o===null?so():o;for(l.dlShiftTo(k,x),e.compareTo(x)>=0&&(e[e.t++]=1,e.subTo(x,e)),rr.ONE.dlShiftTo(b,x),x.subTo(l,l);l.t<b;)l[l.t++]=0;for(;--k>=0;){let c=e[--f]===n?this.DM:Math.floor(e[f]*p+(e[f-1]+h)*m);if((e[f]+=l.am(0,c,e,k,0,b))<c)for(l.dlShiftTo(k,x),e.subTo(x,e);e[f]<--c;)e.subTo(x,e)}o!==null&&(e.drShiftTo(b,o),i!==a&&rr.ZERO.subTo(o,o)),e.t=b,e.clamp(),w>0&&e.rShiftTo(w,e),i<0&&rr.ZERO.subTo(e,e)}function cD(r){const o=so();return this.abs().divRemTo(r,null,o),this.s<0&&o.compareTo(rr.ZERO)>0&&r.subTo(o,o),o}function uD(){if(this.t<1)return 0;const r=this[0];if((r&1)===0)return 0;let o=r&3;return o=o*(2-(r&15)*o)&15,o=o*(2-(r&255)*o)&255,o=o*(2-((r&65535)*o&65535))&65535,o=o*(2-r*o%this.DV)%this.DV,o>0?this.DV-o:-o}function FD(r){return this.compareTo(r)===0}function AD(r,o){let e=0,d=0;const t=Math.min(r.t,this.t);for(;e<t;)d+=this[e]+r[e],o[e++]=d&this.DM,d>>=this.DB;if(r.t<this.t){for(d+=r.s;e<this.t;)d+=this[e],o[e++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;e<r.t;)d+=r[e],o[e++]=d&this.DM,d>>=this.DB;d+=r.s}o.s=d<0?-1:0,d>0?o[e++]=d:d<-1&&(o[e++]=this.DV+d),o.t=e,o.clamp()}function yD(r){const o=so();return this.addTo(r,o),o}function ED(r){const o=so();return this.subTo(r,o),o}function DD(r){const o=so();return this.multiplyTo(r,o),o}function vD(r){const o=so();return this.divRemTo(r,o,null),o}function Qd(r){this.m=r,this.mp=r.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<r.DB-15)-1,this.mt2=2*r.t}function SD(r){const o=so();return r.abs().dlShiftTo(this.m.t,o),o.divRemTo(this.m,null,o),r.s<0&&o.compareTo(rr.ZERO)>0&&this.m.subTo(o,o),o}function _D(r){const o=so();return r.copyTo(o),this.reduce(o),o}function CD(r){for(;r.t<=this.mt2;)r[r.t++]=0;for(let o=0;o<this.m.t;++o){let e=r[o]&32767;const d=e*this.mpl+((e*this.mph+(r[o]>>15)*this.mpl&this.um)<<15)&r.DM;for(e=o+this.m.t,r[e]+=this.m.am(0,d,r,o,0,this.m.t);r[e]>=r.DV;)r[e]-=r.DV,r[++e]++}r.clamp(),r.drShiftTo(this.m.t,r),r.compareTo(this.m)>=0&&r.subTo(this.m,r)}function BD(r,o){r.squareTo(o),this.reduce(o)}function ID(r,o,e){r.multiplyTo(o,e),this.reduce(e)}Qd.prototype.convert=SD,Qd.prototype.revert=_D,Qd.prototype.reduce=CD,Qd.prototype.mulTo=ID,Qd.prototype.sqrTo=BD;function TD(r,o,e){let d=r.bitLength(),t,l=R4(1);const i=new Qd(o);if(d<=0)return l;d<18?t=1:d<48?t=3:d<144?t=4:d<768?t=5:t=6;const a=[];let w=3;const b=t-1,n=(1<<t)-1;if(a[1]=i.convert(this),t>1){const x=so();for(i.sqrTo(a[1],x);w<=n;)a[w]=so(),i.mulTo(x,a[w-2],a[w]),w+=2}let s=r.t-1,p,m=!0,h=so(),f;for(d=M4(r[s])-1;s>=0;){for(d>=b?p=r[s]>>d-b&n:(p=(r[s]&(1<<d+1)-1)<<b-d,s>0&&(p|=r[s-1]>>this.DB+d-b)),w=t;(p&1)===0;)p>>=1,--w;if((d-=w)<0&&(d+=this.DB,--s),m)a[p].copyTo(l),m=!1;else{for(;w>1;)i.sqrTo(l,h),i.sqrTo(h,l),w-=2;w>0?i.sqrTo(l,h):(f=l,l=h,h=f),i.mulTo(h,a[p],l)}for(;s>=0&&(r[s]&1<<d)===0;)i.sqrTo(l,h),f=l,l=h,h=f,--d<0&&(d=this.DB-1,--s)}const k=i.revert(l);return e(null,k),k}rr.prototype.copyTo=eD,rr.prototype.fromInt=dD,rr.prototype.fromString=tD,rr.prototype.clamp=lD,rr.prototype.dlShiftTo=sD,rr.prototype.drShiftTo=pD,rr.prototype.lShiftTo=fD,rr.prototype.rShiftTo=hD,rr.prototype.subTo=mD,rr.prototype.multiplyTo=kD,rr.prototype.squareTo=xD,rr.prototype.divRemTo=gD,rr.prototype.invDigit=uD,rr.prototype.addTo=AD,rr.prototype.toString=iD,rr.prototype.negate=aD,rr.prototype.abs=wD,rr.prototype.compareTo=bD,rr.prototype.bitLength=nD,rr.prototype.mod=cD,rr.prototype.equals=FD,rr.prototype.add=yD,rr.prototype.subtract=ED,rr.prototype.multiply=DD,rr.prototype.divide=vD,rr.prototype.modPow=TD,rr.ZERO=R4(0),rr.ONE=R4(1);const ND=async({a:r,g:o,k:e,x:d,B:t,N:l,U:i})=>new Promise((a,w)=>{o.modPow(d,l,(b,n)=>{if(b){w(b);return}t.subtract(e.multiply(n)).modPow(r.add(i.multiply(d)),l,(s,p)=>{if(s){w(s);return}a(p.mod(l))})})}),PD="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",bm={},$4={};for(let r=0;r<256;r++){let o=r.toString(16).toLowerCase();o.length===1&&(o=`0${o}`),bm[r]=o,$4[o]=r}const rt=r=>{if(r.length%2!==0)throw new Error("Hex encoded strings must have an even number length");const o=new Uint8Array(r.length/2);for(let e=0;e<r.length;e+=2){const d=r.slice(e,e+2).toLowerCase();if(d in $4)o[e/2]=$4[d];else throw new Error(`Cannot decode unrecognized sequence ${d} as hexadecimal`)}return o},U4=r=>{let o="";for(let e=0;e<r.byteLength;e++)o+=bm[r[e]];return o},L4=r=>{const o=new Vi;o.update(r);const e=o.digestSync(),d=U4(e);return new Array(64-d.length).join("0")+d},ea=r=>L4(rt(r)),OD=/^[89a-f]/i,ye=r=>{if(!(r instanceof rr))throw new Error("Not a BigInteger");const o=r.compareTo(rr.ZERO)<0;let e=r.abs().toString(16);if(e=e.length%2!==0?`0${e}`:e,e=OD.test(e)?`00${e}`:e,o){const d=e.split("").map(l=>{const i=~parseInt(l,16)&15;return"0123456789ABCDEF".charAt(i)}).join("");e=new rr(d,16).add(rr.ONE).toString(16),e.toUpperCase().startsWith("FF8")&&(e=e.substring(2))}return e},RD=({A:r,B:o})=>{const e=new rr(ea(ye(r)+ye(o)),16);if(e.equals(rr.ZERO))throw new Error("U cannot be zero.");return e},MD=(r,o,e)=>{const d=new Vi(o);d.update(r);const t=d.digestSync(),l=new Vi(t);return l.update(e),l.digestSync().slice(0,16)},j4=r=>{const o=new S4().random(r).toString();return rt(o)},$D=()=>tl.convert(j4(40));class UD{constructor({userPoolName:o,a:e,g:d,A:t,N:l}){this.encoder=ra,this.userPoolName=o,this.a=e,this.g=d,this.A=t,this.N=l,this.k=new rr(ea(`${ye(l)}${ye(d)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new ar({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new ar({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new ar({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(o,e){this.randomPassword=$D();const d=`${o}${e}:${this.randomPassword}`,t=L4(d),l=U4(j4(16));return this.saltToHashDevices=ye(new rr(l,16)),new Promise((i,a)=>{this.g.modPow(new rr(ea(this.saltToHashDevices+t),16),this.N,(w,b)=>{if(w){a(w);return}this.verifierDevices=ye(b),i()})})}async getPasswordAuthenticationKey({username:o,password:e,serverBValue:d,salt:t}){if(d.mod(this.N).equals(rr.ZERO))throw new Error("B cannot be zero.");const l=RD({A:this.A,B:d}),i=`${this.userPoolName}${o}:${e}`,a=L4(i),w=new rr(ea(ye(t)+a),16),b=await ND({a:this.a,g:this.g,k:this.k,x:w,B:d,N:this.N,U:l}),n=this.encoder.convert("Caldera Derived Key"),s=this.encoder.convert(""),p=new Uint8Array(n.byteLength+s.byteLength);return p.set(n,0),p.set(s,n.byteLength),MD(rt(ye(b)),rt(ye(l)),p)}}const LD=async({a:r,g:o,N:e})=>new Promise((d,t)=>{o.modPow(r,e,(l,i)=>{if(l){t(l);return}if(i.mod(e).equals(rr.ZERO)){t(new Error("Illegal parameter. A mod N cannot be 0."));return}d(i)})}),da=async r=>{const o=new rr(PD,16),e=new rr("2",16),d=jD(),t=await LD({a:d,g:e,N:o});return new UD({userPoolName:r,a:d,g:e,A:t,N:o})},jD=()=>{const r=U4(j4(128));return new rr(r,16)};async function ot({userPoolId:r,userPoolEndpoint:o,newDeviceMetadata:e,accessToken:d}){if(!e)return;const t=r.split("_")[1]||"",l=await da(t),i=e?.DeviceKey,a=e?.DeviceGroupKey;try{await l.generateHashDevice(a??"",i??"")}catch{return}const w={Salt:tl.convert(rt(l.getSaltToHashDevices())),PasswordVerifier:tl.convert(rt(l.getVerifierDevices()))},b=l.getRandomPassword();try{return await XE({endpointResolver:Yr({endpointOverride:o})})({region:Kr(r)},{AccessToken:d,DeviceName:await oE(),DeviceKey:e?.DeviceKey,DeviceSecretVerifierConfig:w}),{deviceKey:i,deviceGroupKey:a,randomPassword:b}}catch{return}}async function zD(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{username:e,signInSession:d,signInDetails:t,challengeName:l}=Ke.getState();if(l!=="WEB_AUTHN"||!e)throw new ar({name:Kd.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:i}=r;P4(!!i,Hr.InvalidPasskeyAuthenticationOptions);const a=await GE(JSON.parse(i)),w=Gi({endpointResolver:Yr({endpointOverride:o.userPoolEndpoint})}),{ChallengeName:b,ChallengeParameters:n,AuthenticationResult:s,Session:p}=await w({region:Kr(o.userPoolId),userAgentValue:xo(wo.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:e,CREDENTIAL:JSON.stringify(a)},ClientId:o.userPoolClientId,Session:d});if(Zd({signInSession:p,username:e,challengeName:b,signInDetails:t}),s)return await Gd({...s,username:e,NewDeviceMetadata:await ot({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:s.NewDeviceMetadata,accessToken:s.AccessToken}),signInDetails:t}),Ke.dispatch({type:"RESET_STATE"}),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(b==="WEB_AUTHN")throw new ar({name:Kd.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:b,challengeParameters:n}}function $o({username:r,userPoolId:o,userPoolClientId:e}){if(typeof window>"u")return;const d=window.AmazonCognitoAdvancedSecurityData;if(typeof d>"u")return;const t=d.getData(r,o,e);return t?{EncodedData:t}:{}}const VD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],HD=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],nm=()=>{const r=new Date,o=HD[r.getUTCDay()],e=VD[r.getUTCMonth()],d=r.getUTCDate();let t=r.getUTCHours();t<10&&(t=`0${t}`);let l=r.getUTCMinutes();l<10&&(l=`0${l}`);let i=r.getUTCSeconds();i<10&&(i=`0${i}`);const a=r.getUTCFullYear();return`${o} ${e} ${d} ${t}:${l}:${i} UTC ${a}`},sm=({userPoolName:r,username:o,challengeParameters:e,dateNow:d,hkdf:t})=>{const l=ra.convert(r),i=ra.convert(o),a=qD(e.SECRET_BLOCK),w=ra.convert(d),b=new Uint8Array(l.byteLength+i.byteLength+a.byteLength+w.byteLength);b.set(l,0),b.set(i,l.byteLength),b.set(a,l.byteLength+i.byteLength),b.set(w,l.byteLength+i.byteLength+a.byteLength);const n=new Vi(t);n.update(b);const s=n.digestSync();return tl.convert(s)},qD=r=>{const o="=".repeat((4-r.length%4)%4),e=(r+o).replace(/-/g,"+").replace(/_/g,"/"),d=g4.convert(e),t=new Uint8Array(d.length);for(let l=0;l<d.length;++l)t[l]=d.charCodeAt(l);return t};async function z4({username:r,config:o,clientMetadata:e,session:d,tokenOrchestrator:t}){const{userPoolId:l,userPoolEndpoint:i}=o,a=o.userPoolClientId,w=await t?.getDeviceMetadata(r);Kh(w);const b=await da(w.deviceGroupKey),n={USERNAME:r,SRP_A:b.A.toString(16),DEVICE_KEY:w.deviceKey},s={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:n,ClientMetadata:e,Session:d},p=Gi({endpointResolver:Yr({endpointOverride:i})}),{ChallengeParameters:m,Session:h}=await p({region:Kr(l)},s);return WD(r,m,e,h,b,o,t)}async function WD(r,o,e,d,t,{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a},w){const b=await w?.getDeviceMetadata(r);Kh(b);const n=new rr(o?.SRP_B,16),s=new rr(o?.SALT,16),{deviceKey:p}=b,{deviceGroupKey:m}=b,h=await t.getPasswordAuthenticationKey({username:b.deviceKey,password:b.randomPassword,serverBValue:n,salt:s}),f=nm(),k={USERNAME:o?.USERNAME??r,PASSWORD_CLAIM_SECRET_BLOCK:o?.SECRET_BLOCK,TIMESTAMP:f,PASSWORD_CLAIM_SIGNATURE:sm({username:p,userPoolName:m,challengeParameters:o,dateNow:f,hkdf:h}),DEVICE_KEY:p},x=$o({username:r,userPoolId:l,userPoolClientId:i}),c={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:i,ChallengeResponses:k,Session:d,ClientMetadata:e,UserContextData:x};return Gi({endpointResolver:Yr({endpointOverride:a})})({region:Kr(l)},c)}async function pm(r,o,e,d,t,l,i){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=l,n=a?.split("_")[1]||"",s=new rr(o?.SRP_B,16),p=new rr(o?.SALT,16),m=o?.USER_ID_FOR_SRP;if(!m)throw new ar({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const h=await t.getPasswordAuthenticationKey({username:m,password:r,serverBValue:s,salt:p}),f=nm(),k={USERNAME:m,PASSWORD_CLAIM_SECRET_BLOCK:o?.SECRET_BLOCK,TIMESTAMP:f,PASSWORD_CLAIM_SIGNATURE:sm({username:m,userPoolName:n,challengeParameters:o,dateNow:f,hkdf:h})},x=await i.getDeviceMetadata(m);x&&x.deviceKey&&(k.DEVICE_KEY=x.deviceKey);const c=$o({username:m,userPoolId:a,userPoolClientId:w}),E={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:k,ClientMetadata:e,Session:d,ClientId:w,UserContextData:c},F=await Gi({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a)},E);return F.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:m,config:l,clientMetadata:e,session:F.Session,tokenOrchestrator:i}):F}async function ta(r,o,e,d){try{return await r(...o)}catch(t){if(t instanceof ar&&t.name==="ResourceNotFoundException"&&t.message.includes("Device does not exist."))return await d.clearDeviceMetadata(e),r(...o);throw t}}function al(r){const{dispatch:o}=Ke;o({type:"SET_USERNAME",value:r})}async function fm({username:r,password:o,clientMetadata:e,config:d,tokenOrchestrator:t,authFlow:l,preferredChallenge:i}){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=d,n=a?.split("_")[1]||"",s=await da(n),p={USERNAME:r,SRP_A:s.A.toString(16)};l==="USER_AUTH"&&i&&(p.PREFERRED_CHALLENGE=i);const m=$o({username:r,userPoolId:a,userPoolClientId:w}),h={AuthFlow:l,AuthParameters:p,ClientMetadata:e,ClientId:w,UserContextData:m},k=await ll({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a),userAgentValue:xo(wo.SignIn)},h),{ChallengeParameters:x,Session:c}=k,E=x?.USERNAME??r;return al(E),k.ChallengeName==="PASSWORD_VERIFIER"?ta(pm,[o,x,e,c,s,d,t],E,t):k}const hm="userAttributes.";function KD(r){return"isSignedIn"in r&&"nextStep"in r}async function YD(r,o,e,d,t){const{userPoolClientId:l,userPoolId:i,userPoolEndpoint:a}=d,w={USERNAME:r,PASSWORD:o},b=await t.getDeviceMetadata(r);b&&b.deviceKey&&(w.DEVICE_KEY=b.deviceKey);const n=$o({username:r,userPoolId:i,userPoolClientId:l}),s={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:w,ClientMetadata:e,ClientId:l,UserContextData:n},m=await ll({endpointResolver:Yr({endpointOverride:a})})({region:Kr(i),userAgentValue:xo(wo.SignIn)},s),h=m.ChallengeParameters?.USERNAME??m.ChallengeParameters?.USER_ID_FOR_SRP??r;return al(h),m.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:h,config:d,clientMetadata:e,session:m.Session,tokenOrchestrator:t}):m}async function GD(r,o,e,d,t){return fm({username:r,password:o,clientMetadata:e,config:d,tokenOrchestrator:t,authFlow:"USER_SRP_AUTH"})}async function XD(r,o,e,d){const{userPoolClientId:t,userPoolId:l,userPoolEndpoint:i}=e,a={USERNAME:r},w=await d.getDeviceMetadata(r);w&&w.deviceKey&&(a.DEVICE_KEY=w.deviceKey);const b=$o({username:r,userPoolId:l,userPoolClientId:t}),n={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:o,ClientId:t,UserContextData:b},p=await ll({endpointResolver:Yr({endpointOverride:i})})({region:Kr(l),userAgentValue:xo(wo.SignIn)},n),m=p.ChallengeParameters?.USERNAME??r;return al(m),p.ChallengeName==="DEVICE_SRP_AUTH"?z4({username:m,config:e,clientMetadata:o,session:p.Session,tokenOrchestrator:d}):p}async function ZD(r,o,e,d,t){Sr(d);const{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a}=d,w=l?.split("_")[1]||"",b=await da(w),n={USERNAME:r,SRP_A:b.A.toString(16),CHALLENGE_NAME:"SRP_A"},s=$o({username:r,userPoolId:l,userPoolClientId:i}),p={AuthFlow:"CUSTOM_AUTH",AuthParameters:n,ClientMetadata:e,ClientId:i,UserContextData:s},m=ll({endpointResolver:Yr({endpointOverride:a})}),{ChallengeParameters:h,Session:f}=await m({region:Kr(l),userAgentValue:xo(wo.SignIn)},p),k=h?.USERNAME??r;return al(k),ta(pm,[o,h,e,f,b,d,t],k,t)}async function et(r){const{challengeName:o,challengeParameters:e,availableChallenges:d}=r,t=Tr.getConfig().Auth?.Cognito;switch(Sr(t),o){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:e}};case"MFA_SETUP":{const{signInSession:l,username:i}=Ke.getState(),a=mm(km(e.MFAS_CAN_SETUP))||[],w=o7(a),b=w.includes("TOTP"),n=w.includes("EMAIL");if(b&&n)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:w}};if(n)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(b){const s=SE({endpointResolver:Yr({endpointOverride:t.userPoolEndpoint})}),{Session:p,SecretCode:m}=await s({region:Kr(t.userPoolId)},{Session:l});return Ke.dispatch({type:"SET_SIGN_IN_SESSION",value:p}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:JD(m,i)}}}throw new ar({name:Kd.SignInException,message:`Cannot initiate MFA setup from available types: ${a}`})}case"NEW_PASSWORD_REQUIRED":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED",missingAttributes:QD(e.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:mm(km(e.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:e.CODE_DELIVERY_DELIVERY_MEDIUM,destination:e.CODE_DELIVERY_DESTINATION}}};case"SOFTWARE_TOKEN_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_TOTP_CODE"}};case"EMAIL_OTP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_EMAIL_CODE",codeDeliveryDetails:{deliveryMedium:e.CODE_DELIVERY_DELIVERY_MEDIUM,destination:e.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{const l=await zD(e);return KD(l)?l:et(l)}case"PASSWORD":case"PASSWORD_SRP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_PASSWORD"}};case"SELECT_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION",availableChallenges:d}}}throw new ar({name:Kd.SignInException,message:`An error occurred during the sign in process. ${o} challengeName returned by the underlying service was not addressed.`})}function JD(r,o){return{sharedSecret:r,getSetupUri:(e,d)=>{const t=`otpauth://totp/${e}:${d??o}?secret=${r}&issuer=${e}`;return new ol(t)}}}function wl(r){if(r===Ki.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(r===Ki.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function QD(r){return r?JSON.parse(r).map(e=>e.includes(hm)?e.replace(hm,""):e):[]}function r7(r){if(r==="SMS_MFA")return"SMS";if(r==="SOFTWARE_TOKEN_MFA")return"TOTP";if(r==="EMAIL_OTP")return"EMAIL"}function mm(r){if(r)return r.map(r7).filter(Boolean)}function km(r){return r?JSON.parse(r):[]}function o7(r){return r.filter(o=>o==="EMAIL"||o==="TOTP")}async function e7(){let r;try{r=await Gh()}catch{}if(r&&r.userId&&r.username)throw new ar({name:lE,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function bl(r){return Ke.getState().username??r}async function d7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{username:e,password:d,options:t}=r,l={loginId:e,authFlowType:"CUSTOM_WITHOUT_SRP"},i=t?.clientMetadata;Vr(!!e,sr.EmptySignInUsername),Vr(!d,sr.CustomAuthSignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ta(XD,[e,i,o,_o],e,_o),s=bl(e);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:l}),b?(await Gd({username:s,...b,NewDeviceMetadata:await ot({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:l}),we(),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),Go(a);const w=wl(a.name);if(w)return w;throw a}}async function t7(r){const{username:o,password:e,options:d}=r,t={loginId:o,authFlowType:"CUSTOM_WITH_SRP"},l=Tr.getConfig().Auth?.Cognito;Sr(l);const i=d?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ZD(o,e,i,l,_o),s=bl(o);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:t}),b?(await Gd({username:s,...b,NewDeviceMetadata:await ot({userPoolId:l.userPoolId,userPoolEndpoint:l.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:t}),we(),await Xd(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),Go(a);const w=wl(a.name);if(w)return w;throw a}}const xm=async()=>{throw new ar({name:qh,message:"The autoSignIn flow has not started, or has been cancelled/completed.",recoverySuggestion:"Please try to use the signIn API or log out before starting a new autoSignIn flow."})};let V4=xm;function H4(r){V4=r}function go(r=!0){r&&(V4=xm),We.dispatch({type:"RESET"})}async function gm(r){const{username:o,password:e}=r,d=Tr.getConfig().Auth?.Cognito,t={loginId:o,authFlowType:"USER_SRP_AUTH"};Sr(d);const l=r.options?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:i,ChallengeParameters:a,AuthenticationResult:w,Session:b}=await GD(o,e,l,d,_o),n=bl(o);return Zd({signInSession:b,username:n,challengeName:i,signInDetails:t}),w?(await Gd({username:n,...w,NewDeviceMetadata:await ot({userPoolId:d.userPoolId,userPoolEndpoint:d.userPoolEndpoint,newDeviceMetadata:w.NewDeviceMetadata,accessToken:w.AccessToken}),signInDetails:t}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:i,challengeParameters:a})}catch(i){we(),go(),Go(i);const a=wl(i.name);if(a)return a;throw i}}async function l7(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l={loginId:o,authFlowType:"USER_PASSWORD_AUTH"};Sr(t);const i=d?.clientMetadata;Vr(!!o,sr.EmptySignInUsername),Vr(!!e,sr.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:w,AuthenticationResult:b,Session:n}=await ta(YD,[o,e,i,t,_o],o,_o),s=bl(o);return Zd({signInSession:n,username:s,challengeName:a,signInDetails:l}),b?(await Gd({...b,username:s,NewDeviceMetadata:await ot({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:b.NewDeviceMetadata,accessToken:b.AccessToken}),signInDetails:l}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:a,challengeParameters:w})}catch(a){we(),go(),Go(a);const w=wl(a.name);if(w)return w;throw a}}async function i7({username:r,clientMetadata:o,config:e,tokenOrchestrator:d,preferredChallenge:t,password:l,session:i}){const{userPoolId:a,userPoolClientId:w,userPoolEndpoint:b}=e,n=$o({username:r,userPoolId:a,userPoolClientId:w}),s={USERNAME:r};if(t){if(t==="PASSWORD_SRP")return Vr(!!l,sr.EmptySignInPassword),fm({username:r,password:l,clientMetadata:o,config:e,tokenOrchestrator:d,authFlow:"USER_AUTH",preferredChallenge:t});t==="PASSWORD"&&(Vr(!!l,sr.EmptySignInPassword),s.PASSWORD=l),s.PREFERRED_CHALLENGE=t}const p={AuthFlow:"USER_AUTH",AuthParameters:s,ClientMetadata:o,ClientId:w,UserContextData:n};i&&(p.Session=i);const h=await ll({endpointResolver:Yr({endpointOverride:b})})({region:Kr(a),userAgentValue:xo(wo.SignIn)},p);return al(r),h}async function cm(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l={loginId:o,authFlowType:"USER_AUTH"};Sr(t);const i=d?.clientMetadata,a=d?.preferredChallenge;Vr(!!o,sr.EmptySignInUsername);try{const w={username:o,config:t,tokenOrchestrator:_o,clientMetadata:i,preferredChallenge:a,password:e},b=We.getState();b.active&&b.username===o&&(w.session=b.session);const n=await i7(w),s=bl(o);return Zd({signInSession:n.Session,username:s,challengeName:n.ChallengeName,signInDetails:l}),n.AuthenticationResult?(await Gd({username:s,...n.AuthenticationResult,NewDeviceMetadata:await ot({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:n.AuthenticationResult.NewDeviceMetadata,accessToken:n.AuthenticationResult.AccessToken}),signInDetails:l}),we(),await Xd(),go(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):et({challengeName:n.ChallengeName,challengeParameters:n.ChallengeParameters,availableChallenges:"AvailableChallenges"in n?n.AvailableChallenges:void 0})}catch(w){we(),go(),Go(w);const b=wl(w.name);if(b)return b;throw w}}async function q4(r){go(!1);const o=r.options?.authFlowType;switch(await e7(),o){case"USER_SRP_AUTH":return gm(r);case"USER_PASSWORD_AUTH":return l7(r);case"CUSTOM_WITHOUT_SRP":return d7(r);case"CUSTOM_WITH_SRP":return t7(r);case"USER_AUTH":return cm(r);default:return gm(r)}}const um=180*1e3;function a7(r){const o=Li.listen("auth-internal",async({payload:d})=>{switch(d.event){case"confirmSignUp":d.data?.isSignUpComplete&&(Li.dispatch("auth-internal",{event:"autoSignIn"}),H4(Am(r)),o())}}),e=setTimeout(()=>{o(),clearTimeout(e),go()},um)}function Fm(r,o){let e;return d=>{e||r(...d),clearTimeout(e),e=setTimeout(()=>{e=void 0},o)}}function w7(r,o,e){const d=Date.now(),t=setInterval(async()=>{if(Date.now()-d>um)clearInterval(t),e(new ar({name:qh,message:"The account was not confirmed on time.",recoverySuggestion:"Try to verify your account by clicking the link sent your email or phone and then login manually."})),go();else try{const a=await q4(r);a.nextStep.signInStep!=="CONFIRM_SIGN_UP"&&(o(a),clearInterval(t),go())}catch(a){clearInterval(t),e(a),go()}},5e3)}const b7=Fm(w7,300),n7=Fm(p7,300);function s7(r){return async()=>new Promise((o,e)=>{b7([r,o,e])})}async function p7(r,o,e){try{const d=r?.options?.authFlowType==="USER_AUTH"?await cm(r):await q4(r);o(d),go()}catch(d){e(d),go()}}function Am(r){return async()=>new Promise((o,e)=>{n7([r,o,e])})}const f7=Am,h7=()=>async r=>{if(r.statusCode>=300){const o=await Wd(r);if(Go(o),o.name===C4.InvalidParameterException&&/'password'/.test(o.message)&&/Member must not be null/.test(o.message)){const e=sr.EmptySignUpPassword,{message:d,recoverySuggestion:t}=uh[e];throw new ar({name:e,message:d,recoverySuggestion:t})}throw new ar({name:o.name,message:o.message})}return rl(r)},m7=r=>no(vo,Do("SignUp"),h7(),{...So,...r});async function k7(r){const{username:o,password:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito,l=t?.signUpVerificationMethod??"code",{clientMetadata:i,validationData:a,autoSignIn:w}=r.options??{};Sr(t),Vr(!!o,sr.EmptySignUpUsername);const b=typeof w!="boolean"?w:void 0,n={username:o,options:b};b?.authFlowType!=="CUSTOM_WITHOUT_SRP"&&(n.password=e);const{userPoolId:s,userPoolClientId:p,userPoolEndpoint:m}=t,h=m7({endpointResolver:Yr({endpointOverride:m})}),f={Username:o,Password:void 0,UserAttributes:d?.userAttributes&&Ah(d?.userAttributes),ClientMetadata:i,ValidationData:a&&Ah(a),ClientId:p,UserContextData:$o({username:o,userPoolId:s,userPoolClientId:p})};e&&(f.Password=e);const{UserSub:k,CodeDeliveryDetails:x,UserConfirmed:c,Session:E}=await h({region:Kr(s),userAgentValue:xo(wo.SignUp)},f);(b||w===!0)&&(We.dispatch({type:"START"}),We.dispatch({type:"SET_USERNAME",value:o}),We.dispatch({type:"SET_SESSION",value:E}));const y={destination:x?.Destination,deliveryMedium:x?.DeliveryMedium,attributeName:x?.AttributeName},F=!!c,I=We.getState().active;if(F)return I?(H4(f7(n)),{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:k}):{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:k};if(I){if(l==="link")return H4(s7(n)),{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:y},userId:k};a7(n)}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:y},userId:k}}const x7=r=>no(vo,Do("ForgotPassword"),Ro(),{...So,...r});async function g7(r){const{username:o}=r;Vr(!!o,sr.EmptyResetPasswordUsername);const e=Tr.getConfig().Auth?.Cognito;Sr(e);const{userPoolClientId:d,userPoolId:t,userPoolEndpoint:l}=e,i=r.options?.clientMetadata,a=$o({username:o,userPoolId:t,userPoolClientId:d}),n=(await x7({endpointResolver:Yr({endpointOverride:l})})({region:Kr(t),userAgentValue:xo(wo.ResetPassword)},{Username:o,ClientMetadata:i,ClientId:d,UserContextData:a})).CodeDeliveryDetails;return{isPasswordReset:!1,nextStep:{resetPasswordStep:"CONFIRM_RESET_PASSWORD_WITH_CODE",codeDeliveryDetails:{deliveryMedium:n?.DeliveryMedium,destination:n?.Destination,attributeName:n?.AttributeName}}}}const c7=r=>no(vo,Do("ConfirmForgotPassword"),Ro(),{...So,...r});async function u7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{userPoolClientId:e,userPoolId:d,userPoolEndpoint:t}=o,{username:l,newPassword:i}=r;Vr(!!l,sr.EmptyConfirmResetPasswordUsername),Vr(!!i,sr.EmptyConfirmResetPasswordNewPassword);const a=r.confirmationCode;Vr(!!a,sr.EmptyConfirmResetPasswordConfirmationCode);const w=r.options?.clientMetadata,b=$o({username:l,userPoolId:d,userPoolClientId:e});await c7({endpointResolver:Yr({endpointOverride:t})})({region:Kr(o.userPoolId),userAgentValue:xo(wo.ConfirmResetPassword)},{Username:l,ConfirmationCode:a,Password:i,ClientMetadata:w,ClientId:o.userPoolClientId,UserContextData:b})}const F7=r=>no(vo,Do("ResendConfirmationCode"),Ro(),{...So,...r});async function A7(r){const{username:o}=r;Vr(!!o,sr.EmptySignUpUsername);const e=Tr.getConfig().Auth?.Cognito;Sr(e);const{userPoolClientId:d,userPoolId:t,userPoolEndpoint:l}=e,i=r.options?.clientMetadata,a=$o({username:o,userPoolId:t,userPoolClientId:d}),w=F7({endpointResolver:Yr({endpointOverride:l})}),{CodeDeliveryDetails:b}=await w({region:Kr(e.userPoolId),userAgentValue:xo(wo.ResendSignUpCode)},{Username:o,ClientMetadata:i,ClientId:e.userPoolClientId,UserContextData:a}),{DeliveryMedium:n,AttributeName:s,Destination:p}={...b};return{destination:p,deliveryMedium:n,attributeName:s||void 0}}const y7=r=>no(vo,Do("ConfirmSignUp"),Ro(),{...So,...r});async function E7(r){const{username:o,confirmationCode:e,options:d}=r,t=Tr.getConfig().Auth?.Cognito;Sr(t);const{userPoolId:l,userPoolClientId:i,userPoolEndpoint:a}=t,w=d?.clientMetadata;Vr(!!o,sr.EmptyConfirmSignUpUsername),Vr(!!e,sr.EmptyConfirmSignUpCode);const b=$o({username:o,userPoolId:l,userPoolClientId:i}),n=y7({endpointResolver:Yr({endpointOverride:a})}),{Session:s}=await n({region:Kr(t.userPoolId),userAgentValue:xo(wo.ConfirmSignUp)},{Username:o,ConfirmationCode:e,ClientMetadata:w,ForceAliasCreation:d?.forceAliasCreation,ClientId:t.userPoolClientId,UserContextData:b});return new Promise((p,m)=>{try{const h={isSignUpComplete:!0,nextStep:{signUpStep:"DONE"}},f=We.getState();if(!f.active||f.username!==o){p(h),go();return}We.dispatch({type:"SET_SESSION",value:s});const k=Li.listen("auth-internal",({payload:x})=>{switch(x.event){case"autoSignIn":p({isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"}}),k()}});Li.dispatch("auth-internal",{event:"confirmSignUp",data:h})}catch(h){m(h)}})}const D7=r=>no(vo,Do("ChangePassword"),Ro(),{...So,...r});async function v7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o);const{userPoolEndpoint:e,userPoolId:d}=o,{oldPassword:t,newPassword:l}=r;Vr(!!t,sr.EmptyUpdatePassword),Vr(!!l,sr.EmptyUpdatePassword);const{tokens:i}=await Jf({forceRefresh:!1});B4(i),await D7({endpointResolver:Yr({endpointOverride:e})})({region:Kr(d),userAgentValue:xo(wo.UpdatePassword)},{AccessToken:i.accessToken.toString(),PreviousPassword:t,ProposedPassword:l})}function S7(r,o){if(o){const e=r?.find(d=>d===o);if(!e)throw sE;return e}else{const e=r?.find(_7)??r?.find(C7),d=r?.find(I7)??r?.find(B7);if(e)return e;throw d?fE:nE}}const _7=r=>r.startsWith(String(window.location.origin+(window.location.pathname||"/"))),C7=r=>r.includes(String(window.location.hostname)),B7=r=>r.startsWith("http://"),I7=r=>r.startsWith("https://"),T7=async r=>{window?.location&&(window.location.href=r.replace("http://","https://"))},N7=async r=>{await r.clearOAuthData(),_o.clearTokens(),await Qf(),Hd.dispatch("auth",{event:"signedOut"},"Auth",pd)},P7=async(r,o=!1,e)=>{Sf(r);const{loginWith:d,userPoolClientId:t}=r,{domain:l,redirectSignOut:i}=d.oauth,a=S7(i,e),w=`https://${l}/logout?${Object.entries({client_id:t,logout_uri:encodeURIComponent(a)}).map(([b,n])=>`${b}=${n}`).join("&")}`;return T7(w)},O7=async(r,o,e,d)=>{const{isOAuthSignIn:t}=await o.loadOAuthSignIn(),l=await e.getOAuthMetadata();if(await N7(o),t||l?.oauthSignIn)return P7(r,!1,d)},R7=r=>no(vo,Do("RevokeToken"),Ro(),{...So,...r}),M7=r=>no(vo,Do("GlobalSignOut"),Ro(),{...So,...r}),ym=new Eo("Auth");async function $7(r){const o=Tr.getConfig().Auth?.Cognito;Sr(o),r?.global?await L7(o):await U7(o);let e;try{Sf(o),e=!0}catch{e=!1}if(e){const d=new Qh(dl);d.setAuthConfig(o);const{type:t}=await O7(o,d,_o,r?.oauth?.redirectUrl)??{};if(t==="error")throw new ar({name:hE,message:"An error occurred when attempting to log out from OAuth provider."})}else _o.clearTokens(),await Qf(),Hd.dispatch("auth",{event:"signedOut"},"Auth",pd)}async function U7(r){try{const{userPoolEndpoint:o,userPoolId:e,userPoolClientId:d}=r,t=await _o.getTokenStore().loadTokens();Wh(t),j7(t.accessToken)&&await R7({endpointResolver:Yr({endpointOverride:o})})({region:Kr(e),userAgentValue:xo(wo.SignOut)},{ClientId:d,Token:t.refreshToken})}catch{ym.debug("Client signOut error caught but will proceed with token removal")}}async function L7(r){try{const{userPoolEndpoint:o,userPoolId:e}=r,d=await _o.getTokenStore().loadTokens();B4(d),await M7({endpointResolver:Yr({endpointOverride:o})})({region:Kr(e),userAgentValue:xo(wo.SignOut)},{AccessToken:d.accessToken.toString()})}catch{ym.debug("Global signOut error caught but will proceed with token removal")}}const j7=r=>!!r?.payload?.origin_jti,z7={identityId:"identityId"},V7=new Eo("DefaultIdentityIdStore");class Em{setAuthConfig(o){ji(o.Cognito),this.authConfig=o,this._authKeys=H7("Cognito",o.Cognito.identityPoolId)}constructor(o){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=o}async loadIdentityId(){ji(this.authConfig?.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{const o=await this.keyValueStorage.getItem(this._authKeys.identityId);return o?(this._hasGuestIdentityId=!0,{id:o,type:"guest"}):null}}catch(o){return V7.log("Error getting stored IdentityId.",o),null}}async storeIdentityId(o){ji(this.authConfig?.Cognito),o.type==="guest"?(this.keyValueStorage.setItem(this._authKeys.identityId,o.id),this._primaryIdentityId=void 0,this._hasGuestIdentityId=!0):(this._primaryIdentityId=o.id,this._hasGuestIdentityId&&(this.keyValueStorage.removeItem(this._authKeys.identityId),this._hasGuestIdentityId=!1))}async clearIdentityId(){this._primaryIdentityId=void 0,await this.keyValueStorage.removeItem(this._authKeys.identityId)}}const H7=(r,o)=>I4(z7)(`com.amplify.${r}`,o),W4=({endpointOverride:r})=>o=>r?{url:new ol(r)}:Y8(o);function Dm(r){const o=fd(r).payload.iss,e={};if(!o)throw new ar({name:"InvalidIdTokenException",message:"Invalid Idtoken."});const d=o.replace(/(^\w+:|^)\/\//,"");return e[d]=r,e}async function q7({tokens:r,authConfig:o,identityIdStore:e}){e.setAuthConfig({Cognito:o});const d=await e.loadIdentityId();if(d)return d.id;const t=r?.idToken?Dm(r.idToken.toString()):{},l=await W7(t,o);return e.storeIdentityId({id:l,type:r?"primary":"guest"}),l}async function W7(r,o){const e=o?.identityPoolId,d=_4(e),t=q8({endpointResolver:W4({endpointOverride:o.identityPoolEndpoint})});let l;try{l=(await t({region:d},{IdentityPoolId:e,Logins:r})).IdentityId}catch(i){throw Go(i),new ar(i)}if(!l)throw new ar({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return l}const la=new Eo("CognitoCredentialsProvider"),vm=3e3*1e3;class Sm{constructor(o){this._nextCredentialsRefresh=0,this._identityIdStore=o}async clearCredentialsAndIdentityId(){la.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){la.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(o){const e=o.authenticated,{tokens:d}=o,{authConfig:t}=o;try{ji(t?.Cognito)}catch{return}if(!e&&!t.Cognito.allowGuestAccess)return;const{forceRefresh:l}=o,i=this.hasTokenChanged(d),a=await q7({tokens:d,authConfig:t.Cognito,identityIdStore:this._identityIdStore});return(l||i)&&this.clearCredentials(),e?(xE(d),this.credsForOIDCTokens(t.Cognito,d,a)):this.getGuestCredentials(a,t.Cognito)}async getGuestCredentials(o,e){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return la.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const d=_4(e.identityPoolId),t=sh({endpointResolver:W4({endpointOverride:e.identityPoolEndpoint})});let l;try{l=await t({region:d},{IdentityId:o})}catch(i){throw Go(i),new ar(i)}if(l?.Credentials?.AccessKeyId&&l?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+vm;const i={credentials:{accessKeyId:l.Credentials.AccessKeyId,secretAccessKey:l.Credentials.SecretKey,sessionToken:l.Credentials.SessionToken,expiration:l.Credentials.Expiration},identityId:o};return l.IdentityId&&(i.identityId=l.IdentityId,this._identityIdStore.storeIdentityId({id:l.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...i,isAuthenticatedCreds:!1},i}else throw new ar({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(o,e,d){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return la.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const t=e.idToken?Dm(e.idToken.toString()):{},l=_4(o.identityPoolId),i=sh({endpointResolver:W4({endpointOverride:o.identityPoolEndpoint})});let a;try{a=await i({region:l},{IdentityId:d,Logins:t})}catch(w){throw Go(w),new ar(w)}if(a?.Credentials?.AccessKeyId&&a?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+vm;const w={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:d};return a.IdentityId&&(w.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...w,isAuthenticatedCreds:!0,associatedIdToken:e.idToken?.toString()},w}else throw new ar({name:"CredentialsException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}isPastTTL(){return this._nextCredentialsRefresh===void 0?!0:this._nextCredentialsRefresh<=Date.now()}hasTokenChanged(o){return!!o&&!!this._credentialsAndIdentityId?.associatedIdToken&&o.idToken?.toString()!==this._credentialsAndIdentityId.associatedIdToken}}const K7=new Sm(new Em(dl)),Y7={configure(r,o){const e=Nf(r),d=new gh({sameSite:"lax"}),t=o?.ssr?d:dl,l=o?.ssr?new Sm(new Em(d)):K7;if(!e.Auth){Tr.configure(e,o);return}if(o?.Auth){Tr.configure(e,o);return}if(!Tr.libraryOptions.Auth){Yd.setAuthConfig(e.Auth),Yd.setKeyValueStorage(t),Tr.configure(e,{...o,Auth:{tokenProvider:Yd,credentialsProvider:l}});return}if(o){const i=Tr.libraryOptions.Auth;o.ssr!==void 0&&(Yd.setKeyValueStorage(t),i.credentialsProvider=l),Tr.configure(e,{Auth:i,...o});return}Tr.configure(e)},getConfig(){return Tr.getConfig()}},G7={Auth:{Cognito:{userPoolId:"ap-south-1_es4yWY1O9",userPoolClientId:"7hte1nkjug6rqsf9air6021aqr",userPoolEndpoint:"https://cognito-idp.ap-south-1.amazonaws.com/"}}};Y7.configure(G7),Yd.setKeyValueStorage(new gh({domain:"localhost",secure:!0,path:"/",expires:30}));const _m={signIn:q4,autoSignIn:V4,signUp:k7,fetchAuthSession:Jf,resetPassword:g7,confirmResetPassword:u7,resendSignUpCode:A7,confirmSignUp:E7,updatePassword:v7,signOut:$7},nl=r=>{if(typeof window<"u"){const{cookie:o}=document,e=o?.split(";")?.find(t=>t?.includes(r));if(!e)return["",""];const d=e?.split("=");return d.length<=1?["",""]:d}return["",""]},Cm=(r,o,e)=>{const d=new Date;d.setTime(d.getTime()+e*24*60*60*1e3);const t="expires="+d.toUTCString();document.cookie=r+"="+o+";"+t+";domain=."+process.env.NEXT_PUBLIC_DOMAIN+";path=/"};async function X7(){try{await _m.signOut()}catch(r){console.log("error signing out: ",r)}}const Bm={jwtExpired:"jwt expired",notLogin:"User must be logged in"},K4=Gt.get();typeof K4=="object"&&Object.entries(K4).length&&Object?.entries(K4)?.forEach(([r,o])=>{r.endsWith("accessToken")});let ia="";typeof window<"u"&&(ia=window.location.href),ia.includes("invite-user")||ia.includes("mailOpened")||ia.includes("/email?"),Rr.interceptors.request.use(async r=>{const o=window.location.pathname?.split("/").find(d=>parseInt(d))??nl(Ef.workspaceId)[1];r.headers["x-tenant-id"]||(r.headers["x-tenant-id"]=o?o.toString():"");const e=nl("accessToken");return r.headers.authorization=`${e[1]}`,{...r}},r=>Promise.reject(r)),Rr.interceptors.response.use(r=>r,async r=>{const e=FA(r.config,"url","").split("/");return((r.response?.data?.message??"")===Bm.jwtExpired||(r.response?.data?.message??"")===Bm.notLogin)&&(nl("count")[1]==="1"&&(await X7(),Cm("count","0",0),window.location.href.includes("auth/")||(window.location.pathname=by.login)),await _m.fetchAuthSession(),window.location.href.includes("auth/")||(Cm("count","1",1),window.location.reload())),r.response?.status===401&&!e.includes("validate-user")&&window.location.reload(),Promise.reject(r.response)});const Z7=()=>{const r=window.location.pathname.split("/").find(e=>parseInt(e))??nl(Ef.workspaceId)[1],o=nl("accessToken");return{"x-tenant-id":r?r.toString():"",authorization:`${o[1]}`}},Im=ay((r,{headers:o})=>({headers:{...o,...Z7()}})),J7=Jr.createHttpLink({uri:Jw.clientGraphqlUrl}),Q7=Jr.createHttpLink({uri:Jw.serverGraphqlUrl}),Y4=new Jr.ApolloClient({cache:new Jr.InMemoryCache({}),link:Jr.ApolloLink.from([Im,J7]),queryDeduplication:!1,devtools:{enabled:!0}}),Tm=new Jr.ApolloClient({cache:new Jr.InMemoryCache({}),link:Jr.ApolloLink.from([Im,Q7]),queryDeduplication:!1,devtools:{enabled:!0}}),r9=Jr.gql`
|
|
154
154
|
query GetAccessUserList($input: UserManagementInputDto!) {
|
|
155
155
|
getAccessUserList(input: $input) {
|
|
156
156
|
id
|
|
@@ -184,4 +184,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
184
184
|
name
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
`,d9=(r,o,e=void 0)=>{const d=o.split(".");let t=r;for(const l of d)if(t&&typeof t=="object"&&l in t)t=t[l];else return e;return t},Pm=r=>r==null?!0:typeof r=="string"||Array.isArray(r)?r.length===0:typeof r=="object"?Object.keys(r).length===0:!1,t9=r=>{const o=typeof r=="string"?r:d9(r,"props.children","");let e=RegExp(/\b\w/g).exec(o);return Pm(e)||(e=((e.shift()||"")+(e.pop()||"")).toUpperCase()),e},l9=r=>r?.toLowerCase().split(/[\s\-_]+/).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),i9=({data:r,value:o})=>u.jsxs("div",{className:"d-flex align-center justify-between flex-1 text-truncate",id:"selection-ownerList",children:[u.jsx("div",{className:"user-oval-32 rounded-circle mr-2 bg-blue-lighten1",children:r.picture?u.jsx(tr.Avatar,{className:"w-100 h-100 rounded-circle",sx:{width:32,height:32},src:r.picture,alt:"profile"}):u.jsx("div",{className:"user-oval-32 rounded-circle align-center d-flex justify-around",children:u.jsx("p",{className:"f-11 f-w-500 txt-secondary-color font-600 align-center d-flex",children:t9(r.name)})})}),u.jsxs("div",{className:"flex-1 text-truncate ml-4 l-h-18",children:[u.jsx("p",{className:"f-14 f-w-400 text-truncate m-0",children:l9(r.name)}),u.jsx("p",{className:"f-12 f-w-400 txt-darken1 text-truncate m-0",children:r.roleName||"--"})]}),o===r.id?u.jsx("div",{className:"f-20 txt-bllue-darken8",children:u.jsx(wb.CheckOutlined,{className:"f-20 txt-bllue-darken8"})}):u.jsx(u.Fragment,{})]}),Ge=g.createContext(null),Om=({selectedAssignees:r,setValue:o,datasetId:e,isForNotification:d=!1})=>{const[t,l]=g.useState([]),[i,a]=g.useState(""),[w,b]=g.useState(!1),{acceptedUser:n,workspaceId:s,validateUser:p}=g.useContext(Ge),m={data:[{id:"b324369714a1420bbbc73d94c2178931",firstName:"guna",lastName:"lan",name:"guna lan",email:"guna@mailsac.com",teamId:null,privilege:[],teamName:null,roleName:"Super Admin",picture:"",timeZone:"",language:"en",dateFormat:null,timeFormat:null,weekStartsOn:"sunday"}]},{data:h}=Jr.useQuery(r9,{variables:{input:{datasetId:e,searchKey:i,workspaceId:Number(s),userId:p.id}},fetchPolicy:"network-only",client:Tm}),f=x=>{let c;t.some(E=>E.id===x.id)?c=t.filter(E=>E.id!==x.id):c=[...t,x],l(c),o(c.map(E=>E.id))},k=x=>{const c=t.filter(E=>E.id!==x);l(c),o(c.map(E=>E.id))};return w?u.jsx(tr.ClickAwayListener,{onClickAway:()=>b(!1),children:u.jsxs("div",{className:"h-34px w-380px position-relative bg-white",children:[t.length?u.jsx("div",{className:"d-flex align-center flex-wrap bg-white z-index-100",children:t?.map(x=>u.jsxs("div",{className:"h-34px d-flex align-center justify-between px-8 cursor-pointer radius-4 hover-show-container border-solid-popper-border ml-4 mt-4",onClick:()=>{k(x.id)},children:[u.jsx("div",{className:"f-14 f-w-500 txt-blue-darken10 ",children:x.name}),u.jsx(NA,{className:"f-20 ml-6"})]},x.id))}):u.jsx("div",{className:"h-34px w-380px d-flex align-center justify-between px-8 cursor-pointer radius-4 hover-show-container",onClick:()=>{},children:"--"}),u.jsx("div",{className:"position-relative",children:u.jsx("div",{className:`position-absolute ${t.length?"top-10px":"top--25px"} radius-8 search-mapdataset z-index-1000 bg-white`,children:u.jsxs("div",{className:"w-380px minh-46px radius-8 popper-border-solid-popper-border",children:[u.jsx("div",{className:"h-46px bg-grey-lighten4 boder-b-solid-popper-border tl-radius-8 tr-radius-8 p-10 d-flex align-center",children:u.jsx(tr.TextField,{sx:{input:{"&::placeholder":{color:Ni["success-disabled"],opacity:100}}},fullWidth:!0,className:"mapdataset-dropdown",id:"single-line",variant:"standard",placeholder:"Search",value:i,onChange:x=>a(x.target.value),autoComplete:"off",autoFocus:!0})}),!h?.getAccessUserList?.length&&i?u.jsx("div",{className:"p-10",children:u.jsx("div",{className:"d-flex align-center multi-select",children:u.jsxs("div",{className:"h-36px d-flex align-center f-w-400 f-14 txt-brown-dark1 pl-8 cursor-pointer",children:[u.jsx("p",{className:" f-w-600 txt-text-grey-primary mr-4",children:"user not found"})," ",` "${i}"`]})},"new-associate")}):u.jsx("div",{className:"bg-white maxh-202px overflow-auto p-8 px-6 bl-radius-8 br-radius-8",children:h?.getAccessUserList?.map((x,c)=>u.jsx("div",{className:` radius-4 px-10 py-8 ${h?.getAccessUserList?.length!==c+1?"mb-4":""} bg-hover-grey-lighten4 cursor-pointer d-flex align-center justify-between hover-show-container ${t?.some(E=>E.id===x.id)?"bg-blue-lighten9":""}`,onClick:()=>{f(x)},children:u.jsxs("div",{className:"d-flex align-center",children:[u.jsx(tr.Checkbox,{checked:t?.some(E=>E.id===x.id),size:"small"},x.id),u.jsx(i9,{data:x,value:""})]})},x.id))})]})})})]})}):u.jsx(u.Fragment,{children:d?u.jsx("div",{style:{textDecoration:"underline",textUnderlineOffset:"2px"},className:"pl-4",onClick:()=>b(!0),children:r.length?r?.map((x,c)=>{const E=n.find(y=>y.id===x);return u.jsx("span",{children:E?.name+`${r.length-1===c?"":","}`})}):u.jsx("div",{className:"",children:" select user"})}):u.jsxs("div",{className:"d-flex h-40px maxh-40px radius-8 border-solid-border px-12 align-center justify-between",onClick:()=>b(!0),children:[u.jsx(a9,{assignTo:r,acceptedUserData:m.data}),u.jsx(rf,{})]})})},a9=({assignTo:r,acceptedUserData:o})=>{const e=r?.map(t=>o?.find(l=>l.id===t)),d=e?.length>4?e.slice(0,4):e;return d?.length?u.jsxs("div",{className:"d-flex align-center",id:"dataCollab-view",children:[d?.map(t=>t?.picture?u.jsx(tr.Avatar,{className:"w-100 h-100 rounded-circle mr-4",sx:{width:32,height:32},src:t.picture,alt:"profile"},t?.id):u.jsx("div",{className:"w-32px h-32px radius-360 bg-orange-lighten5 d-flex align-center justify-center f-10 f-w-500 txt-primary mr-4",children:`${t?.firstName?Xp(t?.firstName[0]):""}${t?.lastName?Xp(t?.lastName[0]):""}`},t?.id)),e?.length>4&&u.jsxs("div",{className:"w-24px h-24px p-2 radius-360 bg-avatarColor txt-blue-darken10 d-flex align-center justify-center avatar",children:["+",e.length-4]})]}):"--"},w9=({options:r,defaultValue:o=[],setValue:e})=>{const[d,t]=g.useState(""),[l,i]=g.useState(o),[a,w]=g.useState(0),b=g.useRef(null),[n,s]=g.useState(!1);g.useEffect(()=>{b.current&&w(b.current.offsetHeight)},[l]);const p=m=>{let h;l.some(f=>f.id===m.id)?h=l.filter(f=>f.id!==m.id):h=[...l,m],i(h),e(h)};return n?u.jsx("div",{className:" bg-white w-380px h-46px border-solid-input-border radius-8 ",children:u.jsx(tr.ClickAwayListener,{onClickAway:()=>{s(!1)},children:u.jsxs("div",{className:"position-relative",children:[u.jsx("div",{ref:b,className:" w-100 res-chip-min-height h-100 radius-4 bg-white d-flex align-center d-flex flex-wrap py-4 gap-8 px-12",children:l.length?u.jsx(u.Fragment,{children:l?.map((m,h)=>u.jsx(tr.Chip,{label:m.displayName,onDelete:()=>p(m),sx:{bgcolor:Ni["popper-border"],border:0,borderRadius:2,margin:"0 !important",padding:"6px 8px 6px 8px",gap:1,".MuiChip-label":{fontSize:14,fontFamily:"Inter, sans-serif !important"}},deleteIcon:u.jsx(wb.CloseOutlined,{sx:{fontSize:"16px",color:m.statusColor?"#fff":"grey"},className:"cursor-pointer icon-close"}),variant:"outlined"},h))}):u.jsx("div",{className:"ml-10 d-flex align-center f-14 txt-text-grey-hint",children:"No fields"})}),u.jsx("div",{className:"position-absolute radius-8 search-mapdataset z-index-1000",style:{top:`${a+4}px`},children:u.jsxs("div",{className:"w-380px minh-46px radius-8 popper-border-solid-popper-border",children:[u.jsx("div",{className:"h-46px bg-grey-lighten4 boder-b-solid-popper-border tl-radius-4 tr-radius-8 p-10",children:u.jsx(tr.TextField,{sx:{input:{"&::placeholder":{color:Ni["success-disabled"],opacity:100}}},fullWidth:!0,className:"mapdataset-dropdown",variant:"standard",placeholder:"Search",value:d,onChange:m=>t(m.target.value),autoFocus:!0})}),u.jsx("div",{className:"bg-white maxh-200px overflow-auto w-100 py-8 px-6 bl-radius-8 br-radius-8",children:u.jsx(u.Fragment,{children:r?.filter(m=>m.displayName.toLowerCase().includes(d.toLowerCase()))?.map(m=>u.jsxs("div",{className:` h-36px radius-4 px-10 py-8 mb-2 bg-hover-grey-lighten4 cursor-pointer d-flex justify-start hover-show-container align-center ${l.some(h=>h.id===m.id)?"bg-blue-lighten9 txt-blue-darken10 radius-4 p-4":""}`,onClick:()=>{p(m)},children:[u.jsx(tr.Checkbox,{className:"mx-10 p-0",size:"small",color:"primary",checked:l.some(h=>h.id===m.id)}),u.jsx("div",{className:"f-14 f-w-400 txt-text-grey-primary",children:m.displayName})]},m.id))})})]})})]})})}):u.jsx(u.Fragment,{children:u.jsxs("div",{className:"d-flex align-center h-46px border-solid-input-border radius-8 p-12 justify-between",onClick:()=>s(!0),children:[u.jsxs("div",{className:"d-flex",children:[Array.isArray(o)&&o?.length?(o?.length>3?o.slice(0,3):o)?.map((m,h)=>u.jsx(tr.Chip,{label:m.displayName,sx:{bgcolor:Ni["popper-border"],border:0,borderRadius:2,margin:"0 !important",padding:"6px 8px 6px 8px",gap:1,".MuiChip-label":{fontSize:14,fontFamily:"Inter, sans-serif !important"}},variant:"outlined"},h)):u.jsx(u.Fragment,{children:"-"}),o?.length>3&&u.jsxs("div",{className:"w-24px h-24px p-2 radius-360 bg-avatarColor txt-blue-darken10 d-flex align-center justify-center avatar h-26px px-6 py-8 bg-lightblue1 radius-4 border-solid-popper-border ml-4",children:["+",o.length-3]})]}),u.jsx(rf,{})]})})},b9=[{field:{id:"256f35efc157446dba47e0922057ff61",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Name",fieldInternalName:"work_4_name",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"single-line",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!0,isSelected:!0,isSortable:!0,sortOrder:"1",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[],columnWidth:null,toggleState:null,workflow:null,name:"Name",internalName:"work_4_name",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:1,isSelected:!0,isPrimaryField:!0,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"d397ae5f3e2f48a280dc6f7644325b00",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Status",fieldInternalName:"stage",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"drop-down",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"2",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[{key:"New",value:"New"},{key:"Open",value:"Open"},{key:"In Progress",value:"In Progress"},{key:"Qualified",value:"Qualified"},{key:"Unqualified",value:"Unqualified"},{key:"Attempted To Contact",value:"Attempted To Contact"},{key:"Connected",value:"Connected"},{key:"Bad Timing",value:"Bad Timing"},{key:"Hot Lead",value:"Hot Lead"}],columnWidth:null,toggleState:null,workflow:null,name:"Status",internalName:"stage",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:2,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"bfb6fa887f67486d93ab3c5516f93f4c",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Owner",fieldInternalName:"owner",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"user",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!0,sortOrder:"3",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[],columnWidth:null,toggleState:null,workflow:null,name:"Owner",internalName:"owner",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:3,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"643e3725963e47fb96fc192ddd8680f4",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Priority",fieldInternalName:"priority",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"priority",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"4",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[{key:"Low",value:"Low",statusColor:null},{key:"Moderate",value:"Moderate",statusColor:null},{key:"High",value:"High",statusColor:null}],columnWidth:null,toggleState:null,workflow:null,name:"Priority",internalName:"priority",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:4,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"e6077294af434793aa036c73337f0163",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T09:33:51.860Z",updatedAt:"2025-08-21T09:33:52.122Z",fieldDisplayName:"interview",fieldInternalName:"interview",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"drop-down",isRequired:!1,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"5",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:null,postfix:null,value:[{key:"stage 1",value:"stage 1",statusColor:"#397E4E"},{key:"stage 2",value:"stage 2",statusColor:"#5DC975"},{key:"stage 3",value:"stage 3",statusColor:"#9DD32D"},{key:"stage 4",value:"stage 4",statusColor:"#CAB642"},{key:"stage 5",value:"stage 5",statusColor:"#E0CC33"}],columnWidth:null,toggleState:!0,workflow:null,name:"interview",internalName:"interview",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:6,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!1,isImmutable:!1},{field:{id:"c6104a0ccd7e4636a72bf13380c6491e",isActive:!0,isDeleted:!1,createdAt:"2025-08-22T09:26:10.456Z",updatedAt:"2025-08-22T09:26:10.733Z",fieldDisplayName:"coll",fieldInternalName:"coll",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"collaborators",isRequired:!1,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"6",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:null,postfix:null,value:[],columnWidth:null,toggleState:null,workflow:null,name:"coll",internalName:"coll",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:7,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!1,isImmutable:!1}],G4={status_changes:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["priority","drop-down"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is value of"},{segmentsId:2,type:"dropdown",valueType:"field-options",mapSegmentsId:0,value:""}]},number_lessthan:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["number","currency"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is less than"},{segmentsId:2,type:"input",valueType:"number",value:"",mapSegmentsId:0}]},number_greaterthan:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["number","currency"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is greater than"},{segmentsId:2,type:"input",valueType:"number",value:"",mapSegmentsId:0}]}},n9=[{key:"status_changes",displayContent:"status is value of",conditionAuto:G4.status_changes},{key:"number_lessthan",displayContent:"Number is less than",conditionAuto:G4.number_lessthan},{key:"number_greaterthan",displayContent:"Number is greater than",conditionAuto:G4.number_greaterthan}],sl={changes_field_value:{key:"changes_field_value",segments:[{segmentsId:0,type:"text",value:"set"},{segmentsId:1,type:"dropdown",valueType:"field",optionType:"",fieldType:"",value:"",childSegments:[3]},{segmentsId:2,type:"text",value:"to"},{segmentsId:3,type:"input",valueType:"number",value:"",mapSegmentsId:1}]},send_notification:{key:"send_notification",segments:[{segmentsId:0,type:"text",value:"Notify the"},{segmentsId:1,type:"user",valueType:"user-notification",optionType:"",fieldType:"",value:[],childSegments:[3]},{segmentsId:2,type:"text",value:"as"},{segmentsId:3,type:"notification",valueType:"",value:"",mapSegmentsId:1}]},move_to_other_work:{key:"move_to_other_work",segments:[{segmentsId:0,type:"text",value:"Move to"},{segmentsId:1,type:"moveRecordToOtherWork",valueType:"moveRecordToOtherWork",optionType:"",fieldType:"",value:[]}]},copy_to_other_workspace_work:{key:"copy_to_other_workspace_work",segments:[{segmentsId:0,type:"text",value:"Move to"},{segmentsId:1,type:"workspace",valueType:"workspace",optionType:"",fieldType:"",value:[],childSegments:[2]},{segmentsId:2,type:"moveRecordToOtherWork",valueType:"moveRecordToOtherWork",optionType:"",fieldType:"",value:[],mapSegmentsId:1}]},send_notification_to_field:{key:"send_notification_to_field",segments:[{segmentsId:0,type:"text",value:"Notify the"},{segmentsId:1,type:"dropdown",valueType:"users",optionType:"",fieldType:"",value:[],childSegments:[3]},{segmentsId:2,type:"text",value:"as"},{segmentsId:3,type:"notification",valueType:"",value:"",mapSegmentsId:1}]}},s9=[{key:"changes_field_value",displayAutomation:"change Field Value",automation:sl.changes_field_value},{key:"send_notification",displayAutomation:"send Notification",automation:sl.send_notification},{key:"move_to_other_work",displayAutomation:"move to other work",automation:sl.move_to_other_work},{key:"copy_to_other_workspace_work",displayAutomation:"move to other workspace work",automation:sl.copy_to_other_workspace_work},{key:"send_notification_to_field",displayAutomation:"send Notification by field",automation:sl.send_notification_to_field}];var pl={},Rm;function p9(){if(Rm)return pl;Rm=1;var r=Qo();Object.defineProperty(pl,"__esModule",{value:!0}),pl.default=void 0;var o=r(je()),e=he();return pl.default=(0,o.default)((0,e.jsx)("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"}),"AddRounded"),pl}var f9=p9();const Mm=zo(f9),X4=({defaultValue:r,setValue:o,isDisable:e=!1})=>{const[d,t]=g.useState(r),{col:l}=g.useContext(Ge),[i,a]=g.useState(!0);g.useEffect(()=>{t(r)},[r]);const w=(p,m,h)=>{const f=d.blocks.map((k,x)=>x!==p?k:{...k,segments:k.segments.map((c,E)=>E!==m?c:{...c,value:h})});t(k=>({...k,blocks:f})),o({...d,blocks:f})},b=(p,m)=>{const h={...d};h.blocks=[...h.blocks,{...p,key:m}],t(h),a(!1)},n=({optionType:p,valueType:m,fieldId:h})=>{const f=l?.map(k=>k.field);if(m==="field")return f.filter(k=>p?.includes(k.dataType)&&!k.isAssociated).map(k=>({id:k.id,displayName:k.name,internalName:k.internalName}));if(m==="field-options")return f.find(x=>x.id===h)?.value?.map(x=>({id:x.key,displayName:x.value}))},s=p=>{let m={...d,blocks:d.blocks.filter((h,f)=>f!==p)};t(m),o(m)};return u.jsxs(u.Fragment,{children:[u.jsx("div",{children:d?.blocks?.map((p,m)=>u.jsxs("div",{className:"d-flex hide-icon",children:[u.jsxs("div",{className:"f-w-400 f-14 txt-black2 d-flex flex-wrap flex-1 align-center",children:[m?u.jsx("span",{children:"And only if"}):u.jsx("span",{children:"When a"}),p.segments.map((h,f)=>h.type==="text"?u.jsxs("span",{children:[" ",h.value," "]},f):h.type==="input"?u.jsx(tr.TextField,{id:"standard-basic",variant:"standard",className:"mx-8",disabled:e,defaultValue:h.value,type:h.valueType,onChange:k=>w(m,f,k.target.value),sx:{margin:0,maxWidth:100,padding:0,"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-root":{margin:0}}}):h.type==="dropdown"?u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{IconComponent:()=>null,value:h.value,disabled:e,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},onChange:k=>w(m,f,k.target.value),children:n({optionType:h.optionType,valueType:h.valueType,fieldId:p?.segments?.[h.mapSegmentsId]?.value})?.map(k=>u.jsx(tr.MenuItem,{value:k.id,children:k.displayName},k.id))},`${m}_${f}`)}):null)]}),d.blocks.length>1?u.jsx("img",{src:"/delete.svg",className:"hide cursor-pointer",onClick:()=>{s(m)}}):u.jsx(u.Fragment,{}),u.jsx("div",{children:!e&&d.blocks.length-1===m?u.jsx(u.Fragment,{children:u.jsx(Mm,{className:"f-w-400 f-14 txt-black2 cursor-pointer",onClick:()=>{a(!0)}})}):u.jsx(u.Fragment,{})})]},m))}),!e&&i?u.jsx(u.Fragment,{children:u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{labelId:"demo-simple-select-standard-label",id:"demo-simple-select-standard",IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:n9?.map(p=>u.jsx(tr.MenuItem,{onClick:()=>b(p.conditionAuto,p.key),children:p.displayContent},p.key))})})}):u.jsx(u.Fragment,{})]})},h9=({edgeData:r,updateEdgeData:o,setSelectedId:e})=>{console.log("==>edgeData",r);const{setValue:d,watch:t}=bb.useForm({defaultValues:{permission:r?.data?.permission||[],requiredColumns:r?.data?.requiredColumns||[],condition:r?.data?.condition||{id:"",blocks:[]}}}),l=b9?.map(i=>({id:i.field.id,displayName:i?.field?.name,internalName:i?.field?.internalName}));return u.jsx("div",{style:{position:"absolute",top:0,right:0,height:"100%",width:"420px",background:"#fff",borderLeft:"1px solid #ccc",zIndex:1e3},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:"Configuration"}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsx("div",{className:"flex-1",children:u.jsxs("div",{className:"p-10",children:[u.jsxs("div",{className:"h-44px flex-1 radius-8 px-12 py-6 d-flex justify-between align-center cursor-pointer",style:{backgroundColor:r4(r?.data?.sourceColor),border:`1px solid ${Ve(r?.data?.sourceColor)}`},children:[u.jsx("div",{className:"f-w-600 f-14 txt-black mr-20 ",style:{color:Ve(r?.data?.sourceColor)},children:r?.data?.sourceLabel}),u.jsx("img",{src:"/arrow.svg",alt:"arrow",className:"mr-20"}),u.jsx("div",{className:"f-w-600 f-14 txt-black mr-20 ",style:{color:Ve(r.data?.targetColor)},children:r?.data?.targetLabel})]}),u.jsx("div",{className:"border-solid-border1 my-16"}),u.jsxs("div",{className:"mb-16",children:[u.jsx("p",{className:"f-w-600 f-14 txt-black2 mb-6",children:"Permissions"}),u.jsx(Om,{selectedAssignees:t("permission"),datasetId:"460e5046a84043f7b8193feb2ece19d0",setValue:i=>{d("permission",i)}})]}),u.jsxs("div",{className:"mb-16",children:[u.jsx("p",{className:"f-w-600 f-14 txt-black2 mb-6",children:"Required Columns"}),u.jsx(w9,{defaultValue:t("requiredColumns"),options:l,setValue:i=>{d("requiredColumns",i)}})]}),u.jsxs("div",{children:[u.jsx("div",{className:"d-flex align-center justify-between",children:u.jsx("p",{className:"f-w-600 f-14 txt-black2",children:"Condition"})}),u.jsx(X4,{defaultValue:t("condition"),setValue:i=>{d("condition",i)}})]})]})}),u.jsxs("div",{className:"d-flex justify-end",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10",onClick:()=>e({id:"",type:"config"}),children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",onClick:()=>{o({id:r.id,data:{...r.data,...t()}}),e({id:"",type:"config"})},children:"Update"})]})]})})};var fl={},$m;function m9(){if($m)return fl;$m=1;var r=Qo();Object.defineProperty(fl,"__esModule",{value:!0}),fl.default=void 0;var o=r(je()),e=he();return fl.default=(0,o.default)((0,e.jsx)("path",{d:"m19 15-1.41-1.41L13 18.17V2h-2v16.17l-4.59-4.59L5 15l7 7z"}),"South"),fl}var k9=m9();const Um=zo(k9);var hl={},Lm;function x9(){if(Lm)return hl;Lm=1;var r=Qo();Object.defineProperty(hl,"__esModule",{value:!0}),hl.default=void 0;var o=r(je()),e=he();return hl.default=(0,o.default)((0,e.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),hl}var g9=x9();const c9=zo(g9);var ml={},jm;function u9(){if(jm)return ml;jm=1;var r=Qo();Object.defineProperty(ml,"__esModule",{value:!0}),ml.default=void 0;var o=r(je()),e=he();return ml.default=(0,o.default)((0,e.jsx)("path",{d:"M17.77 3.77 16 2 6 12l10 10 1.77-1.77L9.54 12z"}),"ArrowBackIosNew"),ml}var F9=u9();const A9=zo(F9);var kl={},zm;function y9(){if(zm)return kl;zm=1;var r=Qo();Object.defineProperty(kl,"__esModule",{value:!0}),kl.default=void 0;var o=r(je()),e=he();return kl.default=(0,o.default)((0,e.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4m0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7"}),"VisibilityOutlined"),kl}var E9=y9();const D9=zo(E9),v9=({defaultValue:r,setValue:o})=>{const[e,d]=g.useState(r),[t,l]=g.useState(!1),{acceptedUser:i,col:a,exampleData:w}=g.useContext(Ge),b=a?.map(s=>s.field),n=g.useMemo(()=>{const s=new Map;return b.forEach(p=>{if(p.dataType==="user"){const m=w[p.internalName],h=i.find(f=>f.id===m);s.set(p.internalName,h?.name??"")}else if(p.dataType==="collaborators"){const m=w[p.internalName].split(",");let h=[];m.forEach(f=>{const k=i.find(x=>x.id===f);h=[...h,k?.name||""]}),s.set(p.internalName,h.join(","))}else s.set(p.internalName,w[p.internalName])}),s},[b,i]);return u.jsxs("div",{children:[u.jsx("div",{style:{textDecoration:"underline",textUnderlineOffset:"2px"},onClick:()=>{l(!0)},children:"Template"}),t?u.jsx(tr.ClickAwayListener,{onClickAway:()=>l(!1),children:u.jsx("div",{className:"w-100 d-flex align-center txt-black2 f-12 mb-8",children:u.jsxs("div",{className:"w-358px border-solid-lightblue1 radius-12 bg-white",children:[u.jsx("div",{className:"h-46px border-b-solid-popper-border tl-radius-10 tr-radius-10 px-10 d-flex align-center f-14 f-w-400",children:"Send Notification"}),u.jsxs("div",{className:"my-8 h-31px d-flex align-center px-6 f-12",children:[u.jsx("div",{className:"w-82px d-flex align-center justify-center ",children:"Templates :"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Reminder"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Status Update"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Deadline Alert"})]}),u.jsxs("div",{className:"h-151px px-12 mb-8",children:[u.jsx("div",{className:"h-31px f-w-600 f-12 d-flex align-center",children:"Message"}),u.jsx(tr.TextField,{placeholder:"Type your message here...",className:"f-12",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:e,onChange:s=>{d(s.target.value)}})]}),u.jsx("div",{style:{gap:"4px"},className:"px-12 py-8 d-flex flex-wrap mb-8",children:b?.map(s=>u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4 f-12",onClick:()=>{d(p=>p+`{${s.internalName}}`)},children:s.name}))}),u.jsx("div",{className:"p-12 mb-8",children:u.jsxs("div",{className:"h-160px radius-8 border-solid-lightblue1 bg-lightblue3 px-8 d-flex flex-column pb-8",children:[u.jsxs("div",{className:"h-31px d-flex align-center",children:[u.jsx(D9,{className:"f-12"}),u.jsx("p",{className:"ml-4 f-12 ",children:"Preview"})]}),u.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},className:"border-solid-lightblue1 h-100 flex-1 bg-white radius-4 p-8",children:e?.replace(/\{(\w+)\}/g,(s,p)=>n.get(p))})]})}),u.jsxs("div",{className:"bl-radius-10 br-radius-10 h-56px border-t-solid-popper-border d-flex justify-end px-12 align-center",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10 h-31px radius-8",onClick:()=>{l(!1)},children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",className:"h-31px radius-8",onClick:()=>{o(e),l(!1)},children:"Done"})]})]})})}):u.jsx(u.Fragment,{})]})},S9={};function _9(r,o){switch(o.type){case"ADD_OR_UPDATE":return{...r,[o.key]:o.value};case"DELETE":const e={...r};return delete e[o.key],e;default:return r}}const C9=({datasetId:r,workspaceId:o,targetWorkspaceId:e,autoIndex:d,segmentIndex:t,setValue:l,defaultValue:i})=>{const{mappingField:a,targetWork:w}=i,[b,n]=g.useState(null),[s,p]=g.useReducer(_9,a??S9),[m,h]=g.useState(!1);g.useEffect(()=>{n(w)},[a,w]);const{data:f}=Jr.useQuery(o9,{variables:{input:{workspaceId:Number(e)}},fetchPolicy:"network-only",client:Y4}),{data:k}=Jr.useQuery(Nm,{variables:{input:{workspaceId:Number(o),datasetId:r}},fetchPolicy:"network-only",client:Y4}),{data:x}=Jr.useQuery(Nm,{variables:{input:{workspaceId:Number(e),datasetId:b}},fetchPolicy:"network-only",client:Y4,skip:!b}),c=f?.getDataset?.filter(E=>E.id!==r)??[];return u.jsxs("div",{children:[u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{value:b,IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:c?.map(E=>u.jsx(tr.MenuItem,{value:E.id,onClick:()=>{n(E.id),h(!0)},children:E.name},E.id))},`${d}_${t}`)}),m?u.jsx(u.Fragment,{children:u.jsx(tr.ClickAwayListener,{onClickAway:()=>{},children:u.jsx("div",{className:"w-100 d-flex align-center mt-8",children:u.jsxs("div",{className:"w-358px border-solid-lightblue1 radius-8 bg-white h-367px",children:[u.jsx("div",{className:"border-b-solid-lightblue1 d-flex align-center px-10 txt-black2 h-46px",children:"Map Source to Destination"}),u.jsx("div",{className:"overflow-auto flex-1 h-264px",children:k?.getField?.filter(E=>!E.isAssociatedField&&!["created_on","updated_on"].includes(E.fieldInternalName))?.map(E=>{const y=x?.getField?.filter(D=>E.dataType===D.dataType&&!Object.values(s).includes(D.fieldInternalName)&&!["created_on","updated_on"].includes(E.fieldInternalName))||[],F=x?.getField?.find(D=>D.fieldInternalName===s[E.fieldInternalName]),I=F?[...y,F]:y;return u.jsxs("div",{className:"d-flex align-center h-52px",children:[u.jsx("div",{className:"txt-brown-dark1 f-12 f-w-600 text-truncate pl-16 w-200px",children:E.fieldDisplayName}),u.jsx("div",{className:"flex-1 d-flex align-center",children:I?.length||E.fieldInternalName in s?u.jsx(tr.Select,{className:"w-115px h-40px radius-8 f-10 p-0",defaultValue:s[E?.fieldInternalName]??null,children:I?.map(D=>u.jsx(tr.MenuItem,{value:D.fieldInternalName,onClick:()=>{p({type:"ADD_OR_UPDATE",key:E.fieldInternalName,value:D.fieldInternalName})},children:D.fieldDisplayName},D.id))}):u.jsx("div",{className:"w-115px h-40px radius-8 border-solid-red1 bg-lightred txt-red1 d-flex align-center justify-center f-10 f-w-400",children:"No field to show"})})]})})}),u.jsxs("div",{className:"bl-radius-10 br-radius-10 h-56px border-t-solid-popper-border d-flex justify-end px-12 align-center",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10 h-31px radius-8",onClick:()=>{h(!1)},children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",className:"h-31px radius-8",onClick:()=>{l({sourceWork:r,targetWork:b,mappingField:s}),h(!1)},children:"Done"})]})]})})})}):u.jsx(u.Fragment,{})]})},B9=({defaultValue:r,setValue:o})=>{const{validateUser:e}=g.useContext(Ge),{data:d}=Jr.useQuery(e9,{variables:{input:{userId:e.id,orgId:e?.organisation?.id}},fetchPolicy:"network-only",client:Tm}),t=d?.getWorkspaceList;return u.jsx("div",{children:u.jsx(tr.Select,{className:"w-115px h-40px radius-8 f-10 p-0",defaultValue:r,children:t?.map(l=>u.jsx(tr.MenuItem,{value:l.id,onClick:()=>{o(l.id)},children:l.name},l.id))})})},Vm=({defaultValue:r,setValue:o,isDisable:e=!1})=>{const[d,t]=g.useState([]),[l,i]=g.useState(!0),{col:a,datasetId:w,workspaceId:b}=g.useContext(Ge);g.useEffect(()=>{t(r)},[r]);const n=(h,f)=>{i(!1),t(k=>[...k,h])},s=h=>{const f=d.filter((k,x)=>x!==h);t(f),o(f)},p=(h,f,k)=>{const x=d.map((c,E)=>{if(E!==h)return c;const y=c.segments[f],F=y.valueType==="field",I=F?y.childSegments||[]:[],D=c.segments.map(v=>{if(v.segmentsId===y.segmentsId)if(F){const _=a.find(T=>T.field.id===k);return{...v,datasetId:_?.datasetId,datasetName:_?.datasetName,fieldType:_?.field.dataType,property:_?.field?.internalName,isAssociate:_?.field?.isAssociated,value:k}}else return{...v,value:k};if(F&&I.includes(v.segmentsId)){const _=a.find(T=>T.field.id===k);return{...v,type:["drop-down"].includes(_?.field?.dataType)?"dropdown":"input",value:"",valueType:"field-options"}}return v});return{...c,segments:D}});o(x),t(x)},m=({optionType:h,valueType:f,fieldId:k})=>{const x=a?.map(c=>c.field);if(f==="field")return x.map(c=>({id:c.id,displayName:c.name,internalName:c.internalName}));if(f==="field-options")return x.find(E=>E.id===k)?.value?.map(E=>({id:E.key,displayName:E.value}));if(f==="users")return x.filter(c=>["user","collaborators"].includes(c.dataType)).map(c=>({id:c.internalName,displayName:c.name,internalName:c.internalName}))};return u.jsxs(u.Fragment,{children:[u.jsx("div",{children:d?.map((h,f)=>u.jsxs("div",{className:"d-flex hide-icon",children:[u.jsxs("div",{className:"f-w-400 f-14 txt-black2 d-flex flex-wrap flex-1 align-center",children:[f?u.jsx("span",{children:"And "}):u.jsx("span",{children:"Then "}),h.segments.map((k,x)=>{if(k.type==="text")return u.jsxs("span",{className:"ml-2",children:[" ",k.value," "]},x);if(k.type==="input")return u.jsx(tr.TextField,{id:"standard-basic",variant:"standard",className:"mx-8",disabled:e,defaultValue:k.value,type:k.valueType,onChange:c=>p(f,x,c.target.value),sx:{margin:0,maxWidth:100,padding:0,"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-root":{margin:0}}});if(k.type==="dropdown")return u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{IconComponent:()=>null,value:k.value,disabled:e,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},onChange:c=>p(f,x,c.target.value),children:m({optionType:k.optionType,valueType:k.valueType,fieldId:h?.segments?.[k.mapSegmentsId]?.value})?.map(c=>u.jsx(tr.MenuItem,{value:c.id,children:c.displayName},c.id))},`${f}_${x}`)});if(k.type==="user")return u.jsx(Om,{selectedAssignees:k.value,setValue:c=>{p(f,x,c)},datasetId:w,isForNotification:!0});if(k.type==="notification")return u.jsx(v9,{defaultValue:k.value,setValue:c=>{p(f,x,c)}});if(k.type==="workspace")return u.jsx("div",{children:u.jsx(B9,{defaultValue:k.value,setValue:c=>{p(f,x,c)}})});if(k.type==="moveRecordToOtherWork"){let c=d[f]?.segments[k.mapSegmentsId]?.value;return u.jsx(C9,{defaultValue:k.value,datasetId:w,workspaceId:b,targetWorkspaceId:c??b,autoIndex:f,segmentIndex:x,setValue:E=>{p(f,x,E)}})}return null})]}),d.length>1?u.jsx("img",{src:"/delete.svg",className:"hide cursor-pointer",onClick:()=>{s(f)}}):u.jsx(u.Fragment,{}),u.jsx("div",{children:!e&&d.length-1===f?u.jsx(u.Fragment,{children:u.jsx(Mm,{className:"f-w-400 f-14 txt-black2 cursor-pointer",onClick:()=>{i(!0)}})}):u.jsx(u.Fragment,{})})]},f))}),!e&&l?u.jsx(u.Fragment,{children:u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{labelId:"demo-simple-select-standard-label",id:"demo-simple-select-standard",IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:s9?.map(h=>u.jsx(tr.MenuItem,{onClick:()=>n(h.automation,h.key),children:h.displayAutomation},h.key))})})}):u.jsx(u.Fragment,{})]})},I9=({selectedId:r,setSelectedId:o,setSelectAutomation:e,setisCreateNewAutomation:d})=>{const[t,l]=g.useState([]),{workspaceId:i}=g.useContext(Ge);g.useEffect(()=>{const n=async s=>{try{const p=await xA(s,i);l(p)}catch(p){console.error("Error fetching automation:",p)}};r?.id&&n(r?.id)},[r?.id]);const a=async({id:n,isActive:s})=>{await gA({id:n,isActive:s,workspaceId:i})},w=async({id:n})=>{await cA({id:n,workspaceId:i})},b={inputProps:{"aria-label":"Size switch demo"}};return u.jsx("div",{style:{top:0,right:0,height:"100%",width:"422px",background:"#fff",borderLeft:"1px solid #ccc"},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:[u.jsx(A9,{className:"mr-8 f-14 cursor-pointer",onClick:()=>o({id:"",type:"auto"})}),"Automation"]}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsxs("div",{className:"p-10 flex-1 overflow-auto",children:[u.jsx("div",{className:"mb-12 border-dashed-newborder h-48px radius-8 bg-blue-lighten9 d-flex align-center txt-darkblue cursor-pointer",onClick:()=>{d(!0)},children:u.jsxs("div",{className:"p-14 d-flex align-center",children:[u.jsx(c9,{}),u.jsx("p",{className:"f-w-600 f-14 ml-8",children:"New"})]})}),t?.data?.map(n=>u.jsxs("div",{className:"border-solid-input-border radius-12 px-12 py-10 d-flex mb-12 align-start",children:[u.jsxs("div",{className:"flex-1",onClick:()=>{e(n)},children:[u.jsx(X4,{defaultValue:n.condition,setValue:s=>{},isDisable:!0}),u.jsx("div",{children:u.jsx(Um,{className:"my-8"})}),u.jsx(Vm,{defaultValue:n.automation,setValue:s=>{},isDisable:!0})]}),u.jsx(tr.Switch,{...b,defaultChecked:n.isActive,onChange:s=>{a({id:n.id,isActive:s.target.checked})}}),u.jsx("img",{src:"/delete.svg",onClick:()=>{w({id:n.id})}})]}))]})]})})},T9=({editEdgeData:r,setSelectedId:o,selectAutomation:e,isCreateNewAutomation:d})=>{const{setValue:t,watch:l}=bb.useForm({defaultValues:{condition:{id:"",blocks:[]},automation:[]}}),{acceptedUser:i,selectFieldId:a,validateUser:w,workspaceId:b}=g.useContext(Ge);g.useEffect(()=>{t("automation",e.automation??[]),t("condition",e.condition??{id:"",blocks:[]})},[e.id]);const n=async()=>{const s=l(),p=s.automation?.map(m=>{switch(m.key){case"changes_field_value":const h=m.segments?.find(v=>v.valueType==="field"),f=m.segments[h?.childSegments?.[0]];return{targetWorkspaceId:b,targetFieldId:h.value,actionType:Xt.UPDATE_FIELD,content:{propertyData:[{datasetId:h.datasetId,datasetName:h.datasetName,isAssociate:h.isAssociate,property:h.property,fieldType:h.fieldType,value:f.value,setValue:f.value}],datasetId:h.datasetId,datasetName:h.datasetName}};case"send_notification":const k=m.segments?.find(v=>v.valueType==="user-notification"),x=m.segments[k?.childSegments?.[0]],c=v=>v.map(T=>{const L=i.find(q=>q.id===T);return{id:L?.id,email:L?.email}});return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.NOTIFY,content:{isDeleted:!1,isActive:!0,workspaceId:b,senderEmail:w.email,senderId:w.id,notificationType:"push",notificationTitle:"Automation",notificationDescription:x.value,notificationMetadata:{},isRead:!1,receiverDetails:c(k.value)}};case"move_to_other_work":let E=m.segments?.find(v=>v.valueType==="moveRecordToOtherWork");return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.MOVE_RECORD,content:{...E?.value}};case"copy_to_other_workspace_work":let y=m.segments?.find(v=>v.valueType==="workspace"),F=m.segments?.find(v=>v.valueType==="moveRecordToOtherWork");return{targetWorkspaceId:y?.value??b,targetFieldId:"",actionType:Xt.COPY_RECORD_TO_OTHER_WORKSPACE,content:{...F?.value}};case"send_notification_to_field":const I=m.segments?.find(v=>v.valueType==="users"),D=m.segments[I?.childSegments?.[0]];return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.NOTIFY,content:{isDeleted:!1,isActive:!0,workspaceId:b,senderEmail:w.email,senderId:w.id,notificationType:"push",notificationTitle:"Automation",notificationDescription:D.value,notificationMetadata:{},isRead:!1,receiverDetails:[],selectField:I.value}}}});d?await mA({workspaceId:b+"",fieldId:a,from:r?.source,to:r?.target,workflowSegId:r?.id,condition:s.condition,automation:s.automation,automationAction:p}):await kA({id:e.id,condition:s.condition,automation:s.automation,automationAction:p,workspaceId:b+""})};return u.jsx("div",{style:{position:"absolute",top:0,right:0,height:"100%",maxHeight:"704px",width:"420px",background:"#fff",borderLeft:"1px solid #ccc",zIndex:1e3},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container maxh-703px",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:"Properties"}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsxs("div",{className:"flex-1 overflow-auto hide-scroll",children:[u.jsx(X4,{defaultValue:l("condition"),setValue:s=>{t("condition",s)}}),u.jsx("div",{children:u.jsx(Um,{className:"my-8"})}),u.jsx(Vm,{defaultValue:l("automation"),setValue:s=>{t("automation",s)}})]}),u.jsxs("div",{className:"d-flex justify-end",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10",onClick:()=>o({id:"",type:"auto"}),children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",onClick:()=>{o({id:"",type:"auto"}),n()},children:"Update"})]})]})})},N9=({editEdgeData:r,selectedId:o,setSelectedId:e})=>{const[d,t]=g.useState({}),[l,i]=g.useState(!1);return Pm(d)&&!l?u.jsx(I9,{selectedId:o,setSelectedId:e,setSelectAutomation:t,setisCreateNewAutomation:i}):u.jsx(T9,{editEdgeData:r,selectAutomation:d,setSelectedId:e,isCreateNewAutomation:l})},P9=({selectedId:r,editEdgeData:o,updateEdgeData:e,setSelectedId:d})=>r.type===yf.Auto?u.jsx(N9,{editEdgeData:o,selectedId:r,setSelectedId:d}):u.jsx(h9,{edgeData:o,updateEdgeData:e,setSelectedId:d}),O9=({edges:r,updateEdgeData:o,saveToBackend:e})=>{const[d,t]=g.useState({id:"",type:yf.Config});return u.jsx("div",{children:d.id?u.jsx(P9,{selectedId:d,updateEdgeData:o,editEdgeData:r?.find(l=>l.id===d.id),setSelectedId:t}):u.jsx(_A,{edges:r,setSelectedId:t,saveToBackend:e})})},R9=({children:r,col:o,selectFieldId:e,validateUser:d,workspaceId:t,exampleData:l,acceptedUser:i,datasetId:a})=>u.jsx(Ge.Provider,{value:{col:o,selectFieldId:e,validateUser:d,workspaceId:t,exampleData:l,acceptedUser:i,datasetId:a},children:r}),M9={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",borderRadius:2,boxShadow:"24",p:4,background:"linear-gradient(101.49deg, #F8FDFF 11.98%, #FBF2FB 119.18%)",border:"1px solid #EAEFF4",outline:"none"},$9=({fieldId:r,col:o,validateUser:e,workspaceId:d,exampleData:t,acceptedUser:l,datasetId:i,onClose:a})=>{const w=o?.find(c=>c.field.id===r),b=$5(w.field.value),[n,s,p]=Eg(b),[m,h,f]=Dg([]);g.useEffect(()=>{(async E=>{try{const y=await uA({fieldId:E,workspaceId:d});s(y.data.workflowDefinition.nodes),h(y.data.workflowDefinition.edges)}catch(y){console.error("Error fetching automation:",y)}})(r)},[r]);const k=({id:c,data:E})=>{h(y=>y?.map(F=>(F.id===c&&(F.data=E),F)))},x=async()=>{const c=U5(m);await hA({workspaceId:d,workflow:{nodes:n,edges:m,workflow:c},fieldId:r})};return u.jsx(tr.Modal,{open:!0,onClose:()=>a,children:u.jsx(R9,{col:o,selectFieldId:r,validateUser:e,workspaceId:d,exampleData:t,acceptedUser:l,datasetId:i,children:u.jsx("div",{className:"workflow-we3434",children:u.jsxs("div",{className:"w-1225px h-703px border-solid-lightblue1 d-flex flex-column",style:M9,children:[u.jsxs("div",{className:"h-56px border-b-solid-border d-flex align-center justify-between px-20",children:[u.jsx("div",{className:"f-w-600 f-18 px-12",children:"Workflow"}),u.jsxs("div",{className:"d-flex align-center px-12",children:[u.jsx("div",{className:"border-solid-ligntbrown h-14px mr-8"}),u.jsx(M5,{className:"h-24px w-24px txt-lightblack3",onClick:()=>a()})]})]}),u.jsxs("div",{className:"flex-1 d-flex",children:[u.jsx(lw,{children:u.jsx(vA,{nodes:n,edges:m,setEdges:h,onNodesChange:p,onEdgesChange:f})}),u.jsx(O9,{edges:m,updateEdgeData:k,saveToBackend:x})]})]})})})})};Bo.ReactFlowModal=$9,Object.defineProperty(Bo,Symbol.toStringTag,{value:"Module"})});
|
|
187
|
+
`,d9=(r,o,e=void 0)=>{const d=o?.split(".");let t=r;for(const l of d)if(t&&typeof t=="object"&&l in t)t=t[l];else return e;return t},Pm=r=>r==null?!0:typeof r=="string"||Array.isArray(r)?r.length===0:typeof r=="object"?Object.keys(r).length===0:!1,t9=r=>{const o=typeof r=="string"?r:d9(r,"props.children","");let e=RegExp(/\b\w/g).exec(o);return Pm(e)||(e=((e.shift()||"")+(e.pop()||"")).toUpperCase()),e},l9=r=>r?.toLowerCase()?.split(/[\s\-_]+/).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),i9=({data:r,value:o})=>u.jsxs("div",{className:"d-flex align-center justify-between flex-1 text-truncate",id:"selection-ownerList",children:[u.jsx("div",{className:"user-oval-32 rounded-circle mr-2 bg-blue-lighten1",children:r.picture?u.jsx(tr.Avatar,{className:"w-100 h-100 rounded-circle",sx:{width:32,height:32},src:r.picture,alt:"profile"}):u.jsx("div",{className:"user-oval-32 rounded-circle align-center d-flex justify-around",children:u.jsx("p",{className:"f-11 f-w-500 txt-secondary-color font-600 align-center d-flex",children:t9(r.name)})})}),u.jsxs("div",{className:"flex-1 text-truncate ml-4 l-h-18",children:[u.jsx("p",{className:"f-14 f-w-400 text-truncate m-0",children:l9(r.name)}),u.jsx("p",{className:"f-12 f-w-400 txt-darken1 text-truncate m-0",children:r.roleName||"--"})]}),o===r.id?u.jsx("div",{className:"f-20 txt-bllue-darken8",children:u.jsx(wb.CheckOutlined,{className:"f-20 txt-bllue-darken8"})}):u.jsx(u.Fragment,{})]}),Ge=g.createContext(null),Om=({selectedAssignees:r,setValue:o,datasetId:e,isForNotification:d=!1})=>{const[t,l]=g.useState([]),[i,a]=g.useState(""),[w,b]=g.useState(!1),{acceptedUser:n,workspaceId:s,validateUser:p}=g.useContext(Ge),m={data:[{id:"b324369714a1420bbbc73d94c2178931",firstName:"guna",lastName:"lan",name:"guna lan",email:"guna@mailsac.com",teamId:null,privilege:[],teamName:null,roleName:"Super Admin",picture:"",timeZone:"",language:"en",dateFormat:null,timeFormat:null,weekStartsOn:"sunday"}]},{data:h}=Jr.useQuery(r9,{variables:{input:{datasetId:e,searchKey:i,workspaceId:Number(s),userId:p.id}},fetchPolicy:"network-only",client:Tm});console.log("filteredOptions",h);const f=x=>{let c;t.some(E=>E.id===x.id)?c=t.filter(E=>E.id!==x.id):c=[...t,x],l(c),o(c.map(E=>E.id))},k=x=>{const c=t.filter(E=>E.id!==x);l(c),o(c.map(E=>E.id))};return w?u.jsx(tr.ClickAwayListener,{onClickAway:()=>b(!1),children:u.jsxs("div",{className:"h-34px w-380px position-relative bg-white",children:[t.length?u.jsx("div",{className:"d-flex align-center flex-wrap bg-white z-index-100",children:t?.map(x=>u.jsxs("div",{className:"h-34px d-flex align-center justify-between px-8 cursor-pointer radius-4 hover-show-container border-solid-popper-border ml-4 mt-4",onClick:()=>{k(x.id)},children:[u.jsx("div",{className:"f-14 f-w-500 txt-blue-darken10 ",children:x.name}),u.jsx(NA,{className:"f-20 ml-6"})]},x.id))}):u.jsx("div",{className:"h-34px w-380px d-flex align-center justify-between px-8 cursor-pointer radius-4 hover-show-container",onClick:()=>{},children:"--"}),u.jsx("div",{className:"position-relative",children:u.jsx("div",{className:`position-absolute ${t.length?"top-10px":"top--25px"} radius-8 search-mapdataset z-index-1000 bg-white`,children:u.jsxs("div",{className:"w-380px minh-46px radius-8 popper-border-solid-popper-border",children:[u.jsx("div",{className:"h-46px bg-grey-lighten4 boder-b-solid-popper-border tl-radius-8 tr-radius-8 p-10 d-flex align-center",children:u.jsx(tr.TextField,{sx:{input:{"&::placeholder":{color:Ni["success-disabled"],opacity:100}}},fullWidth:!0,className:"mapdataset-dropdown",id:"single-line",variant:"standard",placeholder:"Search",value:i,onChange:x=>a(x.target.value),autoComplete:"off",autoFocus:!0})}),!h?.getAccessUserList?.length&&i?u.jsx("div",{className:"p-10",children:u.jsx("div",{className:"d-flex align-center multi-select",children:u.jsxs("div",{className:"h-36px d-flex align-center f-w-400 f-14 txt-brown-dark1 pl-8 cursor-pointer",children:[u.jsx("p",{className:" f-w-600 txt-text-grey-primary mr-4",children:"user not found"})," ",` "${i}"`]})},"new-associate")}):u.jsx("div",{className:"bg-white maxh-202px overflow-auto p-8 px-6 bl-radius-8 br-radius-8",children:h?.getAccessUserList?.map((x,c)=>u.jsx("div",{className:` radius-4 px-10 py-8 ${h?.getAccessUserList?.length!==c+1?"mb-4":""} bg-hover-grey-lighten4 cursor-pointer d-flex align-center justify-between hover-show-container ${t?.some(E=>E.id===x.id)?"bg-blue-lighten9":""}`,onClick:()=>{f(x)},children:u.jsxs("div",{className:"d-flex align-center",children:[u.jsx(tr.Checkbox,{checked:t?.some(E=>E.id===x.id),size:"small"},x.id),u.jsx(i9,{data:x,value:""})]})},x.id))})]})})})]})}):u.jsx(u.Fragment,{children:d?u.jsx("div",{style:{textDecoration:"underline",textUnderlineOffset:"2px"},className:"pl-4",onClick:()=>b(!0),children:r.length?r?.map((x,c)=>{const E=n.find(y=>y.id===x);return u.jsx("span",{children:E?.name+`${r.length-1===c?"":","}`})}):u.jsx("div",{className:"",children:" select user"})}):u.jsxs("div",{className:"d-flex h-40px maxh-40px radius-8 border-solid-border px-12 align-center justify-between",onClick:()=>b(!0),children:[u.jsx(a9,{assignTo:r,acceptedUserData:m.data}),u.jsx(rf,{})]})})},a9=({assignTo:r,acceptedUserData:o})=>{const e=r?.map(t=>o?.find(l=>l.id===t)),d=e?.length>4?e.slice(0,4):e;return d?.length?u.jsxs("div",{className:"d-flex align-center",id:"dataCollab-view",children:[d?.map(t=>t?.picture?u.jsx(tr.Avatar,{className:"w-100 h-100 rounded-circle mr-4",sx:{width:32,height:32},src:t.picture,alt:"profile"},t?.id):u.jsx("div",{className:"w-32px h-32px radius-360 bg-orange-lighten5 d-flex align-center justify-center f-10 f-w-500 txt-primary mr-4",children:`${t?.firstName?Xp(t?.firstName[0]):""}${t?.lastName?Xp(t?.lastName[0]):""}`},t?.id)),e?.length>4&&u.jsxs("div",{className:"w-24px h-24px p-2 radius-360 bg-avatarColor txt-blue-darken10 d-flex align-center justify-center avatar",children:["+",e.length-4]})]}):"--"},w9=({options:r,defaultValue:o=[],setValue:e})=>{const[d,t]=g.useState(""),[l,i]=g.useState(o),[a,w]=g.useState(0),b=g.useRef(null),[n,s]=g.useState(!1);g.useEffect(()=>{b.current&&w(b.current.offsetHeight)},[l]);const p=m=>{let h;l.some(f=>f.id===m.id)?h=l.filter(f=>f.id!==m.id):h=[...l,m],i(h),e(h)};return n?u.jsx("div",{className:" bg-white w-380px h-46px border-solid-input-border radius-8 ",children:u.jsx(tr.ClickAwayListener,{onClickAway:()=>{s(!1)},children:u.jsxs("div",{className:"position-relative",children:[u.jsx("div",{ref:b,className:" w-100 res-chip-min-height h-100 radius-4 bg-white d-flex align-center d-flex flex-wrap py-4 gap-8 px-12",children:l.length?u.jsx(u.Fragment,{children:l?.map((m,h)=>u.jsx(tr.Chip,{label:m.displayName,onDelete:()=>p(m),sx:{bgcolor:Ni["popper-border"],border:0,borderRadius:2,margin:"0 !important",padding:"6px 8px 6px 8px",gap:1,".MuiChip-label":{fontSize:14,fontFamily:"Inter, sans-serif !important"}},deleteIcon:u.jsx(wb.CloseOutlined,{sx:{fontSize:"16px",color:m.statusColor?"#fff":"grey"},className:"cursor-pointer icon-close"}),variant:"outlined"},h))}):u.jsx("div",{className:"ml-10 d-flex align-center f-14 txt-text-grey-hint",children:"No fields"})}),u.jsx("div",{className:"position-absolute radius-8 search-mapdataset z-index-1000",style:{top:`${a+4}px`},children:u.jsxs("div",{className:"w-380px minh-46px radius-8 popper-border-solid-popper-border",children:[u.jsx("div",{className:"h-46px bg-grey-lighten4 boder-b-solid-popper-border tl-radius-4 tr-radius-8 p-10",children:u.jsx(tr.TextField,{sx:{input:{"&::placeholder":{color:Ni["success-disabled"],opacity:100}}},fullWidth:!0,className:"mapdataset-dropdown",variant:"standard",placeholder:"Search",value:d,onChange:m=>t(m.target.value),autoFocus:!0})}),u.jsx("div",{className:"bg-white maxh-200px overflow-auto w-100 py-8 px-6 bl-radius-8 br-radius-8",children:u.jsx(u.Fragment,{children:r?.filter(m=>m.displayName.toLowerCase().includes(d.toLowerCase()))?.map(m=>u.jsxs("div",{className:` h-36px radius-4 px-10 py-8 mb-2 bg-hover-grey-lighten4 cursor-pointer d-flex justify-start hover-show-container align-center ${l.some(h=>h.id===m.id)?"bg-blue-lighten9 txt-blue-darken10 radius-4 p-4":""}`,onClick:()=>{p(m)},children:[u.jsx(tr.Checkbox,{className:"mx-10 p-0",size:"small",color:"primary",checked:l.some(h=>h.id===m.id)}),u.jsx("div",{className:"f-14 f-w-400 txt-text-grey-primary",children:m.displayName})]},m.id))})})]})})]})})}):u.jsx(u.Fragment,{children:u.jsxs("div",{className:"d-flex align-center h-46px border-solid-input-border radius-8 p-12 justify-between",onClick:()=>s(!0),children:[u.jsxs("div",{className:"d-flex",children:[Array.isArray(o)&&o?.length?(o?.length>3?o.slice(0,3):o)?.map((m,h)=>u.jsx(tr.Chip,{label:m.displayName,sx:{bgcolor:Ni["popper-border"],border:0,borderRadius:2,margin:"0 !important",padding:"6px 8px 6px 8px",gap:1,".MuiChip-label":{fontSize:14,fontFamily:"Inter, sans-serif !important"}},variant:"outlined"},h)):u.jsx(u.Fragment,{children:"-"}),o?.length>3&&u.jsxs("div",{className:"w-24px h-24px p-2 radius-360 bg-avatarColor txt-blue-darken10 d-flex align-center justify-center avatar h-26px px-6 py-8 bg-lightblue1 radius-4 border-solid-popper-border ml-4",children:["+",o.length-3]})]}),u.jsx(rf,{})]})})},b9=[{field:{id:"256f35efc157446dba47e0922057ff61",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Name",fieldInternalName:"work_4_name",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"single-line",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!0,isSelected:!0,isSortable:!0,sortOrder:"1",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[],columnWidth:null,toggleState:null,workflow:null,name:"Name",internalName:"work_4_name",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:1,isSelected:!0,isPrimaryField:!0,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"d397ae5f3e2f48a280dc6f7644325b00",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Status",fieldInternalName:"stage",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"drop-down",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"2",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[{key:"New",value:"New"},{key:"Open",value:"Open"},{key:"In Progress",value:"In Progress"},{key:"Qualified",value:"Qualified"},{key:"Unqualified",value:"Unqualified"},{key:"Attempted To Contact",value:"Attempted To Contact"},{key:"Connected",value:"Connected"},{key:"Bad Timing",value:"Bad Timing"},{key:"Hot Lead",value:"Hot Lead"}],columnWidth:null,toggleState:null,workflow:null,name:"Status",internalName:"stage",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:2,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"bfb6fa887f67486d93ab3c5516f93f4c",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Owner",fieldInternalName:"owner",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"user",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!0,sortOrder:"3",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[],columnWidth:null,toggleState:null,workflow:null,name:"Owner",internalName:"owner",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:3,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"643e3725963e47fb96fc192ddd8680f4",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T08:44:05.608Z",updatedAt:"2025-08-21T08:44:05.608Z",fieldDisplayName:"Priority",fieldInternalName:"priority",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"priority",isRequired:!0,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"4",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:"",postfix:"",value:[{key:"Low",value:"Low",statusColor:null},{key:"Moderate",value:"Moderate",statusColor:null},{key:"High",value:"High",statusColor:null}],columnWidth:null,toggleState:null,workflow:null,name:"Priority",internalName:"priority",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:4,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!0,isImmutable:!1},{field:{id:"e6077294af434793aa036c73337f0163",isActive:!0,isDeleted:!1,createdAt:"2025-08-21T09:33:51.860Z",updatedAt:"2025-08-21T09:33:52.122Z",fieldDisplayName:"interview",fieldInternalName:"interview",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"drop-down",isRequired:!1,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"5",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:null,postfix:null,value:[{key:"stage 1",value:"stage 1",statusColor:"#397E4E"},{key:"stage 2",value:"stage 2",statusColor:"#5DC975"},{key:"stage 3",value:"stage 3",statusColor:"#9DD32D"},{key:"stage 4",value:"stage 4",statusColor:"#CAB642"},{key:"stage 5",value:"stage 5",statusColor:"#E0CC33"}],columnWidth:null,toggleState:!0,workflow:null,name:"interview",internalName:"interview",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:6,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!1,isImmutable:!1},{field:{id:"c6104a0ccd7e4636a72bf13380c6491e",isActive:!0,isDeleted:!1,createdAt:"2025-08-22T09:26:10.456Z",updatedAt:"2025-08-22T09:26:10.733Z",fieldDisplayName:"coll",fieldInternalName:"coll",datasetName:"work_4",sensitive:!1,hidden:!1,isHideField:!1,dataType:"collaborators",isRequired:!1,isUnique:!1,isAssociatedField:!1,isSystemDefined:!1,isImmutable:!1,isPrimaryField:!1,isSelected:!0,isSortable:!1,sortOrder:"6",createdBy:"7fda40cd83dc4391a7b751a67c0dfaa6",updatedBy:null,deletedBy:null,CreatedById:"7fda40cd83dc4391a7b751a67c0dfaa6",deletedAt:null,prefix:null,postfix:null,value:[],columnWidth:null,toggleState:null,workflow:null,name:"coll",internalName:"coll",isAssociated:!1,type:"work_4"},group:{id:"fc4a57aec9094c47bbdf55a4f028072c",datasetName:"work_4",groupName:"Work 4 Information"},position:7,isSelected:!0,isPrimaryField:!1,isDeleted:!1,isAssociated:!1,datasetName:"work_4",datasetId:"557465b7fd9244849f00076491369c84",isRequired:!1,isImmutable:!1}],G4={status_changes:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["priority","drop-down"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is value of"},{segmentsId:2,type:"dropdown",valueType:"field-options",mapSegmentsId:0,value:""}]},number_lessthan:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["number","currency"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is less than"},{segmentsId:2,type:"input",valueType:"number",value:"",mapSegmentsId:0}]},number_greaterthan:{type:"condition",segments:[{segmentsId:0,type:"dropdown",valueType:"field",optionType:["number","currency"],value:"",childSegments:[2]},{segmentsId:1,type:"text",value:"is greater than"},{segmentsId:2,type:"input",valueType:"number",value:"",mapSegmentsId:0}]}},n9=[{key:"status_changes",displayContent:"status is value of",conditionAuto:G4.status_changes},{key:"number_lessthan",displayContent:"Number is less than",conditionAuto:G4.number_lessthan},{key:"number_greaterthan",displayContent:"Number is greater than",conditionAuto:G4.number_greaterthan}],sl={changes_field_value:{key:"changes_field_value",segments:[{segmentsId:0,type:"text",value:"set"},{segmentsId:1,type:"dropdown",valueType:"field",optionType:"",fieldType:"",value:"",childSegments:[3]},{segmentsId:2,type:"text",value:"to"},{segmentsId:3,type:"input",valueType:"number",value:"",mapSegmentsId:1}]},send_notification:{key:"send_notification",segments:[{segmentsId:0,type:"text",value:"Notify the"},{segmentsId:1,type:"user",valueType:"user-notification",optionType:"",fieldType:"",value:[],childSegments:[3]},{segmentsId:2,type:"text",value:"as"},{segmentsId:3,type:"notification",valueType:"",value:"",mapSegmentsId:1}]},move_to_other_work:{key:"move_to_other_work",segments:[{segmentsId:0,type:"text",value:"Move to"},{segmentsId:1,type:"moveRecordToOtherWork",valueType:"moveRecordToOtherWork",optionType:"",fieldType:"",value:[]}]},copy_to_other_workspace_work:{key:"copy_to_other_workspace_work",segments:[{segmentsId:0,type:"text",value:"Move to"},{segmentsId:1,type:"workspace",valueType:"workspace",optionType:"",fieldType:"",value:[],childSegments:[2]},{segmentsId:2,type:"moveRecordToOtherWork",valueType:"moveRecordToOtherWork",optionType:"",fieldType:"",value:[],mapSegmentsId:1}]},send_notification_to_field:{key:"send_notification_to_field",segments:[{segmentsId:0,type:"text",value:"Notify the"},{segmentsId:1,type:"dropdown",valueType:"users",optionType:"",fieldType:"",value:[],childSegments:[3]},{segmentsId:2,type:"text",value:"as"},{segmentsId:3,type:"notification",valueType:"",value:"",mapSegmentsId:1}]}},s9=[{key:"changes_field_value",displayAutomation:"change Field Value",automation:sl.changes_field_value},{key:"send_notification",displayAutomation:"send Notification",automation:sl.send_notification},{key:"move_to_other_work",displayAutomation:"move to other work",automation:sl.move_to_other_work},{key:"copy_to_other_workspace_work",displayAutomation:"move to other workspace work",automation:sl.copy_to_other_workspace_work},{key:"send_notification_to_field",displayAutomation:"send Notification by field",automation:sl.send_notification_to_field}];var pl={},Rm;function p9(){if(Rm)return pl;Rm=1;var r=Qo();Object.defineProperty(pl,"__esModule",{value:!0}),pl.default=void 0;var o=r(je()),e=he();return pl.default=(0,o.default)((0,e.jsx)("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"}),"AddRounded"),pl}var f9=p9();const Mm=zo(f9),X4=({defaultValue:r,setValue:o,isDisable:e=!1})=>{const[d,t]=g.useState(r),{col:l}=g.useContext(Ge),[i,a]=g.useState(!0);g.useEffect(()=>{t(r)},[r]);const w=(p,m,h)=>{const f=d.blocks.map((k,x)=>x!==p?k:{...k,segments:k.segments.map((c,E)=>E!==m?c:{...c,value:h})});t(k=>({...k,blocks:f})),o({...d,blocks:f})},b=(p,m)=>{const h={...d};h.blocks=[...h.blocks,{...p,key:m}],t(h),a(!1)},n=({optionType:p,valueType:m,fieldId:h})=>{const f=l?.map(k=>k.field);if(m==="field")return f.filter(k=>p?.includes(k.dataType)&&!k.isAssociated).map(k=>({id:k.id,displayName:k.name,internalName:k.internalName}));if(m==="field-options")return f.find(x=>x.id===h)?.value?.map(x=>({id:x.key,displayName:x.value}))},s=p=>{let m={...d,blocks:d.blocks.filter((h,f)=>f!==p)};t(m),o(m)};return u.jsxs(u.Fragment,{children:[u.jsx("div",{children:d?.blocks?.map((p,m)=>u.jsxs("div",{className:"d-flex hide-icon",children:[u.jsxs("div",{className:"f-w-400 f-14 txt-black2 d-flex flex-wrap flex-1 align-center",children:[m?u.jsx("span",{children:"And only if"}):u.jsx("span",{children:"When a"}),p.segments.map((h,f)=>h.type==="text"?u.jsxs("span",{children:[" ",h.value," "]},f):h.type==="input"?u.jsx(tr.TextField,{id:"standard-basic",variant:"standard",className:"mx-8",disabled:e,defaultValue:h.value,type:h.valueType,onChange:k=>w(m,f,k.target.value),sx:{margin:0,maxWidth:100,padding:0,"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-root":{margin:0}}}):h.type==="dropdown"?u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{IconComponent:()=>null,value:h.value,disabled:e,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},onChange:k=>w(m,f,k.target.value),children:n({optionType:h.optionType,valueType:h.valueType,fieldId:p?.segments?.[h.mapSegmentsId]?.value})?.map(k=>u.jsx(tr.MenuItem,{value:k.id,children:k.displayName},k.id))},`${m}_${f}`)}):null)]}),d.blocks.length>1?u.jsx("img",{src:"/delete.svg",className:"hide cursor-pointer",onClick:()=>{s(m)}}):u.jsx(u.Fragment,{}),u.jsx("div",{children:!e&&d.blocks.length-1===m?u.jsx(u.Fragment,{children:u.jsx(Mm,{className:"f-w-400 f-14 txt-black2 cursor-pointer",onClick:()=>{a(!0)}})}):u.jsx(u.Fragment,{})})]},m))}),!e&&i?u.jsx(u.Fragment,{children:u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{labelId:"demo-simple-select-standard-label",id:"demo-simple-select-standard",IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:n9?.map(p=>u.jsx(tr.MenuItem,{onClick:()=>b(p.conditionAuto,p.key),children:p.displayContent},p.key))})})}):u.jsx(u.Fragment,{})]})},h9=({edgeData:r,updateEdgeData:o,setSelectedId:e})=>{console.log("==>edgeData",r);const{setValue:d,watch:t}=bb.useForm({defaultValues:{permission:r?.data?.permission||[],requiredColumns:r?.data?.requiredColumns||[],condition:r?.data?.condition||{id:"",blocks:[]}}}),l=b9?.map(i=>({id:i.field.id,displayName:i?.field?.name,internalName:i?.field?.internalName}));return u.jsx("div",{style:{position:"absolute",top:0,right:0,height:"100%",width:"420px",background:"#fff",borderLeft:"1px solid #ccc",zIndex:1e3},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:"Configuration"}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsx("div",{className:"flex-1",children:u.jsxs("div",{className:"p-10",children:[u.jsxs("div",{className:"h-44px flex-1 radius-8 px-12 py-6 d-flex justify-between align-center cursor-pointer",style:{backgroundColor:r4(r?.data?.sourceColor),border:`1px solid ${Ve(r?.data?.sourceColor)}`},children:[u.jsx("div",{className:"f-w-600 f-14 txt-black mr-20 ",style:{color:Ve(r?.data?.sourceColor)},children:r?.data?.sourceLabel}),u.jsx("img",{src:"/arrow.svg",alt:"arrow",className:"mr-20"}),u.jsx("div",{className:"f-w-600 f-14 txt-black mr-20 ",style:{color:Ve(r.data?.targetColor)},children:r?.data?.targetLabel})]}),u.jsx("div",{className:"border-solid-border1 my-16"}),u.jsxs("div",{className:"mb-16",children:[u.jsx("p",{className:"f-w-600 f-14 txt-black2 mb-6",children:"Permissions"}),u.jsx(Om,{selectedAssignees:t("permission"),datasetId:"460e5046a84043f7b8193feb2ece19d0",setValue:i=>{d("permission",i)}})]}),u.jsxs("div",{className:"mb-16",children:[u.jsx("p",{className:"f-w-600 f-14 txt-black2 mb-6",children:"Required Columns"}),u.jsx(w9,{defaultValue:t("requiredColumns"),options:l,setValue:i=>{d("requiredColumns",i)}})]}),u.jsxs("div",{children:[u.jsx("div",{className:"d-flex align-center justify-between",children:u.jsx("p",{className:"f-w-600 f-14 txt-black2",children:"Condition"})}),u.jsx(X4,{defaultValue:t("condition"),setValue:i=>{d("condition",i)}})]})]})}),u.jsxs("div",{className:"d-flex justify-end",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10",onClick:()=>e({id:"",type:"config"}),children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",onClick:()=>{o({id:r.id,data:{...r.data,...t()}}),e({id:"",type:"config"})},children:"Update"})]})]})})};var fl={},$m;function m9(){if($m)return fl;$m=1;var r=Qo();Object.defineProperty(fl,"__esModule",{value:!0}),fl.default=void 0;var o=r(je()),e=he();return fl.default=(0,o.default)((0,e.jsx)("path",{d:"m19 15-1.41-1.41L13 18.17V2h-2v16.17l-4.59-4.59L5 15l7 7z"}),"South"),fl}var k9=m9();const Um=zo(k9);var hl={},Lm;function x9(){if(Lm)return hl;Lm=1;var r=Qo();Object.defineProperty(hl,"__esModule",{value:!0}),hl.default=void 0;var o=r(je()),e=he();return hl.default=(0,o.default)((0,e.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),hl}var g9=x9();const c9=zo(g9);var ml={},jm;function u9(){if(jm)return ml;jm=1;var r=Qo();Object.defineProperty(ml,"__esModule",{value:!0}),ml.default=void 0;var o=r(je()),e=he();return ml.default=(0,o.default)((0,e.jsx)("path",{d:"M17.77 3.77 16 2 6 12l10 10 1.77-1.77L9.54 12z"}),"ArrowBackIosNew"),ml}var F9=u9();const A9=zo(F9);var kl={},zm;function y9(){if(zm)return kl;zm=1;var r=Qo();Object.defineProperty(kl,"__esModule",{value:!0}),kl.default=void 0;var o=r(je()),e=he();return kl.default=(0,o.default)((0,e.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4m0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7"}),"VisibilityOutlined"),kl}var E9=y9();const D9=zo(E9),v9=({defaultValue:r,setValue:o})=>{const[e,d]=g.useState(r),[t,l]=g.useState(!1),{acceptedUser:i,col:a,exampleData:w}=g.useContext(Ge),b=a?.map(s=>s.field),n=g.useMemo(()=>{const s=new Map;return b.forEach(p=>{if(p.dataType==="user"){const m=w[p.internalName],h=i.find(f=>f.id===m);s.set(p.internalName,h?.name??"")}else if(p.dataType==="collaborators"){const m=w[p.internalName]?.split(",");let h=[];m.forEach(f=>{const k=i.find(x=>x.id===f);h=[...h,k?.name||""]}),s.set(p.internalName,h.join(","))}else s.set(p.internalName,w[p.internalName])}),s},[b,i]);return u.jsxs("div",{children:[u.jsx("div",{style:{textDecoration:"underline",textUnderlineOffset:"2px"},onClick:()=>{l(!0)},children:"Template"}),t?u.jsx(tr.ClickAwayListener,{onClickAway:()=>l(!1),children:u.jsx("div",{className:"w-100 d-flex align-center txt-black2 f-12 mb-8",children:u.jsxs("div",{className:"w-358px border-solid-lightblue1 radius-12 bg-white",children:[u.jsx("div",{className:"h-46px border-b-solid-popper-border tl-radius-10 tr-radius-10 px-10 d-flex align-center f-14 f-w-400",children:"Send Notification"}),u.jsxs("div",{className:"my-8 h-31px d-flex align-center px-6 f-12",children:[u.jsx("div",{className:"w-82px d-flex align-center justify-center ",children:"Templates :"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Reminder"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Status Update"}),u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4",children:"Deadline Alert"})]}),u.jsxs("div",{className:"h-151px px-12 mb-8",children:[u.jsx("div",{className:"h-31px f-w-600 f-12 d-flex align-center",children:"Message"}),u.jsx(tr.TextField,{placeholder:"Type your message here...",className:"f-12",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:e,onChange:s=>{d(s.target.value)}})]}),u.jsx("div",{style:{gap:"4px"},className:"px-12 py-8 d-flex flex-wrap mb-8",children:b?.map(s=>u.jsx("div",{className:"radius-100 p-8 maxh-28px h-28px w-auto border-solid-popper-border ml-4 f-12",onClick:()=>{d(p=>p+`{${s.internalName}}`)},children:s.name}))}),u.jsx("div",{className:"p-12 mb-8",children:u.jsxs("div",{className:"h-160px radius-8 border-solid-lightblue1 bg-lightblue3 px-8 d-flex flex-column pb-8",children:[u.jsxs("div",{className:"h-31px d-flex align-center",children:[u.jsx(D9,{className:"f-12"}),u.jsx("p",{className:"ml-4 f-12 ",children:"Preview"})]}),u.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},className:"border-solid-lightblue1 h-100 flex-1 bg-white radius-4 p-8",children:e?.replace(/\{(\w+)\}/g,(s,p)=>n.get(p))})]})}),u.jsxs("div",{className:"bl-radius-10 br-radius-10 h-56px border-t-solid-popper-border d-flex justify-end px-12 align-center",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10 h-31px radius-8",onClick:()=>{l(!1)},children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",className:"h-31px radius-8",onClick:()=>{o(e),l(!1)},children:"Done"})]})]})})}):u.jsx(u.Fragment,{})]})},S9={};function _9(r,o){switch(o.type){case"ADD_OR_UPDATE":return{...r,[o.key]:o.value};case"DELETE":const e={...r};return delete e[o.key],e;default:return r}}const C9=({datasetId:r,workspaceId:o,targetWorkspaceId:e,autoIndex:d,segmentIndex:t,setValue:l,defaultValue:i})=>{const{mappingField:a,targetWork:w}=i,[b,n]=g.useState(null),[s,p]=g.useReducer(_9,a??S9),[m,h]=g.useState(!1);g.useEffect(()=>{n(w)},[a,w]);const{data:f}=Jr.useQuery(o9,{variables:{input:{workspaceId:Number(e)}},fetchPolicy:"network-only",client:Y4}),{data:k}=Jr.useQuery(Nm,{variables:{input:{workspaceId:Number(o),datasetId:r}},fetchPolicy:"network-only",client:Y4}),{data:x}=Jr.useQuery(Nm,{variables:{input:{workspaceId:Number(e),datasetId:b}},fetchPolicy:"network-only",client:Y4,skip:!b}),c=f?.getDataset?.filter(E=>E.id!==r)??[];return u.jsxs("div",{children:[u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{value:b,IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:c?.map(E=>u.jsx(tr.MenuItem,{value:E.id,onClick:()=>{n(E.id),h(!0)},children:E.name},E.id))},`${d}_${t}`)}),m?u.jsx(u.Fragment,{children:u.jsx(tr.ClickAwayListener,{onClickAway:()=>{},children:u.jsx("div",{className:"w-100 d-flex align-center mt-8",children:u.jsxs("div",{className:"w-358px border-solid-lightblue1 radius-8 bg-white h-367px",children:[u.jsx("div",{className:"border-b-solid-lightblue1 d-flex align-center px-10 txt-black2 h-46px",children:"Map Source to Destination"}),u.jsx("div",{className:"overflow-auto flex-1 h-264px",children:k?.getField?.filter(E=>!E.isAssociatedField&&!["created_on","updated_on"].includes(E.fieldInternalName))?.map(E=>{const y=x?.getField?.filter(D=>E.dataType===D.dataType&&!Object.values(s).includes(D.fieldInternalName)&&!["created_on","updated_on"].includes(E.fieldInternalName))||[],F=x?.getField?.find(D=>D.fieldInternalName===s[E.fieldInternalName]),I=F?[...y,F]:y;return u.jsxs("div",{className:"d-flex align-center h-52px",children:[u.jsx("div",{className:"txt-brown-dark1 f-12 f-w-600 text-truncate pl-16 w-200px",children:E.fieldDisplayName}),u.jsx("div",{className:"flex-1 d-flex align-center",children:I?.length||E.fieldInternalName in s?u.jsx(tr.Select,{className:"w-115px h-40px radius-8 f-10 p-0",defaultValue:s[E?.fieldInternalName]??null,children:I?.map(D=>u.jsx(tr.MenuItem,{value:D.fieldInternalName,onClick:()=>{p({type:"ADD_OR_UPDATE",key:E.fieldInternalName,value:D.fieldInternalName})},children:D.fieldDisplayName},D.id))}):u.jsx("div",{className:"w-115px h-40px radius-8 border-solid-red1 bg-lightred txt-red1 d-flex align-center justify-center f-10 f-w-400",children:"No field to show"})})]})})}),u.jsxs("div",{className:"bl-radius-10 br-radius-10 h-56px border-t-solid-popper-border d-flex justify-end px-12 align-center",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10 h-31px radius-8",onClick:()=>{h(!1)},children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",className:"h-31px radius-8",onClick:()=>{l({sourceWork:r,targetWork:b,mappingField:s}),h(!1)},children:"Done"})]})]})})})}):u.jsx(u.Fragment,{})]})},B9=({defaultValue:r,setValue:o})=>{const{validateUser:e}=g.useContext(Ge),{data:d}=Jr.useQuery(e9,{variables:{input:{userId:e.id,orgId:e?.organisation?.id}},fetchPolicy:"network-only",client:Tm}),t=d?.getWorkspaceList;return u.jsx("div",{children:u.jsx(tr.Select,{className:"w-115px h-40px radius-8 f-10 p-0",defaultValue:r,children:t?.map(l=>u.jsx(tr.MenuItem,{value:l.id,onClick:()=>{o(l.id)},children:l.name},l.id))})})},Vm=({defaultValue:r,setValue:o,isDisable:e=!1})=>{const[d,t]=g.useState([]),[l,i]=g.useState(!0),{col:a,datasetId:w,workspaceId:b}=g.useContext(Ge);g.useEffect(()=>{t(r)},[r]);const n=(h,f)=>{i(!1),t(k=>[...k,h])},s=h=>{const f=d.filter((k,x)=>x!==h);t(f),o(f)},p=(h,f,k)=>{const x=d.map((c,E)=>{if(E!==h)return c;const y=c.segments[f],F=y.valueType==="field",I=F?y.childSegments||[]:[],D=c.segments.map(v=>{if(v.segmentsId===y.segmentsId)if(F){const _=a.find(T=>T.field.id===k);return{...v,datasetId:_?.datasetId,datasetName:_?.datasetName,fieldType:_?.field.dataType,property:_?.field?.internalName,isAssociate:_?.field?.isAssociated,value:k}}else return{...v,value:k};if(F&&I.includes(v.segmentsId)){const _=a.find(T=>T.field.id===k);return{...v,type:["drop-down"].includes(_?.field?.dataType)?"dropdown":"input",value:"",valueType:"field-options"}}return v});return{...c,segments:D}});o(x),t(x)},m=({optionType:h,valueType:f,fieldId:k})=>{const x=a?.map(c=>c.field);if(f==="field")return x.map(c=>({id:c.id,displayName:c.name,internalName:c.internalName}));if(f==="field-options")return x.find(E=>E.id===k)?.value?.map(E=>({id:E.key,displayName:E.value}));if(f==="users")return x.filter(c=>["user","collaborators"].includes(c.dataType)).map(c=>({id:c.internalName,displayName:c.name,internalName:c.internalName}))};return u.jsxs(u.Fragment,{children:[u.jsx("div",{children:d?.map((h,f)=>u.jsxs("div",{className:"d-flex hide-icon",children:[u.jsxs("div",{className:"f-w-400 f-14 txt-black2 d-flex flex-wrap flex-1 align-center",children:[f?u.jsx("span",{children:"And "}):u.jsx("span",{children:"Then "}),h.segments.map((k,x)=>{if(k.type==="text")return u.jsxs("span",{className:"ml-2",children:[" ",k.value," "]},x);if(k.type==="input")return u.jsx(tr.TextField,{id:"standard-basic",variant:"standard",className:"mx-8",disabled:e,defaultValue:k.value,type:k.valueType,onChange:c=>p(f,x,c.target.value),sx:{margin:0,maxWidth:100,padding:0,"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-root":{margin:0}}});if(k.type==="dropdown")return u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{IconComponent:()=>null,value:k.value,disabled:e,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},onChange:c=>p(f,x,c.target.value),children:m({optionType:k.optionType,valueType:k.valueType,fieldId:h?.segments?.[k.mapSegmentsId]?.value})?.map(c=>u.jsx(tr.MenuItem,{value:c.id,children:c.displayName},c.id))},`${f}_${x}`)});if(k.type==="user")return u.jsx(Om,{selectedAssignees:k.value,setValue:c=>{p(f,x,c)},datasetId:w,isForNotification:!0});if(k.type==="notification")return u.jsx(v9,{defaultValue:k.value,setValue:c=>{p(f,x,c)}});if(k.type==="workspace")return u.jsx("div",{children:u.jsx(B9,{defaultValue:k.value,setValue:c=>{p(f,x,c)}})});if(k.type==="moveRecordToOtherWork"){let c=d[f]?.segments[k.mapSegmentsId]?.value;return u.jsx(C9,{defaultValue:k.value,datasetId:w,workspaceId:b,targetWorkspaceId:c??b,autoIndex:f,segmentIndex:x,setValue:E=>{p(f,x,E)}})}return null})]}),d.length>1?u.jsx("img",{src:"/delete.svg",className:"hide cursor-pointer",onClick:()=>{s(f)}}):u.jsx(u.Fragment,{}),u.jsx("div",{children:!e&&d.length-1===f?u.jsx(u.Fragment,{children:u.jsx(Mm,{className:"f-w-400 f-14 txt-black2 cursor-pointer",onClick:()=>{i(!0)}})}):u.jsx(u.Fragment,{})})]},f))}),!e&&l?u.jsx(u.Fragment,{children:u.jsx(tr.FormControl,{variant:"standard",sx:{width:"auto"},className:"mx-8",children:u.jsx(tr.Select,{labelId:"demo-simple-select-standard-label",id:"demo-simple-select-standard",IconComponent:()=>null,sx:{minWidth:30,padding:0,"& .MuiSelect-select":{padding:"0 !important",paddingRight:"0 !important"},"& .MuiInputBase-input":{padding:"0 !important",paddingRight:"0 !important"}},children:s9?.map(h=>u.jsx(tr.MenuItem,{onClick:()=>n(h.automation,h.key),children:h.displayAutomation},h.key))})})}):u.jsx(u.Fragment,{})]})},I9=({selectedId:r,setSelectedId:o,setSelectAutomation:e,setisCreateNewAutomation:d})=>{const[t,l]=g.useState([]),{workspaceId:i}=g.useContext(Ge);g.useEffect(()=>{const n=async s=>{try{const p=await xA(s,i);l(p)}catch(p){console.error("Error fetching automation:",p)}};r?.id&&n(r?.id)},[r?.id]);const a=async({id:n,isActive:s})=>{await gA({id:n,isActive:s,workspaceId:i})},w=async({id:n})=>{await cA({id:n,workspaceId:i})},b={inputProps:{"aria-label":"Size switch demo"}};return u.jsx("div",{style:{top:0,right:0,height:"100%",width:"422px",background:"#fff",borderLeft:"1px solid #ccc"},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:[u.jsx(A9,{className:"mr-8 f-14 cursor-pointer",onClick:()=>o({id:"",type:"auto"})}),"Automation"]}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsxs("div",{className:"p-10 flex-1 overflow-auto",children:[u.jsx("div",{className:"mb-12 border-dashed-newborder h-48px radius-8 bg-blue-lighten9 d-flex align-center txt-darkblue cursor-pointer",onClick:()=>{d(!0)},children:u.jsxs("div",{className:"p-14 d-flex align-center",children:[u.jsx(c9,{}),u.jsx("p",{className:"f-w-600 f-14 ml-8",children:"New"})]})}),t?.data?.map(n=>u.jsxs("div",{className:"border-solid-input-border radius-12 px-12 py-10 d-flex mb-12 align-start",children:[u.jsxs("div",{className:"flex-1",onClick:()=>{e(n)},children:[u.jsx(X4,{defaultValue:n.condition,setValue:s=>{},isDisable:!0}),u.jsx("div",{children:u.jsx(Um,{className:"my-8"})}),u.jsx(Vm,{defaultValue:n.automation,setValue:s=>{},isDisable:!0})]}),u.jsx(tr.Switch,{...b,defaultChecked:n.isActive,onChange:s=>{a({id:n.id,isActive:s.target.checked})}}),u.jsx("img",{src:"/delete.svg",onClick:()=>{w({id:n.id})}})]}))]})]})})},T9=({editEdgeData:r,setSelectedId:o,selectAutomation:e,isCreateNewAutomation:d})=>{const{setValue:t,watch:l}=bb.useForm({defaultValues:{condition:{id:"",blocks:[]},automation:[]}}),{acceptedUser:i,selectFieldId:a,validateUser:w,workspaceId:b}=g.useContext(Ge);g.useEffect(()=>{t("automation",e.automation??[]),t("condition",e.condition??{id:"",blocks:[]})},[e.id]);const n=async()=>{const s=l(),p=s.automation?.map(m=>{switch(m.key){case"changes_field_value":const h=m.segments?.find(v=>v.valueType==="field"),f=m.segments[h?.childSegments?.[0]];return{targetWorkspaceId:b,targetFieldId:h.value,actionType:Xt.UPDATE_FIELD,content:{propertyData:[{datasetId:h.datasetId,datasetName:h.datasetName,isAssociate:h.isAssociate,property:h.property,fieldType:h.fieldType,value:f.value,setValue:f.value}],datasetId:h.datasetId,datasetName:h.datasetName}};case"send_notification":const k=m.segments?.find(v=>v.valueType==="user-notification"),x=m.segments[k?.childSegments?.[0]],c=v=>v.map(T=>{const L=i.find(q=>q.id===T);return{id:L?.id,email:L?.email}});return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.NOTIFY,content:{isDeleted:!1,isActive:!0,workspaceId:b,senderEmail:w.email,senderId:w.id,notificationType:"push",notificationTitle:"Automation",notificationDescription:x.value,notificationMetadata:{},isRead:!1,receiverDetails:c(k.value)}};case"move_to_other_work":let E=m.segments?.find(v=>v.valueType==="moveRecordToOtherWork");return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.MOVE_RECORD,content:{...E?.value}};case"copy_to_other_workspace_work":let y=m.segments?.find(v=>v.valueType==="workspace"),F=m.segments?.find(v=>v.valueType==="moveRecordToOtherWork");return{targetWorkspaceId:y?.value??b,targetFieldId:"",actionType:Xt.COPY_RECORD_TO_OTHER_WORKSPACE,content:{...F?.value}};case"send_notification_to_field":const I=m.segments?.find(v=>v.valueType==="users"),D=m.segments[I?.childSegments?.[0]];return{targetWorkspaceId:b,targetFieldId:"",actionType:Xt.NOTIFY,content:{isDeleted:!1,isActive:!0,workspaceId:b,senderEmail:w.email,senderId:w.id,notificationType:"push",notificationTitle:"Automation",notificationDescription:D.value,notificationMetadata:{},isRead:!1,receiverDetails:[],selectField:I.value}}}});d?await mA({workspaceId:b+"",fieldId:a,from:r?.source,to:r?.target,workflowSegId:r?.id,condition:s.condition,automation:s.automation,automationAction:p}):await kA({id:e.id,condition:s.condition,automation:s.automation,automationAction:p,workspaceId:b+""})};return u.jsx("div",{style:{position:"absolute",top:0,right:0,height:"100%",maxHeight:"704px",width:"420px",background:"#fff",borderLeft:"1px solid #ccc",zIndex:1e3},children:u.jsxs("div",{className:"px-16 py-12 d-flex flex-column edge-container maxh-703px",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h-36px d-flex align-center f-w-600 f-14 txt-darkblue px-8",children:"Properties"}),u.jsx("div",{className:"border-solid-border1 my-12"})]}),u.jsxs("div",{className:"flex-1 overflow-auto hide-scroll",children:[u.jsx(X4,{defaultValue:l("condition"),setValue:s=>{t("condition",s)}}),u.jsx("div",{children:u.jsx(Um,{className:"my-8"})}),u.jsx(Vm,{defaultValue:l("automation"),setValue:s=>{t("automation",s)}})]}),u.jsxs("div",{className:"d-flex justify-end",children:[u.jsx(tr.Button,{variant:"outlined",color:"inherit",className:"mr-10",onClick:()=>o({id:"",type:"auto"}),children:"Cancel"}),u.jsx(tr.Button,{variant:"outlined",color:"primary",onClick:()=>{o({id:"",type:"auto"}),n()},children:"Update"})]})]})})},N9=({editEdgeData:r,selectedId:o,setSelectedId:e})=>{const[d,t]=g.useState({}),[l,i]=g.useState(!1);return Pm(d)&&!l?u.jsx(I9,{selectedId:o,setSelectedId:e,setSelectAutomation:t,setisCreateNewAutomation:i}):u.jsx(T9,{editEdgeData:r,selectAutomation:d,setSelectedId:e,isCreateNewAutomation:l})},P9=({selectedId:r,editEdgeData:o,updateEdgeData:e,setSelectedId:d})=>r.type===yf.Auto?u.jsx(N9,{editEdgeData:o,selectedId:r,setSelectedId:d}):u.jsx(h9,{edgeData:o,updateEdgeData:e,setSelectedId:d}),O9=({edges:r,updateEdgeData:o,saveToBackend:e})=>{const[d,t]=g.useState({id:"",type:yf.Config});return u.jsx("div",{children:d.id?u.jsx(P9,{selectedId:d,updateEdgeData:o,editEdgeData:r?.find(l=>l.id===d.id),setSelectedId:t}):u.jsx(_A,{edges:r,setSelectedId:t,saveToBackend:e})})},R9=({children:r,col:o,selectFieldId:e,validateUser:d,workspaceId:t,exampleData:l,acceptedUser:i,datasetId:a})=>u.jsx(Ge.Provider,{value:{col:o,selectFieldId:e,validateUser:d,workspaceId:t,exampleData:l,acceptedUser:i,datasetId:a},children:r}),M9={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",borderRadius:2,boxShadow:"24",p:4,background:"linear-gradient(101.49deg, #F8FDFF 11.98%, #FBF2FB 119.18%)",border:"1px solid #EAEFF4",outline:"none"},$9=({fieldId:r,col:o,validateUser:e,workspaceId:d,exampleData:t,acceptedUser:l,datasetId:i,onClose:a})=>{const w=o?.find(c=>c.field.id===r),b=$5(w.field.value),[n,s,p]=Eg(b),[m,h,f]=Dg([]);g.useEffect(()=>{(async E=>{try{const y=await uA({fieldId:E,workspaceId:d});s(y.data.workflowDefinition.nodes),h(y.data.workflowDefinition.edges)}catch(y){console.error("Error fetching automation:",y)}})(r)},[r]);const k=({id:c,data:E})=>{h(y=>y?.map(F=>(F.id===c&&(F.data=E),F)))},x=async()=>{const c=U5(m);await hA({workspaceId:d,workflow:{nodes:n,edges:m,workflow:c},fieldId:r})};return u.jsx(tr.Modal,{open:!0,onClose:()=>a,children:u.jsx(R9,{col:o,selectFieldId:r,validateUser:e,workspaceId:d,exampleData:t,acceptedUser:l,datasetId:i,children:u.jsx("div",{className:"workflow-we3434",children:u.jsxs("div",{className:"w-1225px h-703px border-solid-lightblue1 d-flex flex-column",style:M9,children:[u.jsxs("div",{className:"h-56px border-b-solid-border d-flex align-center justify-between px-20",children:[u.jsx("div",{className:"f-w-600 f-18 px-12",children:"Workflow"}),u.jsxs("div",{className:"d-flex align-center px-12",children:[u.jsx("div",{className:"border-solid-ligntbrown h-14px mr-8"}),u.jsx(M5,{className:"h-24px w-24px txt-lightblack3",onClick:()=>a()})]})]}),u.jsxs("div",{className:"flex-1 d-flex",children:[u.jsx(lw,{children:u.jsx(vA,{nodes:n,edges:m,setEdges:h,onNodesChange:p,onEdgesChange:f})}),u.jsx(O9,{edges:m,updateEdgeData:k,saveToBackend:x})]})]})})})})};Bo.ReactFlowModal=$9,Object.defineProperty(Bo,Symbol.toStringTag,{value:"Module"})});
|