@amp-labs/react 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),I=require("react"),y=require("@chakra-ui/react"),Li=require("@emotion/react"),uo=require("@emotion/styled"),Mi={warning:{bg:"red.50",outlineColor:"red.800",outline:"2px solid",outlineOffset:"0",borderColor:"red.800",color:"red.800",_hover:{bg:"red.100"}}},$i=y.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.300"},_selected:{color:"black",fontWeight:"500",bg:"gray.200",border:"none",_hover:{bg:"gray.300"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.200"},_selected:{color:"red.800",fontWeight:"500",bg:"red.100",border:"none",_hover:{bg:"red.200"}}}}},Button:{variants:Mi}}}),Ui=y.extendTheme(y.withDefaultColorScheme({colorScheme:"facebook",components:["Button"]}),$i);function qi({children:e}){return c.jsx(y.ChakraProvider,{theme:Ui,children:e})}const Fo=I.createContext(null),Wi=Fo.Provider,X=()=>{const e=I.useContext(Fo);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var G=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e))(G||{});const Po=I.createContext(void 0);function Je(){const e=I.useContext(Po);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const zi=(()=>{const e={};return Object.values(G).forEach(t=>{e[t]={}}),e})();function Ji({children:e}){const[t,r]=I.useState(zi),n=I.useCallback((g,m)=>{r(b=>{const w={...b};return w[g]=w[g]||{},w[g][m]=!0,w})},[r]),o=I.useCallback((g,m)=>{var b;return!!((b=t[g])!=null&&b[m])},[t]),a=I.useCallback((g,m)=>{r(b=>{var v;const w={...b};return(v=w[g])==null||delete v[m],w})},[r]),s=I.useCallback(g=>{r(m=>{const b={...m};return b[g]={},b})},[r]),u=I.useCallback((g,m)=>{r(b=>{const w={...b};return w[g]=w[g]||{},m.forEach(v=>{w[g][v]=!0}),w})},[r]),p=I.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:o,removeError:a,resetBoundary:s,setErrors:u}),[t,r,n,o,a,s,u]);return c.jsx(Po.Provider,{value:p,children:e})}function We({message:e}){return c.jsx(y.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:c.jsxs(y.Stack,{alignItems:"center",children:[c.jsx(y.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&c.jsx(y.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Ee({message:e}){return c.jsxs(y.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[c.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),c.jsx(y.Box,{boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center","align-self":"stretch",padding:"12px 50px 12px 50px",borderRadius:"8px",border:"2px solid #FECACA",background:"#FEF2F2",children:c.jsx(y.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Hi="https://api.withampersand.com/v1".replace(/\/+$/,"");class Do{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Hi}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Bo}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Ki=new Do,_r=class _r{constructor(t=Ki){this.configuration=t,this.fetchApi=async(r,n)=>{let o={url:r,init:n};for(const s of this.middleware)s.pre&&(o=await s.pre({fetch:this.fetchApi,...o})||o);let a;try{a=await(this.configuration.fetchApi||fetch)(o.url,o.init)}catch(s){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:o.url,init:o.init,error:s,response:a?a.clone():void 0})||a);if(a===void 0)throw s instanceof Error?new Yi(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(a=await s.post({fetch:this.fetchApi,url:o.url,init:o.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const r=this.clone();return r.middleware=r.middleware.concat(...t),r}withPreMiddleware(...t){const r=t.map(n=>({pre:n}));return this.withMiddleware(...r)}withPostMiddleware(...t){const r=t.map(n=>({post:n}));return this.withMiddleware(...r)}isJsonMime(t){return t?_r.jsonRegex.test(t):!1}async request(t,r){const{url:n,init:o}=await this.createFetchParams(t,r),a=await this.fetchApi(n,o);if(a&&a.status>=200&&a.status<300)return a;throw new Xi(a,"Response returned an error code")}async createFetchParams(t,r){let n=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(n+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(g=>o[g]===void 0?delete o[g]:{});const a=typeof r=="function"?r:async()=>r,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},u={...s,...await a({init:s,context:t})},p={...u,body:Vi(u.body)||u.body instanceof URLSearchParams||Gi(u.body)?u.body:JSON.stringify(u.body)};return{url:n,init:p}}clone(){const t=this.constructor,r=new t(this.configuration);return r.middleware=this.middleware.slice(),r}};_r.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let re=_r;function Gi(e){return typeof Blob<"u"&&e instanceof Blob}function Vi(e){return typeof FormData<"u"&&e instanceof FormData}class Xi extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class Yi extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class _ extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function N(e,t){const r=e[t];return r!=null}function Bo(e,t=""){return Object.keys(e).map(r=>Lo(r,e[r],t)).filter(r=>r.length>0).join("&")}function Lo(e,t,r=""){const n=r+(r.length?`[${e}]`:e);if(t instanceof Array){const o=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${o}`}if(t instanceof Set){const o=Array.from(t);return Lo(e,o,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Bo(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function Qn(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class L{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class Fe{constructor(t){this.raw=t}async value(){}}class Zi{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Qi(e){return ea(e)}function ea(e,t){return e==null?e:{name:e.name,valuePrefix:N(e,"valuePrefix")?e.valuePrefix:void 0}}function ta(e){return ra(e)}function ra(e,t){return e==null?e:{name:e.name}}function na(e){return oa(e)}function oa(e,t){return e==null?e:{attachmentType:e.attachmentType,query:N(e,"query")?ta(e.query):void 0,header:N(e,"header")?Qi(e.header):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function ia(e){return aa(e)}function aa(e,t){return e}function sa(e){return ca(e)}function ca(e,t){return e==null?e:{days:N(e,"days")?e.days:void 0,fullHistory:N(e,"fullHistory")?e.fullHistory:void 0}}function Mo(e){return da(e)}function da(e,t){return e==null?e:{defaultPeriod:sa(e.defaultPeriod)}}function la(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ua(e){if(e!==void 0)return e===null?null:{defaultPeriod:la(e.defaultPeriod)}}function pa(e){return fa(e)}function fa(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function $o(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function ha(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,backfill:ua(e.backfill)}}function ga(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,ha)}}function ma(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function ya(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,ma)}}function wa(e){return Ia(e)}function Ia(e,t){return e==null?e:{docsURL:N(e,"docsURL")?e.docsURL:void 0}}function Uo(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function gr(e){return va(e)}function va(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:N(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function ba(e){return Sa(e)}function Sa(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function xa(e){return Oa(e)}function Oa(e,t){return e==null?e:{provider:e.provider,read:N(e,"read")?e.read:void 0,write:N(e,"write")?e.write:void 0,proxy:N(e,"proxy")?pa(e.proxy):void 0}}function qo(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:$o(e.proxy)}}function Ca(e){return Na(e)}function Na(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:xa(e.content)}}function Ta(e){return Ra(e)}function Ra(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Wo(e){return _a(e)}function _a(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return ja(e)}function ja(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:N(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:N(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function vr(e){return Aa(e)}function Aa(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:Wo(e.group),consumer:Ta(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:N(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function ka(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Ea(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Fa(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Ea(e.metadata)}}function Pa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function Da(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:qo(e.content)}}function Ba(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Da(e.config)}}function La(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function Ma(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:La(e.latestRevision)}}function $a(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Ua(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function qa(e){return Wa(e)}function Wa(e,t){return e==null?e:{url:N(e,"url")?e.url:void 0,headers:N(e,"headers")?e.headers:void 0}}function za(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return Ja(e)}function Ja(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:qa(e.metadata),createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ha(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Ka(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret}}function Ga(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret}}function Va(e){if(e!==void 0)return e===null?null:{projectId:e.projectId,providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Ha(e.basicAuth),oauth2ClientCredentials:Ka(e.oauth2ClientCredentials),oauth2Password:Ga(e.oauth2Password)}}function Xa(e){return Ya(e)}function Ya(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Za(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function zo(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:N(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:N(e,"default")?e.default:void 0,prompt:N(e,"prompt")?e.prompt:void 0}}function Bn(e){return Qa(e)}function Qa(e,t){return e==null?e:{...Za(e),...zo(e)}}function Jo(e){return es(e)}function es(e,t){return e}function ts(e){return rs(e)}function rs(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(Bn):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(Bn):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Jo(e.optionalFieldsAuto):void 0,allFields:N(e,"allFields")?e.allFields.map(Bn):void 0,backfill:N(e,"backfill")?Mo(e.backfill):void 0}}function ns(e){return os(e)}function os(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(ts):void 0}}function is(e){return as(e)}function as(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ss(e){return cs(e)}function cs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(is):void 0}}function ds(e){return ls(e)}function ls(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?ns(e.read):void 0,write:N(e,"write")?ss(e.write):void 0,proxy:N(e,"proxy")?Xa(e.proxy):void 0}}function us(e){return ps(e)}function ps(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:ds(e.content)}}function fs(e){if(e!==void 0)return e===null?null:{providerAppId:e.providerAppId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:e.providerConsumerRef,refreshToken:e.refreshToken,scopes:e.scopes}}function hs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:qo(e.content)}}function gs(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:fs(e.connection),config:hs(e.config)}}function qt(e){return ms(e)}function ms(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:N(e,"group")?Wo(e.group):void 0,healthStatus:e.healthStatus,connection:vr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,config:Ca(e.config)}}function ys(e){return ws(e)}function ws(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Is(e,t){return e==null?e:{fieldName:e.fieldName}}function po(e){return vs(e)}function vs(e,t){return e==null?e:{...Is(e),...zo(e)}}function bs(e){return Ss(e)}function Ss(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(po):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(po):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Jo(e.optionalFieldsAuto):void 0,backfill:N(e,"backfill")?Mo(e.backfill):void 0}}function xs(e){return Os(e)}function Os(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(bs):void 0}}function Cs(e){return Ns(e)}function Ns(e,t){return e==null?e:{objectName:e.objectName}}function Ts(e){return Rs(e)}function Rs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Cs):void 0}}function _s(e){return js(e)}function js(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?xs(e.read):void 0,write:N(e,"write")?Ts(e.write):void 0,proxy:N(e,"proxy")?ys(e.proxy):void 0}}function As(e){return ks(e)}function ks(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:_s(e.content)}}function fo(e){return Es(e)}function Es(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:As(e.latestRevision)}}function Fs(e){return Ps(e)}function Ps(e,t){return e==null?e:{msg:e.msg,operationEventId:N(e,"operation_event_id")?e.operation_event_id:void 0,operationId:N(e,"operation_id")?e.operation_id:void 0}}function Ds(e){return Bs(e)}function Bs(e,t){return e==null?e:{timestamp:e.timestamp,message:Fs(e.message),severity:e.severity}}function Ls(e){return Ms(e)}function Ms(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function $s(e){return Us(e)}function Us(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function qs(e){return Ws(e)}function Ws(e,t){return e==null?e:{regular:N(e,"regular")?$s(e.regular):void 0,darkMode:N(e,"darkMode")?Ls(e.darkMode):void 0}}function zs(e){return Js(e)}function Js(e,t){return e==null?e:{workspaceRefField:N(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:N(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:N(e,"scopesField")?e.scopesField:void 0}}function Hs(e){return Ks(e)}function Ks(e,t){return e==null?e:{grantType:e.grantType,authURL:N(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:N(e,"audience")?e.audience:void 0,tokenMetadataFields:zs(e.tokenMetadataFields),docsURL:N(e,"docsURL")?e.docsURL:void 0,authURLParams:N(e,"authURLParams")?e.authURLParams:void 0}}function Gs(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,projectId:e.projectId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerAppId:e.providerAppId,provider:e.provider}}function ho(e){return Vs(e)}function Vs(e,t){return e==null?e:{projectId:e.projectId,integrationId:e.integrationId,configId:e.configId,actionType:e.actionType,id:e.id,installationId:e.installationId,status:e.status,result:N(e,"result")?e.result:void 0,latestOperationEventId:N(e,"latestOperationEventId")?e.latestOperationEventId:void 0,metadata:N(e,"metadata")?e.metadata:void 0,createTime:N(e,"createTime")?new Date(e.createTime):void 0}}function Xs(e){return Ys(e)}function Ys(e,t){return e==null?e:{bulkWrite:ba(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function go(e){return Zs(e)}function Zs(e,t){return e==null?e:{name:e.name,authType:ia(e.authType),baseURL:e.baseURL,oauth2Opts:N(e,"oauth2Opts")?Hs(e.oauth2Opts):void 0,apiKeyOpts:N(e,"apiKeyOpts")?na(e.apiKeyOpts):void 0,basicOpts:N(e,"basicOpts")?wa(e.basicOpts):void 0,support:Xs(e.support),providerOpts:e.providerOpts,displayName:N(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:N(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:N(e,"media")?qs(e.media):void 0}}function Qs(e){return ec(e)}function ec(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function tc(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:za(e.metadata)}}function rc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:tc(e.destination)}}function nc(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:ga(e.read),write:ya(e.write),proxy:$o(e.proxy)}}function oc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:nc(e.content)}}function ic(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:oc(e.config)}}function ac(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:ic(e.installation)}}function sc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function cc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:sc(e.project)}}function dc(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function lc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:dc(e.providerApp)}}class uc extends re{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Va(t.generateConnectionParams)},r);return new L(a,s=>vr(s))}async generateConnection(t,r){return await(await this.generateConnectionRaw(t,r)).value()}async getConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:n},r);return new L(a,s=>vr(s))}async getConnection(t,r){return await(await this.getConnectionRaw(t,r)).value()}async listConnectionsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const n={};t.provider!==void 0&&(n.provider=t.provider),t.groupRef!==void 0&&(n.groupRef=t.groupRef),t.consumerRef!==void 0&&(n.consumerRef=t.consumerRef);const o={},a=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(vr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class pc extends re{async createConsumerRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createConsumer.");if(t.consumer===null||t.consumer===void 0)throw new _("consumer","Required parameter requestParameters.consumer was null or undefined when calling createConsumer.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/consumers".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:ka(t.consumer)},r);return new Fe(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class fc extends re{async createDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createDestination.");if(t.destination===null||t.destination===void 0)throw new _("destination","Required parameter requestParameters.destination was null or undefined when calling createDestination.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Fa(t.destination)},r);return new L(a,s=>mr(s))}async createDestination(t,r){return await(await this.createDestinationRaw(t,r)).value()}async deleteDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling deleteDestination.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"DELETE",headers:o,query:n},r);return new Fe(a)}async deleteDestination(t,r){await this.deleteDestinationRaw(t,r)}async getDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getDestination.");if(t.destinationName===null||t.destinationName===void 0)throw new _("destinationName","Required parameter requestParameters.destinationName was null or undefined when calling getDestination.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationName}",encodeURIComponent(String(t.destinationName))),method:"GET",headers:o,query:n},r);return new L(a,s=>mr(s))}async getDestination(t,r){return await(await this.getDestinationRaw(t,r)).value()}async listDestinationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listDestinations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(mr))}async listDestinations(t,r){return await(await this.listDestinationsRaw(t,r)).value()}async updateDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling updateDestination.");if(t.destinationUpdate===null||t.destinationUpdate===void 0)throw new _("destinationUpdate","Required parameter requestParameters.destinationUpdate was null or undefined when calling updateDestination.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"PATCH",headers:o,query:n,body:rc(t.destinationUpdate)},r);return new L(a,s=>mr(s))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class hc extends re{async createGroupRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createGroup.");if(t.group===null||t.group===void 0)throw new _("group","Required parameter requestParameters.group was null or undefined when calling createGroup.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/groups".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Pa(t.group)},r);return new Fe(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class gc extends re{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:Ba(t.installation)},r);return new L(a,s=>qt(s))}async createInstallation(t,r){return await(await this.createInstallationRaw(t,r)).value()}async deleteInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"DELETE",headers:o,query:n},r);return new Fe(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:n},r);return new L(a,s=>qt(s))}async getInstallation(t,r){return await(await this.getInstallationRaw(t,r)).value()}async importInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations:import".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:gs(t.installation)},r);return new L(a,s=>qt(s))}async importInstallation(t,r){return await(await this.importInstallationRaw(t,r)).value()}async listInstallationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const n={};t.groupRef!==void 0&&(n.groupRef=t.groupRef);const o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(qt))}async listInstallations(t,r){return await(await this.listInstallationsRaw(t,r)).value()}async updateInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new _("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"PATCH",headers:o,query:n,body:ac(t.installationUpdate)},r);return new L(a,s=>qt(s))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class mc extends re{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:n,body:Uo(t.batchUpsertIntegrationsRequest)},r);return new L(a,s=>s.map(fo))}async batchUpsertIntegrations(t,r){return await(await this.batchUpsertIntegrationsRaw(t,r)).value()}async createIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new _("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Ma(t.integration)},r);return new Fe(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:o,query:n},r);return new Fe(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(fo))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class yc extends re{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new _("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:n,body:Gs(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new L(a):new Zi(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class wc extends re{async getOperationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getOperation.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling getOperation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:o,query:n},r);return new L(a,s=>ho(s))}async getOperation(t,r){return await(await this.getOperationRaw(t,r)).value()}async listOperationLogsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperationLogs.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling listOperationLogs.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}/logs".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(Ds))}async listOperationLogs(t,r){return await(await this.listOperationLogsRaw(t,r)).value()}async listOperationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listOperations.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling listOperations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}/operations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(ho))}async listOperations(t,r){return await(await this.listOperationsRaw(t,r)).value()}}class Ic extends re{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new _("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects",method:"POST",headers:o,query:n,body:$a(t.project)},r);return new L(a,s=>gr(s))}async createProject(t,r){return await(await this.createProjectRaw(t,r)).value()}async deleteProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:o,query:n},r);return new Fe(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new L(a,s=>gr(s))}async getProject(t,r){return await(await this.getProjectRaw(t,r)).value()}async listProjectsRaw(t){const r={},n={},o=await this.request({path:"/projects",method:"GET",headers:n,query:r},t);return new L(o,a=>a.map(gr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new _("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:n,body:cc(t.projectUpdate)},r);return new L(a,s=>gr(s))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class vc extends re{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new _("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const n={},o={},a=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:n},r);return new L(a,s=>go(s))}async getProvider(t,r){return await(await this.getProviderRaw(t,r)).value()}async listProvidersRaw(t){const r={},n={},o=await this.request({path:"/providers",method:"GET",headers:n,query:r},t);return new L(o,a=>Qn(a,go))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class bc extends re{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new _("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Ua(t.providerApp)},r);return new L(a,s=>Ir(s))}async createProviderApp(t,r){return await(await this.createProviderAppRaw(t,r)).value()}async deleteProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:o,query:n},r);return new Fe(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new L(a,s=>s.map(Ir))}async listProviderApps(t,r){return await(await this.listProviderAppsRaw(t,r)).value()}async updateProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new _("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:o,query:n,body:lc(t.providerAppUpdate)},r);return new L(a,s=>Ir(s))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class Sc extends re{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:Uo(t.revision)},r);return new Fe(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new _("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const n={};t.connectionId!==void 0&&(n.connectionId=t.connectionId);const o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:o,query:n},r);return new L(a,s=>us(s))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class xc extends re{async generateUploadUrlRaw(t){const r={},n={},o=await this.request({path:"/generate-upload-url",method:"GET",headers:n,query:r},t);return new L(o,a=>Qs(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class Oc{constructor(t){this.connectionApi=new uc(t),this.consumerApi=new pc(t),this.destinationApi=new fc(t),this.groupApi=new hc(t),this.installationApi=new gc(t),this.integrationApi=new mc(t),this.oAuthApi=new yc(t),this.operationApi=new wc(t),this.projectApi=new Ic(t),this.providerApi=new vc(t),this.providerAppApi=new bc(t),this.revisionApi=new Sc(t),this.uploadURLApi=new xc(t)}}const Cc="1.7.0",Nc="v1",yr="https://api.withampersand.com";function Ho(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return yr;case"mock":return"http://127.0.0.1:4010";case"":return yr;default:return e??yr}}catch{return yr}}const Tc=(e,t)=>`${e}/${t}`;function Rc(){return Tc(Ho(),Nc)}const _c=Ho(),jc=Rc(),Ac=new Do({basePath:jc,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Cc}});let kc=new Oc(Ac);const H=()=>kc,Ko=I.createContext({integrations:null}),Go=()=>{const e=I.useContext(Ko);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Ec({projectId:e,children:t}){const r=X(),{setError:n,isError:o}=Je(),[a,s]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),s(m||[])}).catch(m=>{p(!1),n(G.INTEGRATION_LIST,e),console.error("Error retrieving integration information for : ",m)})},[e,r,n]);const g=I.useMemo(()=>({integrations:a}),[a]);return o(G.INTEGRATION_LIST,e)?c.jsx(Ee,{message:"Error retrieving integrations for the project, double check the API key"}):c.jsx(Ko.Provider,{value:g,children:u?c.jsx(We,{}):t})}const Vo=I.createContext({project:null,appName:"",projectId:""}),V=()=>{const e=I.useContext(Vo);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Fc({projectId:e,children:t}){const r=X(),{isError:n,setError:o}=Je(),[a,s]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),s(m)}).catch(m=>{o(G.PROJECT,e),p(!1),console.error("Error loading Ampersand project: ",m)})},[e,r,p,o]);const g=I.useMemo(()=>({projectId:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(G.PROJECT,e)?c.jsx(Ee,{message:`Error loading project ${e}`}):c.jsx(Vo.Provider,{value:g,children:u?c.jsx(We,{}):t})}function Pc(e){const{options:{apiKey:t,projectId:r},children:n}=e;return c.jsx(qi,{children:c.jsx(Ji,{children:c.jsx(Wi,{value:t,children:c.jsx(Fc,{projectId:r,children:c.jsx(Ec,{projectId:r,children:n})})})})})}const Xo=I.createContext(null);function Dc(){const e=I.useContext(Xo);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
2
- component is wrapped with AmpersandProvider`);return e}function de(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Bc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Yo=I.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0});function Pe(){const e=I.useContext(Yo);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Lc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:o,groupName:a,onInstallSuccess:s,onUpdateSuccess:u}){const p=X(),{projectId:g}=V(),{integrations:m}=Go(),[b,w]=I.useState([]),[v,x]=I.useState(!0),{setError:S,isError:O}=Je(),j=(b==null?void 0:b[0])||null,R=I.useMemo(()=>Bc(t,m||[]),[t,m]);I.useEffect(()=>{R===null&&(m!=null&&m.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,R,m]);const D=I.useCallback(J=>{w([J])},[w]),M=I.useCallback(()=>{R!=null&&R.id&&H().installationApi.listInstallations({projectIdOrName:g,integrationId:R.id,groupRef:o},{headers:{"X-Api-Key":p??""}}).then(J=>{x(!1),w(J||[])}).catch(J=>{S(G.INSTALLATION_LIST,R.id),x(!1),console.error("Error retrieving installation information: ",J)})},[R,g,p,S,o]),oe=(R==null?void 0:R.id)||"";I.useEffect(()=>{M()},[M]);const ee=I.useMemo(()=>({integrationId:(R==null?void 0:R.id)||"",provider:(R==null?void 0:R.provider)||"",integrationObj:R,consumerRef:r,consumerName:n,groupRef:o,groupName:a,installation:j,setInstallation:D,resetInstallations:M,onInstallSuccess:s,onUpdateSuccess:u}),[R,r,n,o,a,j,D,M,s,u]);if(R!==null){const J=`Error retrieving installation information for integration "${(R==null?void 0:R.name)||"unknown"}"`;return O(G.INSTALLATION_LIST,oe)?c.jsx(Ee,{message:J}):c.jsx(Yo.Provider,{value:ee,children:v?c.jsx(We,{}):e})}return c.jsx(Ee,{message:`Integration "${t}" not found`})}const Zo=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),St=()=>{const e=I.useContext(Zo);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Qo({provider:e,groupRef:t,children:r}){const n=X(),{projectId:o}=V(),[a,s]=I.useState(null),[u,p]=I.useState(null),[g,m]=I.useState(!0),{setError:b,isError:w}=Je(),{provider:v}=Pe();if(!o)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const x=e||v;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");I.useEffect(()=>{H().connectionApi.listConnections({projectIdOrName:o,groupRef:t,provider:x},{headers:{"X-Api-Key":n??""}}).then(O=>{m(!1),s(O)}).catch(O=>{m(!1),b(G.CONNECTION_LIST,o),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,O)})},[o,n,t,x,b]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:s,setSelectedConnection:p}),[a,u,s,p]);return w(G.CONNECTION_LIST,o)?c.jsx(Ee,{message:"Error retrieving existing connections"}):c.jsx(Zo.Provider,{value:S,children:g?c.jsx(We,{}):r})}var qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function eo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xr={exports:{}};xr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",o=1,a=2,s=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",b="[object Date]",w="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",j="[object Null]",R="[object Object]",D="[object Promise]",M="[object Proxy]",oe="[object RegExp]",ee="[object Set]",J="[object String]",ie="[object Symbol]",be="[object Undefined]",he="[object WeakMap]",Ne="[object ArrayBuffer]",st="[object DataView]",Br="[object Float32Array]",Lr="[object Float64Array]",Mr="[object Int8Array]",$r="[object Int16Array]",Ur="[object Int32Array]",qr="[object Uint8Array]",Wr="[object Uint8ClampedArray]",zr="[object Uint16Array]",Jr="[object Uint32Array]",Hr=/[\\^$.*+?()[\]{}|]/g,$=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,U={};U[Br]=U[Lr]=U[Mr]=U[$r]=U[Ur]=U[qr]=U[Wr]=U[zr]=U[Jr]=!0,U[u]=U[p]=U[Ne]=U[m]=U[st]=U[b]=U[w]=U[v]=U[S]=U[O]=U[R]=U[oe]=U[ee]=U[J]=U[he]=!1;var De=typeof qe=="object"&&qe&&qe.Object===Object&&qe,Zt=typeof self=="object"&&self&&self.Object===Object&&self,te=De||Zt||Function("return this")(),Ct=t&&!t.nodeType&&t,ct=Ct&&!0&&e&&!e.nodeType&&e,Nt=ct&&ct.exports===Ct,dt=Nt&&De.process,Qt=function(){try{return dt&&dt.binding&&dt.binding("util")}catch{}}(),er=Qt&&Qt.isTypedArray;function Kr(l,i){for(var d=-1,f=l==null?0:l.length,C=0,T=[];++d<f;){var A=l[d];i(A,d,l)&&(T[C++]=A)}return T}function Gr(l,i){for(var d=-1,f=i.length,C=l.length;++d<f;)l[C+d]=i[d];return l}function Vr(l,i){for(var d=-1,f=l==null?0:l.length;++d<f;)if(i(l[d],d,l))return!0;return!1}function Xr(l,i){for(var d=-1,f=Array(l);++d<l;)f[d]=i(d);return f}function Yr(l){return function(i){return l(i)}}function lt(l,i){return l.has(i)}function Tt(l,i){return l==null?void 0:l[i]}function ut(l){var i=-1,d=Array(l.size);return l.forEach(function(f,C){d[++i]=[C,f]}),d}function Se(l,i){return function(d){return l(i(d))}}function tr(l){var i=-1,d=Array(l.size);return l.forEach(function(f){d[++i]=f}),d}var rr=Array.prototype,Zr=Function.prototype,pt=Object.prototype,Be=te["__core-js_shared__"],Rt=Zr.toString,ae=pt.hasOwnProperty,_t=function(){var l=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),jt=pt.toString,Qr=RegExp("^"+Rt.call(ae).replace(Hr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Nt?te.Buffer:void 0,le=te.Symbol,He=te.Uint8Array,or=pt.propertyIsEnumerable,ir=rr.splice,Te=le?le.toStringTag:void 0,At=Object.getOwnPropertySymbols,Ke=nr?nr.isBuffer:void 0,en=Se(Object.keys,Object),ge=Me(te,"DataView"),Ge=Me(te,"Map"),kt=Me(te,"Promise"),Et=Me(te,"Set"),Ft=Me(te,"WeakMap"),Ve=Me(Object,"create"),me=Ie(ge),tn=Ie(Ge),rn=Ie(kt),nn=Ie(Et),on=Ie(Ft),ar=le?le.prototype:void 0,xe=ar?ar.valueOf:void 0;function Re(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function an(){this.__data__=Ve?Ve(null):{},this.size=0}function sn(l){var i=this.has(l)&&delete this.__data__[l];return this.size-=i?1:0,i}function cn(l){var i=this.__data__;if(Ve){var d=i[l];return d===n?void 0:d}return ae.call(i,l)?i[l]:void 0}function dn(l){var i=this.__data__;return Ve?i[l]!==void 0:ae.call(i,l)}function Le(l,i){var d=this.__data__;return this.size+=this.has(l)?0:1,d[l]=Ve&&i===void 0?n:i,this}Re.prototype.clear=an,Re.prototype.delete=sn,Re.prototype.get=cn,Re.prototype.has=dn,Re.prototype.set=Le;function ye(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function ln(){this.__data__=[],this.size=0}function un(l){var i=this.__data__,d=gt(i,l);if(d<0)return!1;var f=i.length-1;return d==f?i.pop():ir.call(i,d,1),--this.size,!0}function pn(l){var i=this.__data__,d=gt(i,l);return d<0?void 0:i[d][1]}function fn(l){return gt(this.__data__,l)>-1}function hn(l,i){var d=this.__data__,f=gt(d,l);return f<0?(++this.size,d.push([l,i])):d[f][1]=i,this}ye.prototype.clear=ln,ye.prototype.delete=un,ye.prototype.get=pn,ye.prototype.has=fn,ye.prototype.set=hn;function we(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function gn(){this.size=0,this.__data__={hash:new Re,map:new(Ge||ye),string:new Re}}function ft(l){var i=Ze(this,l).delete(l);return this.size-=i?1:0,i}function Pt(l){return Ze(this,l).get(l)}function mn(l){return Ze(this,l).has(l)}function ht(l,i){var d=Ze(this,l),f=d.size;return d.set(l,i),this.size+=d.size==f?0:1,this}we.prototype.clear=gn,we.prototype.delete=ft,we.prototype.get=Pt,we.prototype.has=mn,we.prototype.set=ht;function Xe(l){var i=-1,d=l==null?0:l.length;for(this.__data__=new we;++i<d;)this.add(l[i])}function yn(l){return this.__data__.set(l,n),this}function wn(l){return this.__data__.has(l)}Xe.prototype.add=Xe.prototype.push=yn,Xe.prototype.has=wn;function Oe(l){var i=this.__data__=new ye(l);this.size=i.size}function sr(){this.__data__=new ye,this.size=0}function In(l){var i=this.__data__,d=i.delete(l);return this.size=i.size,d}function vn(l){return this.__data__.get(l)}function bn(l){return this.__data__.has(l)}function Sn(l,i){var d=this.__data__;if(d instanceof ye){var f=d.__data__;if(!Ge||f.length<r-1)return f.push([l,i]),this.size=++d.size,this;d=this.__data__=new we(f)}return d.set(l,i),this.size=d.size,this}Oe.prototype.clear=sr,Oe.prototype.delete=In,Oe.prototype.get=vn,Oe.prototype.has=bn,Oe.prototype.set=Sn;function xn(l,i){var d=Qe(l),f=!d&&Fn(l),C=!d&&!f&&It(l),T=!d&&!f&&!C&&Ut(l),A=d||f||C||T,F=A?Xr(l.length,String):[],k=F.length;for(var E in l)ae.call(l,E)&&!(A&&(E=="length"||C&&(E=="offset"||E=="parent")||T&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||An(E,k)))&&F.push(E);return F}function gt(l,i){for(var d=l.length;d--;)if(wt(l[d][0],i))return d;return-1}function On(l,i,d){var f=i(l);return Qe(l)?f:Gr(f,d(l))}function Ye(l){return l==null?l===void 0?be:j:Te&&Te in Object(l)?_n(l):Lt(l)}function cr(l){return et(l)&&Ye(l)==u}function dr(l,i,d,f,C){return l===i?!0:l==null||i==null||!et(l)&&!et(i)?l!==l&&i!==i:mt(l,i,d,f,dr,C)}function mt(l,i,d,f,C,T){var A=Qe(l),F=Qe(i),k=A?p:ue(l),E=F?p:ue(i);k=k==u?R:k,E=E==u?R:E;var q=k==R,W=E==R,K=k==E;if(K&&It(l)){if(!It(i))return!1;A=!0,q=!1}if(K&&!q)return T||(T=new Oe),A||Ut(l)?Bt(l,i,d,f,C,T):Tn(l,i,k,d,f,C,T);if(!(d&o)){var Z=q&&ae.call(l,"__wrapped__"),Q=W&&ae.call(i,"__wrapped__");if(Z||Q){var ve=Z?l.value():l,je=Q?i.value():i;return T||(T=new Oe),C(ve,je,d,f,T)}}return K?(T||(T=new Oe),Rn(l,i,d,f,C,T)):!1}function Dt(l){if(!$t(l)||En(l))return!1;var i=$e(l)?Qr:$;return i.test(Ie(l))}function Cn(l){return et(l)&&ur(l.length)&&!!U[Ye(l)]}function Nn(l){if(!yt(l))return en(l);var i=[];for(var d in Object(l))ae.call(l,d)&&d!="constructor"&&i.push(d);return i}function Bt(l,i,d,f,C,T){var A=d&o,F=l.length,k=i.length;if(F!=k&&!(A&&k>F))return!1;var E=T.get(l);if(E&&T.get(i))return E==i;var q=-1,W=!0,K=d&a?new Xe:void 0;for(T.set(l,i),T.set(i,l);++q<F;){var Z=l[q],Q=i[q];if(f)var ve=A?f(Q,Z,q,i,l,T):f(Z,Q,q,l,i,T);if(ve!==void 0){if(ve)continue;W=!1;break}if(K){if(!Vr(i,function(je,tt){if(!lt(K,tt)&&(Z===je||C(Z,je,d,f,T)))return K.push(tt)})){W=!1;break}}else if(!(Z===Q||C(Z,Q,d,f,T))){W=!1;break}}return T.delete(l),T.delete(i),W}function Tn(l,i,d,f,C,T,A){switch(d){case st:if(l.byteLength!=i.byteLength||l.byteOffset!=i.byteOffset)return!1;l=l.buffer,i=i.buffer;case Ne:return!(l.byteLength!=i.byteLength||!T(new He(l),new He(i)));case m:case b:case O:return wt(+l,+i);case w:return l.name==i.name&&l.message==i.message;case oe:case J:return l==i+"";case S:var F=ut;case ee:var k=f&o;if(F||(F=tr),l.size!=i.size&&!k)return!1;var E=A.get(l);if(E)return E==i;f|=a,A.set(l,i);var q=Bt(F(l),F(i),f,C,T,A);return A.delete(l),q;case ie:if(xe)return xe.call(l)==xe.call(i)}return!1}function Rn(l,i,d,f,C,T){var A=d&o,F=lr(l),k=F.length,E=lr(i),q=E.length;if(k!=q&&!A)return!1;for(var W=k;W--;){var K=F[W];if(!(A?K in i:ae.call(i,K)))return!1}var Z=T.get(l);if(Z&&T.get(i))return Z==i;var Q=!0;T.set(l,i),T.set(i,l);for(var ve=A;++W<k;){K=F[W];var je=l[K],tt=i[K];if(f)var lo=A?f(tt,je,K,i,l,T):f(je,tt,K,l,i,T);if(!(lo===void 0?je===tt||C(je,tt,d,f,T):lo)){Q=!1;break}ve||(ve=K=="constructor")}if(Q&&!ve){var fr=l.constructor,hr=i.constructor;fr!=hr&&"constructor"in l&&"constructor"in i&&!(typeof fr=="function"&&fr instanceof fr&&typeof hr=="function"&&hr instanceof hr)&&(Q=!1)}return T.delete(l),T.delete(i),Q}function lr(l){return On(l,Pn,jn)}function Ze(l,i){var d=l.__data__;return kn(i)?d[typeof i=="string"?"string":"hash"]:d.map}function Me(l,i){var d=Tt(l,i);return Dt(d)?d:void 0}function _n(l){var i=ae.call(l,Te),d=l[Te];try{l[Te]=void 0;var f=!0}catch{}var C=jt.call(l);return f&&(i?l[Te]=d:delete l[Te]),C}var jn=At?function(l){return l==null?[]:(l=Object(l),Kr(At(l),function(i){return or.call(l,i)}))}:Dn,ue=Ye;(ge&&ue(new ge(new ArrayBuffer(1)))!=st||Ge&&ue(new Ge)!=S||kt&&ue(kt.resolve())!=D||Et&&ue(new Et)!=ee||Ft&&ue(new Ft)!=he)&&(ue=function(l){var i=Ye(l),d=i==R?l.constructor:void 0,f=d?Ie(d):"";if(f)switch(f){case me:return st;case tn:return S;case rn:return D;case nn:return ee;case on:return he}return i});function An(l,i){return i=i??s,!!i&&(typeof l=="number"||Yt.test(l))&&l>-1&&l%1==0&&l<i}function kn(l){var i=typeof l;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?l!=="__proto__":l===null}function En(l){return!!_t&&_t in l}function yt(l){var i=l&&l.constructor,d=typeof i=="function"&&i.prototype||pt;return l===d}function Lt(l){return jt.call(l)}function Ie(l){if(l!=null){try{return Rt.call(l)}catch{}try{return l+""}catch{}}return""}function wt(l,i){return l===i||l!==l&&i!==i}var Fn=cr(function(){return arguments}())?cr:function(l){return et(l)&&ae.call(l,"callee")&&!or.call(l,"callee")},Qe=Array.isArray;function Mt(l){return l!=null&&ur(l.length)&&!$e(l)}var It=Ke||pr;function _e(l,i){return dr(l,i)}function $e(l){if(!$t(l))return!1;var i=Ye(l);return i==v||i==x||i==g||i==M}function ur(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=s}function $t(l){var i=typeof l;return l!=null&&(i=="object"||i=="function")}function et(l){return l!=null&&typeof l=="object"}var Ut=er?Yr(er):Cn;function Pn(l){return Mt(l)?xn(l):Nn(l)}function Dn(){return[]}function pr(){return!1}e.exports=_e})(xr,xr.exports);var Mc=xr.exports;const $c=eo(Mc),xt="other";function ze(e){return e.mapToName!==void 0}function Uc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function qc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}function Wc(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>ze(n)&&!!n.mapToName))||[]}function zc(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}const Jc=(e,t)=>{var r,n,o;return(o=(n=(r=e==null?void 0:e.content)==null?void 0:r.read)==null?void 0:n.objects)==null?void 0:o[t]};function Hc(e){return ze(e)?e.mapToName:e.fieldName}const ei=(e,t)=>{var n,o,a;const r=[];return(a=(o=(n=t.content)==null?void 0:n.read)==null?void 0:o.objects)==null||a.forEach(s=>{r.push({name:s==null?void 0:s.objectName,completed:e?!!Jc(e,s.objectName):!1})}),r},ti=e=>{var r;return{name:xt,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function Kc(e,t){var a;const r=ei(e,t),o=!!((a=t==null?void 0:t.content)!=null&&a.write)?ti(e):void 0;return o&&r.push(o),r}function ri(e,t,r){const n=(e==null?void 0:e.filter(a=>!(t!=null&&t[a==null?void 0:a.mapToName])))||[],o=n.map(a=>a.mapToName);return r(G.MAPPING,o),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:o}}function to(e,t){return $c(e,t)}const Gc=(e,t,r)=>{var v,x,S,O,j,R;if(!e)return null;const n=Uc(e,t),o=n&&qc(n),a=n&&zc(n),s=n&&Wc(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,g=((S=(x=(v=p==null?void 0:p.read)==null?void 0:v.objects)==null?void 0:x[t])==null?void 0:S.selectedFields)||{},m=((R=(j=(O=p==null?void 0:p.read)==null?void 0:O.objects)==null?void 0:j[t])==null?void 0:R.selectedFieldMappings)||{},b={...g},w={...m};return{allFields:u,requiredFields:o,optionalFields:a,requiredMapFields:s,selectedOptionalFields:g,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:b,requiredMapFields:w}}},Vc=(e,t)=>{var s,u;if(!e)return null;const r=(u=(s=t==null?void 0:t.content)==null?void 0:s.write)==null?void 0:u.objects,n=Object.keys(r||{}),o={};n.forEach(p=>{o[p]=!0});const a={...o};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:o,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:a}}};function ni(e,t,r){var a,s;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,o=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:Gc(n,t,r),write:Vc(o,r)}}const oi=(e,t,r,n)=>{const o=ni(e,r,t);n(r,o)},Xc=(e,t,r)=>{const n=Kc(t,e),o={};n.forEach(({name:a,completed:s})=>{s&&(o[a]=ni(e,a,t))}),r(o)},ii=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(Hc(a))),{...Array.from(n).reduce((a,s)=>({...a,[s]:!0}),{}),...r||{}}},ai=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},r={};return t&&Object.keys(t).forEach(n=>{t[n]!==void 0?r[n]=t[n]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${n}`)}),r};function si(e,t){return t[e]||void 0}function ro({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:o,apiKey:a,setInstallation:s,onInstallSuccess:u}){const p={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:o,config:e}};return H().installationApi.createInstallation(p,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}}).then(g=>{s(g),u==null||u(g.id,g.config)}).catch(g=>{console.error("ERROR: ",g)})}function jr(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const Yc=(e,t)=>{const r=e.content.read,n=r==null?void 0:r.objects;return n==null?void 0:n.find(o=>o.objectName===t)},Zc=(e,t,r,n)=>{const o=ii(e),a=ai(e),s=Yc(r,t);if(!s)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const u={revisionId:r.id,createdBy:`consumer:${n}`,content:{provider:r.content.provider,read:{objects:{[t]:{objectName:t,schedule:s.schedule,destination:s.destination,selectedFields:o,selectedFieldMappings:a,backfill:s.backfill}}}}};return jr(r)&&(u.content.proxy={enabled:!0}),u},Qc=(e,t,r,n,o,a,s,u,p,g,m)=>{const b=Zc(p,a,u,n);return b?ro({createConfig:b,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:s,setInstallation:g,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ci=e=>{var a,s;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(s=e.write)==null?void 0:s.selectedNonConfigurableWriteFields,o=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;o.includes(p)&&(t[p]={objectName:p})}),t},ed=e=>{const t=e.content.write;return t==null?void 0:t.objects},td=(e,t,r)=>{if(!ed(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=ci(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return jr(t)&&(a.content.proxy={enabled:!0}),a},rd=(e,t,r,n,o,a,s,u,p,g)=>{const m=td(u,s,n);return m?ro({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:a,setInstallation:p,onInstallSuccess:g}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};function nd(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const di="uninstall-installation",od=I.forwardRef(({text:e="Uninstall"},t)=>{const r=y.useTab({ref:t}),n=y.useMultiStyleConfig("Tabs",r);return c.jsxs(y.Button,{__css:n.warningTab,...r,minHeight:15,children:[c.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[nd(),c.jsx(y.Box,{textAlign:"left",children:c.jsx(y.Text,{color:"red.800",children:e})})]}),r.children]})}),li=I.createContext({hydratedRevision:null,loading:!1}),Gt=()=>{const e=I.useContext(li);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function id({projectId:e,children:t}){var D;const{selectedConnection:r}=St(),{integrationId:n,integrationObj:o}=Pe(),[a,s]=I.useState(null),[u,p]=I.useState(!0),{isError:g,removeError:m,setError:b}=Je(),w=X(),v=r==null?void 0:r.id,x=(D=o==null?void 0:o.latestRevision)==null?void 0:D.id,S=(o==null?void 0:o.name)||n;I.useEffect(()=>{e&&n&&x&&v&&w&&H().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:x,connectionId:v},{headers:{"X-Api-Key":w??""}}).then(M=>{s(M),p(!1),m(G.HYDRATED_REVISION,S)}).catch(M=>{console.error(`Error loading integration ${S}`,M),p(!1),b(G.HYDRATED_REVISION,S)})},[e,n,x,v,w,m,b,S]);const O=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),R=`Error retrieving integration details for '${(o==null?void 0:o.name)||n||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return c.jsx(li.Provider,{value:O,children:g(G.HYDRATED_REVISION,S)?c.jsx(Ee,{message:R}):t})}var ui=Symbol.for("immer-nothing"),mo=Symbol.for("immer-draftable"),se=Symbol.for("immer-state"),ad=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function ne(e,...t){if(process.env.NODE_ENV!=="production"){const r=ad[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var vt=Object.getPrototypeOf;function bt(e){return!!e&&!!e[se]}function it(e){var t;return e?pi(e)||Array.isArray(e)||!!e[mo]||!!((t=e.constructor)!=null&&t[mo])||kr(e)||Er(e):!1}var sd=Object.prototype.constructor.toString();function pi(e){if(!e||typeof e!="object")return!1;const t=vt(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===sd}function Or(e,t){Ar(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function Ar(e){const t=e[se];return t?t.type_:Array.isArray(e)?1:kr(e)?2:Er(e)?3:0}function qn(e,t){return Ar(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fi(e,t,r){const n=Ar(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function cd(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kr(e){return e instanceof Map}function Er(e){return e instanceof Set}function rt(e){return e.copy_||e.base_}function Wn(e,t){if(kr(e))return new Map(e);if(Er(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=pi(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[se];let o=Reflect.ownKeys(n);for(let a=0;a<o.length;a++){const s=o[a],u=n[s];u.writable===!1&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[s]={configurable:!0,writable:!0,enumerable:u.enumerable,value:e[s]})}return Object.create(vt(e),n)}else{const n=vt(e);if(n!==null&&r)return{...e};const o=Object.create(n);return Object.assign(o,e)}}function no(e,t=!1){return Fr(e)||bt(e)||!it(e)||(Ar(e)>1&&(e.set=e.add=e.clear=e.delete=dd),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>no(n,!0))),e}function dd(){ne(2)}function Fr(e){return Object.isFrozen(e)}var ld={};function at(e){const t=ld[e];return t||ne(0,e),t}var Ht;function hi(){return Ht}function ud(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yo(e,t){t&&(at("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function zn(e){Jn(e),e.drafts_.forEach(pd),e.drafts_=null}function Jn(e){e===Ht&&(Ht=e.parent_)}function wo(e){return Ht=ud(Ht,e)}function pd(e){const t=e[se];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Io(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[se].modified_&&(zn(t),ne(4)),it(e)&&(e=Cr(t,e),t.parent_||Nr(t,e)),t.patches_&&at("Patches").generateReplacementPatches_(r[se].base_,e,t.patches_,t.inversePatches_)):e=Cr(t,r,[]),zn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ui?e:void 0}function Cr(e,t,r){if(Fr(t))return t;const n=t[se];if(!n)return Or(t,(o,a)=>vo(e,n,t,o,a,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Nr(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const o=n.copy_;let a=o,s=!1;n.type_===3&&(a=new Set(o),o.clear(),s=!0),Or(a,(u,p)=>vo(e,n,o,u,p,r,s)),Nr(e,o,!1),r&&e.patches_&&at("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function vo(e,t,r,n,o,a,s){if(process.env.NODE_ENV!=="production"&&o===r&&ne(5),bt(o)){const u=a&&t&&t.type_!==3&&!qn(t.assigned_,n)?a.concat(n):void 0,p=Cr(e,o,u);if(fi(r,n,p),bt(p))e.canAutoFreeze_=!1;else return}else s&&r.add(o);if(it(o)&&!Fr(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Cr(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Nr(e,o)}}function Nr(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&no(t,r)}function fd(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:hi(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,a=oo;r&&(o=[n],a=Kt);const{revoke:s,proxy:u}=Proxy.revocable(o,a);return n.draft_=u,n.revoke_=s,u}var oo={get(e,t){if(t===se)return e;const r=rt(e);if(!qn(r,t))return hd(e,r,t);const n=r[t];return e.finalized_||!it(n)?n:n===Ln(e.base_,t)?(Mn(e),e.copy_[t]=Kn(n,e)):n},has(e,t){return t in rt(e)},ownKeys(e){return Reflect.ownKeys(rt(e))},set(e,t,r){const n=gi(rt(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const o=Ln(rt(e),t),a=o==null?void 0:o[se];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(cd(r,o)&&(r!==void 0||qn(e.base_,t)))return!0;Mn(e),Hn(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ln(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mn(e),Hn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=rt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){ne(11)},getPrototypeOf(e){return vt(e.base_)},setPrototypeOf(){ne(12)}},Kt={};Or(oo,(e,t)=>{Kt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Kt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&ne(13),Kt.set.call(this,e,t,void 0)};Kt.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&ne(14),oo.set.call(this,e[0],t,r,e[0])};function Ln(e,t){const r=e[se];return(r?rt(r):e)[t]}function hd(e,t,r){var o;const n=gi(t,r);return n?"value"in n?n.value:(o=n.get)==null?void 0:o.call(e.draft_):void 0}function gi(e,t){if(!(t in e))return;let r=vt(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=vt(r)}}function Hn(e){e.modified_||(e.modified_=!0,e.parent_&&Hn(e.parent_))}function Mn(e){e.copy_||(e.copy_=Wn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gd=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const a=r;r=t;const s=this;return function(p=a,...g){return s.produce(p,m=>r.call(this,m,...g))}}typeof r!="function"&&ne(6),n!==void 0&&typeof n!="function"&&ne(7);let o;if(it(t)){const a=wo(this),s=Kn(t,void 0);let u=!0;try{o=r(s),u=!1}finally{u?zn(a):Jn(a)}return yo(a,n),Io(o,a)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===ui&&(o=void 0),this.autoFreeze_&&no(o,!0),n){const a=[],s=[];at("Patches").generateReplacementPatches_(t,o,a,s),n(a,s)}return o}else ne(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...u)=>this.produceWithPatches(s,p=>t(p,...u));let n,o;return[this.produce(t,r,(s,u)=>{n=s,o=u}),n,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){it(e)||ne(8),bt(e)&&(e=md(e));const t=wo(this),r=Kn(e,void 0);return r[se].isManual_=!0,Jn(t),r}finishDraft(e,t){const r=e&&e[se];(!r||!r.isManual_)&&ne(9);const{scope_:n}=r;return yo(n,t),Io(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));const n=at("Patches").applyPatches_;return bt(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Kn(e,t){const r=kr(e)?at("MapSet").proxyMap_(e,t):Er(e)?at("MapSet").proxySet_(e,t):fd(e,t);return(t?t.scope_:hi()).drafts_.push(r),r}function md(e){return bt(e)||ne(10,e),mi(e)}function mi(e){if(!it(e)||Fr(e))return e;const t=e[se];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Wn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Wn(e,!0);return Or(r,(n,o)=>{fi(r,n,mi(o))}),t&&(t.finalized_=!1),r}var ce=new gd,Wt=ce.produce;ce.produceWithPatches.bind(ce);ce.setAutoFreeze.bind(ce);ce.setUseStrictShallowCopy.bind(ce);ce.applyPatches.bind(ce);ce.createDraft.bind(ce);ce.finishDraft.bind(ce);const yi=I.createContext(void 0),yd={};function io(){const e=I.useContext(yi);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function wd({children:e}){const{installation:t}=Pe(),{hydratedRevision:r,loading:n}=Gt(),[o,a]=I.useState(yd),s=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&s&&!(Object.entries(o).length>0)&&Xc(r,s,a)},[r,n,s,o]);const u=I.useCallback((v,x)=>{a(S=>Wt(S,O=>{O[v]=Wt(O[v],x)}))},[a]),p=I.useCallback((v,x)=>{a(S=>Wt(S,O=>{O[v]=x}))},[a]),g=I.useCallback(()=>{a(Wt(v=>{const x=v.other.write;x&&(x.isWriteModified=!1)}))},[a]),m=I.useCallback(v=>{a(Wt(x=>{var O;const S=(O=x[v])==null?void 0:O.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),b=I.useCallback(v=>{v===xt?g():m(v)},[m,g]),w=I.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:b}),[o,p,b,u]);return c.jsx(yi.Provider,{value:w,children:e})}const Id=c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[c.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),c.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function vd(e,t){return t?I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},I.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Id:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:c.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const wi=I.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},o)=>{const a=y.useTab({ref:o}),s=y.useMultiStyleConfig("Tabs",a);return c.jsxs(y.Button,{__css:s.tab,...a,variant:"outline",minHeight:15,children:[c.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[vd(t,r),c.jsxs(y.Box,{textAlign:"left",children:[c.jsx(y.Text,{children:n||e}),r&&c.jsx(y.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function bd({pending:e,completed:t,displayName:r}){return c.jsxs(c.Fragment,{children:[c.jsx(y.Divider,{marginY:3}),c.jsx(wi,{objectName:xt,completed:t,pending:e,displayName:r},"other-write")]})}const Ii=I.createContext(null);function vi(){const e=I.useContext(Ii);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function Sd(e,t){return e!=null&&e[t]?e[t]:{name:di,completed:!1}}function xd({children:e}){var O,j,R;const{project:t}=V(),{installation:r,provider:n}=Pe(),{hydratedRevision:o}=Gt(),{objectConfigurationsState:a}=io(),[s,u]=I.useState(0),p=(t==null?void 0:t.appName)||"",g=r==null?void 0:r.config,m=o&&ei(g,o),b=m!==null,w=!!((O=o==null?void 0:o.content)!=null&&O.write),v=w?ti(g):void 0,x=[...m||[]];v&&w&&x.push(v);const S=Sd(x,s);return c.jsx(Ii.Provider,{value:S==null?void 0:S.name,children:c.jsxs(y.Box,{p:8,maxWidth:"55rem",border:"1px solid #EFEFEF",borderRadius:6,boxShadow:"md",margin:"auto",bgColor:"whitesmoke",display:"flex",gap:"6",minHeight:"100%",color:"gray.800",fontSize:"md",children:[c.jsxs(y.Box,{width:"20rem",children:[c.jsxs(y.Text,{children:[de(n)," integration"]}),c.jsx(y.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),b&&c.jsxs(y.Tabs,{index:s,onChange:u,orientation:"horizontal",children:[m.map(D=>{var M,oe,ee,J;return c.jsx(wi,{objectName:D.name,completed:D.completed,pending:((oe=(M=a[D.name])==null?void 0:M.read)==null?void 0:oe.isOptionalFieldsModified)||((J=(ee=a[D.name])==null?void 0:ee.read)==null?void 0:J.isRequiredMapFieldsModified)},D.name)}),w&&v&&c.jsx(bd,{completed:v.completed,pending:(R=(j=a==null?void 0:a.other)==null?void 0:j.write)==null?void 0:R.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&c.jsxs(c.Fragment,{children:[c.jsx(y.Divider,{marginTop:10,marginBottom:3}),c.jsx(od,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]})})}const Ot=()=>{const{appName:e}=V(),{objectConfigurationsState:t,setConfigureState:r}=io(),{selectedObjectName:n}=vi(),o=si(n||"",t);return{appName:e,configureState:o,setConfigureState:r,selectedObjectName:n}};function Od(e,t,r){var o;const n=((o=e==null?void 0:e.read)==null?void 0:o.selectedFieldMappings)||{};if(n[t]=r,e!=null&&e.read){const a=e.read.savedConfig.requiredMapFields,u=!to(a,n);e.read.isRequiredMapFieldsModified=u}}function bi(e,t,r,n){t(e,o=>Od(o,r,n))}function Cd({field:e,onSelectChange:t,allFields:r}){var b;const{configureState:n,selectedObjectName:o,setConfigureState:a}=Ot(),[s,u]=I.useState(!0),p=(b=n==null?void 0:n.read)==null?void 0:b.selectedFieldMappings,g=p==null?void 0:p[e.mapToName];I.useEffect(()=>{e._default&&!g&&o&&n&&bi(o,a,e.mapToName,e._default),u(!1)},[e,a,o,g,n]);const m=I.useMemo(()=>r==null?void 0:r.map(w=>c.jsx("option",{value:w.fieldName,children:w.displayName},w.fieldName)),[r]);return c.jsxs(y.Stack,{children:[c.jsx(y.Text,{fontWeight:"500",children:e.mapToDisplayName}),c.jsx(y.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),c.jsx(y.Select,{name:e.mapToName,variant:"flushed",value:g||void 0,onChange:t,placeholder:g?void 0:"Please select one",disabled:s,children:m})]},e.mapToName)}function Pr({string:e}){return c.jsxs(y.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[c.jsx(y.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),c.jsx(y.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:c.jsx(y.Divider,{marginLeft:2})})]})}function Nd(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ot(),{isError:n,removeError:o}=Je(),a=u=>{const{value:p,name:g}=u.target;p&&(e&&bi(e,r,g,p),n(G.MAPPING,g)&&o(G.MAPPING,g))},s=I.useMemo(()=>{var u,p;return((p=(u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)==null?void 0:p.filter(ze))||[]},[t]);return s.length?c.jsxs(y.Box,{children:[c.jsx(Pr,{string:"Map the following fields (required)"}),c.jsx(y.Stack,{children:s.map(u=>{var p;return c.jsxs(y.FormControl,{isInvalid:n(G.MAPPING,u.mapToName),children:[c.jsx(Cd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),c.jsx(y.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function Td(e,t,r){var o,a;const n=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(n[t]=r,r||delete n[t],(a=e.read)!=null&&a.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,p=!to(s,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function bo(e,t,r,n){t(e,o=>Td(o,r,n))}function Rd(){var b,w;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ot(),o=(b=t==null?void 0:t.read)==null?void 0:b.selectedOptionalFields,a=v=>{const{name:x,checked:S}=v.target;n&&t&&bo(n,r,x,S)},s=(w=t==null?void 0:t.read)==null?void 0:w.optionalFields,u=v=>{const{checked:x}=v.target;n&&s&&s.forEach(S=>{ze(S)||bo(n,r,S.fieldName,x)})},p=!!(s&&s.length>0),g=Object.keys(o||{}).length===(s==null?void 0:s.length),m=!g&&Object.keys(o||{}).length>0;return p&&c.jsxs(c.Fragment,{children:[c.jsx(Pr,{string:`${e} reads the following optional fields`}),c.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((s==null?void 0:s.length)||0)>=2&&c.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:c.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),s.map(v=>ze(v)?null:c.jsx(y.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:c.jsx(y.Checkbox,{name:v.fieldName,id:v.fieldName,isChecked:!!(o!=null&&o[v==null?void 0:v.fieldName]),onChange:a,children:v.displayName})},v.fieldName))]})]})}function _d(){var n,o,a;const{configureState:e,selectedObjectName:t}=Ot(),{appName:r}=V();return c.jsxs(c.Fragment,{children:[c.jsx(Pr,{string:`${r} reads the following ${t} fields`}),c.jsx(y.Box,{marginBottom:"20px",display:"flex",gap:1,children:(o=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&o.length?(a=e.read)==null?void 0:a.requiredFields.map(s=>ze(s)?null:c.jsx(y.Tag,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function jd(){return c.jsxs(c.Fragment,{children:[c.jsx(_d,{}),c.jsx(Nd,{}),c.jsx(Rd,{})]})}function Ad(e,t,r){var n,o,a;if(((n=e==null?void 0:e.write)==null?void 0:n.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const s=e.write.selectedNonConfigurableWriteFields;if(s[t]=r,r||delete s[t],(a=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,g=!to(u,s);e.write.isWriteModified=g}}}function So(e,t,r,n){t(e,o=>{Ad(o,r,n)})}function kd(){var b,w,v,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ot(),o=(b=r==null?void 0:r.write)==null?void 0:b.selectedNonConfigurableWriteFields,a=(w=r==null?void 0:r.write)==null?void 0:w.writeObjects,s=S=>{const{name:O,checked:j}=S.target;t&&r&&So(t,n,O,j)},u=S=>{var j,R;const{checked:O}=S.target;t&&r&&((R=(j=r==null?void 0:r.write)==null?void 0:j.writeObjects)==null||R.forEach(D=>{So(t,n,D.objectName,O)}))},p=!!a,g=Object.keys(o||{}).length===((x=(v=r==null?void 0:r.write)==null?void 0:v.writeObjects)==null?void 0:x.length),m=!g&&Object.keys(o||{}).length>0;return p&&c.jsxs(c.Fragment,{children:[c.jsx(Pr,{string:`Allow ${e} to write to these object`}),c.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((a==null?void 0:a.length)||0)>=2&&c.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:c.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),a.map(S=>c.jsx(y.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:c.jsx(y.Checkbox,{name:S.objectName,id:S.objectName,onChange:s,isChecked:!!(o!=null&&o[S.objectName]),children:S.displayName})},S.objectName))]})]})}function Ed(){const e=X(),{projectId:t,appName:r}=V(),{integrationId:n,installation:o,resetInstallations:a}=Pe(),[s,u]=I.useState(!1),p=!t||!n||!(o!=null&&o.id)||s,g=async()=>{if(!p){u(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:o.id});try{await H().installationApi.deleteInstallation({projectIdOrName:t,integrationId:n,installationId:o.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),a(),console.warn("successfully uninstalled installation: ",o.id)}catch(w){console.error("error uninstalling installation",w)}finally{u(!1)}}},m=s?"Uninstalling...":"Yes, uninstall",b=o!=null&&o.id?`Once you uninstall this integration, all your configuration will be lost, and "${r}" may stop working.`:"You've successfully uninstalled the integration.";return c.jsxs(y.Stack,{children:[c.jsx(y.Text,{paddingBottom:3,children:b}),(o==null?void 0:o.id)&&c.jsx(y.Button,{onClick:g,variant:"warning",isDisabled:p,children:m})]})}function Si({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var S,O,j;const{hydratedRevision:o,loading:a}=Gt(),{configureState:s,selectedObjectName:u}=Ot(),p=((S=s==null?void 0:s.read)==null?void 0:S.isOptionalFieldsModified)||((O=s==null?void 0:s.read)==null?void 0:O.isRequiredMapFieldsModified),g=(j=s==null?void 0:s.write)==null?void 0:j.isWriteModified,w=a||r||!s||!u||!(p||g||n),v=u===xt,x=u===di;return r?c.jsx(We,{}):c.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[c.jsxs(y.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[c.jsx(y.Button,{backgroundColor:"gray.800",_hover:{backgroundColor:"gray.600"},type:"submit",isDisabled:w,children:n?"Install":"Save"}),c.jsx(y.Button,{backgroundColor:"gray.200",color:"blackAlpha.700",_hover:{backgroundColor:"gray.300"},isDisabled:w,onClick:t,children:"Reset"})]}),c.jsxs(y.Box,{p:8,width:"100%",border:"1px solid #EFEFEF",borderRadius:8,boxShadow:"md",textAlign:["left"],margin:"auto",bgColor:"white",maxHeight:"100%",overflowY:"scroll",minHeight:300,children:[a&&c.jsx(We,{}),o&&!x&&!v&&c.jsx(jd,{}),o&&!x&&v&&c.jsx(kd,{}),!a&&x&&c.jsx(Ed,{})]})]})}const xi=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:o,onUpdateSuccess:a}=Pe(),{hydratedRevision:s,loading:u}=Gt(),{selectedObjectName:p}=vi(),{selectedConnection:g}=St(),m=X(),{projectId:b}=V(),{resetBoundary:w,setErrors:v}=Je(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O}=io(),j=si(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:s,loading:u,selectedObjectName:p,selectedConnection:g,apiKey:m,projectId:b,resetBoundary:w,setErrors:v,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O,configureState:j,onInstallSuccess:o,onUpdateSuccess:a}},Fd=void 0;function Pd(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:o,loading:a,selectedObjectName:s,selectedConnection:u,apiKey:p,projectId:g,resetBoundary:m,setErrors:b,resetConfigureState:w,objectConfigurationsState:v,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:O}=xi(),[j,R]=I.useState(!1),D=s===xt,M=I.useCallback(()=>{m(G.MAPPING),o!=null&&o.content&&!a&&s&&oi(o,Fd,s,w)},[m,o,a,s,w]);I.useEffect(()=>{!S&&(o!=null&&o.content)&&!a&&M()},[S,v,o,a,M]);const oe=()=>{const{requiredMapFields:ie,selectedFieldMappings:be}=(S==null?void 0:S.read)||{},{errorList:he}=ri(ie,be,b);he.length>0||(s&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(R(!0),Qc(g,e,t,r,u.id,s,p,o,S,n,O).finally(()=>{R(!1),x(s)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},ee=()=>{s&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(R(!0),rd(g,e,t,r,u.id,p,o,S,n,O).finally(()=>{R(!1),x(s)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},J=ie=>{ie.preventDefault(),D?ee():oe()};return c.jsx(Si,{isCreateMode:!0,isLoading:j,onSave:J,onReset:M})}function Dd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:o,selectedObjectName:a,setInstallation:s,onUpdateSuccess:u}){const p={projectIdOrName:t,installationId:n,integrationId:r,installationUpdate:{updateMask:[`config.content.read.objects.${a}`],installation:{config:e}}};return H().installationApi.updateInstallation(p,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(g=>{s(g),u==null||u(g.id,g.config)}).catch(g=>{console.error("ERROR: ",g)})}const Bd=(e,t,r,n,o)=>{const a=ii(e),s=ai(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:a,selectedFieldMappings:s}}}}};return jr(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Ld=(e,t,r,n,o,a,s,u,p,g)=>{const m=Bd(a,n||"",u,u.schedule,p);return m?Dd({updateConfig:m,projectId:e,integrationId:t,installationId:r,apiKey:o,selectedObjectName:n,setInstallation:s,onUpdateSuccess:g}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Md=(e,t)=>{const n={content:{write:{objects:ci(e)}}};return jr(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},$d=(e,t,r,n,o,a,s,u)=>{const p=Md(o,a);if(!p)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const g={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:p}}};return H().installationApi.updateInstallation(g,{headers:{"X-Api-Key":n,"Content-Type":"application/json"}}).then(m=>{s(m),u==null||u(m.id,m.config)}).catch(m=>{console.error("ERROR: ",m)})};function Ud({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:o,selectedObjectName:a,apiKey:s,projectId:u,resetBoundary:p,setErrors:g,resetConfigureState:m,resetPendingConfigurationState:b,configureState:w,onUpdateSuccess:v}=xi(),[x,S]=I.useState(!1),O=a===xt,{config:j}=e,R=I.useCallback(()=>{p(G.MAPPING),n!=null&&n.content&&!o&&a&&oi(n,j,a,m)},[p,n,o,a,j,m]);I.useEffect(()=>{w||R()},[w,R]),I.useEffect(()=>{e&&R()},[e,R]);const D=I.useMemo(()=>{var ie,be,he;return(he=(be=(ie=n==null?void 0:n.content)==null?void 0:ie.read)==null?void 0:be.objects)==null?void 0:he.find(Ne=>(Ne==null?void 0:Ne.objectName)===a)},[n,a]),M=()=>{const{requiredMapFields:J,selectedFieldMappings:ie}=(w==null?void 0:w.read)||{},{errorList:be}=ri(J,ie,g);be.length>0||(n&&e&&a&&s&&u&&D?(S(!0),Ld(u,t.id,e.id,a,s,w,r,D,n,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},oe=()=>{e&&a&&s&&u&&n?(S(!0),$d(u,t.id,e.id,s,w,n,r,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},ee=J=>{J.preventDefault(),O?oe():M()};return c.jsx(Si,{onSave:ee,onReset:R,isLoading:x})}function qd(){const{integrationObj:e,installation:t}=Pe();return e?t&&e?c.jsx(Ud,{installation:t,integrationObj:e}):c.jsx(Pd,{}):c.jsx(Ee,{message:"We can't load the integration"})}const Wd=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function zd({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:o,apiKey:a,hydratedRevision:s,setInstallation:u,onInstallSuccess:p}){const g=Wd(s,n);return g?ro({createConfig:g,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:a,setInstallation:u,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function Jd(){return c.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),c.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({text:e}){return c.jsx(y.Container,{children:c.jsxs(y.Box,{p:8,maxWidth:"600px",minHeight:"290px",borderWidth:1,borderRadius:8,boxShadow:"lg",margin:"auto",marginTop:"40px",bgColor:"white",paddingTop:"100px",color:"gray.800",fontSize:"md",children:[c.jsx(y.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:c.jsx(y.Box,{margin:"auto",children:c.jsx(Jd,{})})}),c.jsx(y.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}function Hd({provider:e}){const t=`You have successfully installed your ${de(e)} integration.`;return c.jsx(Oi,{text:t})}const Kd=e=>{const{read:t,write:r,proxy:n}=(e==null?void 0:e.content)??{};return!t&&!r&&(n==null?void 0:n.enabled)||!1};function Gd({children:e}){var O;const{projectId:t}=V(),r=X(),{hydratedRevision:n,loading:o}=Gt(),{integrationObj:a,installation:s,groupRef:u,consumerRef:p,setInstallation:g}=Pe(),{selectedConnection:m}=St(),[b,w]=I.useState(!1),v=o||b,x=(O=n==null?void 0:n.content)==null?void 0:O.provider,S=Kd(n);return I.useEffect(()=>{!v&&n&&S&&!s&&m&&r&&(a!=null&&a.id)&&(w(!0),zd({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:m==null?void 0:m.id,hydratedRevision:n,setInstallation:g}).then(()=>{w(!1)}).catch(j=>{w(!1),console.error("Error when creating proxy installation:",j)}))},[n,S,s,m,r,t,a==null?void 0:a.id,u,p,g,v]),a?v?c.jsx(We,{}):S&&x&&s?c.jsx(Hd,{provider:x}):c.jsx("div",{children:e}):c.jsx(Ee,{message:"We can't load the integration"})}function Vd({children:e}){return c.jsx(y.Container,{children:c.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function Xd({error:e}){return e?c.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[c.jsx(y.AlertIcon,{}),c.jsx(y.AlertDescription,{children:e})]}):null}function Yd({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),s=()=>a(!o),[u,p]=I.useState(""),g=w=>p(w.currentTarget.value),m=u.length>0,b=n||!m;return c.jsx(Vd,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xd,{error:r}),c.jsx("br",{}),c.jsx(y.Stack,{spacing:4,children:c.jsxs(y.InputGroup,{size:"md",children:[c.jsx(y.Input,{onChange:g,pr:"4.5rem",type:o?"text":"password",placeholder:"API Key"}),c.jsx(y.InputRightElement,{width:"4.5rem",children:c.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:s,children:o?"Hide":"Show"})})]})}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:b,width:"100%",type:"submit",onClick:()=>{t(u)},children:"Next"})]})})}function Zd({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:s,setSelectedConnection:u}){const p=V(),[g,m]=I.useState(!1),[b,w]=I.useState(null),v=X();I.useEffect(()=>{if(e&&H&&g&&b!=null){const S={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,apiKey:b};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:S},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info: ",O)})}},[v,e,g,r,t,o,n,p,u,b]);const x=S=>{w(S),m(!0)};return s===null?c.jsx(Yd,{provider:e,handleSubmit:x,error:null}):a}function Qd({children:e}){return c.jsx(y.Container,{children:c.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function el({error:e}){return e?c.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[c.jsx(y.AlertIcon,{}),c.jsx(y.AlertDescription,{children:e})]}):null}function tl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),s=()=>a(!o),[u,p]=I.useState(""),[g,m]=I.useState(""),b=O=>p(O.currentTarget.value),w=O=>m(O.currentTarget.value),v=u.length>0,x=g.length>0,S=n||!v||!x;return c.jsx(Qd,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(el,{error:r}),c.jsx("br",{}),c.jsxs(y.Stack,{spacing:4,children:[c.jsx(y.Input,{placeholder:"Username",onChange:b}),c.jsxs(y.InputGroup,{size:"md",children:[c.jsx(y.Input,{onChange:w,pr:"4.5rem",type:o?"text":"password",placeholder:"Password"}),c.jsx(y.InputRightElement,{width:"4.5rem",children:c.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:s,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:S,width:"100%",type:"submit",onClick:()=>{t(u,g)},children:"Next"})]})})}function rl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:s,setSelectedConnection:u}){const p=V(),[g,m]=I.useState(!1),[b,w]=I.useState(null),v=X();I.useEffect(()=>{if(e&&H&&g&&b!=null){const S={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,basicAuth:{username:b.user,password:b.pass}};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:S},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info: ",O)})}},[v,e,g,r,t,o,n,p,b,u]);const x=(S,O)=>{w({user:S,pass:O}),m(!0)};return s===null?c.jsx(tl,{provider:e,handleSubmit:x,error:null}):a}function nl(e){const{selectedConnection:t}=St();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function ol({onSuccess:e}){nl(e)}function il({children:e}){return c.jsx(y.Container,{children:c.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function al({error:e}){return e?c.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[c.jsx(y.AlertIcon,{}),c.jsx(y.AlertDescription,{children:e})]}):null}function sl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return c.jsx(il,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(al,{error:r}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function cl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:s,setSelectedConnection:u}){const p=V(),g=X(),[m,b]=I.useState(!1);I.useEffect(()=>{if(e&&H&&m){const v={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:v},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{u(x)}).catch(x=>{console.error("Error loading provider info: ",x)})}},[g,e,m,r,t,o,n,u,p]);const w=()=>{b(!0)};return s===null?c.jsx(sl,{provider:e,handleSubmit:w,error:null}):a}function Vt({children:e}){return c.jsx(y.Container,{children:c.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function Xt({error:e}){return e?c.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[c.jsx(y.AlertIcon,{}),c.jsx(y.AlertDescription,{children:e})]}):null}function dl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),[s,u]=I.useState(""),[p,g]=I.useState(""),m=()=>a(!o),b=O=>u(O.currentTarget.value),w=O=>g(O.currentTarget.value),v=s.length>0,x=p.length>0,S=n||!v||!x;return c.jsx(Vt,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsxs(y.Stack,{spacing:4,children:[c.jsx(y.Input,{placeholder:"Client ID",onChange:w}),c.jsxs(y.InputGroup,{size:"md",children:[c.jsx(y.Input,{onChange:b,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),c.jsx(y.InputRightElement,{width:"4.5rem",children:c.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:m,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:S,width:"100%",type:"submit",onClick:()=>{t({clientId:p,clientSecret:s})},children:"Next"})]})})}function ll({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,selectedConnection:a,setSelectedConnection:s}){const{projectId:u}=V(),p=X(),[g,m]=I.useState(null),b=async w=>{m(null);const v={projectId:u,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret}};H().connectionApi.generateConnection({projectIdOrName:u,generateConnectionParams:v},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{s(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?c.jsx(dl,{provider:e,handleSubmit:b,error:g}):c.jsx("em",{children:"Loading..."})}const Ci=async(e,t,r,n,o,a,s,u)=>{var g;const p=await H().providerApi.getProvider({provider:o},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${o} not found`);if(p.authType==="oauth2"&&((g=p.oauth2Opts)==null?void 0:g.grantType)==="authorizationCode"){const b=(await H().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(x=>x.provider===o);if(!b)throw new Error(`You must first set up a ${de(o)} Provider App using the Ampersand Console.`);const w={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:s,providerAppId:b.id,provider:o}};return await H().oAuthApi.oauthConnect(w)}throw new Error(`Provider ${o} does not support an OAuth2 web flow.`)},xo=600,Oo=600,ul="AUTHORIZATION_SUCCEEDED",pl="AUTHORIZATION_FAILED";function fl(e,t,r){return I.useCallback(async n=>{const o=await H().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(o)},[e,t,r])}function hl(e,t,r,n){return I.useCallback(()=>{if(!n)return;const o=window.screenX+(window.outerWidth-xo)/2,a=window.screenY+(window.outerHeight-Oo)/2.5,s=`width=${xo},height=${Oo},left=${o},top=${a}`,u=window.open(n,e,s);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function gl(e){return I.useCallback(t=>{var r;if(t.origin===_c){if(t.data.eventType===ul){const n=(r=t.data.data)==null?void 0:r.connection;n?e(n):console.error("Connection ID not found in event data: ",{event:t})}t.data.eventType===pl&&console.error("OAuth failed: ",{event:t})}},[e])}function Ni({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onClose:n}){const o=X(),{projectId:a}=V(),[s,u]=I.useState(null),[p,g]=I.useState(null),{setSelectedConnection:m}=St(),b=gl(u),w=hl(r,g,b,t),v=fl(a,o,m);I.useEffect(()=>{t&&!p&&w()},[t,p,w,b,r]),I.useEffect(()=>{s&&v(s).then(()=>{p==null||p.close()}).catch(S=>{console.error("Error refreshing connection: ",S),n(S.message??"Unexpected error: not able to refresh connection")})},[s,o,m,v,p,n]);const x=p&&setInterval(()=>{(p!=null&&p.closed||!p)&&x&&(clearInterval(x),window.removeEventListener("message",b),g(null),s?s&&n&&n(null):(console.error("OAuth failed. Please try again."),n&&n("OAuth failed. Please try again.")))},500);return c.jsx("div",{children:e})}function ml({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return c.jsx(Vt,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function yl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o}){const{projectId:a}=V(),s=X(),[u,p]=I.useState(null),[g,m]=I.useState(null),b=async()=>{m(null);try{const v=await Ci(a,t,n,s,e,void 0,r,o);p(v)}catch(v){console.error("Could not fetch OAuth popup URL",{err:v}),m(v.message??"Unexpected error")}},w=I.useCallback(v=>{m(v),p(null)},[]);return c.jsx(Ni,{windowTitle:`Connect to ${de(e)}`,oauthUrl:u,onClose:w,children:c.jsx(ml,{provider:e,handleSubmit:b,error:g})})}function wl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),[s,u]=I.useState(""),[p,g]=I.useState(""),[m,b]=I.useState(""),w=()=>a(!o),v=M=>u(M.currentTarget.value),x=M=>g(M.currentTarget.value),S=M=>b(M.currentTarget.value),O=s.length>0,j=p.length>0,R=m.length>0,D=n||!O||!j||!R;return c.jsx(Vt,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsxs(y.Stack,{spacing:4,children:[c.jsx(y.Input,{placeholder:"MyWorkspace",onChange:S}),c.jsx(y.Input,{placeholder:"Client ID",onChange:x}),c.jsxs(y.InputGroup,{size:"md",children:[c.jsx(y.Input,{onChange:v,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),c.jsx(y.InputRightElement,{width:"4.5rem",children:c.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:w,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:!D,width:"100%",type:"submit",onClick:()=>{t({workspace:m,clientId:p,clientSecret:s})},children:"Next"})]})})}function Il({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,selectedConnection:a,setSelectedConnection:s}){const{projectId:u}=V(),p=X(),[g,m]=I.useState(null),b=async w=>{m(null);const v={projectId:u,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,providerWorkspaceRef:w.workspace,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret}};H().connectionApi.generateConnection({projectIdOrName:u,generateConnectionParams:v},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{s(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?c.jsx(wl,{provider:e,handleSubmit:b,error:g}):c.jsx("em",{children:"Loading..."})}function vl(){const e=I.useContext(Li.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var Ti=I.createContext({});Ti.displayName="ColorModeContext";function Ri(){const e=I.useContext(Ti);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function bl(){const e=Ri(),t=vl();return{...e,theme:t}}var Sl=(...e)=>e.filter(Boolean).join(" ");function ot(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function nt(e,...t){return xl(e)?e(...t):e}var xl=e=>typeof e=="function",Tr={exports:{}};Tr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",o=800,a=16,s=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",b="[object Date]",w="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",j="[object Null]",R="[object Object]",D="[object Proxy]",M="[object RegExp]",oe="[object Set]",ee="[object String]",J="[object Undefined]",ie="[object WeakMap]",be="[object ArrayBuffer]",he="[object DataView]",Ne="[object Float32Array]",st="[object Float64Array]",Br="[object Int8Array]",Lr="[object Int16Array]",Mr="[object Int32Array]",$r="[object Uint8Array]",Ur="[object Uint8ClampedArray]",qr="[object Uint16Array]",Wr="[object Uint32Array]",zr=/[\\^$.*+?()[\]{}|]/g,Jr=/^\[object .+?Constructor\]$/,Hr=/^(?:0|[1-9]\d*)$/,$={};$[Ne]=$[st]=$[Br]=$[Lr]=$[Mr]=$[$r]=$[Ur]=$[qr]=$[Wr]=!0,$[u]=$[p]=$[be]=$[m]=$[he]=$[b]=$[w]=$[v]=$[S]=$[O]=$[R]=$[M]=$[oe]=$[ee]=$[ie]=!1;var Yt=typeof qe=="object"&&qe&&qe.Object===Object&&qe,U=typeof self=="object"&&self&&self.Object===Object&&self,De=Yt||U||Function("return this")(),Zt=t&&!t.nodeType&&t,te=Zt&&!0&&e&&!e.nodeType&&e,Ct=te&&te.exports===Zt,ct=Ct&&Yt.process,Nt=function(){try{var i=te&&te.require&&te.require("util").types;return i||ct&&ct.binding&&ct.binding("util")}catch{}}(),dt=Nt&&Nt.isTypedArray;function Qt(i,d,f){switch(f.length){case 0:return i.call(d);case 1:return i.call(d,f[0]);case 2:return i.call(d,f[0],f[1]);case 3:return i.call(d,f[0],f[1],f[2])}return i.apply(d,f)}function er(i,d){for(var f=-1,C=Array(i);++f<i;)C[f]=d(f);return C}function Kr(i){return function(d){return i(d)}}function Gr(i,d){return i==null?void 0:i[d]}function Vr(i,d){return function(f){return i(d(f))}}var Xr=Array.prototype,Yr=Function.prototype,lt=Object.prototype,Tt=De["__core-js_shared__"],ut=Yr.toString,Se=lt.hasOwnProperty,tr=function(){var i=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),rr=lt.toString,Zr=ut.call(Object),pt=RegExp("^"+ut.call(Se).replace(zr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Be=Ct?De.Buffer:void 0,Rt=De.Symbol,ae=De.Uint8Array;Be&&Be.allocUnsafe;var _t=Vr(Object.getPrototypeOf,Object),jt=Object.create,Qr=lt.propertyIsEnumerable,nr=Xr.splice,le=Rt?Rt.toStringTag:void 0,He=function(){try{var i=Dt(Object,"defineProperty");return i({},"",{}),i}catch{}}(),or=Be?Be.isBuffer:void 0,ir=Math.max,Te=Date.now,At=Dt(De,"Map"),Ke=Dt(Object,"create"),en=function(){function i(){}return function(d){if(!_e(d))return{};if(jt)return jt(d);i.prototype=d;var f=new i;return i.prototype=void 0,f}}();function ge(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function Ge(){this.__data__=Ke?Ke(null):{},this.size=0}function kt(i){var d=this.has(i)&&delete this.__data__[i];return this.size-=d?1:0,d}function Et(i){var d=this.__data__;if(Ke){var f=d[i];return f===n?void 0:f}return Se.call(d,i)?d[i]:void 0}function Ft(i){var d=this.__data__;return Ke?d[i]!==void 0:Se.call(d,i)}function Ve(i,d){var f=this.__data__;return this.size+=this.has(i)?0:1,f[i]=Ke&&d===void 0?n:d,this}ge.prototype.clear=Ge,ge.prototype.delete=kt,ge.prototype.get=Et,ge.prototype.has=Ft,ge.prototype.set=Ve;function me(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function tn(){this.__data__=[],this.size=0}function rn(i){var d=this.__data__,f=ft(d,i);if(f<0)return!1;var C=d.length-1;return f==C?d.pop():nr.call(d,f,1),--this.size,!0}function nn(i){var d=this.__data__,f=ft(d,i);return f<0?void 0:d[f][1]}function on(i){return ft(this.__data__,i)>-1}function ar(i,d){var f=this.__data__,C=ft(f,i);return C<0?(++this.size,f.push([i,d])):f[C][1]=d,this}me.prototype.clear=tn,me.prototype.delete=rn,me.prototype.get=nn,me.prototype.has=on,me.prototype.set=ar;function xe(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function Re(){this.size=0,this.__data__={hash:new ge,map:new(At||me),string:new ge}}function an(i){var d=mt(this,i).delete(i);return this.size-=d?1:0,d}function sn(i){return mt(this,i).get(i)}function cn(i){return mt(this,i).has(i)}function dn(i,d){var f=mt(this,i),C=f.size;return f.set(i,d),this.size+=f.size==C?0:1,this}xe.prototype.clear=Re,xe.prototype.delete=an,xe.prototype.get=sn,xe.prototype.has=cn,xe.prototype.set=dn;function Le(i){var d=this.__data__=new me(i);this.size=d.size}function ye(){this.__data__=new me,this.size=0}function ln(i){var d=this.__data__,f=d.delete(i);return this.size=d.size,f}function un(i){return this.__data__.get(i)}function pn(i){return this.__data__.has(i)}function fn(i,d){var f=this.__data__;if(f instanceof me){var C=f.__data__;if(!At||C.length<r-1)return C.push([i,d]),this.size=++f.size,this;f=this.__data__=new xe(C)}return f.set(i,d),this.size=f.size,this}Le.prototype.clear=ye,Le.prototype.delete=ln,Le.prototype.get=un,Le.prototype.has=pn,Le.prototype.set=fn;function hn(i,d){var f=Ie(i),C=!f&&Lt(i),T=!f&&!C&&Qe(i),A=!f&&!C&&!T&&$t(i),F=f||C||T||A,k=F?er(i.length,String):[],E=k.length;for(var q in i)F&&(q=="length"||T&&(q=="offset"||q=="parent")||A&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||Bt(q,E))||k.push(q);return k}function we(i,d,f){(f!==void 0&&!yt(i[d],f)||f===void 0&&!(d in i))&&Pt(i,d,f)}function gn(i,d,f){var C=i[d];(!(Se.call(i,d)&&yt(C,f))||f===void 0&&!(d in i))&&Pt(i,d,f)}function ft(i,d){for(var f=i.length;f--;)if(yt(i[f][0],d))return f;return-1}function Pt(i,d,f){d=="__proto__"&&He?He(i,d,{configurable:!0,enumerable:!0,value:f,writable:!0}):i[d]=f}var mn=dr();function ht(i){return i==null?i===void 0?J:j:le&&le in Object(i)?Cn(i):_n(i)}function Xe(i){return $e(i)&&ht(i)==u}function yn(i){if(!_e(i)||lr(i))return!1;var d=Mt(i)?pt:Jr;return d.test(En(i))}function wn(i){return $e(i)&&It(i.length)&&!!$[ht(i)]}function Oe(i){if(!_e(i))return Me(i);var d=Ze(i),f=[];for(var C in i)C=="constructor"&&(d||!Se.call(i,C))||f.push(C);return f}function sr(i,d,f,C,T){i!==d&&mn(d,function(A,F){if(T||(T=new Le),_e(A))In(i,d,F,f,sr,C,T);else{var k=C?C(ue(i,F),A,F+"",i,d,T):void 0;k===void 0&&(k=A),we(i,F,k)}},Ut)}function In(i,d,f,C,T,A,F){var k=ue(i,f),E=ue(d,f),q=F.get(E);if(q){we(i,f,q);return}var W=A?A(k,E,f+"",i,d,F):void 0,K=W===void 0;if(K){var Z=Ie(E),Q=!Z&&Qe(E),ve=!Z&&!Q&&$t(E);W=E,Z||Q||ve?Ie(k)?W=k:Fn(k)?W=On(k):Q?(K=!1,W=Sn(E)):ve?(K=!1,W=gt(E)):W=[]:ur(E)||Lt(E)?(W=k,Lt(k)?W=et(k):(!_e(k)||Mt(k))&&(W=Nn(E))):K=!1}K&&(F.set(E,W),T(W,E,C,A,F),F.delete(E)),we(i,f,W)}function vn(i,d){return An(jn(i,d,pr),i+"")}var bn=He?function(i,d){return He(i,"toString",{configurable:!0,enumerable:!1,value:Dn(d),writable:!0})}:pr;function Sn(i,d){return i.slice()}function xn(i){var d=new i.constructor(i.byteLength);return new ae(d).set(new ae(i)),d}function gt(i,d){var f=xn(i.buffer);return new i.constructor(f,i.byteOffset,i.length)}function On(i,d){var f=-1,C=i.length;for(d||(d=Array(C));++f<C;)d[f]=i[f];return d}function Ye(i,d,f,C){var T=!f;f||(f={});for(var A=-1,F=d.length;++A<F;){var k=d[A],E=void 0;E===void 0&&(E=i[k]),T?Pt(f,k,E):gn(f,k,E)}return f}function cr(i){return vn(function(d,f){var C=-1,T=f.length,A=T>1?f[T-1]:void 0,F=T>2?f[2]:void 0;for(A=i.length>3&&typeof A=="function"?(T--,A):void 0,F&&Tn(f[0],f[1],F)&&(A=T<3?void 0:A,T=1),d=Object(d);++C<T;){var k=f[C];k&&i(d,k,C,A)}return d})}function dr(i){return function(d,f,C){for(var T=-1,A=Object(d),F=C(d),k=F.length;k--;){var E=F[++T];if(f(A[E],E,A)===!1)break}return d}}function mt(i,d){var f=i.__data__;return Rn(d)?f[typeof d=="string"?"string":"hash"]:f.map}function Dt(i,d){var f=Gr(i,d);return yn(f)?f:void 0}function Cn(i){var d=Se.call(i,le),f=i[le];try{i[le]=void 0;var C=!0}catch{}var T=rr.call(i);return C&&(d?i[le]=f:delete i[le]),T}function Nn(i){return typeof i.constructor=="function"&&!Ze(i)?en(_t(i)):{}}function Bt(i,d){var f=typeof i;return d=d??s,!!d&&(f=="number"||f!="symbol"&&Hr.test(i))&&i>-1&&i%1==0&&i<d}function Tn(i,d,f){if(!_e(f))return!1;var C=typeof d;return(C=="number"?wt(f)&&Bt(d,f.length):C=="string"&&d in f)?yt(f[d],i):!1}function Rn(i){var d=typeof i;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?i!=="__proto__":i===null}function lr(i){return!!tr&&tr in i}function Ze(i){var d=i&&i.constructor,f=typeof d=="function"&&d.prototype||lt;return i===f}function Me(i){var d=[];if(i!=null)for(var f in Object(i))d.push(f);return d}function _n(i){return rr.call(i)}function jn(i,d,f){return d=ir(d===void 0?i.length-1:d,0),function(){for(var C=arguments,T=-1,A=ir(C.length-d,0),F=Array(A);++T<A;)F[T]=C[d+T];T=-1;for(var k=Array(d+1);++T<d;)k[T]=C[T];return k[d]=f(F),Qt(i,this,k)}}function ue(i,d){if(!(d==="constructor"&&typeof i[d]=="function")&&d!="__proto__")return i[d]}var An=kn(bn);function kn(i){var d=0,f=0;return function(){var C=Te(),T=a-(C-f);if(f=C,T>0){if(++d>=o)return arguments[0]}else d=0;return i.apply(void 0,arguments)}}function En(i){if(i!=null){try{return ut.call(i)}catch{}try{return i+""}catch{}}return""}function yt(i,d){return i===d||i!==i&&d!==d}var Lt=Xe(function(){return arguments}())?Xe:function(i){return $e(i)&&Se.call(i,"callee")&&!Qr.call(i,"callee")},Ie=Array.isArray;function wt(i){return i!=null&&It(i.length)&&!Mt(i)}function Fn(i){return $e(i)&&wt(i)}var Qe=or||l;function Mt(i){if(!_e(i))return!1;var d=ht(i);return d==v||d==x||d==g||d==D}function It(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=s}function _e(i){var d=typeof i;return i!=null&&(d=="object"||d=="function")}function $e(i){return i!=null&&typeof i=="object"}function ur(i){if(!$e(i)||ht(i)!=R)return!1;var d=_t(i);if(d===null)return!0;var f=Se.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&ut.call(f)==Zr}var $t=dt?Kr(dt):wn;function et(i){return Ye(i,Ut(i))}function Ut(i){return wt(i)?hn(i):Oe(i)}var Pn=cr(function(i,d,f,C){sr(i,d,f,C)});function Dn(i){return function(){return i}}function pr(i){return i}function l(){return!1}e.exports=Pn})(Tr,Tr.exports);var Ol=Tr.exports;const ke=eo(Ol);var Cl=e=>/!(important)?$/.test(e),Co=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,Nl=(e,t)=>r=>{const n=String(t),o=Cl(n),a=Co(n),s=e?`${e}.${a}`:a;let u=ot(r.__cssMap)&&s in r.__cssMap?r.__cssMap[s].varRef:t;return u=Co(u),o?`${u} !important`:u};function ao(e){const{scale:t,transform:r,compose:n}=e;return(a,s)=>{var u;const p=Nl(t,a)(s);let g=(u=r==null?void 0:r(p,s))!=null?u:p;return n&&(g=n(g,s)),g}}var wr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function pe(e,t){return r=>{const n={property:r,scale:e};return n.transform=ao({scale:e,transform:t}),n}}var Tl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Rl(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Tl(t),transform:r?ao({scale:r,compose:n}):n}}var _i=["rotate(var(--chakra-rotate, 0))","scaleX(var(--chakra-scale-x, 1))","scaleY(var(--chakra-scale-y, 1))","skewX(var(--chakra-skew-x, 0))","skewY(var(--chakra-skew-y, 0))"];function _l(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",..._i].join(" ")}function jl(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",..._i].join(" ")}var Al={"--chakra-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-sepia":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-drop-shadow":"var(--chakra-empty,/*!*/ /*!*/)",filter:["var(--chakra-blur)","var(--chakra-brightness)","var(--chakra-contrast)","var(--chakra-grayscale)","var(--chakra-hue-rotate)","var(--chakra-invert)","var(--chakra-saturate)","var(--chakra-sepia)","var(--chakra-drop-shadow)"].join(" ")},kl={backdropFilter:["var(--chakra-backdrop-blur)","var(--chakra-backdrop-brightness)","var(--chakra-backdrop-contrast)","var(--chakra-backdrop-grayscale)","var(--chakra-backdrop-hue-rotate)","var(--chakra-backdrop-invert)","var(--chakra-backdrop-opacity)","var(--chakra-backdrop-saturate)","var(--chakra-backdrop-sepia)"].join(" "),"--chakra-backdrop-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-opacity":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-sepia":"var(--chakra-empty,/*!*/ /*!*/)"};function El(e){return{"--chakra-ring-offset-shadow":"var(--chakra-ring-inset) 0 0 0 var(--chakra-ring-offset-width) var(--chakra-ring-offset-color)","--chakra-ring-shadow":"var(--chakra-ring-inset) 0 0 0 calc(var(--chakra-ring-width) + var(--chakra-ring-offset-width)) var(--chakra-ring-color)","--chakra-ring-width":e,boxShadow:["var(--chakra-ring-offset-shadow)","var(--chakra-ring-shadow)","var(--chakra-shadow, 0 0 #0000)"].join(", ")}}var Fl={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Gn={"to-t":"to top","to-tr":"to top right","to-r":"to right","to-br":"to bottom right","to-b":"to bottom","to-bl":"to bottom left","to-l":"to left","to-tl":"to top left"},Pl=new Set(Object.values(Gn)),Vn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),Dl=e=>e.trim();function Bl(e,t){if(e==null||Vn.has(e))return e;if(!(Xn(e)||Vn.has(e)))return`url('${e}')`;const o=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=o==null?void 0:o[1],s=o==null?void 0:o[2];if(!a||!s)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...g]=s.split(",").map(Dl).filter(Boolean);if((g==null?void 0:g.length)===0)return e;const m=p in Gn?Gn[p]:p;g.unshift(m);const b=g.map(w=>{if(Pl.has(w))return w;const v=w.indexOf(" "),[x,S]=v!==-1?[w.substr(0,v),w.substr(v+1)]:[w],O=Xn(S)?S:S&&S.split(" "),j=`colors.${x}`,R=j in t.__cssMap?t.__cssMap[j].varRef:x;return O?[R,...Array.isArray(O)?O:[O]].join(" "):R});return`${u}(${b.join(", ")})`}var Xn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Ll=(e,t)=>Bl(e,t??{});function Ml(e){return/^var\(--.+\)$/.test(e)}var $l=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Ce=e=>t=>`${e}(${t})`,P={filter(e){return e!=="auto"?e:Al},backdropFilter(e){return e!=="auto"?e:kl},ring(e){return El(P.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?_l():e==="auto-gpu"?jl():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=$l(e);return t||typeof e=="number"?`${e}px`:e},fraction(e){return typeof e!="number"||e>1?e:`${e*100}%`},float(e,t){const r={left:"right",right:"left"};return t.direction==="rtl"?r[e]:e},degree(e){if(Ml(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Ll,blur:Ce("blur"),opacity:Ce("opacity"),brightness:Ce("brightness"),contrast:Ce("contrast"),dropShadow:Ce("drop-shadow"),grayscale:Ce("grayscale"),hueRotate:e=>Ce("hue-rotate")(P.degree(e)),invert:Ce("invert"),saturate:Ce("saturate"),sepia:Ce("sepia"),bgImage(e){return e==null||Xn(e)||Vn.has(e)?e:`url(${e})`},outline(e){const t=String(e)==="0"||String(e)==="none";return e!==null&&t?{outline:"2px solid transparent",outlineOffset:"2px"}:{outline:e}},flexDirection(e){var t;const{space:r,divide:n}=(t=Fl[e])!=null?t:{},o={flexDirection:e};return r&&(o[r]=1),n&&(o[n]=1),o}},h={borderWidths:pe("borderWidths"),borderStyles:pe("borderStyles"),colors:pe("colors"),borders:pe("borders"),gradients:pe("gradients",P.gradient),radii:pe("radii",P.px),space:pe("space",wr(P.vh,P.px)),spaceT:pe("space",wr(P.vh,P.px)),degreeT(e){return{property:e,transform:P.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:ao({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:pe("sizes",wr(P.vh,P.px)),sizesT:pe("sizes",wr(P.vh,P.fraction)),shadows:pe("shadows"),logical:Rl,blur:pe("blur",P.blur)},br={background:h.colors("background"),backgroundColor:h.colors("backgroundColor"),backgroundImage:h.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:P.bgClip},bgSize:h.prop("backgroundSize"),bgPosition:h.prop("backgroundPosition"),bg:h.colors("background"),bgColor:h.colors("backgroundColor"),bgPos:h.prop("backgroundPosition"),bgRepeat:h.prop("backgroundRepeat"),bgAttachment:h.prop("backgroundAttachment"),bgGradient:h.gradients("backgroundImage"),bgClip:{transform:P.bgClip}};Object.assign(br,{bgImage:br.backgroundImage,bgImg:br.backgroundImage});var B={border:h.borders("border"),borderWidth:h.borderWidths("borderWidth"),borderStyle:h.borderStyles("borderStyle"),borderColor:h.colors("borderColor"),borderRadius:h.radii("borderRadius"),borderTop:h.borders("borderTop"),borderBlockStart:h.borders("borderBlockStart"),borderTopLeftRadius:h.radii("borderTopLeftRadius"),borderStartStartRadius:h.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:h.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:h.radii("borderTopRightRadius"),borderStartEndRadius:h.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:h.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:h.borders("borderRight"),borderInlineEnd:h.borders("borderInlineEnd"),borderBottom:h.borders("borderBottom"),borderBlockEnd:h.borders("borderBlockEnd"),borderBottomLeftRadius:h.radii("borderBottomLeftRadius"),borderBottomRightRadius:h.radii("borderBottomRightRadius"),borderLeft:h.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:h.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:h.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:h.borders(["borderLeft","borderRight"]),borderInline:h.borders("borderInline"),borderY:h.borders(["borderTop","borderBottom"]),borderBlock:h.borders("borderBlock"),borderTopWidth:h.borderWidths("borderTopWidth"),borderBlockStartWidth:h.borderWidths("borderBlockStartWidth"),borderTopColor:h.colors("borderTopColor"),borderBlockStartColor:h.colors("borderBlockStartColor"),borderTopStyle:h.borderStyles("borderTopStyle"),borderBlockStartStyle:h.borderStyles("borderBlockStartStyle"),borderBottomWidth:h.borderWidths("borderBottomWidth"),borderBlockEndWidth:h.borderWidths("borderBlockEndWidth"),borderBottomColor:h.colors("borderBottomColor"),borderBlockEndColor:h.colors("borderBlockEndColor"),borderBottomStyle:h.borderStyles("borderBottomStyle"),borderBlockEndStyle:h.borderStyles("borderBlockEndStyle"),borderLeftWidth:h.borderWidths("borderLeftWidth"),borderInlineStartWidth:h.borderWidths("borderInlineStartWidth"),borderLeftColor:h.colors("borderLeftColor"),borderInlineStartColor:h.colors("borderInlineStartColor"),borderLeftStyle:h.borderStyles("borderLeftStyle"),borderInlineStartStyle:h.borderStyles("borderInlineStartStyle"),borderRightWidth:h.borderWidths("borderRightWidth"),borderInlineEndWidth:h.borderWidths("borderInlineEndWidth"),borderRightColor:h.colors("borderRightColor"),borderInlineEndColor:h.colors("borderInlineEndColor"),borderRightStyle:h.borderStyles("borderRightStyle"),borderInlineEndStyle:h.borderStyles("borderInlineEndStyle"),borderTopRadius:h.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:h.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:h.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:h.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(B,{rounded:B.borderRadius,roundedTop:B.borderTopRadius,roundedTopLeft:B.borderTopLeftRadius,roundedTopRight:B.borderTopRightRadius,roundedTopStart:B.borderStartStartRadius,roundedTopEnd:B.borderStartEndRadius,roundedBottom:B.borderBottomRadius,roundedBottomLeft:B.borderBottomLeftRadius,roundedBottomRight:B.borderBottomRightRadius,roundedBottomStart:B.borderEndStartRadius,roundedBottomEnd:B.borderEndEndRadius,roundedLeft:B.borderLeftRadius,roundedRight:B.borderRightRadius,roundedStart:B.borderInlineStartRadius,roundedEnd:B.borderInlineEndRadius,borderStart:B.borderInlineStart,borderEnd:B.borderInlineEnd,borderTopStartRadius:B.borderStartStartRadius,borderTopEndRadius:B.borderStartEndRadius,borderBottomStartRadius:B.borderEndStartRadius,borderBottomEndRadius:B.borderEndEndRadius,borderStartRadius:B.borderInlineStartRadius,borderEndRadius:B.borderInlineEndRadius,borderStartWidth:B.borderInlineStartWidth,borderEndWidth:B.borderInlineEndWidth,borderStartColor:B.borderInlineStartColor,borderEndColor:B.borderInlineEndColor,borderStartStyle:B.borderInlineStartStyle,borderEndStyle:B.borderInlineEndStyle});var Ul={color:h.colors("color"),textColor:h.colors("color"),fill:h.colors("fill"),stroke:h.colors("stroke")},Yn={boxShadow:h.shadows("boxShadow"),mixBlendMode:!0,blendMode:h.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:h.prop("backgroundBlendMode"),opacity:!0};Object.assign(Yn,{shadow:Yn.boxShadow});var ql={filter:{transform:P.filter},blur:h.blur("--chakra-blur"),brightness:h.propT("--chakra-brightness",P.brightness),contrast:h.propT("--chakra-contrast",P.contrast),hueRotate:h.propT("--chakra-hue-rotate",P.hueRotate),invert:h.propT("--chakra-invert",P.invert),saturate:h.propT("--chakra-saturate",P.saturate),dropShadow:h.propT("--chakra-drop-shadow",P.dropShadow),backdropFilter:{transform:P.backdropFilter},backdropBlur:h.blur("--chakra-backdrop-blur"),backdropBrightness:h.propT("--chakra-backdrop-brightness",P.brightness),backdropContrast:h.propT("--chakra-backdrop-contrast",P.contrast),backdropHueRotate:h.propT("--chakra-backdrop-hue-rotate",P.hueRotate),backdropInvert:h.propT("--chakra-backdrop-invert",P.invert),backdropSaturate:h.propT("--chakra-backdrop-saturate",P.saturate)},Rr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:P.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:h.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:h.space("gap"),rowGap:h.space("rowGap"),columnGap:h.space("columnGap")};Object.assign(Rr,{flexDir:Rr.flexDirection});var ji={gridGap:h.space("gridGap"),gridColumnGap:h.space("gridColumnGap"),gridRowGap:h.space("gridRowGap"),gridColumn:!0,gridRow:!0,gridAutoFlow:!0,gridAutoColumns:!0,gridColumnStart:!0,gridColumnEnd:!0,gridRowStart:!0,gridRowEnd:!0,gridAutoRows:!0,gridTemplate:!0,gridTemplateColumns:!0,gridTemplateRows:!0,gridTemplateAreas:!0,gridArea:!0},Wl={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:P.outline},outlineOffset:!0,outlineColor:h.colors("outlineColor")},fe={width:h.sizesT("width"),inlineSize:h.sizesT("inlineSize"),height:h.sizes("height"),blockSize:h.sizes("blockSize"),boxSize:h.sizes(["width","height"]),minWidth:h.sizes("minWidth"),minInlineSize:h.sizes("minInlineSize"),minHeight:h.sizes("minHeight"),minBlockSize:h.sizes("minBlockSize"),maxWidth:h.sizes("maxWidth"),maxInlineSize:h.sizes("maxInlineSize"),maxHeight:h.sizes("maxHeight"),maxBlockSize:h.sizes("maxBlockSize"),overflow:!0,overflowX:!0,overflowY:!0,overscrollBehavior:!0,overscrollBehaviorX:!0,overscrollBehaviorY:!0,display:!0,aspectRatio:!0,hideFrom:{scale:"breakpoints",transform:(e,t)=>{var r,n,o;return{[`@media screen and (min-width: ${(o=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n.minW)!=null?o:e})`]:{display:"none"}}}},hideBelow:{scale:"breakpoints",transform:(e,t)=>{var r,n,o;return{[`@media screen and (max-width: ${(o=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n._minW)!=null?o:e})`]:{display:"none"}}}},verticalAlign:!0,boxSizing:!0,boxDecorationBreak:!0,float:h.propT("float",P.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(fe,{w:fe.width,h:fe.height,minW:fe.minWidth,maxW:fe.maxWidth,minH:fe.minHeight,maxH:fe.maxHeight,overscroll:fe.overscrollBehavior,overscrollX:fe.overscrollBehaviorX,overscrollY:fe.overscrollBehaviorY});var zl={listStyleType:!0,listStylePosition:!0,listStylePos:h.prop("listStylePosition"),listStyleImage:!0,listStyleImg:h.prop("listStyleImage")};function Jl(e,t,r,n){const o=typeof t=="string"?t.split("."):[t];for(n=0;n<o.length&&e;n+=1)e=e[o[n]];return e===void 0?r:e}var Hl=e=>{const t=new WeakMap;return(n,o,a,s)=>{if(typeof n>"u")return e(n,o,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(o))return u.get(o);const p=e(n,o,a,s);return u.set(o,p),p}},Kl=Hl(Jl),Gl={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Vl={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},$n=(e,t,r)=>{const n={},o=Kl(e,t,{});for(const a in o)a in r&&r[a]!=null||(n[a]=o[a]);return n},Xl={srOnly:{transform(e){return e===!0?Gl:e==="focusable"?Vl:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>$n(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>$n(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>$n(t,e,r)}},Jt={position:!0,pos:h.prop("position"),zIndex:h.prop("zIndex","zIndices"),inset:h.spaceT("inset"),insetX:h.spaceT(["left","right"]),insetInline:h.spaceT("insetInline"),insetY:h.spaceT(["top","bottom"]),insetBlock:h.spaceT("insetBlock"),top:h.spaceT("top"),insetBlockStart:h.spaceT("insetBlockStart"),bottom:h.spaceT("bottom"),insetBlockEnd:h.spaceT("insetBlockEnd"),left:h.spaceT("left"),insetInlineStart:h.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:h.spaceT("right"),insetInlineEnd:h.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(Jt,{insetStart:Jt.insetInlineStart,insetEnd:Jt.insetInlineEnd});var Yl={ring:{transform:P.ring},ringColor:h.colors("--chakra-ring-color"),ringOffset:h.prop("--chakra-ring-offset-width"),ringOffsetColor:h.colors("--chakra-ring-offset-color"),ringInset:h.prop("--chakra-ring-inset")},z={margin:h.spaceT("margin"),marginTop:h.spaceT("marginTop"),marginBlockStart:h.spaceT("marginBlockStart"),marginRight:h.spaceT("marginRight"),marginInlineEnd:h.spaceT("marginInlineEnd"),marginBottom:h.spaceT("marginBottom"),marginBlockEnd:h.spaceT("marginBlockEnd"),marginLeft:h.spaceT("marginLeft"),marginInlineStart:h.spaceT("marginInlineStart"),marginX:h.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:h.spaceT("marginInline"),marginY:h.spaceT(["marginTop","marginBottom"]),marginBlock:h.spaceT("marginBlock"),padding:h.space("padding"),paddingTop:h.space("paddingTop"),paddingBlockStart:h.space("paddingBlockStart"),paddingRight:h.space("paddingRight"),paddingBottom:h.space("paddingBottom"),paddingBlockEnd:h.space("paddingBlockEnd"),paddingLeft:h.space("paddingLeft"),paddingInlineStart:h.space("paddingInlineStart"),paddingInlineEnd:h.space("paddingInlineEnd"),paddingX:h.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:h.space("paddingInline"),paddingY:h.space(["paddingTop","paddingBottom"]),paddingBlock:h.space("paddingBlock")};Object.assign(z,{m:z.margin,mt:z.marginTop,mr:z.marginRight,me:z.marginInlineEnd,marginEnd:z.marginInlineEnd,mb:z.marginBottom,ml:z.marginLeft,ms:z.marginInlineStart,marginStart:z.marginInlineStart,mx:z.marginX,my:z.marginY,p:z.padding,pt:z.paddingTop,py:z.paddingY,px:z.paddingX,pb:z.paddingBottom,pl:z.paddingLeft,ps:z.paddingInlineStart,paddingStart:z.paddingInlineStart,pr:z.paddingRight,pe:z.paddingInlineEnd,paddingEnd:z.paddingInlineEnd});var Zl={textDecorationColor:h.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:h.shadows("textShadow")},Ql={clipPath:!0,transform:h.propT("transform",P.transform),transformOrigin:!0,translateX:h.spaceT("--chakra-translate-x"),translateY:h.spaceT("--chakra-translate-y"),skewX:h.degreeT("--chakra-skew-x"),skewY:h.degreeT("--chakra-skew-y"),scaleX:h.prop("--chakra-scale-x"),scaleY:h.prop("--chakra-scale-y"),scale:h.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:h.degreeT("--chakra-rotate")},eu={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:h.prop("transitionDuration","transition.duration"),transitionProperty:h.prop("transitionProperty","transition.property"),transitionTimingFunction:h.prop("transitionTimingFunction","transition.easing")},tu={fontFamily:h.prop("fontFamily","fonts"),fontSize:h.prop("fontSize","fontSizes",P.px),fontWeight:h.prop("fontWeight","fontWeights"),lineHeight:h.prop("lineHeight","lineHeights"),letterSpacing:h.prop("letterSpacing","letterSpacings"),textAlign:!0,fontStyle:!0,textIndent:!0,wordBreak:!0,overflowWrap:!0,textOverflow:!0,textTransform:!0,whiteSpace:!0,isTruncated:{transform(e){if(e===!0)return{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},noOfLines:{static:{overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"var(--chakra-line-clamp)"},property:"--chakra-line-clamp"}},ru={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:h.spaceT("scrollMargin"),scrollMarginTop:h.spaceT("scrollMarginTop"),scrollMarginBottom:h.spaceT("scrollMarginBottom"),scrollMarginLeft:h.spaceT("scrollMarginLeft"),scrollMarginRight:h.spaceT("scrollMarginRight"),scrollMarginX:h.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:h.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:h.spaceT("scrollPadding"),scrollPaddingTop:h.spaceT("scrollPaddingTop"),scrollPaddingBottom:h.spaceT("scrollPaddingBottom"),scrollPaddingLeft:h.spaceT("scrollPaddingLeft"),scrollPaddingRight:h.spaceT("scrollPaddingRight"),scrollPaddingX:h.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:h.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function Ai(e){return ot(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(Ai).join(` ${e} `).replace(/calc/g,""),No=(...e)=>`calc(${Dr("+",...e)})`,To=(...e)=>`calc(${Dr("-",...e)})`,Zn=(...e)=>`calc(${Dr("*",...e)})`,Ro=(...e)=>`calc(${Dr("/",...e)})`,_o=e=>{const t=Ai(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Zn(t,-1)},zt=Object.assign(e=>({add:(...t)=>zt(No(e,...t)),subtract:(...t)=>zt(To(e,...t)),multiply:(...t)=>zt(Zn(e,...t)),divide:(...t)=>zt(Ro(e,...t)),negate:()=>zt(_o(e)),toString:()=>e.toString()}),{add:No,subtract:To,multiply:Zn,divide:Ro,negate:_o});function nu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function jo(e){if(e==null)return e;const{unitless:t}=nu(e);return t||typeof e=="number"?`${e}px`:e}function ou(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${jo(e)})`),t&&r.push("and",`(max-width: ${jo(t)})`),r.join(" ")}var Y={hover:(e,t)=>`${e}:hover ${t}, ${e}[data-hover] ${t}`,focus:(e,t)=>`${e}:focus ${t}, ${e}[data-focus] ${t}`,focusVisible:(e,t)=>`${e}:focus-visible ${t}`,focusWithin:(e,t)=>`${e}:focus-within ${t}`,active:(e,t)=>`${e}:active ${t}, ${e}[data-active] ${t}`,disabled:(e,t)=>`${e}:disabled ${t}, ${e}[data-disabled] ${t}`,invalid:(e,t)=>`${e}:invalid ${t}, ${e}[data-invalid] ${t}`,checked:(e,t)=>`${e}:checked ${t}, ${e}[data-checked] ${t}`,indeterminate:(e,t)=>`${e}:indeterminate ${t}, ${e}[aria-checked=mixed] ${t}, ${e}[data-indeterminate] ${t}`,readOnly:(e,t)=>`${e}:read-only ${t}, ${e}[readonly] ${t}, ${e}[data-read-only] ${t}`,expanded:(e,t)=>`${e}:read-only ${t}, ${e}[aria-expanded=true] ${t}, ${e}[data-expanded] ${t}`,placeholderShown:(e,t)=>`${e}:placeholder-shown ${t}`},Ue=e=>ki(t=>e(t,"&"),"[role=group]","[data-group]",".group"),Ae=e=>ki(t=>e(t,"~ &"),"[data-peer]",".peer"),ki=(e,...t)=>t.map(e).join(", "),so={_hover:"&:hover, &[data-hover]",_active:"&:active, &[data-active]",_focus:"&:focus, &[data-focus]",_highlighted:"&[data-highlighted]",_focusWithin:"&:focus-within",_focusVisible:"&:focus-visible, &[data-focus-visible]",_disabled:"&:disabled, &[disabled], &[aria-disabled=true], &[data-disabled]",_readOnly:"&[aria-readonly=true], &[readonly], &[data-readonly]",_before:"&::before",_after:"&::after",_empty:"&:empty",_expanded:"&[aria-expanded=true], &[data-expanded]",_checked:"&[aria-checked=true], &[data-checked]",_grabbed:"&[aria-grabbed=true], &[data-grabbed]",_pressed:"&[aria-pressed=true], &[data-pressed]",_invalid:"&[aria-invalid=true], &[data-invalid]",_valid:"&[data-valid], &[data-state=valid]",_loading:"&[data-loading], &[aria-busy=true]",_selected:"&[aria-selected=true], &[data-selected]",_hidden:"&[hidden], &[data-hidden]",_autofill:"&:-webkit-autofill",_even:"&:nth-of-type(even)",_odd:"&:nth-of-type(odd)",_first:"&:first-of-type",_firstLetter:"&::first-letter",_last:"&:last-of-type",_notFirst:"&:not(:first-of-type)",_notLast:"&:not(:last-of-type)",_visited:"&:visited",_activeLink:"&[aria-current=page]",_activeStep:"&[aria-current=step]",_indeterminate:"&:indeterminate, &[aria-checked=mixed], &[data-indeterminate]",_groupHover:Ue(Y.hover),_peerHover:Ae(Y.hover),_groupFocus:Ue(Y.focus),_peerFocus:Ae(Y.focus),_groupFocusVisible:Ue(Y.focusVisible),_peerFocusVisible:Ae(Y.focusVisible),_groupActive:Ue(Y.active),_peerActive:Ae(Y.active),_groupDisabled:Ue(Y.disabled),_peerDisabled:Ae(Y.disabled),_groupInvalid:Ue(Y.invalid),_peerInvalid:Ae(Y.invalid),_groupChecked:Ue(Y.checked),_peerChecked:Ae(Y.checked),_groupFocusWithin:Ue(Y.focusWithin),_peerFocusWithin:Ae(Y.focusWithin),_peerPlaceholderShown:Ae(Y.placeholderShown),_placeholder:"&::placeholder",_placeholderShown:"&:placeholder-shown",_fullScreen:"&:fullscreen",_selection:"&::selection",_rtl:"[dir=rtl] &, &[dir=rtl]",_ltr:"[dir=ltr] &, &[dir=ltr]",_mediaDark:"@media (prefers-color-scheme: dark)",_mediaReduceMotion:"@media (prefers-reduced-motion: reduce)",_dark:".chakra-ui-dark &:not([data-theme]),[data-theme=dark] &:not([data-theme]),&[data-theme=dark]",_light:".chakra-ui-light &:not([data-theme]),[data-theme=light] &:not([data-theme]),&[data-theme=light]",_horizontal:"&[data-orientation=horizontal]",_vertical:"&[data-orientation=vertical]"},iu=Object.keys(so),co=ke({},br,B,Ul,Rr,fe,ql,Yl,Wl,ji,Xl,Jt,Yn,z,ru,tu,Zl,Ql,zl,eu);Object.assign({},z,fe,Rr,ji,Jt);var au=[...Object.keys(co),...iu],su={...co,...so},cu=e=>e in su,du=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:o}=t.__breakpoints,a={};for(const s in e){let u=nt(e[s],t);if(u==null)continue;if(u=ot(u)&&r(u)?n(u):u,!Array.isArray(u)){a[s]=u;continue}const p=u.slice(0,o.length).length;for(let g=0;g<p;g+=1){const m=o==null?void 0:o[g];if(!m){a[s]=u[g];continue}a[m]=a[m]||{},u[g]!=null&&(a[m][s]=u[g])}}return a};function lu(e){const t=[];let r="",n=!1;for(let o=0;o<e.length;o++){const a=e[o];a==="("?(n=!0,r+=a):a===")"?(n=!1,r+=a):a===","&&!n?(t.push(r),r=""):r+=a}return r=r.trim(),r&&t.push(r),t}function uu(e){return/^var\(--.+\)$/.test(e)}var pu=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!uu(t),fu=(e,t)=>{var r,n;if(t==null)return t;const o=p=>{var g,m;return(m=(g=e.__cssMap)==null?void 0:g[p])==null?void 0:m.varRef},a=p=>{var g;return(g=o(p))!=null?g:p},[s,u]=lu(t);return t=(n=(r=o(s))!=null?r:a(u))!=null?n:a(t),t};function hu(e){const{configs:t={},pseudos:r={},theme:n}=e,o=(a,s=!1)=>{var u,p,g;const m=nt(a,n),b=du(m)(n);let w={};for(let v in b){const x=b[v];let S=nt(x,n);v in r&&(v=r[v]),pu(v,S)&&(S=fu(n,S));let O=t[v];if(O===!0&&(O={property:v}),ot(S)){w[v]=(u=w[v])!=null?u:{},w[v]=ke({},w[v],o(S,!0));continue}let j=(g=(p=O==null?void 0:O.transform)==null?void 0:p.call(O,S,n,m))!=null?g:S;j=O!=null&&O.processResult?o(j,!0):j;const R=nt(O==null?void 0:O.property,n);if(!s&&(O!=null&&O.static)){const D=nt(O.static,n);w=ke({},w,D)}if(R&&Array.isArray(R)){for(const D of R)w[D]=j;continue}if(R){R==="&"&&ot(j)?w=ke({},w,j):w[R]=j;continue}if(ot(j)){w=ke({},w,j);continue}w[v]=j}return w};return o}var gu=e=>t=>hu({theme:t,pseudos:so,configs:co})(e);function mu(e,t){if(Array.isArray(e))return e;if(ot(e))return t(e);if(e!=null)return[e]}function yu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function wu(e){const t=e.__breakpoints;return function(n,o,a,s){var u,p;if(!t)return;const g={},m=mu(a,t.toArrayValue);if(!m)return g;const b=m.length,w=b===1,v=!!n.parts;for(let x=0;x<b;x++){const S=t.details[x],O=t.details[yu(m,x)],j=ou(S.minW,O==null?void 0:O._minW),R=nt((u=n[o])==null?void 0:u[m[x]],s);if(R){if(v){(p=n.parts)==null||p.forEach(D=>{ke(g,{[D]:w?R[D]:{[j]:R[D]}})});continue}if(!v){w?ke(g,R):g[j]=R;continue}g[j]=R}}return g}}function Iu(e){return t=>{var r;const{variant:n,size:o,theme:a}=t,s=wu(a);return ke({},nt((r=e.baseStyle)!=null?r:{},t),s(e,"sizes",o,t),s(e,"variants",n,t))}}function vu(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function bu(e,t,r,n){const o=typeof t=="string"?t.split("."):[t];for(n=0;n<o.length&&e;n+=1)e=e[o[n]];return e===void 0?r:e}var Su=e=>{const t=new WeakMap;return(n,o,a,s)=>{if(typeof n>"u")return e(n,o,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(o))return u.get(o);const p=e(n,o,a,s);return u.set(o,p),p}},xu=Su(bu);function Ei(e,t){const r={};return Object.keys(e).forEach(n=>{const o=e[n];t(o,n,e)&&(r[n]=o)}),r}var Fi=e=>Ei(e,t=>t!=null);function Ou(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Cu(e,...t){return Ou(e)?e(...t):e}var Nu=typeof Element<"u",Tu=typeof Map=="function",Ru=typeof Set=="function",_u=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Sr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,n,o;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(!Sr(e[n],t[n]))return!1;return!0}var a;if(Tu&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;for(a=e.entries();!(n=a.next()).done;)if(!Sr(n.value[1],t.get(n.value[0])))return!1;return!0}if(Ru&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;return!0}if(_u&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(e[n]!==t[n])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;if(Nu&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((o[n]==="_owner"||o[n]==="__v"||o[n]==="__o")&&e.$$typeof)&&!Sr(e[o[n]],t[o[n]]))return!1;return!0}return e!==e&&t!==t}var ju=function(t,r){try{return Sr(t,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const Au=eo(ju);function ku(e,t={}){var r;const{styleConfig:n,...o}=t,{theme:a,colorMode:s}=bl(),u=xu(a,`components.${e}`),p=n||u,g=ke({theme:a,colorMode:s},(r=p==null?void 0:p.defaultProps)!=null?r:{},Fi(vu(o,["children"]))),m=I.useRef({});if(p){const w=Iu(p)(g);Au(m.current,w)||(m.current=w)}return m.current}function Eu(e,t={}){return ku(e,t)}var Fu=new Set([...au,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),Pu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Du(e){return Pu.has(e)||!Fu.has(e)}function Bu(e,...t){if(e==null)throw new TypeError("Cannot convert undefined or null to object");const r={...e};for(const n of t)if(n!=null)for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(o in r&&delete r[o],r[o]=n[o]);return r}var Ao,Lu=(Ao=uo.default)!=null?Ao:uo,Mu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:o,sx:a,...s}=t,u=Ei(s,(b,w)=>cu(w)),p=Cu(e,t),g=Bu({},o,p,Fi(u),a),m=gu(g)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Du);const o=Mu({baseStyle:r}),a=Lu(e,n)(o);return I.forwardRef(function(p,g){const{colorMode:m,forced:b}=Ri();return I.createElement(a,{ref:g,"data-theme":b?m:void 0,...p})})}function $u(){const e=new Map;return new Proxy(Un,{apply(t,r,n){return Un(...n)},get(t,r){return e.has(r)||e.set(r,Un(r)),e.get(r)}})}var ko=$u();function Pi(e){return I.forwardRef(e)}var Eo={path:c.jsxs("g",{stroke:"currentColor",strokeWidth:"1.5",children:[c.jsx("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),c.jsx("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),c.jsx("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},Di=Pi((e,t)=>{const{as:r,viewBox:n,color:o="currentColor",focusable:a=!1,children:s,className:u,__css:p,...g}=e,m=Sl("chakra-icon",u),b=Eu("Icon",e),w={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:o,...p,...b},v={ref:t,focusable:a,className:m,__css:w},x=n??Eo.viewBox;if(r&&typeof r!="string")return c.jsx(ko.svg,{as:r,...v,...g});const S=s??Eo.path;return c.jsx(ko.svg,{verticalAlign:"middle",viewBox:x,...v,...g,children:S})});Di.displayName="Icon";function Uu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:o={}}=e,a=I.Children.toArray(e.path),s=Pi((u,p)=>c.jsx(Di,{ref:p,viewBox:t,...o,...u,children:a.length?a:c.jsx("path",{fill:"currentColor",d:r})}));return s.displayName=n,s}var qu=Uu({displayName:"ExternalLinkIcon",path:c.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[c.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),c.jsx("path",{d:"M15 3h6v6"}),c.jsx("path",{d:"M10 14L21 3"})]})});const Wu="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function zu({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return c.jsx(Vt,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(y.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),c.jsxs(y.Link,{href:Wu,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",c.jsx(qu,{mx:"2px"})]}),c.jsx(Xt,{error:r}),c.jsxs(y.Flex,{marginTop:"1em",children:[c.jsx(y.Input,{placeholder:"MyDomain",onChange:o=>t(o.currentTarget.value)}),c.jsx(y.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Ju({provider:e,handleSubmit:t,setWorkspace:r,error:n,isButtonDisabled:o}){return c.jsx(Vt,{children:c.jsxs(y.FormControl,{children:[c.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsxs(y.Heading,{as:"h4",size:"md",children:["Enter your ",de(e)," workspace"]})}),c.jsx(Xt,{error:n}),c.jsx(y.Flex,{marginTop:"1em",children:c.jsx(y.Input,{placeholder:"MyWorkspace",onChange:a=>r(a.currentTarget.value)})}),c.jsx("br",{}),c.jsx(y.Button,{isDisabled:o,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}const Hu="salesforce";function Ku({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o}){const{projectId:a}=V(),s=X(),[u,p]=I.useState(""),[g,m]=I.useState(null),[b,w]=I.useState(null),v=async()=>{if(w(null),!u){w("Workspace is required");return}try{const O=await Ci(a,t,n,s,e,u,r,o);m(O)}catch(O){console.error(O),w((O==null?void 0:O.message)??"Unexpected error")}},x=I.useCallback(O=>{w(O),m(null)},[]),S=e===Hu?c.jsx(zu,{handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0}):c.jsx(Ju,{provider:e,handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0});return c.jsx(Ni,{windowTitle:`Connect to ${de(e)}`,oauthUrl:g,onClose:x,children:S})}function Gu({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:o,groupName:a,selectedConnection:s,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return c.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p}=t.oauth2Opts,g=t.oauth2Opts.explicitWorkspaceRequired;return p==="authorizationCode"?g?c.jsx(Ku,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):c.jsx(yl,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):p==="clientCredentials"?g?c.jsx(Il,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a,setSelectedConnection:u,selectedConnection:s}):c.jsx(ll,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a,setSelectedConnection:u,selectedConnection:s}):p==="password"?c.jsx("em",{children:"Password flow not supported yet"}):p==="PKCE"?c.jsx("em",{children:"PKCE flow not supported yet"}):c.jsxs("em",{children:["Unsupported grant type: ",p]})}const Vu=async(e,t)=>{const r=await H().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!r)throw new Error(`Provider ${t} not found`);return r};function Bi({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,onSuccess:s}){const u=X(),[p,g]=I.useState(null),{provider:m}=Pe(),{selectedConnection:b,setSelectedConnection:w,connections:v}=St();ol({onSuccess:s});const x=e||m;if(I.useEffect(()=>{if(!b&&v&&v.length>0){const[S]=v;w(S)}Vu(u,x).then(S=>{g(S)}).catch(S=>{console.error("Error loading provider info: ",S)})},[v,b,w,u,x]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");return b?a:p==null?c.jsx("strong",{children:"Provider not found"}):p.authType==="none"?c.jsx(cl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="basic"?c.jsx(rl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="apiKey"?c.jsx(Zd,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:b,groupRef:n,groupName:o,children:a}):c.jsx(Gu,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:o,setSelectedConnection:w,selectedConnection:b})}function Xu({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onInstallSuccess:a,onUpdateSuccess:s}){var g;const{projectId:u}=V(),{errorState:p}=Je();return(g=p[G.INTEGRATION_LIST])!=null&&g.apiError?c.jsx(Ee,{message:"Something went wrong, couldn't find integration information"}):c.jsx(Lc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onInstallSuccess:a,onUpdateSuccess:s,children:c.jsx(Qo,{groupRef:n,children:c.jsx(Bi,{consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:c.jsx(id,{projectId:u,children:c.jsx(Gd,{children:c.jsx(wd,{children:c.jsx(xd,{children:c.jsx(qd,{})})})})})})})})}function Yu({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?c.jsx(y.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:c.jsx(We,{message:"Redirecting..."})}):t}function Zu({provider:e}){const{appName:t}=V(),r=`You have successfully connected your ${de(e)} account to ${t}.`;return c.jsx(Oi,{text:r})}function Qu({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,redirectUrl:a,onSuccess:s}){return c.jsx(Qo,{provider:e,groupRef:n,children:c.jsx(Bi,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onSuccess:s,children:c.jsx(Yu,{redirectURL:a,children:c.jsx(Zu,{provider:e})})})})}const ep=(e,t)=>{const r=X(),{projectId:n}=V(),{integrations:o}=Go(),[a,s]=I.useState(!1),[u,p]=I.useState(null);if(!r||!n)throw new Error("useIsIntegrationInstalled must be used within AmpersandProvider");if(!e)throw new Error("useIsIntegrationInstalled requires an integration name");if(!t)throw new Error("useIsIntegrationInstalled requires a groupRef");const g=I.useMemo(()=>o==null?void 0:o.reduce((m,b)=>(b==null?void 0:b.name)===e?b:m,{}),[o,e]);return I.useEffect(()=>{g&&H().installationApi.listInstallations({projectIdOrName:n,integrationId:g.id,groupRef:t},{headers:{"x-api-key":r}}).then(m=>{s(!0),p(m.length>0)}).catch(m=>{console.error("Error listing installations: ",m),s(!0)})},[t,r,n,g]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Xo;exports.AmpersandProvider=Pc;exports.ConnectProvider=Qu;exports.InstallIntegration=Xu;exports.useAmpersandProvider=Dc;exports.useIsIntegrationInstalled=ep;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),I=require("react"),w=require("@chakra-ui/react"),Mi=require("@emotion/react"),uo=require("@emotion/styled"),$i={warning:{bg:"red.50",outlineColor:"red.800",outline:"2px solid",outlineOffset:"0",borderColor:"red.800",color:"red.800",_hover:{bg:"red.100"}}},Ui=w.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.300"},_selected:{color:"black",fontWeight:"500",bg:"gray.200",border:"none",_hover:{bg:"gray.300"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.200"},_selected:{color:"red.800",fontWeight:"500",bg:"red.100",border:"none",_hover:{bg:"red.200"}}}}},Button:{variants:$i}}}),qi=w.extendTheme(w.withDefaultColorScheme({colorScheme:"facebook",components:["Button"]}),Ui);function Wi({children:e}){return s.jsx(w.ChakraProvider,{theme:qi,children:e})}const Fo=I.createContext(null),zi=Fo.Provider,X=()=>{const e=I.useContext(Fo);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var G=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e))(G||{});const Po=I.createContext(void 0);function Je(){const e=I.useContext(Po);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Ji=(()=>{const e={};return Object.values(G).forEach(t=>{e[t]={}}),e})();function Hi({children:e}){const[t,r]=I.useState(Ji),n=I.useCallback((g,m)=>{r(b=>{const y={...b};return y[g]=y[g]||{},y[g][m]=!0,y})},[r]),o=I.useCallback((g,m)=>{var b;return!!((b=t[g])!=null&&b[m])},[t]),a=I.useCallback((g,m)=>{r(b=>{var v;const y={...b};return(v=y[g])==null||delete v[m],y})},[r]),c=I.useCallback(g=>{r(m=>{const b={...m};return b[g]={},b})},[r]),u=I.useCallback((g,m)=>{r(b=>{const y={...b};return y[g]=y[g]||{},m.forEach(v=>{y[g][v]=!0}),y})},[r]),p=I.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:o,removeError:a,resetBoundary:c,setErrors:u}),[t,r,n,o,a,c,u]);return s.jsx(Po.Provider,{value:p,children:e})}function Te({message:e}){return s.jsx(w.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:s.jsxs(w.Stack,{alignItems:"center",children:[s.jsx(w.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&s.jsx(w.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Pe({message:e}){return s.jsxs(w.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx(w.Box,{boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center","align-self":"stretch",padding:"12px 50px 12px 50px",borderRadius:"8px",border:"2px solid #FECACA",background:"#FEF2F2",children:s.jsx(w.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Ki="https://api.withampersand.com/v1".replace(/\/+$/,"");class Do{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Ki}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Bo}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Gi=new Do,_r=class _r{constructor(t=Gi){this.configuration=t,this.fetchApi=async(r,n)=>{let o={url:r,init:n};for(const c of this.middleware)c.pre&&(o=await c.pre({fetch:this.fetchApi,...o})||o);let a;try{a=await(this.configuration.fetchApi||fetch)(o.url,o.init)}catch(c){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:o.url,init:o.init,error:c,response:a?a.clone():void 0})||a);if(a===void 0)throw c instanceof Error?new Zi(c,"The request failed and the interceptors did not return an alternative response"):c}for(const c of this.middleware)c.post&&(a=await c.post({fetch:this.fetchApi,url:o.url,init:o.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const r=this.clone();return r.middleware=r.middleware.concat(...t),r}withPreMiddleware(...t){const r=t.map(n=>({pre:n}));return this.withMiddleware(...r)}withPostMiddleware(...t){const r=t.map(n=>({post:n}));return this.withMiddleware(...r)}isJsonMime(t){return t?_r.jsonRegex.test(t):!1}async request(t,r){const{url:n,init:o}=await this.createFetchParams(t,r),a=await this.fetchApi(n,o);if(a&&a.status>=200&&a.status<300)return a;throw new Yi(a,"Response returned an error code")}async createFetchParams(t,r){let n=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(n+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(g=>o[g]===void 0?delete o[g]:{});const a=typeof r=="function"?r:async()=>r,c={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},u={...c,...await a({init:c,context:t})},p={...u,body:Xi(u.body)||u.body instanceof URLSearchParams||Vi(u.body)?u.body:JSON.stringify(u.body)};return{url:n,init:p}}clone(){const t=this.constructor,r=new t(this.configuration);return r.middleware=this.middleware.slice(),r}};_r.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let ne=_r;function Vi(e){return typeof Blob<"u"&&e instanceof Blob}function Xi(e){return typeof FormData<"u"&&e instanceof FormData}class Yi extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class Zi extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class _ extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function N(e,t){const r=e[t];return r!=null}function Bo(e,t=""){return Object.keys(e).map(r=>Lo(r,e[r],t)).filter(r=>r.length>0).join("&")}function Lo(e,t,r=""){const n=r+(r.length?`[${e}]`:e);if(t instanceof Array){const o=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${o}`}if(t instanceof Set){const o=Array.from(t);return Lo(e,o,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Bo(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function Qn(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class M{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class De{constructor(t){this.raw=t}async value(){}}class Qi{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function ea(e){return ta(e)}function ta(e,t){return e==null?e:{name:e.name,valuePrefix:N(e,"valuePrefix")?e.valuePrefix:void 0}}function ra(e){return na(e)}function na(e,t){return e==null?e:{name:e.name}}function oa(e){return ia(e)}function ia(e,t){return e==null?e:{attachmentType:e.attachmentType,query:N(e,"query")?ra(e.query):void 0,header:N(e,"header")?ea(e.header):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function aa(e){return sa(e)}function sa(e,t){return e}function ca(e){return da(e)}function da(e,t){return e==null?e:{days:N(e,"days")?e.days:void 0,fullHistory:N(e,"fullHistory")?e.fullHistory:void 0}}function Mo(e){return la(e)}function la(e,t){return e==null?e:{defaultPeriod:ca(e.defaultPeriod)}}function ua(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function pa(e){if(e!==void 0)return e===null?null:{defaultPeriod:ua(e.defaultPeriod)}}function fa(e){return ha(e)}function ha(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function $o(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function ga(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,backfill:pa(e.backfill)}}function ma(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,ga)}}function wa(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function ya(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,wa)}}function Ia(e){return va(e)}function va(e,t){return e==null?e:{docsURL:N(e,"docsURL")?e.docsURL:void 0}}function Uo(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function gr(e){return ba(e)}function ba(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:N(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Sa(e){return xa(e)}function xa(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Oa(e){return Ca(e)}function Ca(e,t){return e==null?e:{provider:e.provider,read:N(e,"read")?e.read:void 0,write:N(e,"write")?e.write:void 0,proxy:N(e,"proxy")?fa(e.proxy):void 0}}function qo(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:$o(e.proxy)}}function Ta(e){return Na(e)}function Na(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Oa(e.content)}}function Ra(e){return _a(e)}function _a(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Wo(e){return ja(e)}function ja(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Aa(e)}function Aa(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:N(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:N(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function vr(e){return ka(e)}function ka(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:Wo(e.group),consumer:Ra(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:N(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ea(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Fa(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Pa(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Fa(e.metadata)}}function Da(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function Ba(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:qo(e.content)}}function La(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Ba(e.config)}}function Ma(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function $a(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Ma(e.latestRevision)}}function Ua(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function qa(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Wa(e){return za(e)}function za(e,t){return e==null?e:{url:N(e,"url")?e.url:void 0,headers:N(e,"headers")?e.headers:void 0}}function Ja(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return Ha(e)}function Ha(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:Wa(e.metadata),createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Ga(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret}}function Va(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret}}function Xa(e){if(e!==void 0)return e===null?null:{projectId:e.projectId,providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Ka(e.basicAuth),oauth2ClientCredentials:Ga(e.oauth2ClientCredentials),oauth2Password:Va(e.oauth2Password)}}function Ya(e){return Za(e)}function Za(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Qa(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function zo(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:N(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:N(e,"default")?e.default:void 0,prompt:N(e,"prompt")?e.prompt:void 0}}function Bn(e){return es(e)}function es(e,t){return e==null?e:{...Qa(e),...zo(e)}}function Jo(e){return ts(e)}function ts(e,t){return e}function rs(e){return ns(e)}function ns(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(Bn):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(Bn):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Jo(e.optionalFieldsAuto):void 0,allFields:N(e,"allFields")?e.allFields.map(Bn):void 0,backfill:N(e,"backfill")?Mo(e.backfill):void 0}}function os(e){return is(e)}function is(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(rs):void 0}}function as(e){return ss(e)}function ss(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function cs(e){return ds(e)}function ds(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(as):void 0}}function ls(e){return us(e)}function us(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?os(e.read):void 0,write:N(e,"write")?cs(e.write):void 0,proxy:N(e,"proxy")?Ya(e.proxy):void 0}}function ps(e){return fs(e)}function fs(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:ls(e.content)}}function hs(e){if(e!==void 0)return e===null?null:{providerAppId:e.providerAppId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:e.providerConsumerRef,refreshToken:e.refreshToken,scopes:e.scopes}}function gs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:qo(e.content)}}function ms(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:hs(e.connection),config:gs(e.config)}}function qt(e){return ws(e)}function ws(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:N(e,"group")?Wo(e.group):void 0,healthStatus:e.healthStatus,connection:vr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,config:Ta(e.config)}}function ys(e){return Is(e)}function Is(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function vs(e,t){return e==null?e:{fieldName:e.fieldName}}function po(e){return bs(e)}function bs(e,t){return e==null?e:{...vs(e),...zo(e)}}function Ss(e){return xs(e)}function xs(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(po):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(po):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Jo(e.optionalFieldsAuto):void 0,backfill:N(e,"backfill")?Mo(e.backfill):void 0}}function Os(e){return Cs(e)}function Cs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Ss):void 0}}function Ts(e){return Ns(e)}function Ns(e,t){return e==null?e:{objectName:e.objectName}}function Rs(e){return _s(e)}function _s(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Ts):void 0}}function js(e){return As(e)}function As(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?Os(e.read):void 0,write:N(e,"write")?Rs(e.write):void 0,proxy:N(e,"proxy")?ys(e.proxy):void 0}}function ks(e){return Es(e)}function Es(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:js(e.content)}}function fo(e){return Fs(e)}function Fs(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:ks(e.latestRevision)}}function Ps(e){return Ds(e)}function Ds(e,t){return e==null?e:{msg:e.msg,operationEventId:N(e,"operation_event_id")?e.operation_event_id:void 0,operationId:N(e,"operation_id")?e.operation_id:void 0}}function Bs(e){return Ls(e)}function Ls(e,t){return e==null?e:{timestamp:e.timestamp,message:Ps(e.message),severity:e.severity}}function Ms(e){return $s(e)}function $s(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Us(e){return qs(e)}function qs(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Ws(e){return zs(e)}function zs(e,t){return e==null?e:{regular:N(e,"regular")?Us(e.regular):void 0,darkMode:N(e,"darkMode")?Ms(e.darkMode):void 0}}function Js(e){return Hs(e)}function Hs(e,t){return e==null?e:{workspaceRefField:N(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:N(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:N(e,"scopesField")?e.scopesField:void 0}}function Ks(e){return Gs(e)}function Gs(e,t){return e==null?e:{grantType:e.grantType,authURL:N(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:N(e,"audience")?e.audience:void 0,tokenMetadataFields:Js(e.tokenMetadataFields),docsURL:N(e,"docsURL")?e.docsURL:void 0,authURLParams:N(e,"authURLParams")?e.authURLParams:void 0}}function Vs(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,projectId:e.projectId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerAppId:e.providerAppId,provider:e.provider}}function ho(e){return Xs(e)}function Xs(e,t){return e==null?e:{projectId:e.projectId,integrationId:e.integrationId,configId:e.configId,actionType:e.actionType,id:e.id,installationId:e.installationId,status:e.status,result:N(e,"result")?e.result:void 0,latestOperationEventId:N(e,"latestOperationEventId")?e.latestOperationEventId:void 0,metadata:N(e,"metadata")?e.metadata:void 0,createTime:N(e,"createTime")?new Date(e.createTime):void 0}}function Ys(e){return Zs(e)}function Zs(e,t){return e==null?e:{bulkWrite:Sa(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function go(e){return Qs(e)}function Qs(e,t){return e==null?e:{name:e.name,authType:aa(e.authType),baseURL:e.baseURL,oauth2Opts:N(e,"oauth2Opts")?Ks(e.oauth2Opts):void 0,apiKeyOpts:N(e,"apiKeyOpts")?oa(e.apiKeyOpts):void 0,basicOpts:N(e,"basicOpts")?Ia(e.basicOpts):void 0,support:Ys(e.support),providerOpts:e.providerOpts,displayName:N(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:N(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:N(e,"media")?Ws(e.media):void 0}}function ec(e){return tc(e)}function tc(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function rc(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:Ja(e.metadata)}}function nc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:rc(e.destination)}}function oc(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:ma(e.read),write:ya(e.write),proxy:$o(e.proxy)}}function ic(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:oc(e.content)}}function ac(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:ic(e.config)}}function sc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:ac(e.installation)}}function cc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function dc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:cc(e.project)}}function lc(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function uc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:lc(e.providerApp)}}class pc extends ne{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Xa(t.generateConnectionParams)},r);return new M(a,c=>vr(c))}async generateConnection(t,r){return await(await this.generateConnectionRaw(t,r)).value()}async getConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:n},r);return new M(a,c=>vr(c))}async getConnection(t,r){return await(await this.getConnectionRaw(t,r)).value()}async listConnectionsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const n={};t.provider!==void 0&&(n.provider=t.provider),t.groupRef!==void 0&&(n.groupRef=t.groupRef),t.consumerRef!==void 0&&(n.consumerRef=t.consumerRef);const o={},a=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(vr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class fc extends ne{async createConsumerRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createConsumer.");if(t.consumer===null||t.consumer===void 0)throw new _("consumer","Required parameter requestParameters.consumer was null or undefined when calling createConsumer.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/consumers".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Ea(t.consumer)},r);return new De(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class hc extends ne{async createDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createDestination.");if(t.destination===null||t.destination===void 0)throw new _("destination","Required parameter requestParameters.destination was null or undefined when calling createDestination.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Pa(t.destination)},r);return new M(a,c=>mr(c))}async createDestination(t,r){return await(await this.createDestinationRaw(t,r)).value()}async deleteDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling deleteDestination.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"DELETE",headers:o,query:n},r);return new De(a)}async deleteDestination(t,r){await this.deleteDestinationRaw(t,r)}async getDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getDestination.");if(t.destinationName===null||t.destinationName===void 0)throw new _("destinationName","Required parameter requestParameters.destinationName was null or undefined when calling getDestination.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationName}",encodeURIComponent(String(t.destinationName))),method:"GET",headers:o,query:n},r);return new M(a,c=>mr(c))}async getDestination(t,r){return await(await this.getDestinationRaw(t,r)).value()}async listDestinationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listDestinations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(mr))}async listDestinations(t,r){return await(await this.listDestinationsRaw(t,r)).value()}async updateDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling updateDestination.");if(t.destinationUpdate===null||t.destinationUpdate===void 0)throw new _("destinationUpdate","Required parameter requestParameters.destinationUpdate was null or undefined when calling updateDestination.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"PATCH",headers:o,query:n,body:nc(t.destinationUpdate)},r);return new M(a,c=>mr(c))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class gc extends ne{async createGroupRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createGroup.");if(t.group===null||t.group===void 0)throw new _("group","Required parameter requestParameters.group was null or undefined when calling createGroup.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/groups".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:Da(t.group)},r);return new De(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class mc extends ne{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:La(t.installation)},r);return new M(a,c=>qt(c))}async createInstallation(t,r){return await(await this.createInstallationRaw(t,r)).value()}async deleteInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"DELETE",headers:o,query:n},r);return new De(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:n},r);return new M(a,c=>qt(c))}async getInstallation(t,r){return await(await this.getInstallationRaw(t,r)).value()}async importInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations:import".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:ms(t.installation)},r);return new M(a,c=>qt(c))}async importInstallation(t,r){return await(await this.importInstallationRaw(t,r)).value()}async listInstallationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const n={};t.groupRef!==void 0&&(n.groupRef=t.groupRef);const o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(qt))}async listInstallations(t,r){return await(await this.listInstallationsRaw(t,r)).value()}async updateInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new _("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"PATCH",headers:o,query:n,body:sc(t.installationUpdate)},r);return new M(a,c=>qt(c))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class wc extends ne{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:n,body:Uo(t.batchUpsertIntegrationsRequest)},r);return new M(a,c=>c.map(fo))}async batchUpsertIntegrations(t,r){return await(await this.batchUpsertIntegrationsRaw(t,r)).value()}async createIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new _("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:$a(t.integration)},r);return new De(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:o,query:n},r);return new De(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(fo))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class yc extends ne{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new _("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:n,body:Vs(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new M(a):new Qi(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class Ic extends ne{async getOperationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getOperation.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling getOperation.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:o,query:n},r);return new M(a,c=>ho(c))}async getOperation(t,r){return await(await this.getOperationRaw(t,r)).value()}async listOperationLogsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperationLogs.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling listOperationLogs.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}/logs".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(Bs))}async listOperationLogs(t,r){return await(await this.listOperationLogsRaw(t,r)).value()}async listOperationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listOperations.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling listOperations.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}/operations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(ho))}async listOperations(t,r){return await(await this.listOperationsRaw(t,r)).value()}}class vc extends ne{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new _("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects",method:"POST",headers:o,query:n,body:Ua(t.project)},r);return new M(a,c=>gr(c))}async createProject(t,r){return await(await this.createProjectRaw(t,r)).value()}async deleteProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:o,query:n},r);return new De(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new M(a,c=>gr(c))}async getProject(t,r){return await(await this.getProjectRaw(t,r)).value()}async listProjectsRaw(t){const r={},n={},o=await this.request({path:"/projects",method:"GET",headers:n,query:r},t);return new M(o,a=>a.map(gr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new _("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:n,body:dc(t.projectUpdate)},r);return new M(a,c=>gr(c))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class bc extends ne{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new _("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const n={},o={},a=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:n},r);return new M(a,c=>go(c))}async getProvider(t,r){return await(await this.getProviderRaw(t,r)).value()}async listProvidersRaw(t){const r={},n={},o=await this.request({path:"/providers",method:"GET",headers:n,query:r},t);return new M(o,a=>Qn(a,go))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Sc extends ne{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new _("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:n,body:qa(t.providerApp)},r);return new M(a,c=>Ir(c))}async createProviderApp(t,r){return await(await this.createProviderAppRaw(t,r)).value()}async deleteProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:o,query:n},r);return new De(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const n={},o={},a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:n},r);return new M(a,c=>c.map(Ir))}async listProviderApps(t,r){return await(await this.listProviderAppsRaw(t,r)).value()}async updateProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new _("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:o,query:n,body:uc(t.providerAppUpdate)},r);return new M(a,c=>Ir(c))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class xc extends ne{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const n={},o={};o["Content-Type"]="application/json";const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:n,body:Uo(t.revision)},r);return new De(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new _("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const n={};t.connectionId!==void 0&&(n.connectionId=t.connectionId);const o={},a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:o,query:n},r);return new M(a,c=>ps(c))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class Oc extends ne{async generateUploadUrlRaw(t){const r={},n={},o=await this.request({path:"/generate-upload-url",method:"GET",headers:n,query:r},t);return new M(o,a=>ec(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class Cc{constructor(t){this.connectionApi=new pc(t),this.consumerApi=new fc(t),this.destinationApi=new hc(t),this.groupApi=new gc(t),this.installationApi=new mc(t),this.integrationApi=new wc(t),this.oAuthApi=new yc(t),this.operationApi=new Ic(t),this.projectApi=new vc(t),this.providerApi=new bc(t),this.providerAppApi=new Sc(t),this.revisionApi=new xc(t),this.uploadURLApi=new Oc(t)}}const Tc="1.8.0",Nc="v1",wr="https://api.withampersand.com";function Ho(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return wr;case"mock":return"http://127.0.0.1:4010";case"":return wr;default:return e??wr}}catch{return wr}}const Rc=(e,t)=>`${e}/${t}`;function _c(){return Rc(Ho(),Nc)}const jc=Ho(),Ac=_c(),kc=new Do({basePath:Ac,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Tc}});let Ec=new Cc(kc);const H=()=>Ec,Ko=I.createContext({integrations:null}),Go=()=>{const e=I.useContext(Ko);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Fc({projectIdOrName:e,children:t}){const r=X(),{setError:n,isError:o}=Je(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m||[])}).catch(m=>{p(!1),n(G.INTEGRATION_LIST,e),console.error("Error retrieving integration information for : ",m)})},[e,r,n]);const g=I.useMemo(()=>({integrations:a}),[a]);return o(G.INTEGRATION_LIST,e)?s.jsx(Pe,{message:"Error retrieving integrations for the project, double check the API key"}):s.jsx(Ko.Provider,{value:g,children:u?s.jsx(Te,{}):t})}const Vo=I.createContext({project:null,appName:"",projectId:""}),V=()=>{const e=I.useContext(Vo);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Pc({projectIdOrName:e,children:t}){const r=X(),{isError:n,setError:o}=Je(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m)}).catch(m=>{o(G.PROJECT,e),p(!1),console.error("Error loading Ampersand project: ",m)})},[e,r,p,o]);const g=I.useMemo(()=>({projectId:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(G.PROJECT,e)?s.jsx(Pe,{message:`Error loading project ${e}`}):s.jsx(Vo.Provider,{value:g,children:u?s.jsx(Te,{}):t})}function Dc(e){const{options:{apiKey:t,projectId:r,project:n},children:o}=e,a=n||r;if(r&&n)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!a)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return s.jsx(Wi,{children:s.jsx(Hi,{children:s.jsx(zi,{value:t,children:s.jsx(Pc,{projectIdOrName:a,children:s.jsx(Fc,{projectIdOrName:a,children:o})})})})})}const Xo=I.createContext(null);function Bc(){const e=I.useContext(Xo);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
2
+ component is wrapped with AmpersandProvider`);return e}function de(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Lc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Yo=I.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0});function Ne(){const e=I.useContext(Yo);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Mc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:o,groupName:a,onInstallSuccess:c,onUpdateSuccess:u}){const p=X(),{projectId:g}=V(),{integrations:m}=Go(),[b,y]=I.useState([]),[v,x]=I.useState(!0),{setError:S,isError:O}=Je(),j=(b==null?void 0:b[0])||null,T=I.useMemo(()=>Lc(t,m||[]),[t,m]);I.useEffect(()=>{T===null&&(m!=null&&m.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,T,m]);const P=I.useCallback(J=>{y([J])},[y]),L=I.useCallback(()=>{T!=null&&T.id&&H().installationApi.listInstallations({projectIdOrName:g,integrationId:T.id,groupRef:o},{headers:{"X-Api-Key":p??""}}).then(J=>{x(!1),y(J||[])}).catch(J=>{S(G.INSTALLATION_LIST,T.id),x(!1),console.error("Error retrieving installation information: ",J)})},[T,g,p,S,o]),Z=(T==null?void 0:T.id)||"";I.useEffect(()=>{L()},[L]);const te=I.useMemo(()=>({integrationId:(T==null?void 0:T.id)||"",provider:(T==null?void 0:T.provider)||"",integrationObj:T,consumerRef:r,consumerName:n,groupRef:o,groupName:a,installation:j,setInstallation:P,resetInstallations:L,onInstallSuccess:c,onUpdateSuccess:u}),[T,r,n,o,a,j,P,L,c,u]);if(T!==null){const J=`Error retrieving installation information for integration "${(T==null?void 0:T.name)||"unknown"}"`;return O(G.INSTALLATION_LIST,Z)?s.jsx(Pe,{message:J}):s.jsx(Yo.Provider,{value:te,children:v?s.jsx(Te,{}):e})}return s.jsx(Pe,{message:`Integration "${t}" not found`})}const Zo=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),xt=()=>{const e=I.useContext(Zo);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Qo({provider:e,groupRef:t,children:r}){const n=X(),{projectId:o}=V(),[a,c]=I.useState(null),[u,p]=I.useState(null),[g,m]=I.useState(!0),{setError:b,isError:y}=Je(),{provider:v}=Ne();if(!o)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const x=e||v;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");I.useEffect(()=>{H().connectionApi.listConnections({projectIdOrName:o,groupRef:t,provider:x},{headers:{"X-Api-Key":n??""}}).then(O=>{m(!1),c(O)}).catch(O=>{m(!1),b(G.CONNECTION_LIST,o),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,O)})},[o,n,t,x,b]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:c,setSelectedConnection:p}),[a,u,c,p]);return y(G.CONNECTION_LIST,o)?s.jsx(Pe,{message:"Error retrieving existing connections"}):s.jsx(Zo.Provider,{value:S,children:g?s.jsx(Te,{}):r})}var We=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function eo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xr={exports:{}};xr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",o=1,a=2,c=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",b="[object Date]",y="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",j="[object Null]",T="[object Object]",P="[object Promise]",L="[object Proxy]",Z="[object RegExp]",te="[object Set]",J="[object String]",ie="[object Symbol]",be="[object Undefined]",he="[object WeakMap]",Re="[object ArrayBuffer]",ct="[object DataView]",Br="[object Float32Array]",Lr="[object Float64Array]",Mr="[object Int8Array]",$r="[object Int16Array]",Ur="[object Int32Array]",qr="[object Uint8Array]",Wr="[object Uint8ClampedArray]",zr="[object Uint16Array]",Jr="[object Uint32Array]",Hr=/[\\^$.*+?()[\]{}|]/g,$=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,U={};U[Br]=U[Lr]=U[Mr]=U[$r]=U[Ur]=U[qr]=U[Wr]=U[zr]=U[Jr]=!0,U[u]=U[p]=U[Re]=U[m]=U[ct]=U[b]=U[y]=U[v]=U[S]=U[O]=U[T]=U[Z]=U[te]=U[J]=U[he]=!1;var Be=typeof We=="object"&&We&&We.Object===Object&&We,Zt=typeof self=="object"&&self&&self.Object===Object&&self,re=Be||Zt||Function("return this")(),Ct=t&&!t.nodeType&&t,dt=Ct&&!0&&e&&!e.nodeType&&e,Tt=dt&&dt.exports===Ct,lt=Tt&&Be.process,Qt=function(){try{return lt&&lt.binding&&lt.binding("util")}catch{}}(),er=Qt&&Qt.isTypedArray;function Kr(l,i){for(var d=-1,f=l==null?0:l.length,C=0,R=[];++d<f;){var A=l[d];i(A,d,l)&&(R[C++]=A)}return R}function Gr(l,i){for(var d=-1,f=i.length,C=l.length;++d<f;)l[C+d]=i[d];return l}function Vr(l,i){for(var d=-1,f=l==null?0:l.length;++d<f;)if(i(l[d],d,l))return!0;return!1}function Xr(l,i){for(var d=-1,f=Array(l);++d<l;)f[d]=i(d);return f}function Yr(l){return function(i){return l(i)}}function ut(l,i){return l.has(i)}function Nt(l,i){return l==null?void 0:l[i]}function pt(l){var i=-1,d=Array(l.size);return l.forEach(function(f,C){d[++i]=[C,f]}),d}function Se(l,i){return function(d){return l(i(d))}}function tr(l){var i=-1,d=Array(l.size);return l.forEach(function(f){d[++i]=f}),d}var rr=Array.prototype,Zr=Function.prototype,ft=Object.prototype,Le=re["__core-js_shared__"],Rt=Zr.toString,ae=ft.hasOwnProperty,_t=function(){var l=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),jt=ft.toString,Qr=RegExp("^"+Rt.call(ae).replace(Hr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Tt?re.Buffer:void 0,le=re.Symbol,He=re.Uint8Array,or=ft.propertyIsEnumerable,ir=rr.splice,_e=le?le.toStringTag:void 0,At=Object.getOwnPropertySymbols,Ke=nr?nr.isBuffer:void 0,en=Se(Object.keys,Object),ge=$e(re,"DataView"),Ge=$e(re,"Map"),kt=$e(re,"Promise"),Et=$e(re,"Set"),Ft=$e(re,"WeakMap"),Ve=$e(Object,"create"),me=Ie(ge),tn=Ie(Ge),rn=Ie(kt),nn=Ie(Et),on=Ie(Ft),ar=le?le.prototype:void 0,xe=ar?ar.valueOf:void 0;function je(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function an(){this.__data__=Ve?Ve(null):{},this.size=0}function sn(l){var i=this.has(l)&&delete this.__data__[l];return this.size-=i?1:0,i}function cn(l){var i=this.__data__;if(Ve){var d=i[l];return d===n?void 0:d}return ae.call(i,l)?i[l]:void 0}function dn(l){var i=this.__data__;return Ve?i[l]!==void 0:ae.call(i,l)}function Me(l,i){var d=this.__data__;return this.size+=this.has(l)?0:1,d[l]=Ve&&i===void 0?n:i,this}je.prototype.clear=an,je.prototype.delete=sn,je.prototype.get=cn,je.prototype.has=dn,je.prototype.set=Me;function we(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function ln(){this.__data__=[],this.size=0}function un(l){var i=this.__data__,d=mt(i,l);if(d<0)return!1;var f=i.length-1;return d==f?i.pop():ir.call(i,d,1),--this.size,!0}function pn(l){var i=this.__data__,d=mt(i,l);return d<0?void 0:i[d][1]}function fn(l){return mt(this.__data__,l)>-1}function hn(l,i){var d=this.__data__,f=mt(d,l);return f<0?(++this.size,d.push([l,i])):d[f][1]=i,this}we.prototype.clear=ln,we.prototype.delete=un,we.prototype.get=pn,we.prototype.has=fn,we.prototype.set=hn;function ye(l){var i=-1,d=l==null?0:l.length;for(this.clear();++i<d;){var f=l[i];this.set(f[0],f[1])}}function gn(){this.size=0,this.__data__={hash:new je,map:new(Ge||we),string:new je}}function ht(l){var i=Ze(this,l).delete(l);return this.size-=i?1:0,i}function Pt(l){return Ze(this,l).get(l)}function mn(l){return Ze(this,l).has(l)}function gt(l,i){var d=Ze(this,l),f=d.size;return d.set(l,i),this.size+=d.size==f?0:1,this}ye.prototype.clear=gn,ye.prototype.delete=ht,ye.prototype.get=Pt,ye.prototype.has=mn,ye.prototype.set=gt;function Xe(l){var i=-1,d=l==null?0:l.length;for(this.__data__=new ye;++i<d;)this.add(l[i])}function wn(l){return this.__data__.set(l,n),this}function yn(l){return this.__data__.has(l)}Xe.prototype.add=Xe.prototype.push=wn,Xe.prototype.has=yn;function Oe(l){var i=this.__data__=new we(l);this.size=i.size}function sr(){this.__data__=new we,this.size=0}function In(l){var i=this.__data__,d=i.delete(l);return this.size=i.size,d}function vn(l){return this.__data__.get(l)}function bn(l){return this.__data__.has(l)}function Sn(l,i){var d=this.__data__;if(d instanceof we){var f=d.__data__;if(!Ge||f.length<r-1)return f.push([l,i]),this.size=++d.size,this;d=this.__data__=new ye(f)}return d.set(l,i),this.size=d.size,this}Oe.prototype.clear=sr,Oe.prototype.delete=In,Oe.prototype.get=vn,Oe.prototype.has=bn,Oe.prototype.set=Sn;function xn(l,i){var d=Qe(l),f=!d&&Fn(l),C=!d&&!f&&vt(l),R=!d&&!f&&!C&&Ut(l),A=d||f||C||R,F=A?Xr(l.length,String):[],k=F.length;for(var E in l)ae.call(l,E)&&!(A&&(E=="length"||C&&(E=="offset"||E=="parent")||R&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||An(E,k)))&&F.push(E);return F}function mt(l,i){for(var d=l.length;d--;)if(It(l[d][0],i))return d;return-1}function On(l,i,d){var f=i(l);return Qe(l)?f:Gr(f,d(l))}function Ye(l){return l==null?l===void 0?be:j:_e&&_e in Object(l)?_n(l):Lt(l)}function cr(l){return et(l)&&Ye(l)==u}function dr(l,i,d,f,C){return l===i?!0:l==null||i==null||!et(l)&&!et(i)?l!==l&&i!==i:wt(l,i,d,f,dr,C)}function wt(l,i,d,f,C,R){var A=Qe(l),F=Qe(i),k=A?p:ue(l),E=F?p:ue(i);k=k==u?T:k,E=E==u?T:E;var q=k==T,W=E==T,K=k==E;if(K&&vt(l)){if(!vt(i))return!1;A=!0,q=!1}if(K&&!q)return R||(R=new Oe),A||Ut(l)?Bt(l,i,d,f,C,R):Nn(l,i,k,d,f,C,R);if(!(d&o)){var Q=q&&ae.call(l,"__wrapped__"),ee=W&&ae.call(i,"__wrapped__");if(Q||ee){var ve=Q?l.value():l,ke=ee?i.value():i;return R||(R=new Oe),C(ve,ke,d,f,R)}}return K?(R||(R=new Oe),Rn(l,i,d,f,C,R)):!1}function Dt(l){if(!$t(l)||En(l))return!1;var i=Ue(l)?Qr:$;return i.test(Ie(l))}function Cn(l){return et(l)&&ur(l.length)&&!!U[Ye(l)]}function Tn(l){if(!yt(l))return en(l);var i=[];for(var d in Object(l))ae.call(l,d)&&d!="constructor"&&i.push(d);return i}function Bt(l,i,d,f,C,R){var A=d&o,F=l.length,k=i.length;if(F!=k&&!(A&&k>F))return!1;var E=R.get(l);if(E&&R.get(i))return E==i;var q=-1,W=!0,K=d&a?new Xe:void 0;for(R.set(l,i),R.set(i,l);++q<F;){var Q=l[q],ee=i[q];if(f)var ve=A?f(ee,Q,q,i,l,R):f(Q,ee,q,l,i,R);if(ve!==void 0){if(ve)continue;W=!1;break}if(K){if(!Vr(i,function(ke,tt){if(!ut(K,tt)&&(Q===ke||C(Q,ke,d,f,R)))return K.push(tt)})){W=!1;break}}else if(!(Q===ee||C(Q,ee,d,f,R))){W=!1;break}}return R.delete(l),R.delete(i),W}function Nn(l,i,d,f,C,R,A){switch(d){case ct:if(l.byteLength!=i.byteLength||l.byteOffset!=i.byteOffset)return!1;l=l.buffer,i=i.buffer;case Re:return!(l.byteLength!=i.byteLength||!R(new He(l),new He(i)));case m:case b:case O:return It(+l,+i);case y:return l.name==i.name&&l.message==i.message;case Z:case J:return l==i+"";case S:var F=pt;case te:var k=f&o;if(F||(F=tr),l.size!=i.size&&!k)return!1;var E=A.get(l);if(E)return E==i;f|=a,A.set(l,i);var q=Bt(F(l),F(i),f,C,R,A);return A.delete(l),q;case ie:if(xe)return xe.call(l)==xe.call(i)}return!1}function Rn(l,i,d,f,C,R){var A=d&o,F=lr(l),k=F.length,E=lr(i),q=E.length;if(k!=q&&!A)return!1;for(var W=k;W--;){var K=F[W];if(!(A?K in i:ae.call(i,K)))return!1}var Q=R.get(l);if(Q&&R.get(i))return Q==i;var ee=!0;R.set(l,i),R.set(i,l);for(var ve=A;++W<k;){K=F[W];var ke=l[K],tt=i[K];if(f)var lo=A?f(tt,ke,K,i,l,R):f(ke,tt,K,l,i,R);if(!(lo===void 0?ke===tt||C(ke,tt,d,f,R):lo)){ee=!1;break}ve||(ve=K=="constructor")}if(ee&&!ve){var fr=l.constructor,hr=i.constructor;fr!=hr&&"constructor"in l&&"constructor"in i&&!(typeof fr=="function"&&fr instanceof fr&&typeof hr=="function"&&hr instanceof hr)&&(ee=!1)}return R.delete(l),R.delete(i),ee}function lr(l){return On(l,Pn,jn)}function Ze(l,i){var d=l.__data__;return kn(i)?d[typeof i=="string"?"string":"hash"]:d.map}function $e(l,i){var d=Nt(l,i);return Dt(d)?d:void 0}function _n(l){var i=ae.call(l,_e),d=l[_e];try{l[_e]=void 0;var f=!0}catch{}var C=jt.call(l);return f&&(i?l[_e]=d:delete l[_e]),C}var jn=At?function(l){return l==null?[]:(l=Object(l),Kr(At(l),function(i){return or.call(l,i)}))}:Dn,ue=Ye;(ge&&ue(new ge(new ArrayBuffer(1)))!=ct||Ge&&ue(new Ge)!=S||kt&&ue(kt.resolve())!=P||Et&&ue(new Et)!=te||Ft&&ue(new Ft)!=he)&&(ue=function(l){var i=Ye(l),d=i==T?l.constructor:void 0,f=d?Ie(d):"";if(f)switch(f){case me:return ct;case tn:return S;case rn:return P;case nn:return te;case on:return he}return i});function An(l,i){return i=i??c,!!i&&(typeof l=="number"||Yt.test(l))&&l>-1&&l%1==0&&l<i}function kn(l){var i=typeof l;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?l!=="__proto__":l===null}function En(l){return!!_t&&_t in l}function yt(l){var i=l&&l.constructor,d=typeof i=="function"&&i.prototype||ft;return l===d}function Lt(l){return jt.call(l)}function Ie(l){if(l!=null){try{return Rt.call(l)}catch{}try{return l+""}catch{}}return""}function It(l,i){return l===i||l!==l&&i!==i}var Fn=cr(function(){return arguments}())?cr:function(l){return et(l)&&ae.call(l,"callee")&&!or.call(l,"callee")},Qe=Array.isArray;function Mt(l){return l!=null&&ur(l.length)&&!Ue(l)}var vt=Ke||pr;function Ae(l,i){return dr(l,i)}function Ue(l){if(!$t(l))return!1;var i=Ye(l);return i==v||i==x||i==g||i==L}function ur(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=c}function $t(l){var i=typeof l;return l!=null&&(i=="object"||i=="function")}function et(l){return l!=null&&typeof l=="object"}var Ut=er?Yr(er):Cn;function Pn(l){return Mt(l)?xn(l):Tn(l)}function Dn(){return[]}function pr(){return!1}e.exports=Ae})(xr,xr.exports);var $c=xr.exports;const Uc=eo($c),it="other";function ze(e){return e.mapToName!==void 0}function qc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function Wc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}function zc(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>ze(n)&&!!n.mapToName))||[]}function Jc(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}const ei=(e,t)=>{var r,n,o;return(o=(n=(r=e==null?void 0:e.content)==null?void 0:r.read)==null?void 0:n.objects)==null?void 0:o[t]};function Hc(e){return ze(e)?e.mapToName:e.fieldName}const ti=(e,t)=>{var n,o,a;const r=[];return(a=(o=(n=t.content)==null?void 0:n.read)==null?void 0:o.objects)==null||a.forEach(c=>{r.push({name:c==null?void 0:c.objectName,completed:e?!!ei(e,c.objectName):!1})}),r},ri=e=>{var r;return{name:it,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function Kc(e,t){var a;const r=ti(e,t),o=!!((a=t==null?void 0:t.content)!=null&&a.write)?ri(e):void 0;return o&&r.push(o),r}function ni(e,t,r){const n=(e==null?void 0:e.filter(a=>!(t!=null&&t[a==null?void 0:a.mapToName])))||[],o=n.map(a=>a.mapToName);return r(G.MAPPING,o),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:o}}function to(e,t){return Uc(e,t)}const Gc=(e,t,r)=>{var v,x,S,O,j,T;if(!e)return null;const n=qc(e,t),o=n&&Wc(n),a=n&&Jc(n),c=n&&zc(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,g=((S=(x=(v=p==null?void 0:p.read)==null?void 0:v.objects)==null?void 0:x[t])==null?void 0:S.selectedFields)||{},m=((T=(j=(O=p==null?void 0:p.read)==null?void 0:O.objects)==null?void 0:j[t])==null?void 0:T.selectedFieldMappings)||{},b={...g},y={...m};return{allFields:u,requiredFields:o,optionalFields:a,requiredMapFields:c,selectedOptionalFields:g,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:b,requiredMapFields:y}}},Vc=(e,t)=>{var c,u;if(!e)return null;const r=(u=(c=t==null?void 0:t.content)==null?void 0:c.write)==null?void 0:u.objects,n=Object.keys(r||{}),o={};n.forEach(p=>{o[p]=!0});const a={...o};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:o,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:a}}};function oi(e,t,r){var a,c;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,o=(c=e==null?void 0:e.content)==null?void 0:c.write;return{read:Gc(n,t,r),write:Vc(o,r)}}const ii=(e,t,r,n)=>{const o=oi(e,r,t);n(r,o)},Xc=(e,t,r)=>{const n=Kc(t,e),o={};n.forEach(({name:a,completed:c})=>{c&&(o[a]=oi(e,a,t))}),r(o)},ai=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(Hc(a))),{...Array.from(n).reduce((a,c)=>({...a,[c]:!0}),{}),...r||{}}},si=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},r={};return t&&Object.keys(t).forEach(n=>{t[n]!==void 0?r[n]=t[n]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${n}`)}),r};function ci(e,t){return t[e]||void 0}function ro({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:o,apiKey:a,setInstallation:c,onInstallSuccess:u}){const p={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:o,config:e}};return H().installationApi.createInstallation(p,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}}).then(g=>{c(g),u==null||u(g.id,g.config)}).catch(g=>{console.error("ERROR: ",g)})}function jr(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const Yc=(e,t)=>{const r=e.content.read,n=r==null?void 0:r.objects;return n==null?void 0:n.find(o=>o.objectName===t)},Zc=(e,t,r,n)=>{const o=ai(e),a=si(e),c=Yc(r,t);if(!c)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const u={revisionId:r.id,createdBy:`consumer:${n}`,content:{provider:r.content.provider,read:{objects:{[t]:{objectName:t,schedule:c.schedule,destination:c.destination,selectedFields:o,selectedFieldMappings:a,backfill:c.backfill}}}}};return jr(r)&&(u.content.proxy={enabled:!0}),u},Qc=(e,t,r,n,o,a,c,u,p,g,m)=>{const b=Zc(p,a,u,n);return b?ro({createConfig:b,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:c,setInstallation:g,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},di=e=>{var a,c;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(c=e.write)==null?void 0:c.selectedNonConfigurableWriteFields,o=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;o.includes(p)&&(t[p]={objectName:p})}),t},ed=e=>{const t=e.content.write;return t==null?void 0:t.objects},td=(e,t,r)=>{if(!ed(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=di(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return jr(t)&&(a.content.proxy={enabled:!0}),a},rd=(e,t,r,n,o,a,c,u,p,g)=>{const m=td(u,c,n);return m?ro({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:a,setInstallation:p,onInstallSuccess:g}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};function nd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const li="uninstall-installation",od=I.forwardRef(({text:e="Uninstall"},t)=>{const r=w.useTab({ref:t}),n=w.useMultiStyleConfig("Tabs",r);return s.jsxs(w.Button,{__css:n.warningTab,...r,minHeight:15,children:[s.jsxs(w.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[nd(),s.jsx(w.Box,{textAlign:"left",children:s.jsx(w.Text,{color:"red.800",children:e})})]}),r.children]})}),ui=I.createContext({hydratedRevision:null,loading:!1}),Gt=()=>{const e=I.useContext(ui);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function id({projectId:e,children:t}){var P;const{selectedConnection:r}=xt(),{integrationId:n,integrationObj:o}=Ne(),[a,c]=I.useState(null),[u,p]=I.useState(!0),{isError:g,removeError:m,setError:b}=Je(),y=X(),v=r==null?void 0:r.id,x=(P=o==null?void 0:o.latestRevision)==null?void 0:P.id,S=(o==null?void 0:o.name)||n;I.useEffect(()=>{e&&n&&x&&v&&y&&H().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:x,connectionId:v},{headers:{"X-Api-Key":y??""}}).then(L=>{c(L),p(!1),m(G.HYDRATED_REVISION,S)}).catch(L=>{console.error(`Error loading integration ${S}`,L),p(!1),b(G.HYDRATED_REVISION,S)})},[e,n,x,v,y,m,b,S]);const O=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),T=`Error retrieving integration details for '${(o==null?void 0:o.name)||n||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return s.jsx(ui.Provider,{value:O,children:g(G.HYDRATED_REVISION,S)?s.jsx(Pe,{message:T}):t})}var pi=Symbol.for("immer-nothing"),mo=Symbol.for("immer-draftable"),se=Symbol.for("immer-state"),ad=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function oe(e,...t){if(process.env.NODE_ENV!=="production"){const r=ad[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var bt=Object.getPrototypeOf;function St(e){return!!e&&!!e[se]}function at(e){var t;return e?fi(e)||Array.isArray(e)||!!e[mo]||!!((t=e.constructor)!=null&&t[mo])||kr(e)||Er(e):!1}var sd=Object.prototype.constructor.toString();function fi(e){if(!e||typeof e!="object")return!1;const t=bt(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===sd}function Or(e,t){Ar(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function Ar(e){const t=e[se];return t?t.type_:Array.isArray(e)?1:kr(e)?2:Er(e)?3:0}function qn(e,t){return Ar(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function hi(e,t,r){const n=Ar(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function cd(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kr(e){return e instanceof Map}function Er(e){return e instanceof Set}function rt(e){return e.copy_||e.base_}function Wn(e,t){if(kr(e))return new Map(e);if(Er(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=fi(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[se];let o=Reflect.ownKeys(n);for(let a=0;a<o.length;a++){const c=o[a],u=n[c];u.writable===!1&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[c]={configurable:!0,writable:!0,enumerable:u.enumerable,value:e[c]})}return Object.create(bt(e),n)}else{const n=bt(e);if(n!==null&&r)return{...e};const o=Object.create(n);return Object.assign(o,e)}}function no(e,t=!1){return Fr(e)||St(e)||!at(e)||(Ar(e)>1&&(e.set=e.add=e.clear=e.delete=dd),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>no(n,!0))),e}function dd(){oe(2)}function Fr(e){return Object.isFrozen(e)}var ld={};function st(e){const t=ld[e];return t||oe(0,e),t}var Ht;function gi(){return Ht}function ud(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wo(e,t){t&&(st("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function zn(e){Jn(e),e.drafts_.forEach(pd),e.drafts_=null}function Jn(e){e===Ht&&(Ht=e.parent_)}function yo(e){return Ht=ud(Ht,e)}function pd(e){const t=e[se];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Io(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[se].modified_&&(zn(t),oe(4)),at(e)&&(e=Cr(t,e),t.parent_||Tr(t,e)),t.patches_&&st("Patches").generateReplacementPatches_(r[se].base_,e,t.patches_,t.inversePatches_)):e=Cr(t,r,[]),zn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==pi?e:void 0}function Cr(e,t,r){if(Fr(t))return t;const n=t[se];if(!n)return Or(t,(o,a)=>vo(e,n,t,o,a,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Tr(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const o=n.copy_;let a=o,c=!1;n.type_===3&&(a=new Set(o),o.clear(),c=!0),Or(a,(u,p)=>vo(e,n,o,u,p,r,c)),Tr(e,o,!1),r&&e.patches_&&st("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function vo(e,t,r,n,o,a,c){if(process.env.NODE_ENV!=="production"&&o===r&&oe(5),St(o)){const u=a&&t&&t.type_!==3&&!qn(t.assigned_,n)?a.concat(n):void 0,p=Cr(e,o,u);if(hi(r,n,p),St(p))e.canAutoFreeze_=!1;else return}else c&&r.add(o);if(at(o)&&!Fr(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Cr(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Tr(e,o)}}function Tr(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&no(t,r)}function fd(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:gi(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,a=oo;r&&(o=[n],a=Kt);const{revoke:c,proxy:u}=Proxy.revocable(o,a);return n.draft_=u,n.revoke_=c,u}var oo={get(e,t){if(t===se)return e;const r=rt(e);if(!qn(r,t))return hd(e,r,t);const n=r[t];return e.finalized_||!at(n)?n:n===Ln(e.base_,t)?(Mn(e),e.copy_[t]=Kn(n,e)):n},has(e,t){return t in rt(e)},ownKeys(e){return Reflect.ownKeys(rt(e))},set(e,t,r){const n=mi(rt(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const o=Ln(rt(e),t),a=o==null?void 0:o[se];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(cd(r,o)&&(r!==void 0||qn(e.base_,t)))return!0;Mn(e),Hn(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ln(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mn(e),Hn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=rt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return bt(e.base_)},setPrototypeOf(){oe(12)}},Kt={};Or(oo,(e,t)=>{Kt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Kt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&oe(13),Kt.set.call(this,e,t,void 0)};Kt.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&oe(14),oo.set.call(this,e[0],t,r,e[0])};function Ln(e,t){const r=e[se];return(r?rt(r):e)[t]}function hd(e,t,r){var o;const n=mi(t,r);return n?"value"in n?n.value:(o=n.get)==null?void 0:o.call(e.draft_):void 0}function mi(e,t){if(!(t in e))return;let r=bt(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=bt(r)}}function Hn(e){e.modified_||(e.modified_=!0,e.parent_&&Hn(e.parent_))}function Mn(e){e.copy_||(e.copy_=Wn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gd=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const a=r;r=t;const c=this;return function(p=a,...g){return c.produce(p,m=>r.call(this,m,...g))}}typeof r!="function"&&oe(6),n!==void 0&&typeof n!="function"&&oe(7);let o;if(at(t)){const a=yo(this),c=Kn(t,void 0);let u=!0;try{o=r(c),u=!1}finally{u?zn(a):Jn(a)}return wo(a,n),Io(o,a)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===pi&&(o=void 0),this.autoFreeze_&&no(o,!0),n){const a=[],c=[];st("Patches").generateReplacementPatches_(t,o,a,c),n(a,c)}return o}else oe(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,p=>t(p,...u));let n,o;return[this.produce(t,r,(c,u)=>{n=c,o=u}),n,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){at(e)||oe(8),St(e)&&(e=md(e));const t=yo(this),r=Kn(e,void 0);return r[se].isManual_=!0,Jn(t),r}finishDraft(e,t){const r=e&&e[se];(!r||!r.isManual_)&&oe(9);const{scope_:n}=r;return wo(n,t),Io(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));const n=st("Patches").applyPatches_;return St(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Kn(e,t){const r=kr(e)?st("MapSet").proxyMap_(e,t):Er(e)?st("MapSet").proxySet_(e,t):fd(e,t);return(t?t.scope_:gi()).drafts_.push(r),r}function md(e){return St(e)||oe(10,e),wi(e)}function wi(e){if(!at(e)||Fr(e))return e;const t=e[se];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Wn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Wn(e,!0);return Or(r,(n,o)=>{hi(r,n,wi(o))}),t&&(t.finalized_=!1),r}var ce=new gd,Wt=ce.produce;ce.produceWithPatches.bind(ce);ce.setAutoFreeze.bind(ce);ce.setUseStrictShallowCopy.bind(ce);ce.applyPatches.bind(ce);ce.createDraft.bind(ce);ce.finishDraft.bind(ce);const yi=I.createContext(void 0),wd={};function io(){const e=I.useContext(yi);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function yd({children:e}){const{installation:t}=Ne(),{hydratedRevision:r,loading:n}=Gt(),[o,a]=I.useState(wd),c=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&c&&!(Object.entries(o).length>0)&&Xc(r,c,a)},[r,n,c,o]);const u=I.useCallback((v,x)=>{a(S=>Wt(S,O=>{O[v]=Wt(O[v],x)}))},[a]),p=I.useCallback((v,x)=>{a(S=>Wt(S,O=>{O[v]=x}))},[a]),g=I.useCallback(()=>{a(Wt(v=>{const x=v.other.write;x&&(x.isWriteModified=!1)}))},[a]),m=I.useCallback(v=>{a(Wt(x=>{var O;const S=(O=x[v])==null?void 0:O.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),b=I.useCallback(v=>{v===it?g():m(v)},[m,g]),y=I.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:b}),[o,p,b,u]);return s.jsx(yi.Provider,{value:y,children:e})}const Id=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[s.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),s.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function vd(e,t){return t?I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},I.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Id:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:s.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const Ii=I.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},o)=>{const a=w.useTab({ref:o}),c=w.useMultiStyleConfig("Tabs",a);return s.jsxs(w.Button,{__css:c.tab,...a,variant:"outline",minHeight:15,children:[s.jsxs(w.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[vd(t,r),s.jsxs(w.Box,{textAlign:"left",children:[s.jsx(w.Text,{children:n||e}),r&&s.jsx(w.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function bd({pending:e,completed:t,displayName:r}){return s.jsxs(s.Fragment,{children:[s.jsx(w.Divider,{marginY:3}),s.jsx(Ii,{objectName:it,completed:t,pending:e,displayName:r},"other-write")]})}const vi=I.createContext(null);function bi(){const e=I.useContext(vi);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function Sd(e,t){return e!=null&&e[t]?e[t]:{name:li,completed:!1}}function xd({children:e}){var O,j,T;const{project:t}=V(),{installation:r,provider:n}=Ne(),{hydratedRevision:o}=Gt(),{objectConfigurationsState:a}=io(),[c,u]=I.useState(0),p=(t==null?void 0:t.appName)||"",g=r==null?void 0:r.config,m=o&&ti(g,o),b=m!==null,y=!!((O=o==null?void 0:o.content)!=null&&O.write),v=y?ri(g):void 0,x=[...m||[]];v&&y&&x.push(v);const S=Sd(x,c);return s.jsx(vi.Provider,{value:S==null?void 0:S.name,children:s.jsxs(w.Box,{p:8,maxWidth:"55rem",border:"1px solid #EFEFEF",borderRadius:6,boxShadow:"md",margin:"auto",bgColor:"whitesmoke",display:"flex",gap:"6",minHeight:"100%",color:"gray.800",fontSize:"md",children:[s.jsxs(w.Box,{width:"20rem",children:[s.jsxs(w.Text,{children:[de(n)," integration"]}),s.jsx(w.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),b&&s.jsxs(w.Tabs,{index:c,onChange:u,orientation:"horizontal",children:[m.map(P=>{var L,Z,te,J;return s.jsx(Ii,{objectName:P.name,completed:P.completed,pending:((Z=(L=a[P.name])==null?void 0:L.read)==null?void 0:Z.isOptionalFieldsModified)||((J=(te=a[P.name])==null?void 0:te.read)==null?void 0:J.isRequiredMapFieldsModified)},P.name)}),y&&v&&s.jsx(bd,{completed:v.completed,pending:(T=(j=a==null?void 0:a.other)==null?void 0:j.write)==null?void 0:T.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(w.Divider,{marginTop:10,marginBottom:3}),s.jsx(od,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]})})}const Ot=()=>{const{appName:e}=V(),{objectConfigurationsState:t,setConfigureState:r}=io(),{selectedObjectName:n}=bi(),o=ci(n||"",t);return{appName:e,configureState:o,setConfigureState:r,selectedObjectName:n}};function Od(e,t,r){var o;const n=((o=e==null?void 0:e.read)==null?void 0:o.selectedFieldMappings)||{};if(n[t]=r,e!=null&&e.read){const a=e.read.savedConfig.requiredMapFields,u=!to(a,n);e.read.isRequiredMapFieldsModified=u}}function Si(e,t,r,n){t(e,o=>Od(o,r,n))}function Cd({field:e,onSelectChange:t,allFields:r}){var b;const{configureState:n,selectedObjectName:o,setConfigureState:a}=Ot(),[c,u]=I.useState(!0),p=(b=n==null?void 0:n.read)==null?void 0:b.selectedFieldMappings,g=p==null?void 0:p[e.mapToName];I.useEffect(()=>{e._default&&!g&&o&&n&&Si(o,a,e.mapToName,e._default),u(!1)},[e,a,o,g,n]);const m=I.useMemo(()=>r==null?void 0:r.map(y=>s.jsx("option",{value:y.fieldName,children:y.displayName},y.fieldName)),[r]);return s.jsxs(w.Stack,{children:[s.jsx(w.Text,{fontWeight:"500",children:e.mapToDisplayName}),s.jsx(w.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),s.jsx(w.Select,{name:e.mapToName,variant:"flushed",value:g||void 0,onChange:t,placeholder:g?void 0:"Please select one",disabled:c,children:m})]},e.mapToName)}function Pr({string:e}){return s.jsxs(w.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[s.jsx(w.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),s.jsx(w.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:s.jsx(w.Divider,{marginLeft:2})})]})}function Td(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ot(),{isError:n,removeError:o}=Je(),a=u=>{const{value:p,name:g}=u.target;p&&(e&&Si(e,r,g,p),n(G.MAPPING,g)&&o(G.MAPPING,g))},c=I.useMemo(()=>{var u,p;return((p=(u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)==null?void 0:p.filter(ze))||[]},[t]);return c.length?s.jsxs(w.Box,{children:[s.jsx(Pr,{string:"Map the following fields (required)"}),s.jsx(w.Stack,{children:c.map(u=>{var p;return s.jsxs(w.FormControl,{isInvalid:n(G.MAPPING,u.mapToName),children:[s.jsx(Cd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),s.jsx(w.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function Nd(e,t,r){var o,a;const n=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(n[t]=r,r||delete n[t],(a=e.read)!=null&&a.savedConfig.optionalFields){const c=e.read.savedConfig.optionalFields,p=!to(c,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function bo(e,t,r,n){t(e,o=>Nd(o,r,n))}function Rd(){var b,y;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ot(),o=(b=t==null?void 0:t.read)==null?void 0:b.selectedOptionalFields,a=v=>{const{name:x,checked:S}=v.target;n&&t&&bo(n,r,x,S)},c=(y=t==null?void 0:t.read)==null?void 0:y.optionalFields,u=v=>{const{checked:x}=v.target;n&&c&&c.forEach(S=>{ze(S)||bo(n,r,S.fieldName,x)})},p=!!(c&&c.length>0),g=Object.keys(o||{}).length===(c==null?void 0:c.length),m=!g&&Object.keys(o||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${e} reads the following optional fields`}),s.jsxs(w.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((c==null?void 0:c.length)||0)>=2&&s.jsx(w.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(w.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),c.map(v=>ze(v)?null:s.jsx(w.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:s.jsx(w.Checkbox,{name:v.fieldName,id:v.fieldName,isChecked:!!(o!=null&&o[v==null?void 0:v.fieldName]),onChange:a,children:v.displayName})},v.fieldName))]})]})}function _d(){var n,o,a;const{configureState:e,selectedObjectName:t}=Ot(),{appName:r}=V();return s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${r} reads the following ${t} fields`}),s.jsx(w.Box,{marginBottom:"20px",display:"flex",gap:1,children:(o=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&o.length?(a=e.read)==null?void 0:a.requiredFields.map(c=>ze(c)?null:s.jsx(w.Tag,{children:c.displayName},c.fieldName)):"There are no required fields."})]})}function jd(){return s.jsxs(s.Fragment,{children:[s.jsx(_d,{}),s.jsx(Td,{}),s.jsx(Rd,{})]})}function Ad(e,t,r){var n,o,a;if(((n=e==null?void 0:e.write)==null?void 0:n.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const c=e.write.selectedNonConfigurableWriteFields;if(c[t]=r,r||delete c[t],(a=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,g=!to(u,c);e.write.isWriteModified=g}}}function So(e,t,r,n){t(e,o=>{Ad(o,r,n)})}function kd(){var b,y,v,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ot(),o=(b=r==null?void 0:r.write)==null?void 0:b.selectedNonConfigurableWriteFields,a=(y=r==null?void 0:r.write)==null?void 0:y.writeObjects,c=S=>{const{name:O,checked:j}=S.target;t&&r&&So(t,n,O,j)},u=S=>{var j,T;const{checked:O}=S.target;t&&r&&((T=(j=r==null?void 0:r.write)==null?void 0:j.writeObjects)==null||T.forEach(P=>{So(t,n,P.objectName,O)}))},p=!!a,g=Object.keys(o||{}).length===((x=(v=r==null?void 0:r.write)==null?void 0:v.writeObjects)==null?void 0:x.length),m=!g&&Object.keys(o||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`Allow ${e} to write to these object`}),s.jsxs(w.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((a==null?void 0:a.length)||0)>=2&&s.jsx(w.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(w.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),a.map(S=>s.jsx(w.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:s.jsx(w.Checkbox,{name:S.objectName,id:S.objectName,onChange:c,isChecked:!!(o!=null&&o[S.objectName]),children:S.displayName})},S.objectName))]})]})}function Ed(){const e=X(),{projectId:t,appName:r}=V(),{integrationId:n,installation:o,resetInstallations:a}=Ne(),[c,u]=I.useState(!1),p=!t||!n||!(o!=null&&o.id)||c,g=async()=>{if(!p){u(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:o.id});try{await H().installationApi.deleteInstallation({projectIdOrName:t,integrationId:n,installationId:o.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),a(),console.warn("successfully uninstalled installation: ",o.id)}catch(y){console.error("error uninstalling installation",y)}finally{u(!1)}}},m=c?"Uninstalling...":"Yes, uninstall",b=o!=null&&o.id?`Once you uninstall this integration, all your configuration will be lost, and "${r}" may stop working.`:"You've successfully uninstalled the integration.";return s.jsxs(w.Stack,{children:[s.jsx(w.Text,{paddingBottom:3,children:b}),(o==null?void 0:o.id)&&s.jsx(w.Button,{onClick:g,variant:"warning",isDisabled:p,children:m})]})}function xi({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var P,L,Z;const{installation:o}=Ne(),{hydratedRevision:a,loading:c}=Gt(),{configureState:u,selectedObjectName:p}=Ot(),g=o==null?void 0:o.config,m=g&&p&&!!ei(g,p)||!1,b=((P=u==null?void 0:u.read)==null?void 0:P.isOptionalFieldsModified)||((L=u==null?void 0:u.read)==null?void 0:L.isRequiredMapFieldsModified),y=(Z=u==null?void 0:u.write)==null?void 0:Z.isWriteModified,O=c||r||!u||!p||!(b||y||n||p!==it&&!m),j=p===it,T=p===li;return r?s.jsx(Te,{}):s.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[s.jsxs(w.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[s.jsx(w.Button,{backgroundColor:"gray.800",_hover:{backgroundColor:"gray.600"},type:"submit",isDisabled:O,children:n?"Install":"Save"}),s.jsx(w.Button,{backgroundColor:"gray.200",color:"blackAlpha.700",_hover:{backgroundColor:"gray.300"},isDisabled:O,onClick:t,children:"Reset"})]}),s.jsxs(w.Box,{p:8,width:"100%",border:"1px solid #EFEFEF",borderRadius:8,boxShadow:"md",textAlign:["left"],margin:"auto",bgColor:"white",maxHeight:"100%",overflowY:"scroll",minHeight:300,children:[c&&s.jsx(Te,{}),a&&!T&&!j&&s.jsx(jd,{}),a&&!T&&j&&s.jsx(kd,{}),!c&&T&&s.jsx(Ed,{})]})]})}const Oi=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:o,onUpdateSuccess:a}=Ne(),{hydratedRevision:c,loading:u}=Gt(),{selectedObjectName:p}=bi(),{selectedConnection:g}=xt(),m=X(),{projectId:b}=V(),{resetBoundary:y,setErrors:v}=Je(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O}=io(),j=ci(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:c,loading:u,selectedObjectName:p,selectedConnection:g,apiKey:m,projectId:b,resetBoundary:y,setErrors:v,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O,configureState:j,onInstallSuccess:o,onUpdateSuccess:a}},Fd=void 0;function Pd(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:o,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:p,projectId:g,resetBoundary:m,setErrors:b,resetConfigureState:y,objectConfigurationsState:v,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:O}=Oi(),[j,T]=I.useState(!1),P=c===it,L=I.useCallback(()=>{m(G.MAPPING),o!=null&&o.content&&!a&&c&&ii(o,Fd,c,y)},[m,o,a,c,y]);I.useEffect(()=>{!S&&(o!=null&&o.content)&&!a&&L()},[S,v,o,a,L]);const Z=()=>{const{requiredMapFields:ie,selectedFieldMappings:be}=(S==null?void 0:S.read)||{},{errorList:he}=ni(ie,be,b);he.length>0||(c&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(T(!0),Qc(g,e,t,r,u.id,c,p,o,S,n,O).finally(()=>{T(!1),x(c)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},te=()=>{c&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(T(!0),rd(g,e,t,r,u.id,p,o,S,n,O).finally(()=>{T(!1),x(c)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},J=ie=>{ie.preventDefault(),P?te():Z()};return s.jsx(xi,{isCreateMode:!0,isLoading:j,onSave:J,onReset:L})}function Dd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:o,selectedObjectName:a,setInstallation:c,onUpdateSuccess:u}){const p={projectIdOrName:t,installationId:n,integrationId:r,installationUpdate:{updateMask:[`config.content.read.objects.${a}`],installation:{config:e}}};return H().installationApi.updateInstallation(p,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(g=>{c(g),u==null||u(g.id,g.config)}).catch(g=>{console.error("ERROR: ",g)})}const Bd=(e,t,r,n,o)=>{const a=ai(e),c=si(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:a,selectedFieldMappings:c}}}}};return jr(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Ld=(e,t,r,n,o,a,c,u,p,g)=>{const m=Bd(a,n||"",u,u.schedule,p);return m?Dd({updateConfig:m,projectId:e,integrationId:t,installationId:r,apiKey:o,selectedObjectName:n,setInstallation:c,onUpdateSuccess:g}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Md=(e,t)=>{const n={content:{write:{objects:di(e)}}};return jr(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},$d=(e,t,r,n,o,a,c,u)=>{const p=Md(o,a);if(!p)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const g={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:p}}};return H().installationApi.updateInstallation(g,{headers:{"X-Api-Key":n,"Content-Type":"application/json"}}).then(m=>{c(m),u==null||u(m.id,m.config)}).catch(m=>{console.error("ERROR: ",m)})};function Ud({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:o,selectedObjectName:a,apiKey:c,projectId:u,resetBoundary:p,setErrors:g,resetConfigureState:m,resetPendingConfigurationState:b,configureState:y,onUpdateSuccess:v}=Oi(),[x,S]=I.useState(!1),O=a===it,{config:j}=e,T=I.useCallback(()=>{p(G.MAPPING),n!=null&&n.content&&!o&&a&&ii(n,j,a,m)},[p,n,o,a,j,m]);I.useEffect(()=>{y||T()},[y,T]),I.useEffect(()=>{e&&T()},[e,T]);const P=I.useMemo(()=>{var ie,be,he;return(he=(be=(ie=n==null?void 0:n.content)==null?void 0:ie.read)==null?void 0:be.objects)==null?void 0:he.find(Re=>(Re==null?void 0:Re.objectName)===a)},[n,a]),L=()=>{const{requiredMapFields:J,selectedFieldMappings:ie}=(y==null?void 0:y.read)||{},{errorList:be}=ni(J,ie,g);be.length>0||(n&&e&&a&&c&&u&&P?(S(!0),Ld(u,t.id,e.id,a,c,y,r,P,n,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},Z=()=>{e&&a&&c&&u&&n?(S(!0),$d(u,t.id,e.id,c,y,n,r,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},te=J=>{J.preventDefault(),O?Z():L()};return s.jsx(xi,{onSave:te,onReset:T,isLoading:x})}function qd(){const{integrationObj:e,installation:t}=Ne();return e?t&&e?s.jsx(Ud,{installation:t,integrationObj:e}):s.jsx(Pd,{}):s.jsx(Pe,{message:"We can't load the integration"})}const Wd=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function zd({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:o,apiKey:a,hydratedRevision:c,setInstallation:u,onInstallSuccess:p}){const g=Wd(c,n);return g?ro({createConfig:g,projectId:e,integrationId:t,groupRef:r,connectionId:o,apiKey:a,setInstallation:u,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function Jd(){return s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),s.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ci({text:e}){return s.jsx(w.Container,{children:s.jsxs(w.Box,{p:8,maxWidth:"600px",minHeight:"290px",borderWidth:1,borderRadius:8,boxShadow:"lg",margin:"auto",marginTop:"40px",bgColor:"white",paddingTop:"100px",color:"gray.800",fontSize:"md",children:[s.jsx(w.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:s.jsx(w.Box,{margin:"auto",children:s.jsx(Jd,{})})}),s.jsx(w.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}function Hd({provider:e}){const t=`You have successfully installed your ${de(e)} integration.`;return s.jsx(Ci,{text:t})}const Kd=e=>{const{read:t,write:r,proxy:n}=(e==null?void 0:e.content)??{};return!t&&!r&&(n==null?void 0:n.enabled)||!1};function Gd({children:e}){var O;const{projectId:t}=V(),r=X(),{hydratedRevision:n,loading:o}=Gt(),{integrationObj:a,installation:c,groupRef:u,consumerRef:p,setInstallation:g}=Ne(),{selectedConnection:m}=xt(),[b,y]=I.useState(!1),v=o||b,x=(O=n==null?void 0:n.content)==null?void 0:O.provider,S=Kd(n);return I.useEffect(()=>{!v&&n&&S&&!c&&m&&r&&(a!=null&&a.id)&&(y(!0),zd({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:m==null?void 0:m.id,hydratedRevision:n,setInstallation:g}).then(()=>{y(!1)}).catch(j=>{y(!1),console.error("Error when creating proxy installation:",j)}))},[n,S,c,m,r,t,a==null?void 0:a.id,u,p,g,v]),a?v?s.jsx(Te,{}):S&&x&&c?s.jsx(Hd,{provider:x}):s.jsx("div",{children:e}):s.jsx(Pe,{message:"We can't load the integration"})}function Vd({children:e}){return s.jsx(w.Container,{children:s.jsx(w.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function Xd({error:e}){return e?s.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[s.jsx(w.AlertIcon,{}),s.jsx(w.AlertDescription,{children:e})]}):null}function Yd({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),c=()=>a(!o),[u,p]=I.useState(""),g=y=>p(y.currentTarget.value),m=u.length>0,b=n||!m;return s.jsx(Vd,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(Xd,{error:r}),s.jsx("br",{}),s.jsx(w.Stack,{spacing:4,children:s.jsxs(w.InputGroup,{size:"md",children:[s.jsx(w.Input,{onChange:g,pr:"4.5rem",type:o?"text":"password",placeholder:"API Key"}),s.jsx(w.InputRightElement,{width:"4.5rem",children:s.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:c,children:o?"Hide":"Show"})})]})}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:b,width:"100%",type:"submit",onClick:()=>{t(u)},children:"Next"})]})})}function Zd({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:c,setSelectedConnection:u}){const p=V(),[g,m]=I.useState(!1),[b,y]=I.useState(null),v=X();I.useEffect(()=>{if(e&&H&&g&&b!=null){const S={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,apiKey:b};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:S},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info: ",O)})}},[v,e,g,r,t,o,n,p,u,b]);const x=S=>{y(S),m(!0)};return c===null?s.jsx(Yd,{provider:e,handleSubmit:x,error:null}):a}function Qd({children:e}){return s.jsx(w.Container,{children:s.jsx(w.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function el({error:e}){return e?s.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[s.jsx(w.AlertIcon,{}),s.jsx(w.AlertDescription,{children:e})]}):null}function tl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),c=()=>a(!o),[u,p]=I.useState(""),[g,m]=I.useState(""),b=S=>p(S.currentTarget.value),y=S=>m(S.currentTarget.value),v=u.length>0,x=n||!v;return s.jsx(Qd,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(el,{error:r}),s.jsx("br",{}),s.jsxs(w.Stack,{spacing:4,children:[s.jsx(w.Input,{placeholder:"Username",onChange:b}),s.jsxs(w.InputGroup,{size:"md",children:[s.jsx(w.Input,{onChange:y,pr:"4.5rem",type:o?"text":"password",placeholder:"Password"}),s.jsx(w.InputRightElement,{width:"4.5rem",children:s.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:c,children:o?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:x,width:"100%",type:"submit",onClick:()=>{t(u,g)},children:"Next"})]})})}function rl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:c,setSelectedConnection:u}){const p=V(),[g,m]=I.useState(!1),[b,y]=I.useState(null),v=X();I.useEffect(()=>{if(e&&H&&g&&b!=null){const S={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,basicAuth:{username:b.user,password:b.pass}};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:S},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info: ",O)})}},[v,e,g,r,t,o,n,p,b,u]);const x=(S,O)=>{y({user:S,pass:O}),m(!0)};return c===null?s.jsx(tl,{provider:e,handleSubmit:x,error:null}):a}function nl(e){const{selectedConnection:t}=xt();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function ol({onSuccess:e}){nl(e)}function il({children:e}){return s.jsx(w.Container,{children:s.jsx(w.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function al({error:e}){return e?s.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[s.jsx(w.AlertIcon,{}),s.jsx(w.AlertDescription,{children:e})]}):null}function sl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return s.jsx(il,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(al,{error:r}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function cl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,selectedConnection:c,setSelectedConnection:u}){const p=V(),g=X(),[m,b]=I.useState(!1);I.useEffect(()=>{if(e&&H&&m){const v={projectId:p.projectId,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e};H().connectionApi.generateConnection({projectIdOrName:p.projectId,generateConnectionParams:v},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{u(x)}).catch(x=>{console.error("Error loading provider info: ",x)})}},[g,e,m,r,t,o,n,u,p]);const y=()=>{b(!0)};return c===null?s.jsx(sl,{provider:e,handleSubmit:y,error:null}):a}function Vt({children:e}){return s.jsx(w.Container,{children:s.jsx(w.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function Xt({error:e}){return e?s.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[s.jsx(w.AlertIcon,{}),s.jsx(w.AlertDescription,{children:e})]}):null}function dl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),[c,u]=I.useState(""),[p,g]=I.useState(""),m=()=>a(!o),b=O=>u(O.currentTarget.value),y=O=>g(O.currentTarget.value),v=c.length>0,x=p.length>0,S=n||!v||!x;return s.jsx(Vt,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(Xt,{error:r}),s.jsx("br",{}),s.jsxs(w.Stack,{spacing:4,children:[s.jsx(w.Input,{placeholder:"Client ID",onChange:y}),s.jsxs(w.InputGroup,{size:"md",children:[s.jsx(w.Input,{onChange:b,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),s.jsx(w.InputRightElement,{width:"4.5rem",children:s.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:m,children:o?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:S,width:"100%",type:"submit",onClick:()=>{t({clientId:p,clientSecret:c})},children:"Next"})]})})}function ll({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,selectedConnection:a,setSelectedConnection:c}){const{projectId:u}=V(),p=X(),[g,m]=I.useState(null),b=async y=>{m(null);const v={projectId:u,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:y.clientId,clientSecret:y.clientSecret}};H().connectionApi.generateConnection({projectIdOrName:u,generateConnectionParams:v},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?s.jsx(dl,{provider:e,handleSubmit:b,error:g}):s.jsx(Te,{})}const Ti=async(e,t,r,n,o,a,c,u)=>{var g;const p=await H().providerApi.getProvider({provider:o},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${o} not found`);if(p.authType==="oauth2"&&((g=p.oauth2Opts)==null?void 0:g.grantType)==="authorizationCode"){const b=(await H().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(x=>x.provider===o);if(!b)throw new Error(`You must first set up a ${de(o)} Provider App using the Ampersand Console.`);const y={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:c,providerAppId:b.id,provider:o}};return await H().oAuthApi.oauthConnect(y)}throw new Error(`Provider ${o} does not support an OAuth2 web flow.`)},xo=600,Oo=600,ul="AUTHORIZATION_SUCCEEDED",pl="AUTHORIZATION_FAILED";function fl(e,t,r){return I.useCallback(async n=>{const o=await H().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(o)},[e,t,r])}function hl(e,t,r,n){return I.useCallback(()=>{if(!n)return;const o=window.screenX+(window.outerWidth-xo)/2,a=window.screenY+(window.outerHeight-Oo)/2.5,c=`width=${xo},height=${Oo},left=${o},top=${a}`,u=window.open(n,e,c);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function gl(e){return I.useCallback(t=>{var r;if(t.origin===jc){if(t.data.eventType===ul){const n=(r=t.data.data)==null?void 0:r.connection;n?e(n):console.error("Connection ID not found in event data: ",{event:t})}t.data.eventType===pl&&console.error("OAuth failed: ",{event:t})}},[e])}function Ni({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onClose:n}){const o=X(),{projectId:a}=V(),[c,u]=I.useState(null),[p,g]=I.useState(null),{setSelectedConnection:m}=xt(),b=gl(u),y=hl(r,g,b,t),v=fl(a,o,m);I.useEffect(()=>{t&&!p&&y()},[t,p,y,b,r]),I.useEffect(()=>{c&&v(c).then(()=>{p==null||p.close()}).catch(S=>{console.error("Error refreshing connection: ",S),n(S.message??"Unexpected error: not able to refresh connection")})},[c,o,m,v,p,n]);const x=p&&setInterval(()=>{(p!=null&&p.closed||!p)&&x&&(clearInterval(x),window.removeEventListener("message",b),g(null),c?c&&n&&n(null):(console.error("OAuth failed. Please try again."),n&&n("OAuth failed. Please try again.")))},500);return s.jsx("div",{children:e})}function ml({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return s.jsx(Vt,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(Xt,{error:r}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function wl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o}){const{projectId:a}=V(),c=X(),[u,p]=I.useState(null),[g,m]=I.useState(null),b=async()=>{m(null);try{const v=await Ti(a,t,n,c,e,void 0,r,o);p(v)}catch(v){console.error("Could not fetch OAuth popup URL",{err:v}),m(v.message??"Unexpected error")}},y=I.useCallback(v=>{m(v),p(null)},[]);return s.jsx(Ni,{windowTitle:`Connect to ${de(e)}`,oauthUrl:u,onClose:y,children:s.jsx(ml,{provider:e,handleSubmit:b,error:g})})}function yl({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),[c,u]=I.useState(""),[p,g]=I.useState(""),[m,b]=I.useState(""),y=()=>a(!o),v=L=>u(L.currentTarget.value),x=L=>g(L.currentTarget.value),S=L=>b(L.currentTarget.value),O=c.length>0,j=p.length>0,T=m.length>0,P=n||!O||!j||!T;return s.jsx(Vt,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),s.jsx(Xt,{error:r}),s.jsx("br",{}),s.jsxs(w.Stack,{spacing:4,children:[s.jsx(w.Input,{placeholder:"MyWorkspace",onChange:S}),s.jsx(w.Input,{placeholder:"Client ID",onChange:x}),s.jsxs(w.InputGroup,{size:"md",children:[s.jsx(w.Input,{onChange:v,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),s.jsx(w.InputRightElement,{width:"4.5rem",children:s.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:y,children:o?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:P,width:"100%",type:"submit",onClick:()=>{t({workspace:m,clientId:p,clientSecret:c})},children:"Next"})]})})}function Il({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,selectedConnection:a,setSelectedConnection:c}){const{projectId:u}=V(),p=X(),[g,m]=I.useState(null),b=async y=>{m(null);const v={projectId:u,groupName:o,groupRef:n,consumerName:r,consumerRef:t,provider:e,providerWorkspaceRef:y.workspace,oauth2ClientCredentials:{clientId:y.clientId,clientSecret:y.clientSecret}};H().connectionApi.generateConnection({projectIdOrName:u,generateConnectionParams:v},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?s.jsx(yl,{provider:e,handleSubmit:b,error:g}):s.jsx(Te,{})}function vl(){const e=I.useContext(Mi.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var Ri=I.createContext({});Ri.displayName="ColorModeContext";function _i(){const e=I.useContext(Ri);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function bl(){const e=_i(),t=vl();return{...e,theme:t}}var Sl=(...e)=>e.filter(Boolean).join(" ");function ot(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function nt(e,...t){return xl(e)?e(...t):e}var xl=e=>typeof e=="function",Nr={exports:{}};Nr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",o=800,a=16,c=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",b="[object Date]",y="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",j="[object Null]",T="[object Object]",P="[object Proxy]",L="[object RegExp]",Z="[object Set]",te="[object String]",J="[object Undefined]",ie="[object WeakMap]",be="[object ArrayBuffer]",he="[object DataView]",Re="[object Float32Array]",ct="[object Float64Array]",Br="[object Int8Array]",Lr="[object Int16Array]",Mr="[object Int32Array]",$r="[object Uint8Array]",Ur="[object Uint8ClampedArray]",qr="[object Uint16Array]",Wr="[object Uint32Array]",zr=/[\\^$.*+?()[\]{}|]/g,Jr=/^\[object .+?Constructor\]$/,Hr=/^(?:0|[1-9]\d*)$/,$={};$[Re]=$[ct]=$[Br]=$[Lr]=$[Mr]=$[$r]=$[Ur]=$[qr]=$[Wr]=!0,$[u]=$[p]=$[be]=$[m]=$[he]=$[b]=$[y]=$[v]=$[S]=$[O]=$[T]=$[L]=$[Z]=$[te]=$[ie]=!1;var Yt=typeof We=="object"&&We&&We.Object===Object&&We,U=typeof self=="object"&&self&&self.Object===Object&&self,Be=Yt||U||Function("return this")(),Zt=t&&!t.nodeType&&t,re=Zt&&!0&&e&&!e.nodeType&&e,Ct=re&&re.exports===Zt,dt=Ct&&Yt.process,Tt=function(){try{var i=re&&re.require&&re.require("util").types;return i||dt&&dt.binding&&dt.binding("util")}catch{}}(),lt=Tt&&Tt.isTypedArray;function Qt(i,d,f){switch(f.length){case 0:return i.call(d);case 1:return i.call(d,f[0]);case 2:return i.call(d,f[0],f[1]);case 3:return i.call(d,f[0],f[1],f[2])}return i.apply(d,f)}function er(i,d){for(var f=-1,C=Array(i);++f<i;)C[f]=d(f);return C}function Kr(i){return function(d){return i(d)}}function Gr(i,d){return i==null?void 0:i[d]}function Vr(i,d){return function(f){return i(d(f))}}var Xr=Array.prototype,Yr=Function.prototype,ut=Object.prototype,Nt=Be["__core-js_shared__"],pt=Yr.toString,Se=ut.hasOwnProperty,tr=function(){var i=/[^.]+$/.exec(Nt&&Nt.keys&&Nt.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),rr=ut.toString,Zr=pt.call(Object),ft=RegExp("^"+pt.call(Se).replace(zr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Le=Ct?Be.Buffer:void 0,Rt=Be.Symbol,ae=Be.Uint8Array;Le&&Le.allocUnsafe;var _t=Vr(Object.getPrototypeOf,Object),jt=Object.create,Qr=ut.propertyIsEnumerable,nr=Xr.splice,le=Rt?Rt.toStringTag:void 0,He=function(){try{var i=Dt(Object,"defineProperty");return i({},"",{}),i}catch{}}(),or=Le?Le.isBuffer:void 0,ir=Math.max,_e=Date.now,At=Dt(Be,"Map"),Ke=Dt(Object,"create"),en=function(){function i(){}return function(d){if(!Ae(d))return{};if(jt)return jt(d);i.prototype=d;var f=new i;return i.prototype=void 0,f}}();function ge(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function Ge(){this.__data__=Ke?Ke(null):{},this.size=0}function kt(i){var d=this.has(i)&&delete this.__data__[i];return this.size-=d?1:0,d}function Et(i){var d=this.__data__;if(Ke){var f=d[i];return f===n?void 0:f}return Se.call(d,i)?d[i]:void 0}function Ft(i){var d=this.__data__;return Ke?d[i]!==void 0:Se.call(d,i)}function Ve(i,d){var f=this.__data__;return this.size+=this.has(i)?0:1,f[i]=Ke&&d===void 0?n:d,this}ge.prototype.clear=Ge,ge.prototype.delete=kt,ge.prototype.get=Et,ge.prototype.has=Ft,ge.prototype.set=Ve;function me(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function tn(){this.__data__=[],this.size=0}function rn(i){var d=this.__data__,f=ht(d,i);if(f<0)return!1;var C=d.length-1;return f==C?d.pop():nr.call(d,f,1),--this.size,!0}function nn(i){var d=this.__data__,f=ht(d,i);return f<0?void 0:d[f][1]}function on(i){return ht(this.__data__,i)>-1}function ar(i,d){var f=this.__data__,C=ht(f,i);return C<0?(++this.size,f.push([i,d])):f[C][1]=d,this}me.prototype.clear=tn,me.prototype.delete=rn,me.prototype.get=nn,me.prototype.has=on,me.prototype.set=ar;function xe(i){var d=-1,f=i==null?0:i.length;for(this.clear();++d<f;){var C=i[d];this.set(C[0],C[1])}}function je(){this.size=0,this.__data__={hash:new ge,map:new(At||me),string:new ge}}function an(i){var d=wt(this,i).delete(i);return this.size-=d?1:0,d}function sn(i){return wt(this,i).get(i)}function cn(i){return wt(this,i).has(i)}function dn(i,d){var f=wt(this,i),C=f.size;return f.set(i,d),this.size+=f.size==C?0:1,this}xe.prototype.clear=je,xe.prototype.delete=an,xe.prototype.get=sn,xe.prototype.has=cn,xe.prototype.set=dn;function Me(i){var d=this.__data__=new me(i);this.size=d.size}function we(){this.__data__=new me,this.size=0}function ln(i){var d=this.__data__,f=d.delete(i);return this.size=d.size,f}function un(i){return this.__data__.get(i)}function pn(i){return this.__data__.has(i)}function fn(i,d){var f=this.__data__;if(f instanceof me){var C=f.__data__;if(!At||C.length<r-1)return C.push([i,d]),this.size=++f.size,this;f=this.__data__=new xe(C)}return f.set(i,d),this.size=f.size,this}Me.prototype.clear=we,Me.prototype.delete=ln,Me.prototype.get=un,Me.prototype.has=pn,Me.prototype.set=fn;function hn(i,d){var f=Ie(i),C=!f&&Lt(i),R=!f&&!C&&Qe(i),A=!f&&!C&&!R&&$t(i),F=f||C||R||A,k=F?er(i.length,String):[],E=k.length;for(var q in i)F&&(q=="length"||R&&(q=="offset"||q=="parent")||A&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||Bt(q,E))||k.push(q);return k}function ye(i,d,f){(f!==void 0&&!yt(i[d],f)||f===void 0&&!(d in i))&&Pt(i,d,f)}function gn(i,d,f){var C=i[d];(!(Se.call(i,d)&&yt(C,f))||f===void 0&&!(d in i))&&Pt(i,d,f)}function ht(i,d){for(var f=i.length;f--;)if(yt(i[f][0],d))return f;return-1}function Pt(i,d,f){d=="__proto__"&&He?He(i,d,{configurable:!0,enumerable:!0,value:f,writable:!0}):i[d]=f}var mn=dr();function gt(i){return i==null?i===void 0?J:j:le&&le in Object(i)?Cn(i):_n(i)}function Xe(i){return Ue(i)&&gt(i)==u}function wn(i){if(!Ae(i)||lr(i))return!1;var d=Mt(i)?ft:Jr;return d.test(En(i))}function yn(i){return Ue(i)&&vt(i.length)&&!!$[gt(i)]}function Oe(i){if(!Ae(i))return $e(i);var d=Ze(i),f=[];for(var C in i)C=="constructor"&&(d||!Se.call(i,C))||f.push(C);return f}function sr(i,d,f,C,R){i!==d&&mn(d,function(A,F){if(R||(R=new Me),Ae(A))In(i,d,F,f,sr,C,R);else{var k=C?C(ue(i,F),A,F+"",i,d,R):void 0;k===void 0&&(k=A),ye(i,F,k)}},Ut)}function In(i,d,f,C,R,A,F){var k=ue(i,f),E=ue(d,f),q=F.get(E);if(q){ye(i,f,q);return}var W=A?A(k,E,f+"",i,d,F):void 0,K=W===void 0;if(K){var Q=Ie(E),ee=!Q&&Qe(E),ve=!Q&&!ee&&$t(E);W=E,Q||ee||ve?Ie(k)?W=k:Fn(k)?W=On(k):ee?(K=!1,W=Sn(E)):ve?(K=!1,W=mt(E)):W=[]:ur(E)||Lt(E)?(W=k,Lt(k)?W=et(k):(!Ae(k)||Mt(k))&&(W=Tn(E))):K=!1}K&&(F.set(E,W),R(W,E,C,A,F),F.delete(E)),ye(i,f,W)}function vn(i,d){return An(jn(i,d,pr),i+"")}var bn=He?function(i,d){return He(i,"toString",{configurable:!0,enumerable:!1,value:Dn(d),writable:!0})}:pr;function Sn(i,d){return i.slice()}function xn(i){var d=new i.constructor(i.byteLength);return new ae(d).set(new ae(i)),d}function mt(i,d){var f=xn(i.buffer);return new i.constructor(f,i.byteOffset,i.length)}function On(i,d){var f=-1,C=i.length;for(d||(d=Array(C));++f<C;)d[f]=i[f];return d}function Ye(i,d,f,C){var R=!f;f||(f={});for(var A=-1,F=d.length;++A<F;){var k=d[A],E=void 0;E===void 0&&(E=i[k]),R?Pt(f,k,E):gn(f,k,E)}return f}function cr(i){return vn(function(d,f){var C=-1,R=f.length,A=R>1?f[R-1]:void 0,F=R>2?f[2]:void 0;for(A=i.length>3&&typeof A=="function"?(R--,A):void 0,F&&Nn(f[0],f[1],F)&&(A=R<3?void 0:A,R=1),d=Object(d);++C<R;){var k=f[C];k&&i(d,k,C,A)}return d})}function dr(i){return function(d,f,C){for(var R=-1,A=Object(d),F=C(d),k=F.length;k--;){var E=F[++R];if(f(A[E],E,A)===!1)break}return d}}function wt(i,d){var f=i.__data__;return Rn(d)?f[typeof d=="string"?"string":"hash"]:f.map}function Dt(i,d){var f=Gr(i,d);return wn(f)?f:void 0}function Cn(i){var d=Se.call(i,le),f=i[le];try{i[le]=void 0;var C=!0}catch{}var R=rr.call(i);return C&&(d?i[le]=f:delete i[le]),R}function Tn(i){return typeof i.constructor=="function"&&!Ze(i)?en(_t(i)):{}}function Bt(i,d){var f=typeof i;return d=d??c,!!d&&(f=="number"||f!="symbol"&&Hr.test(i))&&i>-1&&i%1==0&&i<d}function Nn(i,d,f){if(!Ae(f))return!1;var C=typeof d;return(C=="number"?It(f)&&Bt(d,f.length):C=="string"&&d in f)?yt(f[d],i):!1}function Rn(i){var d=typeof i;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?i!=="__proto__":i===null}function lr(i){return!!tr&&tr in i}function Ze(i){var d=i&&i.constructor,f=typeof d=="function"&&d.prototype||ut;return i===f}function $e(i){var d=[];if(i!=null)for(var f in Object(i))d.push(f);return d}function _n(i){return rr.call(i)}function jn(i,d,f){return d=ir(d===void 0?i.length-1:d,0),function(){for(var C=arguments,R=-1,A=ir(C.length-d,0),F=Array(A);++R<A;)F[R]=C[d+R];R=-1;for(var k=Array(d+1);++R<d;)k[R]=C[R];return k[d]=f(F),Qt(i,this,k)}}function ue(i,d){if(!(d==="constructor"&&typeof i[d]=="function")&&d!="__proto__")return i[d]}var An=kn(bn);function kn(i){var d=0,f=0;return function(){var C=_e(),R=a-(C-f);if(f=C,R>0){if(++d>=o)return arguments[0]}else d=0;return i.apply(void 0,arguments)}}function En(i){if(i!=null){try{return pt.call(i)}catch{}try{return i+""}catch{}}return""}function yt(i,d){return i===d||i!==i&&d!==d}var Lt=Xe(function(){return arguments}())?Xe:function(i){return Ue(i)&&Se.call(i,"callee")&&!Qr.call(i,"callee")},Ie=Array.isArray;function It(i){return i!=null&&vt(i.length)&&!Mt(i)}function Fn(i){return Ue(i)&&It(i)}var Qe=or||l;function Mt(i){if(!Ae(i))return!1;var d=gt(i);return d==v||d==x||d==g||d==P}function vt(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=c}function Ae(i){var d=typeof i;return i!=null&&(d=="object"||d=="function")}function Ue(i){return i!=null&&typeof i=="object"}function ur(i){if(!Ue(i)||gt(i)!=T)return!1;var d=_t(i);if(d===null)return!0;var f=Se.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&pt.call(f)==Zr}var $t=lt?Kr(lt):yn;function et(i){return Ye(i,Ut(i))}function Ut(i){return It(i)?hn(i):Oe(i)}var Pn=cr(function(i,d,f,C){sr(i,d,f,C)});function Dn(i){return function(){return i}}function pr(i){return i}function l(){return!1}e.exports=Pn})(Nr,Nr.exports);var Ol=Nr.exports;const Fe=eo(Ol);var Cl=e=>/!(important)?$/.test(e),Co=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,Tl=(e,t)=>r=>{const n=String(t),o=Cl(n),a=Co(n),c=e?`${e}.${a}`:a;let u=ot(r.__cssMap)&&c in r.__cssMap?r.__cssMap[c].varRef:t;return u=Co(u),o?`${u} !important`:u};function ao(e){const{scale:t,transform:r,compose:n}=e;return(a,c)=>{var u;const p=Tl(t,a)(c);let g=(u=r==null?void 0:r(p,c))!=null?u:p;return n&&(g=n(g,c)),g}}var yr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function pe(e,t){return r=>{const n={property:r,scale:e};return n.transform=ao({scale:e,transform:t}),n}}var Nl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Rl(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Nl(t),transform:r?ao({scale:r,compose:n}):n}}var ji=["rotate(var(--chakra-rotate, 0))","scaleX(var(--chakra-scale-x, 1))","scaleY(var(--chakra-scale-y, 1))","skewX(var(--chakra-skew-x, 0))","skewY(var(--chakra-skew-y, 0))"];function _l(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...ji].join(" ")}function jl(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...ji].join(" ")}var Al={"--chakra-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-sepia":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-drop-shadow":"var(--chakra-empty,/*!*/ /*!*/)",filter:["var(--chakra-blur)","var(--chakra-brightness)","var(--chakra-contrast)","var(--chakra-grayscale)","var(--chakra-hue-rotate)","var(--chakra-invert)","var(--chakra-saturate)","var(--chakra-sepia)","var(--chakra-drop-shadow)"].join(" ")},kl={backdropFilter:["var(--chakra-backdrop-blur)","var(--chakra-backdrop-brightness)","var(--chakra-backdrop-contrast)","var(--chakra-backdrop-grayscale)","var(--chakra-backdrop-hue-rotate)","var(--chakra-backdrop-invert)","var(--chakra-backdrop-opacity)","var(--chakra-backdrop-saturate)","var(--chakra-backdrop-sepia)"].join(" "),"--chakra-backdrop-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-opacity":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-sepia":"var(--chakra-empty,/*!*/ /*!*/)"};function El(e){return{"--chakra-ring-offset-shadow":"var(--chakra-ring-inset) 0 0 0 var(--chakra-ring-offset-width) var(--chakra-ring-offset-color)","--chakra-ring-shadow":"var(--chakra-ring-inset) 0 0 0 calc(var(--chakra-ring-width) + var(--chakra-ring-offset-width)) var(--chakra-ring-color)","--chakra-ring-width":e,boxShadow:["var(--chakra-ring-offset-shadow)","var(--chakra-ring-shadow)","var(--chakra-shadow, 0 0 #0000)"].join(", ")}}var Fl={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Gn={"to-t":"to top","to-tr":"to top right","to-r":"to right","to-br":"to bottom right","to-b":"to bottom","to-bl":"to bottom left","to-l":"to left","to-tl":"to top left"},Pl=new Set(Object.values(Gn)),Vn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),Dl=e=>e.trim();function Bl(e,t){if(e==null||Vn.has(e))return e;if(!(Xn(e)||Vn.has(e)))return`url('${e}')`;const o=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=o==null?void 0:o[1],c=o==null?void 0:o[2];if(!a||!c)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...g]=c.split(",").map(Dl).filter(Boolean);if((g==null?void 0:g.length)===0)return e;const m=p in Gn?Gn[p]:p;g.unshift(m);const b=g.map(y=>{if(Pl.has(y))return y;const v=y.indexOf(" "),[x,S]=v!==-1?[y.substr(0,v),y.substr(v+1)]:[y],O=Xn(S)?S:S&&S.split(" "),j=`colors.${x}`,T=j in t.__cssMap?t.__cssMap[j].varRef:x;return O?[T,...Array.isArray(O)?O:[O]].join(" "):T});return`${u}(${b.join(", ")})`}var Xn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Ll=(e,t)=>Bl(e,t??{});function Ml(e){return/^var\(--.+\)$/.test(e)}var $l=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Ce=e=>t=>`${e}(${t})`,D={filter(e){return e!=="auto"?e:Al},backdropFilter(e){return e!=="auto"?e:kl},ring(e){return El(D.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?_l():e==="auto-gpu"?jl():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=$l(e);return t||typeof e=="number"?`${e}px`:e},fraction(e){return typeof e!="number"||e>1?e:`${e*100}%`},float(e,t){const r={left:"right",right:"left"};return t.direction==="rtl"?r[e]:e},degree(e){if(Ml(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Ll,blur:Ce("blur"),opacity:Ce("opacity"),brightness:Ce("brightness"),contrast:Ce("contrast"),dropShadow:Ce("drop-shadow"),grayscale:Ce("grayscale"),hueRotate:e=>Ce("hue-rotate")(D.degree(e)),invert:Ce("invert"),saturate:Ce("saturate"),sepia:Ce("sepia"),bgImage(e){return e==null||Xn(e)||Vn.has(e)?e:`url(${e})`},outline(e){const t=String(e)==="0"||String(e)==="none";return e!==null&&t?{outline:"2px solid transparent",outlineOffset:"2px"}:{outline:e}},flexDirection(e){var t;const{space:r,divide:n}=(t=Fl[e])!=null?t:{},o={flexDirection:e};return r&&(o[r]=1),n&&(o[n]=1),o}},h={borderWidths:pe("borderWidths"),borderStyles:pe("borderStyles"),colors:pe("colors"),borders:pe("borders"),gradients:pe("gradients",D.gradient),radii:pe("radii",D.px),space:pe("space",yr(D.vh,D.px)),spaceT:pe("space",yr(D.vh,D.px)),degreeT(e){return{property:e,transform:D.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:ao({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:pe("sizes",yr(D.vh,D.px)),sizesT:pe("sizes",yr(D.vh,D.fraction)),shadows:pe("shadows"),logical:Rl,blur:pe("blur",D.blur)},br={background:h.colors("background"),backgroundColor:h.colors("backgroundColor"),backgroundImage:h.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:D.bgClip},bgSize:h.prop("backgroundSize"),bgPosition:h.prop("backgroundPosition"),bg:h.colors("background"),bgColor:h.colors("backgroundColor"),bgPos:h.prop("backgroundPosition"),bgRepeat:h.prop("backgroundRepeat"),bgAttachment:h.prop("backgroundAttachment"),bgGradient:h.gradients("backgroundImage"),bgClip:{transform:D.bgClip}};Object.assign(br,{bgImage:br.backgroundImage,bgImg:br.backgroundImage});var B={border:h.borders("border"),borderWidth:h.borderWidths("borderWidth"),borderStyle:h.borderStyles("borderStyle"),borderColor:h.colors("borderColor"),borderRadius:h.radii("borderRadius"),borderTop:h.borders("borderTop"),borderBlockStart:h.borders("borderBlockStart"),borderTopLeftRadius:h.radii("borderTopLeftRadius"),borderStartStartRadius:h.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:h.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:h.radii("borderTopRightRadius"),borderStartEndRadius:h.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:h.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:h.borders("borderRight"),borderInlineEnd:h.borders("borderInlineEnd"),borderBottom:h.borders("borderBottom"),borderBlockEnd:h.borders("borderBlockEnd"),borderBottomLeftRadius:h.radii("borderBottomLeftRadius"),borderBottomRightRadius:h.radii("borderBottomRightRadius"),borderLeft:h.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:h.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:h.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:h.borders(["borderLeft","borderRight"]),borderInline:h.borders("borderInline"),borderY:h.borders(["borderTop","borderBottom"]),borderBlock:h.borders("borderBlock"),borderTopWidth:h.borderWidths("borderTopWidth"),borderBlockStartWidth:h.borderWidths("borderBlockStartWidth"),borderTopColor:h.colors("borderTopColor"),borderBlockStartColor:h.colors("borderBlockStartColor"),borderTopStyle:h.borderStyles("borderTopStyle"),borderBlockStartStyle:h.borderStyles("borderBlockStartStyle"),borderBottomWidth:h.borderWidths("borderBottomWidth"),borderBlockEndWidth:h.borderWidths("borderBlockEndWidth"),borderBottomColor:h.colors("borderBottomColor"),borderBlockEndColor:h.colors("borderBlockEndColor"),borderBottomStyle:h.borderStyles("borderBottomStyle"),borderBlockEndStyle:h.borderStyles("borderBlockEndStyle"),borderLeftWidth:h.borderWidths("borderLeftWidth"),borderInlineStartWidth:h.borderWidths("borderInlineStartWidth"),borderLeftColor:h.colors("borderLeftColor"),borderInlineStartColor:h.colors("borderInlineStartColor"),borderLeftStyle:h.borderStyles("borderLeftStyle"),borderInlineStartStyle:h.borderStyles("borderInlineStartStyle"),borderRightWidth:h.borderWidths("borderRightWidth"),borderInlineEndWidth:h.borderWidths("borderInlineEndWidth"),borderRightColor:h.colors("borderRightColor"),borderInlineEndColor:h.colors("borderInlineEndColor"),borderRightStyle:h.borderStyles("borderRightStyle"),borderInlineEndStyle:h.borderStyles("borderInlineEndStyle"),borderTopRadius:h.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:h.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:h.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:h.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(B,{rounded:B.borderRadius,roundedTop:B.borderTopRadius,roundedTopLeft:B.borderTopLeftRadius,roundedTopRight:B.borderTopRightRadius,roundedTopStart:B.borderStartStartRadius,roundedTopEnd:B.borderStartEndRadius,roundedBottom:B.borderBottomRadius,roundedBottomLeft:B.borderBottomLeftRadius,roundedBottomRight:B.borderBottomRightRadius,roundedBottomStart:B.borderEndStartRadius,roundedBottomEnd:B.borderEndEndRadius,roundedLeft:B.borderLeftRadius,roundedRight:B.borderRightRadius,roundedStart:B.borderInlineStartRadius,roundedEnd:B.borderInlineEndRadius,borderStart:B.borderInlineStart,borderEnd:B.borderInlineEnd,borderTopStartRadius:B.borderStartStartRadius,borderTopEndRadius:B.borderStartEndRadius,borderBottomStartRadius:B.borderEndStartRadius,borderBottomEndRadius:B.borderEndEndRadius,borderStartRadius:B.borderInlineStartRadius,borderEndRadius:B.borderInlineEndRadius,borderStartWidth:B.borderInlineStartWidth,borderEndWidth:B.borderInlineEndWidth,borderStartColor:B.borderInlineStartColor,borderEndColor:B.borderInlineEndColor,borderStartStyle:B.borderInlineStartStyle,borderEndStyle:B.borderInlineEndStyle});var Ul={color:h.colors("color"),textColor:h.colors("color"),fill:h.colors("fill"),stroke:h.colors("stroke")},Yn={boxShadow:h.shadows("boxShadow"),mixBlendMode:!0,blendMode:h.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:h.prop("backgroundBlendMode"),opacity:!0};Object.assign(Yn,{shadow:Yn.boxShadow});var ql={filter:{transform:D.filter},blur:h.blur("--chakra-blur"),brightness:h.propT("--chakra-brightness",D.brightness),contrast:h.propT("--chakra-contrast",D.contrast),hueRotate:h.propT("--chakra-hue-rotate",D.hueRotate),invert:h.propT("--chakra-invert",D.invert),saturate:h.propT("--chakra-saturate",D.saturate),dropShadow:h.propT("--chakra-drop-shadow",D.dropShadow),backdropFilter:{transform:D.backdropFilter},backdropBlur:h.blur("--chakra-backdrop-blur"),backdropBrightness:h.propT("--chakra-backdrop-brightness",D.brightness),backdropContrast:h.propT("--chakra-backdrop-contrast",D.contrast),backdropHueRotate:h.propT("--chakra-backdrop-hue-rotate",D.hueRotate),backdropInvert:h.propT("--chakra-backdrop-invert",D.invert),backdropSaturate:h.propT("--chakra-backdrop-saturate",D.saturate)},Rr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:D.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:h.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:h.space("gap"),rowGap:h.space("rowGap"),columnGap:h.space("columnGap")};Object.assign(Rr,{flexDir:Rr.flexDirection});var Ai={gridGap:h.space("gridGap"),gridColumnGap:h.space("gridColumnGap"),gridRowGap:h.space("gridRowGap"),gridColumn:!0,gridRow:!0,gridAutoFlow:!0,gridAutoColumns:!0,gridColumnStart:!0,gridColumnEnd:!0,gridRowStart:!0,gridRowEnd:!0,gridAutoRows:!0,gridTemplate:!0,gridTemplateColumns:!0,gridTemplateRows:!0,gridTemplateAreas:!0,gridArea:!0},Wl={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:D.outline},outlineOffset:!0,outlineColor:h.colors("outlineColor")},fe={width:h.sizesT("width"),inlineSize:h.sizesT("inlineSize"),height:h.sizes("height"),blockSize:h.sizes("blockSize"),boxSize:h.sizes(["width","height"]),minWidth:h.sizes("minWidth"),minInlineSize:h.sizes("minInlineSize"),minHeight:h.sizes("minHeight"),minBlockSize:h.sizes("minBlockSize"),maxWidth:h.sizes("maxWidth"),maxInlineSize:h.sizes("maxInlineSize"),maxHeight:h.sizes("maxHeight"),maxBlockSize:h.sizes("maxBlockSize"),overflow:!0,overflowX:!0,overflowY:!0,overscrollBehavior:!0,overscrollBehaviorX:!0,overscrollBehaviorY:!0,display:!0,aspectRatio:!0,hideFrom:{scale:"breakpoints",transform:(e,t)=>{var r,n,o;return{[`@media screen and (min-width: ${(o=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n.minW)!=null?o:e})`]:{display:"none"}}}},hideBelow:{scale:"breakpoints",transform:(e,t)=>{var r,n,o;return{[`@media screen and (max-width: ${(o=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n._minW)!=null?o:e})`]:{display:"none"}}}},verticalAlign:!0,boxSizing:!0,boxDecorationBreak:!0,float:h.propT("float",D.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(fe,{w:fe.width,h:fe.height,minW:fe.minWidth,maxW:fe.maxWidth,minH:fe.minHeight,maxH:fe.maxHeight,overscroll:fe.overscrollBehavior,overscrollX:fe.overscrollBehaviorX,overscrollY:fe.overscrollBehaviorY});var zl={listStyleType:!0,listStylePosition:!0,listStylePos:h.prop("listStylePosition"),listStyleImage:!0,listStyleImg:h.prop("listStyleImage")};function Jl(e,t,r,n){const o=typeof t=="string"?t.split("."):[t];for(n=0;n<o.length&&e;n+=1)e=e[o[n]];return e===void 0?r:e}var Hl=e=>{const t=new WeakMap;return(n,o,a,c)=>{if(typeof n>"u")return e(n,o,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(o))return u.get(o);const p=e(n,o,a,c);return u.set(o,p),p}},Kl=Hl(Jl),Gl={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Vl={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},$n=(e,t,r)=>{const n={},o=Kl(e,t,{});for(const a in o)a in r&&r[a]!=null||(n[a]=o[a]);return n},Xl={srOnly:{transform(e){return e===!0?Gl:e==="focusable"?Vl:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>$n(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>$n(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>$n(t,e,r)}},Jt={position:!0,pos:h.prop("position"),zIndex:h.prop("zIndex","zIndices"),inset:h.spaceT("inset"),insetX:h.spaceT(["left","right"]),insetInline:h.spaceT("insetInline"),insetY:h.spaceT(["top","bottom"]),insetBlock:h.spaceT("insetBlock"),top:h.spaceT("top"),insetBlockStart:h.spaceT("insetBlockStart"),bottom:h.spaceT("bottom"),insetBlockEnd:h.spaceT("insetBlockEnd"),left:h.spaceT("left"),insetInlineStart:h.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:h.spaceT("right"),insetInlineEnd:h.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(Jt,{insetStart:Jt.insetInlineStart,insetEnd:Jt.insetInlineEnd});var Yl={ring:{transform:D.ring},ringColor:h.colors("--chakra-ring-color"),ringOffset:h.prop("--chakra-ring-offset-width"),ringOffsetColor:h.colors("--chakra-ring-offset-color"),ringInset:h.prop("--chakra-ring-inset")},z={margin:h.spaceT("margin"),marginTop:h.spaceT("marginTop"),marginBlockStart:h.spaceT("marginBlockStart"),marginRight:h.spaceT("marginRight"),marginInlineEnd:h.spaceT("marginInlineEnd"),marginBottom:h.spaceT("marginBottom"),marginBlockEnd:h.spaceT("marginBlockEnd"),marginLeft:h.spaceT("marginLeft"),marginInlineStart:h.spaceT("marginInlineStart"),marginX:h.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:h.spaceT("marginInline"),marginY:h.spaceT(["marginTop","marginBottom"]),marginBlock:h.spaceT("marginBlock"),padding:h.space("padding"),paddingTop:h.space("paddingTop"),paddingBlockStart:h.space("paddingBlockStart"),paddingRight:h.space("paddingRight"),paddingBottom:h.space("paddingBottom"),paddingBlockEnd:h.space("paddingBlockEnd"),paddingLeft:h.space("paddingLeft"),paddingInlineStart:h.space("paddingInlineStart"),paddingInlineEnd:h.space("paddingInlineEnd"),paddingX:h.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:h.space("paddingInline"),paddingY:h.space(["paddingTop","paddingBottom"]),paddingBlock:h.space("paddingBlock")};Object.assign(z,{m:z.margin,mt:z.marginTop,mr:z.marginRight,me:z.marginInlineEnd,marginEnd:z.marginInlineEnd,mb:z.marginBottom,ml:z.marginLeft,ms:z.marginInlineStart,marginStart:z.marginInlineStart,mx:z.marginX,my:z.marginY,p:z.padding,pt:z.paddingTop,py:z.paddingY,px:z.paddingX,pb:z.paddingBottom,pl:z.paddingLeft,ps:z.paddingInlineStart,paddingStart:z.paddingInlineStart,pr:z.paddingRight,pe:z.paddingInlineEnd,paddingEnd:z.paddingInlineEnd});var Zl={textDecorationColor:h.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:h.shadows("textShadow")},Ql={clipPath:!0,transform:h.propT("transform",D.transform),transformOrigin:!0,translateX:h.spaceT("--chakra-translate-x"),translateY:h.spaceT("--chakra-translate-y"),skewX:h.degreeT("--chakra-skew-x"),skewY:h.degreeT("--chakra-skew-y"),scaleX:h.prop("--chakra-scale-x"),scaleY:h.prop("--chakra-scale-y"),scale:h.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:h.degreeT("--chakra-rotate")},eu={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:h.prop("transitionDuration","transition.duration"),transitionProperty:h.prop("transitionProperty","transition.property"),transitionTimingFunction:h.prop("transitionTimingFunction","transition.easing")},tu={fontFamily:h.prop("fontFamily","fonts"),fontSize:h.prop("fontSize","fontSizes",D.px),fontWeight:h.prop("fontWeight","fontWeights"),lineHeight:h.prop("lineHeight","lineHeights"),letterSpacing:h.prop("letterSpacing","letterSpacings"),textAlign:!0,fontStyle:!0,textIndent:!0,wordBreak:!0,overflowWrap:!0,textOverflow:!0,textTransform:!0,whiteSpace:!0,isTruncated:{transform(e){if(e===!0)return{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},noOfLines:{static:{overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"var(--chakra-line-clamp)"},property:"--chakra-line-clamp"}},ru={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:h.spaceT("scrollMargin"),scrollMarginTop:h.spaceT("scrollMarginTop"),scrollMarginBottom:h.spaceT("scrollMarginBottom"),scrollMarginLeft:h.spaceT("scrollMarginLeft"),scrollMarginRight:h.spaceT("scrollMarginRight"),scrollMarginX:h.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:h.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:h.spaceT("scrollPadding"),scrollPaddingTop:h.spaceT("scrollPaddingTop"),scrollPaddingBottom:h.spaceT("scrollPaddingBottom"),scrollPaddingLeft:h.spaceT("scrollPaddingLeft"),scrollPaddingRight:h.spaceT("scrollPaddingRight"),scrollPaddingX:h.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:h.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function ki(e){return ot(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(ki).join(` ${e} `).replace(/calc/g,""),To=(...e)=>`calc(${Dr("+",...e)})`,No=(...e)=>`calc(${Dr("-",...e)})`,Zn=(...e)=>`calc(${Dr("*",...e)})`,Ro=(...e)=>`calc(${Dr("/",...e)})`,_o=e=>{const t=ki(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Zn(t,-1)},zt=Object.assign(e=>({add:(...t)=>zt(To(e,...t)),subtract:(...t)=>zt(No(e,...t)),multiply:(...t)=>zt(Zn(e,...t)),divide:(...t)=>zt(Ro(e,...t)),negate:()=>zt(_o(e)),toString:()=>e.toString()}),{add:To,subtract:No,multiply:Zn,divide:Ro,negate:_o});function nu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function jo(e){if(e==null)return e;const{unitless:t}=nu(e);return t||typeof e=="number"?`${e}px`:e}function ou(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${jo(e)})`),t&&r.push("and",`(max-width: ${jo(t)})`),r.join(" ")}var Y={hover:(e,t)=>`${e}:hover ${t}, ${e}[data-hover] ${t}`,focus:(e,t)=>`${e}:focus ${t}, ${e}[data-focus] ${t}`,focusVisible:(e,t)=>`${e}:focus-visible ${t}`,focusWithin:(e,t)=>`${e}:focus-within ${t}`,active:(e,t)=>`${e}:active ${t}, ${e}[data-active] ${t}`,disabled:(e,t)=>`${e}:disabled ${t}, ${e}[data-disabled] ${t}`,invalid:(e,t)=>`${e}:invalid ${t}, ${e}[data-invalid] ${t}`,checked:(e,t)=>`${e}:checked ${t}, ${e}[data-checked] ${t}`,indeterminate:(e,t)=>`${e}:indeterminate ${t}, ${e}[aria-checked=mixed] ${t}, ${e}[data-indeterminate] ${t}`,readOnly:(e,t)=>`${e}:read-only ${t}, ${e}[readonly] ${t}, ${e}[data-read-only] ${t}`,expanded:(e,t)=>`${e}:read-only ${t}, ${e}[aria-expanded=true] ${t}, ${e}[data-expanded] ${t}`,placeholderShown:(e,t)=>`${e}:placeholder-shown ${t}`},qe=e=>Ei(t=>e(t,"&"),"[role=group]","[data-group]",".group"),Ee=e=>Ei(t=>e(t,"~ &"),"[data-peer]",".peer"),Ei=(e,...t)=>t.map(e).join(", "),so={_hover:"&:hover, &[data-hover]",_active:"&:active, &[data-active]",_focus:"&:focus, &[data-focus]",_highlighted:"&[data-highlighted]",_focusWithin:"&:focus-within",_focusVisible:"&:focus-visible, &[data-focus-visible]",_disabled:"&:disabled, &[disabled], &[aria-disabled=true], &[data-disabled]",_readOnly:"&[aria-readonly=true], &[readonly], &[data-readonly]",_before:"&::before",_after:"&::after",_empty:"&:empty",_expanded:"&[aria-expanded=true], &[data-expanded]",_checked:"&[aria-checked=true], &[data-checked]",_grabbed:"&[aria-grabbed=true], &[data-grabbed]",_pressed:"&[aria-pressed=true], &[data-pressed]",_invalid:"&[aria-invalid=true], &[data-invalid]",_valid:"&[data-valid], &[data-state=valid]",_loading:"&[data-loading], &[aria-busy=true]",_selected:"&[aria-selected=true], &[data-selected]",_hidden:"&[hidden], &[data-hidden]",_autofill:"&:-webkit-autofill",_even:"&:nth-of-type(even)",_odd:"&:nth-of-type(odd)",_first:"&:first-of-type",_firstLetter:"&::first-letter",_last:"&:last-of-type",_notFirst:"&:not(:first-of-type)",_notLast:"&:not(:last-of-type)",_visited:"&:visited",_activeLink:"&[aria-current=page]",_activeStep:"&[aria-current=step]",_indeterminate:"&:indeterminate, &[aria-checked=mixed], &[data-indeterminate]",_groupHover:qe(Y.hover),_peerHover:Ee(Y.hover),_groupFocus:qe(Y.focus),_peerFocus:Ee(Y.focus),_groupFocusVisible:qe(Y.focusVisible),_peerFocusVisible:Ee(Y.focusVisible),_groupActive:qe(Y.active),_peerActive:Ee(Y.active),_groupDisabled:qe(Y.disabled),_peerDisabled:Ee(Y.disabled),_groupInvalid:qe(Y.invalid),_peerInvalid:Ee(Y.invalid),_groupChecked:qe(Y.checked),_peerChecked:Ee(Y.checked),_groupFocusWithin:qe(Y.focusWithin),_peerFocusWithin:Ee(Y.focusWithin),_peerPlaceholderShown:Ee(Y.placeholderShown),_placeholder:"&::placeholder",_placeholderShown:"&:placeholder-shown",_fullScreen:"&:fullscreen",_selection:"&::selection",_rtl:"[dir=rtl] &, &[dir=rtl]",_ltr:"[dir=ltr] &, &[dir=ltr]",_mediaDark:"@media (prefers-color-scheme: dark)",_mediaReduceMotion:"@media (prefers-reduced-motion: reduce)",_dark:".chakra-ui-dark &:not([data-theme]),[data-theme=dark] &:not([data-theme]),&[data-theme=dark]",_light:".chakra-ui-light &:not([data-theme]),[data-theme=light] &:not([data-theme]),&[data-theme=light]",_horizontal:"&[data-orientation=horizontal]",_vertical:"&[data-orientation=vertical]"},iu=Object.keys(so),co=Fe({},br,B,Ul,Rr,fe,ql,Yl,Wl,Ai,Xl,Jt,Yn,z,ru,tu,Zl,Ql,zl,eu);Object.assign({},z,fe,Rr,Ai,Jt);var au=[...Object.keys(co),...iu],su={...co,...so},cu=e=>e in su,du=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:o}=t.__breakpoints,a={};for(const c in e){let u=nt(e[c],t);if(u==null)continue;if(u=ot(u)&&r(u)?n(u):u,!Array.isArray(u)){a[c]=u;continue}const p=u.slice(0,o.length).length;for(let g=0;g<p;g+=1){const m=o==null?void 0:o[g];if(!m){a[c]=u[g];continue}a[m]=a[m]||{},u[g]!=null&&(a[m][c]=u[g])}}return a};function lu(e){const t=[];let r="",n=!1;for(let o=0;o<e.length;o++){const a=e[o];a==="("?(n=!0,r+=a):a===")"?(n=!1,r+=a):a===","&&!n?(t.push(r),r=""):r+=a}return r=r.trim(),r&&t.push(r),t}function uu(e){return/^var\(--.+\)$/.test(e)}var pu=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!uu(t),fu=(e,t)=>{var r,n;if(t==null)return t;const o=p=>{var g,m;return(m=(g=e.__cssMap)==null?void 0:g[p])==null?void 0:m.varRef},a=p=>{var g;return(g=o(p))!=null?g:p},[c,u]=lu(t);return t=(n=(r=o(c))!=null?r:a(u))!=null?n:a(t),t};function hu(e){const{configs:t={},pseudos:r={},theme:n}=e,o=(a,c=!1)=>{var u,p,g;const m=nt(a,n),b=du(m)(n);let y={};for(let v in b){const x=b[v];let S=nt(x,n);v in r&&(v=r[v]),pu(v,S)&&(S=fu(n,S));let O=t[v];if(O===!0&&(O={property:v}),ot(S)){y[v]=(u=y[v])!=null?u:{},y[v]=Fe({},y[v],o(S,!0));continue}let j=(g=(p=O==null?void 0:O.transform)==null?void 0:p.call(O,S,n,m))!=null?g:S;j=O!=null&&O.processResult?o(j,!0):j;const T=nt(O==null?void 0:O.property,n);if(!c&&(O!=null&&O.static)){const P=nt(O.static,n);y=Fe({},y,P)}if(T&&Array.isArray(T)){for(const P of T)y[P]=j;continue}if(T){T==="&"&&ot(j)?y=Fe({},y,j):y[T]=j;continue}if(ot(j)){y=Fe({},y,j);continue}y[v]=j}return y};return o}var gu=e=>t=>hu({theme:t,pseudos:so,configs:co})(e);function mu(e,t){if(Array.isArray(e))return e;if(ot(e))return t(e);if(e!=null)return[e]}function wu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function yu(e){const t=e.__breakpoints;return function(n,o,a,c){var u,p;if(!t)return;const g={},m=mu(a,t.toArrayValue);if(!m)return g;const b=m.length,y=b===1,v=!!n.parts;for(let x=0;x<b;x++){const S=t.details[x],O=t.details[wu(m,x)],j=ou(S.minW,O==null?void 0:O._minW),T=nt((u=n[o])==null?void 0:u[m[x]],c);if(T){if(v){(p=n.parts)==null||p.forEach(P=>{Fe(g,{[P]:y?T[P]:{[j]:T[P]}})});continue}if(!v){y?Fe(g,T):g[j]=T;continue}g[j]=T}}return g}}function Iu(e){return t=>{var r;const{variant:n,size:o,theme:a}=t,c=yu(a);return Fe({},nt((r=e.baseStyle)!=null?r:{},t),c(e,"sizes",o,t),c(e,"variants",n,t))}}function vu(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function bu(e,t,r,n){const o=typeof t=="string"?t.split("."):[t];for(n=0;n<o.length&&e;n+=1)e=e[o[n]];return e===void 0?r:e}var Su=e=>{const t=new WeakMap;return(n,o,a,c)=>{if(typeof n>"u")return e(n,o,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(o))return u.get(o);const p=e(n,o,a,c);return u.set(o,p),p}},xu=Su(bu);function Fi(e,t){const r={};return Object.keys(e).forEach(n=>{const o=e[n];t(o,n,e)&&(r[n]=o)}),r}var Pi=e=>Fi(e,t=>t!=null);function Ou(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Cu(e,...t){return Ou(e)?e(...t):e}var Tu=typeof Element<"u",Nu=typeof Map=="function",Ru=typeof Set=="function",_u=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Sr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,n,o;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(!Sr(e[n],t[n]))return!1;return!0}var a;if(Nu&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;for(a=e.entries();!(n=a.next()).done;)if(!Sr(n.value[1],t.get(n.value[0])))return!1;return!0}if(Ru&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;return!0}if(_u&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(e[n]!==t[n])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;if(Tu&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((o[n]==="_owner"||o[n]==="__v"||o[n]==="__o")&&e.$$typeof)&&!Sr(e[o[n]],t[o[n]]))return!1;return!0}return e!==e&&t!==t}var ju=function(t,r){try{return Sr(t,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const Au=eo(ju);function ku(e,t={}){var r;const{styleConfig:n,...o}=t,{theme:a,colorMode:c}=bl(),u=xu(a,`components.${e}`),p=n||u,g=Fe({theme:a,colorMode:c},(r=p==null?void 0:p.defaultProps)!=null?r:{},Pi(vu(o,["children"]))),m=I.useRef({});if(p){const y=Iu(p)(g);Au(m.current,y)||(m.current=y)}return m.current}function Eu(e,t={}){return ku(e,t)}var Fu=new Set([...au,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),Pu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Du(e){return Pu.has(e)||!Fu.has(e)}function Bu(e,...t){if(e==null)throw new TypeError("Cannot convert undefined or null to object");const r={...e};for(const n of t)if(n!=null)for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(o in r&&delete r[o],r[o]=n[o]);return r}var Ao,Lu=(Ao=uo.default)!=null?Ao:uo,Mu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:o,sx:a,...c}=t,u=Fi(c,(b,y)=>cu(y)),p=Cu(e,t),g=Bu({},o,p,Pi(u),a),m=gu(g)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Du);const o=Mu({baseStyle:r}),a=Lu(e,n)(o);return I.forwardRef(function(p,g){const{colorMode:m,forced:b}=_i();return I.createElement(a,{ref:g,"data-theme":b?m:void 0,...p})})}function $u(){const e=new Map;return new Proxy(Un,{apply(t,r,n){return Un(...n)},get(t,r){return e.has(r)||e.set(r,Un(r)),e.get(r)}})}var ko=$u();function Di(e){return I.forwardRef(e)}var Eo={path:s.jsxs("g",{stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),s.jsx("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),s.jsx("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},Bi=Di((e,t)=>{const{as:r,viewBox:n,color:o="currentColor",focusable:a=!1,children:c,className:u,__css:p,...g}=e,m=Sl("chakra-icon",u),b=Eu("Icon",e),y={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:o,...p,...b},v={ref:t,focusable:a,className:m,__css:y},x=n??Eo.viewBox;if(r&&typeof r!="string")return s.jsx(ko.svg,{as:r,...v,...g});const S=c??Eo.path;return s.jsx(ko.svg,{verticalAlign:"middle",viewBox:x,...v,...g,children:S})});Bi.displayName="Icon";function Uu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:o={}}=e,a=I.Children.toArray(e.path),c=Di((u,p)=>s.jsx(Bi,{ref:p,viewBox:t,...o,...u,children:a.length?a:s.jsx("path",{fill:"currentColor",d:r})}));return c.displayName=n,c}var qu=Uu({displayName:"ExternalLinkIcon",path:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("path",{d:"M15 3h6v6"}),s.jsx("path",{d:"M10 14L21 3"})]})});const Wu="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function zu({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return s.jsx(Vt,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(w.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),s.jsxs(w.Link,{href:Wu,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",s.jsx(qu,{mx:"2px"})]}),s.jsx(Xt,{error:r}),s.jsxs(w.Flex,{marginTop:"1em",children:[s.jsx(w.Input,{placeholder:"MyDomain",onChange:o=>t(o.currentTarget.value)}),s.jsx(w.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Ju({provider:e,handleSubmit:t,setWorkspace:r,error:n,isButtonDisabled:o}){return s.jsx(Vt,{children:s.jsxs(w.FormControl,{children:[s.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsxs(w.Heading,{as:"h4",size:"md",children:["Enter your ",de(e)," workspace"]})}),s.jsx(Xt,{error:n}),s.jsx(w.Flex,{marginTop:"1em",children:s.jsx(w.Input,{placeholder:"MyWorkspace",onChange:a=>r(a.currentTarget.value)})}),s.jsx("br",{}),s.jsx(w.Button,{isDisabled:o,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}const Hu="salesforce";function Ku({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o}){const{projectId:a}=V(),c=X(),[u,p]=I.useState(""),[g,m]=I.useState(null),[b,y]=I.useState(null),v=async()=>{if(y(null),!u){y("Workspace is required");return}try{const O=await Ti(a,t,n,c,e,u,r,o);m(O)}catch(O){console.error(O),y((O==null?void 0:O.message)??"Unexpected error")}},x=I.useCallback(O=>{y(O),m(null)},[]),S=e===Hu?s.jsx(zu,{handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0}):s.jsx(Ju,{provider:e,handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0});return s.jsx(Ni,{windowTitle:`Connect to ${de(e)}`,oauthUrl:g,onClose:x,children:S})}function Gu({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:o,groupName:a,selectedConnection:c,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return s.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p}=t.oauth2Opts,g=t.oauth2Opts.explicitWorkspaceRequired;return p==="authorizationCode"?g?s.jsx(Ku,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):s.jsx(wl,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):p==="clientCredentials"?g?s.jsx(Il,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a,setSelectedConnection:u,selectedConnection:c}):s.jsx(ll,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a,setSelectedConnection:u,selectedConnection:c}):p==="password"?s.jsx("em",{children:"Password flow not supported yet"}):p==="PKCE"?s.jsx("em",{children:"PKCE flow not supported yet"}):s.jsxs("em",{children:["Unsupported grant type: ",p]})}const Vu=async(e,t)=>{const r=await H().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!r)throw new Error(`Provider ${t} not found`);return r};function Li({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:a,onSuccess:c}){const u=X(),[p,g]=I.useState(null),{provider:m}=Ne(),{selectedConnection:b,setSelectedConnection:y,connections:v}=xt();ol({onSuccess:c});const x=e||m;if(I.useEffect(()=>{if(!b&&v&&v.length>0){const[S]=v;y(S)}Vu(u,x).then(S=>{g(S)}).catch(S=>{console.error("Error loading provider info: ",S)})},[v,b,y,u,x]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");return b?a:p==null?s.jsx("strong",{children:"Provider not found"}):p.authType==="none"?s.jsx(cl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="basic"?s.jsx(rl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="apiKey"?s.jsx(Zd,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):s.jsx(Gu,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:o,setSelectedConnection:y,selectedConnection:b})}function Xu({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onInstallSuccess:a,onUpdateSuccess:c}){var g;const{projectId:u}=V(),{errorState:p}=Je();return(g=p[G.INTEGRATION_LIST])!=null&&g.apiError?s.jsx(Pe,{message:"Something went wrong, couldn't find integration information"}):s.jsx(Mc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onInstallSuccess:a,onUpdateSuccess:c,children:s.jsx(Qo,{groupRef:n,children:s.jsx(Li,{consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:s.jsx(id,{projectId:u,children:s.jsx(Gd,{children:s.jsx(yd,{children:s.jsx(xd,{children:s.jsx(qd,{})})})})})})})})}function Yu({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?s.jsx(w.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:s.jsx(Te,{message:"Redirecting..."})}):t}function Zu({provider:e}){const{appName:t}=V(),r=`You have successfully connected your ${de(e)} account to ${t}.`;return s.jsx(Ci,{text:r})}function Qu({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,redirectUrl:a,onSuccess:c}){return s.jsx(Qo,{provider:e,groupRef:n,children:s.jsx(Li,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onSuccess:c,children:s.jsx(Yu,{redirectURL:a,children:s.jsx(Zu,{provider:e})})})})}const ep=(e,t)=>{const r=X(),{projectId:n}=V(),{integrations:o}=Go(),[a,c]=I.useState(!1),[u,p]=I.useState(null);if(!r||!n)throw new Error("useIsIntegrationInstalled must be used within AmpersandProvider");if(!e)throw new Error("useIsIntegrationInstalled requires an integration name");if(!t)throw new Error("useIsIntegrationInstalled requires a groupRef");const g=I.useMemo(()=>o==null?void 0:o.reduce((m,b)=>(b==null?void 0:b.name)===e?b:m,{}),[o,e]);return I.useEffect(()=>{g&&H().installationApi.listInstallations({projectIdOrName:n,integrationId:g.id,groupRef:t},{headers:{"x-api-key":r}}).then(m=>{c(!0),p(m.length>0)}).catch(m=>{console.error("Error listing installations: ",m),c(!0)})},[t,r,n,g]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Xo;exports.AmpersandProvider=Dc;exports.ConnectProvider=Qu;exports.InstallIntegration=Xu;exports.useAmpersandProvider=Bc;exports.useIsIntegrationInstalled=ep;