@amp-labs/react 1.6.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"),w=require("@chakra-ui/react"),Bi=require("@emotion/react"),uo=require("@emotion/styled"),Li={warning:{bg:"red.50",outlineColor:"red.800",outline:"2px solid",outlineOffset:"0",borderColor:"red.800",color:"red.800",_hover:{bg:"red.100"}}},Mi=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:Li}}}),$i=w.extendTheme(w.withDefaultColorScheme({colorScheme:"facebook",components:["Button"]}),Mi);function Ui({children:e}){return c.jsx(w.ChakraProvider,{theme:$i,children:e})}const Fo=I.createContext(null),qi=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 Wi=(()=>{const e={};return Object.values(G).forEach(t=>{e[t]={}}),e})();function zi({children:e}){const[t,r]=I.useState(Wi),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]),s=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: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(w.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:c.jsxs(w.Stack,{alignItems:"center",children:[c.jsx(w.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&c.jsx(w.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Fe({message:e}){return c.jsxs(w.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(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:c.jsx(w.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Ji="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:Ji}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 Hi=new Do,_r=class _r{constructor(t=Hi){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 Xi(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 Vi(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:Gi(u.body)||u.body instanceof URLSearchParams||Ki(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 Ki(e){return typeof Blob<"u"&&e instanceof Blob}function Gi(e){return typeof FormData<"u"&&e instanceof FormData}class Vi extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class Xi extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class R extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function _(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 Ne{constructor(t){this.raw=t}async value(){}}class Yi{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Zi(e){return Qi(e)}function Qi(e,t){return e==null?e:{name:e.name,valuePrefix:_(e,"valuePrefix")?e.valuePrefix:void 0}}function ea(e){return ta(e)}function ta(e,t){return e==null?e:{name:e.name}}function ra(e){return na(e)}function na(e,t){return e==null?e:{attachmentType:e.attachmentType,query:_(e,"query")?ea(e.query):void 0,header:_(e,"header")?Zi(e.header):void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function oa(e){return ia(e)}function ia(e,t){return e}function aa(e){if(e!==void 0)return e===null?null:{days:e.days}}function sa(e){if(e!==void 0)return e===null?null:{defaultPeriod:aa(e.defaultPeriod)}}function ca(e){return da(e)}function da(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function Mo(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function la(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:sa(e.backfill)}}function ua(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,la)}}function pa(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function fa(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,pa)}}function $o(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function gr(e){return ha(e)}function ha(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:_(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function ga(e){return ma(e)}function ma(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function wa(e){return ya(e)}function ya(e,t){return e==null?e:{provider:e.provider,read:_(e,"read")?e.read:void 0,write:_(e,"write")?e.write:void 0,proxy:_(e,"proxy")?ca(e.proxy):void 0}}function Uo(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Mo(e.proxy)}}function Ia(e){return va(e)}function va(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:wa(e.content)}}function ba(e){return Sa(e)}function Sa(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function qo(e){return xa(e)}function xa(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Ca(e)}function Ca(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:_(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:_(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function vr(e){return Oa(e)}function Oa(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:qo(e.group),consumer:ba(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:_(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Na(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Ta(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Ra(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Ta(e.metadata)}}function _a(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function ja(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Uo(e.content)}}function Aa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:ja(e.config)}}function Ea(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl}}function ka(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Ea(e.latestRevision)}}function Fa(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Pa(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 Da(e){return Ba(e)}function Ba(e,t){return e==null?e:{url:_(e,"url")?e.url:void 0,headers:_(e,"headers")?e.headers:void 0}}function La(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return Ma(e)}function Ma(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:Da(e.metadata),createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function $a(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Ua(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret}}function qa(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret}}function Wa(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:$a(e.basicAuth),oauth2ClientCredentials:Ua(e.oauth2ClientCredentials),oauth2Password:qa(e.oauth2Password)}}function za(e){return Ja(e)}function Ja(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function Ha(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function Wo(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:_(e,"default")?e.default:void 0,prompt:_(e,"prompt")?e.prompt:void 0}}function Bn(e){return Ka(e)}function Ka(e,t){return e==null?e:{...Ha(e),...Wo(e)}}function zo(e){return Ga(e)}function Ga(e,t){return e}function Va(e){return Xa(e)}function Xa(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:_(e,"requiredFields")?e.requiredFields.map(Bn):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(Bn):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?zo(e.optionalFieldsAuto):void 0,allFields:_(e,"allFields")?e.allFields.map(Bn):void 0}}function Ya(e){return Za(e)}function Za(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Va):void 0}}function Qa(e){return es(e)}function es(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ts(e){return rs(e)}function rs(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Qa):void 0}}function ns(e){return os(e)}function os(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,provider:e.provider,read:_(e,"read")?Ya(e.read):void 0,write:_(e,"write")?ts(e.write):void 0,proxy:_(e,"proxy")?za(e.proxy):void 0}}function is(e){return as(e)}function as(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:ns(e.content)}}function ss(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 cs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Uo(e.content)}}function ds(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:ss(e.connection),config:cs(e.config)}}function qt(e){return ls(e)}function ls(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:_(e,"group")?qo(e.group):void 0,healthStatus:e.healthStatus,connection:vr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,config:Ia(e.config)}}function us(e){return ps(e)}function ps(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function fs(e,t){return e==null?e:{fieldName:e.fieldName}}function po(e){return hs(e)}function hs(e,t){return e==null?e:{...fs(e),...Wo(e)}}function gs(e){return ms(e)}function ms(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:_(e,"requiredFields")?e.requiredFields.map(po):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(po):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?zo(e.optionalFieldsAuto):void 0}}function ws(e){return ys(e)}function ys(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(gs):void 0}}function Is(e){return vs(e)}function vs(e,t){return e==null?e:{objectName:e.objectName}}function bs(e){return Ss(e)}function Ss(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Is):void 0}}function xs(e){return Cs(e)}function Cs(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,provider:e.provider,read:_(e,"read")?ws(e.read):void 0,write:_(e,"write")?bs(e.write):void 0,proxy:_(e,"proxy")?us(e.proxy):void 0}}function Os(e){return Ns(e)}function Ns(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:xs(e.content)}}function fo(e){return Ts(e)}function Ts(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Os(e.latestRevision)}}function Rs(e){return _s(e)}function _s(e,t){return e==null?e:{msg:e.msg,operationEventId:_(e,"operation_event_id")?e.operation_event_id:void 0,operationId:_(e,"operation_id")?e.operation_id:void 0}}function js(e){return As(e)}function As(e,t){return e==null?e:{timestamp:e.timestamp,message:Rs(e.message),severity:e.severity}}function Es(e){return ks(e)}function ks(e,t){return e==null?e:{workspaceRefField:_(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:_(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:_(e,"scopesField")?e.scopesField:void 0}}function Fs(e){return Ps(e)}function Ps(e,t){return e==null?e:{grantType:e.grantType,authURL:_(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:_(e,"audience")?e.audience:void 0,tokenMetadataFields:Es(e.tokenMetadataFields),docsURL:_(e,"docsURL")?e.docsURL:void 0,authURLParams:_(e,"authURLParams")?e.authURLParams:void 0}}function Ds(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 Bs(e)}function Bs(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:_(e,"result")?e.result:void 0,latestOperationEventId:_(e,"latestOperationEventId")?e.latestOperationEventId:void 0,metadata:_(e,"metadata")?e.metadata:void 0,createTime:_(e,"createTime")?new Date(e.createTime):void 0}}function Ls(e){return Ms(e)}function Ms(e,t){return e==null?e:{bulkWrite:ga(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function go(e){return $s(e)}function $s(e,t){return e==null?e:{name:e.name,authType:oa(e.authType),baseURL:e.baseURL,oauth2Opts:_(e,"oauth2Opts")?Fs(e.oauth2Opts):void 0,apiKeyOpts:_(e,"apiKeyOpts")?ra(e.apiKeyOpts):void 0,support:Ls(e.support),providerOpts:e.providerOpts,displayName:_(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:_(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0}}function Us(e){return qs(e)}function qs(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function Ws(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:La(e.metadata)}}function zs(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:Ws(e.destination)}}function Js(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:ua(e.read),write:fa(e.write),proxy:Mo(e.proxy)}}function Hs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Js(e.content)}}function Ks(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:Hs(e.config)}}function Gs(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:Ks(e.installation)}}function Vs(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function Xs(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:Vs(e.project)}}function Ys(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 Zs(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:Ys(e.providerApp)}}class Qs extends re{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("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:Wa(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new R("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 R("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 ec extends re{async createConsumerRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createConsumer.");if(t.consumer===null||t.consumer===void 0)throw new R("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:Na(t.consumer)},r);return new Ne(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class tc extends re{async createDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createDestination.");if(t.destination===null||t.destination===void 0)throw new R("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:Ra(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new R("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 Ne(a)}async deleteDestination(t,r){await this.deleteDestinationRaw(t,r)}async getDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getDestination.");if(t.destinationName===null||t.destinationName===void 0)throw new R("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 R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new R("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling updateDestination.");if(t.destinationUpdate===null||t.destinationUpdate===void 0)throw new R("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:zs(t.destinationUpdate)},r);return new L(a,s=>mr(s))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class rc extends re{async createGroupRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createGroup.");if(t.group===null||t.group===void 0)throw new R("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:_a(t.group)},r);return new Ne(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class nc extends re{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new R("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:Aa(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new R("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 Ne(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new R("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:ds(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new R("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new R("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:Gs(t.installationUpdate)},r);return new L(a,s=>qt(s))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class oc extends re{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("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:$o(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new R("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:ka(t.integration)},r);return new Ne(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new R("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 Ne(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("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 ic extends re{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new R("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:Ds(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new L(a):new Yi(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}async oauthConnectCorsRaw(t){const r={},n={},o=await this.request({path:"/oauth-connect",method:"OPTIONS",headers:n,query:r},t);return new Ne(o)}async oauthConnectCors(t){await this.oauthConnectCorsRaw(t)}}class ac extends re{async getOperationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getOperation.");if(t.operationId===null||t.operationId===void 0)throw new R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperationLogs.");if(t.operationId===null||t.operationId===void 0)throw new R("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(js))}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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperations.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listOperations.");if(t.installationId===null||t.installationId===void 0)throw new R("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 sc extends re{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new R("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:Fa(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 R("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 Ne(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new R("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:Xs(t.projectUpdate)},r);return new L(a,s=>gr(s))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class cc extends re{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new R("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 dc extends re{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new R("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:Pa(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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new R("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 Ne(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("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 R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new R("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new R("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:Zs(t.providerAppUpdate)},r);return new L(a,s=>Ir(s))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class lc extends re{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new R("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:$o(t.revision)},r);return new Ne(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new R("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new R("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new R("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new R("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=>is(s))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class uc 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=>Us(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class pc{constructor(t){this.connectionApi=new Qs(t),this.consumerApi=new ec(t),this.destinationApi=new tc(t),this.groupApi=new rc(t),this.installationApi=new nc(t),this.integrationApi=new oc(t),this.oAuthApi=new ic(t),this.operationApi=new ac(t),this.projectApi=new sc(t),this.providerApi=new cc(t),this.providerAppApi=new dc(t),this.revisionApi=new lc(t),this.uploadURLApi=new uc(t)}}const fc="1.6.0",hc="v1",wr="https://api.withampersand.com";function Jo(){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 gc=(e,t)=>`${e}/${t}`;function mc(){return gc(Jo(),hc)}const wc=Jo(),yc=mc(),Ic=new Do({basePath:yc,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":fc}});let vc=new pc(Ic);const H=()=>vc,Ho=I.createContext({integrations:null}),Ko=()=>{const e=I.useContext(Ho);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function bc({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(Fe,{message:"Error retrieving integrations for the project, double check the API key"}):c.jsx(Ho.Provider,{value:g,children:u?c.jsx(We,{}):t})}const Go=I.createContext({project:null,appName:"",projectId:""}),V=()=>{const e=I.useContext(Go);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Sc({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(Fe,{message:`Error loading project ${e}`}):c.jsx(Go.Provider,{value:g,children:u?c.jsx(We,{}):t})}function xc(e){const{options:{apiKey:t,projectId:r},children:n}=e;return c.jsx(Ui,{children:c.jsx(zi,{children:c.jsx(qi,{value:t,children:c.jsx(Sc,{projectId:r,children:c.jsx(bc,{projectId:r,children:n})})})})})}const Vo=I.createContext(null);function Cc(){const e=I.useContext(Vo);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 Oc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Xo=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(Xo);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Nc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:o,groupName:a,onInstallSuccess:s,onUpdateSuccess:u}){const p=X(),{projectId:g}=V(),{integrations:m}=Ko(),[b,y]=I.useState([]),[v,x]=I.useState(!0),{setError:S,isError:C}=Je(),j=(b==null?void 0:b[0])||null,T=I.useMemo(()=>Oc(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 D=I.useCallback(J=>{y([J])},[y]),z=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]),oe=(T==null?void 0:T.id)||"";I.useEffect(()=>{z()},[z]);const ee=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:D,resetInstallations:z,onInstallSuccess:s,onUpdateSuccess:u}),[T,r,n,o,a,j,D,z,s,u]);if(T!==null){const J=`Error retrieving installation information for integration "${(T==null?void 0:T.name)||"unknown"}"`;return C(G.INSTALLATION_LIST,oe)?c.jsx(Fe,{message:J}):c.jsx(Xo.Provider,{value:ee,children:v?c.jsx(We,{}):e})}return c.jsx(Fe,{message:`Integration "${t}" not found`})}const Yo=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),St=()=>{const e=I.useContext(Yo);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Zo({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:y}=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(C=>{m(!1),s(C)}).catch(C=>{m(!1),b(G.CONNECTION_LIST,o),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,C)})},[o,n,t,x,b]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:s,setSelectedConnection:p}),[a,u,s,p]);return y(G.CONNECTION_LIST,o)?c.jsx(Fe,{message:"Error retrieving existing connections"}):c.jsx(Yo.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]",y="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",C="[object Number]",j="[object Null]",T="[object Object]",D="[object Promise]",z="[object Proxy]",oe="[object RegExp]",ee="[object Set]",J="[object String]",ie="[object Symbol]",be="[object Undefined]",he="[object WeakMap]",Te="[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,M=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,$={};$[Br]=$[Lr]=$[Mr]=$[$r]=$[Ur]=$[qr]=$[Wr]=$[zr]=$[Jr]=!0,$[u]=$[p]=$[Te]=$[m]=$[st]=$[b]=$[y]=$[v]=$[S]=$[C]=$[T]=$[oe]=$[ee]=$[J]=$[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")(),Ot=t&&!t.nodeType&&t,ct=Ot&&!0&&e&&!e.nodeType&&e,Nt=ct&&ct.exports===Ot,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,O=0,N=[];++d<f;){var A=l[d];i(A,d,l)&&(N[O++]=A)}return N}function Gr(l,i){for(var d=-1,f=i.length,O=l.length;++d<f;)l[O+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,O){d[++i]=[O,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,Re=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"),Et=Me(te,"Promise"),kt=Me(te,"Set"),Ft=Me(te,"WeakMap"),Ve=Me(Object,"create"),me=Ie(ge),tn=Ie(Ge),rn=Ie(Et),nn=Ie(kt),on=Ie(Ft),ar=le?le.prototype:void 0,xe=ar?ar.valueOf:void 0;function _e(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}_e.prototype.clear=an,_e.prototype.delete=sn,_e.prototype.get=cn,_e.prototype.has=dn,_e.prototype.set=Le;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=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}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 _e,map:new(Ge||we),string:new _e}}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}ye.prototype.clear=gn,ye.prototype.delete=ft,ye.prototype.get=Pt,ye.prototype.has=mn,ye.prototype.set=ht;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 Ce(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}Ce.prototype.clear=sr,Ce.prototype.delete=In,Ce.prototype.get=vn,Ce.prototype.has=bn,Ce.prototype.set=Sn;function xn(l,i){var d=Qe(l),f=!d&&Fn(l),O=!d&&!f&&It(l),N=!d&&!f&&!O&&Ut(l),A=d||f||O||N,F=A?Xr(l.length,String):[],E=F.length;for(var k in l)ae.call(l,k)&&!(A&&(k=="length"||O&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||An(k,E)))&&F.push(k);return F}function gt(l,i){for(var d=l.length;d--;)if(yt(l[d][0],i))return d;return-1}function Cn(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:Re&&Re in Object(l)?_n(l):Lt(l)}function cr(l){return et(l)&&Ye(l)==u}function dr(l,i,d,f,O){return l===i?!0:l==null||i==null||!et(l)&&!et(i)?l!==l&&i!==i:mt(l,i,d,f,dr,O)}function mt(l,i,d,f,O,N){var A=Qe(l),F=Qe(i),E=A?p:ue(l),k=F?p:ue(i);E=E==u?T:E,k=k==u?T:k;var U=E==T,q=k==T,K=E==k;if(K&&It(l)){if(!It(i))return!1;A=!0,U=!1}if(K&&!U)return N||(N=new Ce),A||Ut(l)?Bt(l,i,d,f,O,N):Tn(l,i,E,d,f,O,N);if(!(d&o)){var Z=U&&ae.call(l,"__wrapped__"),Q=q&&ae.call(i,"__wrapped__");if(Z||Q){var ve=Z?l.value():l,Ae=Q?i.value():i;return N||(N=new Ce),O(ve,Ae,d,f,N)}}return K?(N||(N=new Ce),Rn(l,i,d,f,O,N)):!1}function Dt(l){if(!$t(l)||kn(l))return!1;var i=$e(l)?Qr:M;return i.test(Ie(l))}function On(l){return et(l)&&ur(l.length)&&!!$[Ye(l)]}function Nn(l){if(!wt(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,O,N){var A=d&o,F=l.length,E=i.length;if(F!=E&&!(A&&E>F))return!1;var k=N.get(l);if(k&&N.get(i))return k==i;var U=-1,q=!0,K=d&a?new Xe:void 0;for(N.set(l,i),N.set(i,l);++U<F;){var Z=l[U],Q=i[U];if(f)var ve=A?f(Q,Z,U,i,l,N):f(Z,Q,U,l,i,N);if(ve!==void 0){if(ve)continue;q=!1;break}if(K){if(!Vr(i,function(Ae,tt){if(!lt(K,tt)&&(Z===Ae||O(Z,Ae,d,f,N)))return K.push(tt)})){q=!1;break}}else if(!(Z===Q||O(Z,Q,d,f,N))){q=!1;break}}return N.delete(l),N.delete(i),q}function Tn(l,i,d,f,O,N,A){switch(d){case st:if(l.byteLength!=i.byteLength||l.byteOffset!=i.byteOffset)return!1;l=l.buffer,i=i.buffer;case Te:return!(l.byteLength!=i.byteLength||!N(new He(l),new He(i)));case m:case b:case C:return yt(+l,+i);case y:return l.name==i.name&&l.message==i.message;case oe:case J:return l==i+"";case S:var F=ut;case ee:var E=f&o;if(F||(F=tr),l.size!=i.size&&!E)return!1;var k=A.get(l);if(k)return k==i;f|=a,A.set(l,i);var U=Bt(F(l),F(i),f,O,N,A);return A.delete(l),U;case ie:if(xe)return xe.call(l)==xe.call(i)}return!1}function Rn(l,i,d,f,O,N){var A=d&o,F=lr(l),E=F.length,k=lr(i),U=k.length;if(E!=U&&!A)return!1;for(var q=E;q--;){var K=F[q];if(!(A?K in i:ae.call(i,K)))return!1}var Z=N.get(l);if(Z&&N.get(i))return Z==i;var Q=!0;N.set(l,i),N.set(i,l);for(var ve=A;++q<E;){K=F[q];var Ae=l[K],tt=i[K];if(f)var lo=A?f(tt,Ae,K,i,l,N):f(Ae,tt,K,l,i,N);if(!(lo===void 0?Ae===tt||O(Ae,tt,d,f,N):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 N.delete(l),N.delete(i),Q}function lr(l){return Cn(l,Pn,jn)}function Ze(l,i){var d=l.__data__;return En(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,Re),d=l[Re];try{l[Re]=void 0;var f=!0}catch{}var O=jt.call(l);return f&&(i?l[Re]=d:delete l[Re]),O}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||Et&&ue(Et.resolve())!=D||kt&&ue(new kt)!=ee||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 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 En(l){var i=typeof l;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?l!=="__proto__":l===null}function kn(l){return!!_t&&_t in l}function wt(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 yt(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 je(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==z}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):On;function Pn(l){return Mt(l)?xn(l):Nn(l)}function Dn(){return[]}function pr(){return!1}e.exports=je})(xr,xr.exports);var Tc=xr.exports;const Rc=eo(Tc),xt="other";function ze(e){return e.mapToName!==void 0}function _c(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function jc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}function Ac(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>ze(n)&&!!n.mapToName))||[]}function Ec(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!ze(r)&&!!r.fieldName))||null}const kc=(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 Fc(e){return ze(e)?e.mapToName:e.fieldName}const Qo=(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?!!kc(e,s.objectName):!1})}),r},ei=e=>{var r;return{name:xt,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function Pc(e,t){var a;const r=Qo(e,t),o=!!((a=t==null?void 0:t.content)!=null&&a.write)?ei(e):void 0;return o&&r.push(o),r}function ti(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 Rc(e,t)}const Dc=(e,t,r)=>{var v,x,S,C,j,T;if(!e)return null;const n=_c(e,t),o=n&&jc(n),a=n&&Ec(n),s=n&&Ac(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=(C=p==null?void 0:p.read)==null?void 0:C.objects)==null?void 0:j[t])==null?void 0:T.selectedFieldMappings)||{},b={...g},y={...m};return{allFields:u,requiredFields:o,optionalFields:a,requiredMapFields:s,selectedOptionalFields:g,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:b,requiredMapFields:y}}},Bc=(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 ri(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:Dc(n,t,r),write:Bc(o,r)}}const ni=(e,t,r,n)=>{const o=ri(e,r,t);n(r,o)},Lc=(e,t,r)=>{const n=Pc(t,e),o={};n.forEach(({name:a,completed:s})=>{s&&(o[a]=ri(e,a,t))}),r(o)},oi=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(Fc(a))),{...Array.from(n).reduce((a,s)=>({...a,[s]:!0}),{}),...r||{}}},ii=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 ai(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 Mc=(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)},$c=(e,t,r,n)=>{const o=oi(e),a=ii(e),s=Mc(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}}}}};return jr(r)&&(u.content.proxy={enabled:!0}),u},Uc=(e,t,r,n,o,a,s,u,p,g,m)=>{const b=$c(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))},si=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},qc=e=>{const t=e.content.write;return t==null?void 0:t.objects},Wc=(e,t,r)=>{if(!qc(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=si(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},zc=(e,t,r,n,o,a,s,u,p,g)=>{const m=Wc(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 Jc(){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 ci="uninstall-installation",Hc=I.forwardRef(({text:e="Uninstall"},t)=>{const r=w.useTab({ref:t}),n=w.useMultiStyleConfig("Tabs",r);return c.jsxs(w.Button,{__css:n.warningTab,...r,minHeight:15,children:[c.jsxs(w.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[Jc(),c.jsx(w.Box,{textAlign:"left",children:c.jsx(w.Text,{color:"red.800",children:e})})]}),r.children]})}),di=I.createContext({hydratedRevision:null,loading:!1}),Gt=()=>{const e=I.useContext(di);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function Kc({projectId:e,children:t}){var T;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(),y=X(),v=r==null?void 0:r.id,x=(T=o==null?void 0:o.latestRevision)==null?void 0:T.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(D=>{s(D),p(!1),m(G.HYDRATED_REVISION,S)}).catch(D=>{console.error(`Error loading integration ${S}`,D),p(!1),b(G.HYDRATED_REVISION,S)})},[e,n,x,v,y,m,b,S]);const C=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),j=`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(di.Provider,{value:C,children:g(G.HYDRATED_REVISION,S)?c.jsx(Fe,{message:j}):t})}var li=Symbol.for("immer-nothing"),mo=Symbol.for("immer-draftable"),se=Symbol.for("immer-state"),Gc=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=Gc[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?ui(e)||Array.isArray(e)||!!e[mo]||!!((t=e.constructor)!=null&&t[mo])||Er(e)||kr(e):!1}var Vc=Object.prototype.constructor.toString();function ui(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)===Vc}function Cr(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:Er(e)?2:kr(e)?3:0}function qn(e,t){return Ar(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function pi(e,t,r){const n=Ar(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function Xc(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Er(e){return e instanceof Map}function kr(e){return e instanceof Set}function rt(e){return e.copy_||e.base_}function Wn(e,t){if(Er(e))return new Map(e);if(kr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=ui(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=Yc),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>no(n,!0))),e}function Yc(){ne(2)}function Fr(e){return Object.isFrozen(e)}var Zc={};function at(e){const t=Zc[e];return t||ne(0,e),t}var Ht;function fi(){return Ht}function Qc(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wo(e,t){t&&(at("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function zn(e){Jn(e),e.drafts_.forEach(ed),e.drafts_=null}function Jn(e){e===Ht&&(Ht=e.parent_)}function yo(e){return Ht=Qc(Ht,e)}function ed(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=Or(t,e),t.parent_||Nr(t,e)),t.patches_&&at("Patches").generateReplacementPatches_(r[se].base_,e,t.patches_,t.inversePatches_)):e=Or(t,r,[]),zn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==li?e:void 0}function Or(e,t,r){if(Fr(t))return t;const n=t[se];if(!n)return Cr(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),Cr(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=Or(e,o,u);if(pi(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;Or(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 td(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:fi(),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 rd(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=hi(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(Xc(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={};Cr(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 rd(e,t,r){var o;const n=hi(t,r);return n?"value"in n?n.value:(o=n.get)==null?void 0:o.call(e.draft_):void 0}function hi(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 nd=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=yo(this),s=Kn(t,void 0);let u=!0;try{o=r(s),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===li&&(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=od(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_)&&ne(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=at("Patches").applyPatches_;return bt(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Kn(e,t){const r=Er(e)?at("MapSet").proxyMap_(e,t):kr(e)?at("MapSet").proxySet_(e,t):td(e,t);return(t?t.scope_:fi()).drafts_.push(r),r}function od(e){return bt(e)||ne(10,e),gi(e)}function gi(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 Cr(r,(n,o)=>{pi(r,n,gi(o))}),t&&(t.finalized_=!1),r}var ce=new nd,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 mi=I.createContext(void 0),id={};function io(){const e=I.useContext(mi);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function ad({children:e}){const{installation:t}=Pe(),{hydratedRevision:r,loading:n}=Gt(),[o,a]=I.useState(id),s=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&s&&!(Object.entries(o).length>0)&&Lc(r,s,a)},[r,n,s,o]);const u=I.useCallback((v,x)=>{a(S=>Wt(S,C=>{C[v]=Wt(C[v],x)}))},[a]),p=I.useCallback((v,x)=>{a(S=>Wt(S,C=>{C[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 C;const S=(C=x[v])==null?void 0:C.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),b=I.useCallback(v=>{v===xt?g():m(v)},[m,g]),y=I.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:b}),[o,p,b,u]);return c.jsx(mi.Provider,{value:y,children:e})}const sd=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 cd(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?sd: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=w.useTab({ref:o}),s=w.useMultiStyleConfig("Tabs",a);return c.jsxs(w.Button,{__css:s.tab,...a,variant:"outline",minHeight:15,children:[c.jsxs(w.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[cd(t,r),c.jsxs(w.Box,{textAlign:"left",children:[c.jsx(w.Text,{children:n||e}),r&&c.jsx(w.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function dd({pending:e,completed:t,displayName:r}){return c.jsxs(c.Fragment,{children:[c.jsx(w.Divider,{marginY:3}),c.jsx(wi,{objectName:xt,completed:t,pending:e,displayName:r},"other-write")]})}const yi=I.createContext(null);function Ii(){const e=I.useContext(yi);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function ld(e,t){return e!=null&&e[t]?e[t]:{name:ci,completed:!1}}function ud({children:e}){var C,j,T;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&&Qo(g,o),b=m!==null,y=!!((C=o==null?void 0:o.content)!=null&&C.write),v=y?ei(g):void 0,x=[...m||[]];v&&y&&x.push(v);const S=ld(x,s);return c.jsx(yi.Provider,{value:S==null?void 0:S.name,children:c.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:[c.jsxs(w.Box,{width:"20rem",children:[c.jsxs(w.Text,{children:[de(n)," integration"]}),c.jsx(w.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),b&&c.jsxs(w.Tabs,{index:s,onChange:u,orientation:"horizontal",children:[m.map(D=>{var z,oe,ee,J;return c.jsx(wi,{objectName:D.name,completed:D.completed,pending:((oe=(z=a[D.name])==null?void 0:z.read)==null?void 0:oe.isOptionalFieldsModified)||((J=(ee=a[D.name])==null?void 0:ee.read)==null?void 0:J.isRequiredMapFieldsModified)},D.name)}),y&&v&&c.jsx(dd,{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&&c.jsxs(c.Fragment,{children:[c.jsx(w.Divider,{marginTop:10,marginBottom:3}),c.jsx(Hc,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]})})}const Ct=()=>{const{appName:e}=V(),{objectConfigurationsState:t,setConfigureState:r}=io(),{selectedObjectName:n}=Ii(),o=ai(n||"",t);return{appName:e,configureState:o,setConfigureState:r,selectedObjectName:n}};function pd(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 vi(e,t,r,n){t(e,o=>pd(o,r,n))}function fd({field:e,onSelectChange:t,allFields:r}){var b;const{configureState:n,selectedObjectName:o,setConfigureState:a}=Ct(),[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&&vi(o,a,e.mapToName,e._default),u(!1)},[e,a,o,g,n]);const m=I.useMemo(()=>r==null?void 0:r.map(y=>c.jsx("option",{value:y.fieldName,children:y.displayName},y.fieldName)),[r]);return c.jsxs(w.Stack,{children:[c.jsx(w.Text,{fontWeight:"500",children:e.mapToDisplayName}),c.jsx(w.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),c.jsx(w.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(w.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[c.jsx(w.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),c.jsx(w.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:c.jsx(w.Divider,{marginLeft:2})})]})}function hd(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ct(),{isError:n,removeError:o}=Je(),a=u=>{const{value:p,name:g}=u.target;p&&(e&&vi(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(w.Box,{children:[c.jsx(Pr,{string:"Map the following fields (required)"}),c.jsx(w.Stack,{children:s.map(u=>{var p;return c.jsxs(w.FormControl,{isInvalid:n(G.MAPPING,u.mapToName),children:[c.jsx(fd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),c.jsx(w.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function gd(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=>gd(o,r,n))}function md(){var b,y;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ct(),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=(y=t==null?void 0:t.read)==null?void 0:y.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(w.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(w.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:c.jsx(w.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),s.map(v=>ze(v)?null:c.jsx(w.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:c.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 wd(){var n,o,a;const{configureState:e,selectedObjectName:t}=Ct(),{appName:r}=V();return c.jsxs(c.Fragment,{children:[c.jsx(Pr,{string:`${r} reads the following ${t} fields`}),c.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(s=>ze(s)?null:c.jsx(w.Tag,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function yd(){return c.jsxs(c.Fragment,{children:[c.jsx(wd,{}),c.jsx(hd,{}),c.jsx(md,{})]})}function Id(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=>{Id(o,r,n)})}function vd(){var b,y,v,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ct(),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,s=S=>{const{name:C,checked:j}=S.target;t&&r&&So(t,n,C,j)},u=S=>{var j,T;const{checked:C}=S.target;t&&r&&((T=(j=r==null?void 0:r.write)==null?void 0:j.writeObjects)==null||T.forEach(D=>{So(t,n,D.objectName,C)}))},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(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&&c.jsx(w.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:c.jsx(w.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),a.map(S=>c.jsx(w.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:c.jsx(w.Checkbox,{name:S.objectName,id:S.objectName,onChange:s,isChecked:!!(o!=null&&o[S.objectName]),children:S.displayName})},S.objectName))]})]})}function bd(){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(y){console.error("error uninstalling installation",y)}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(w.Stack,{children:[c.jsx(w.Text,{paddingBottom:3,children:b}),(o==null?void 0:o.id)&&c.jsx(w.Button,{onClick:g,variant:"warning",isDisabled:p,children:m})]})}function bi({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var S,C,j;const{hydratedRevision:o,loading:a}=Gt(),{configureState:s,selectedObjectName:u}=Ct(),p=((S=s==null?void 0:s.read)==null?void 0:S.isOptionalFieldsModified)||((C=s==null?void 0:s.read)==null?void 0:C.isRequiredMapFieldsModified),g=(j=s==null?void 0:s.write)==null?void 0:j.isWriteModified,y=a||r||!s||!u||!(p||g||n),v=u===xt,x=u===ci;return r?c.jsx(We,{}):c.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[c.jsxs(w.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[c.jsx(w.Button,{backgroundColor:"gray.800",_hover:{backgroundColor:"gray.600"},type:"submit",isDisabled:y,children:n?"Install":"Save"}),c.jsx(w.Button,{backgroundColor:"gray.200",color:"blackAlpha.700",_hover:{backgroundColor:"gray.300"},isDisabled:y,onClick:t,children:"Reset"})]}),c.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:[a&&c.jsx(We,{}),o&&!x&&!v&&c.jsx(yd,{}),o&&!x&&v&&c.jsx(vd,{}),!a&&x&&c.jsx(bd,{})]})]})}const Si=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:o,onUpdateSuccess:a}=Pe(),{hydratedRevision:s,loading:u}=Gt(),{selectedObjectName:p}=Ii(),{selectedConnection:g}=St(),m=X(),{projectId:b}=V(),{resetBoundary:y,setErrors:v}=Je(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:C}=io(),j=ai(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:s,loading:u,selectedObjectName:p,selectedConnection:g,apiKey:m,projectId:b,resetBoundary:y,setErrors:v,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:C,configureState:j,onInstallSuccess:o,onUpdateSuccess:a}},Sd=void 0;function xd(){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:y,objectConfigurationsState:v,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:C}=Si(),[j,T]=I.useState(!1),D=s===xt,z=I.useCallback(()=>{m(G.MAPPING),o!=null&&o.content&&!a&&s&&ni(o,Sd,s,y)},[m,o,a,s,y]);I.useEffect(()=>{!S&&(o!=null&&o.content)&&!a&&z()},[S,v,o,a,z]);const oe=()=>{const{requiredMapFields:ie,selectedFieldMappings:be}=(S==null?void 0:S.read)||{},{errorList:he}=ti(ie,be,b);he.length>0||(s&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(T(!0),Uc(g,e,t,r,u.id,s,p,o,S,n,C).finally(()=>{T(!1),x(s)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},ee=()=>{s&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&o?(T(!0),zc(g,e,t,r,u.id,p,o,S,n,C).finally(()=>{T(!1),x(s)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},J=ie=>{ie.preventDefault(),D?ee():oe()};return c.jsx(bi,{isCreateMode:!0,isLoading:j,onSave:J,onReset:z})}function Cd({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 Od=(e,t,r,n,o)=>{const a=oi(e),s=ii(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},Nd=(e,t,r,n,o,a,s,u,p,g)=>{const m=Od(a,n||"",u,u.schedule,p);return m?Cd({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))},Td=(e,t)=>{const n={content:{write:{objects:si(e)}}};return jr(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},Rd=(e,t,r,n,o,a,s,u)=>{const p=Td(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 _d({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:y,onUpdateSuccess:v}=Si(),[x,S]=I.useState(!1),C=a===xt,{config:j}=e,T=I.useCallback(()=>{p(G.MAPPING),n!=null&&n.content&&!o&&a&&ni(n,j,a,m)},[p,n,o,a,j,m]);I.useEffect(()=>{y||T()},[y,T]),I.useEffect(()=>{e&&T()},[e,T]);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(Te=>(Te==null?void 0:Te.objectName)===a)},[n,a]),z=()=>{const{requiredMapFields:J,selectedFieldMappings:ie}=(y==null?void 0:y.read)||{},{errorList:be}=ti(J,ie,g);be.length>0||(n&&e&&a&&s&&u&&D?(S(!0),Nd(u,t.id,e.id,a,s,y,r,D,n,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},oe=()=>{e&&a&&s&&u&&n?(S(!0),Rd(u,t.id,e.id,s,y,n,r,v).finally(()=>{S(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},ee=J=>{J.preventDefault(),C?oe():z()};return c.jsx(bi,{onSave:ee,onReset:T,isLoading:x})}function jd(){const{integrationObj:e,installation:t}=Pe();return e?t&&e?c.jsx(_d,{installation:t,integrationObj:e}):c.jsx(xd,{}):c.jsx(Fe,{message:"We can't load the integration"})}const Ad=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Ed({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:o,apiKey:a,hydratedRevision:s,setInstallation:u,onInstallSuccess:p}){const g=Ad(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 kd(){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 xi({text:e}){return c.jsx(w.Container,{children:c.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:[c.jsx(w.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:c.jsx(w.Box,{margin:"auto",children:c.jsx(kd,{})})}),c.jsx(w.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}function Fd({provider:e}){const t=`You have successfully installed your ${de(e)} integration.`;return c.jsx(xi,{text:t})}const Pd=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 Dd({children:e}){var C;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,y]=I.useState(!1),v=o||b,x=(C=n==null?void 0:n.content)==null?void 0:C.provider,S=Pd(n);return I.useEffect(()=>{!v&&n&&S&&!s&&m&&r&&(a!=null&&a.id)&&(y(!0),Ed({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,s,m,r,t,a==null?void 0:a.id,u,p,g,v]),a?v?c.jsx(We,{}):S&&x&&s?c.jsx(Fd,{provider:x}):c.jsx("div",{children:e}):c.jsx(Fe,{message:"We can't load the integration"})}function Bd({children:e}){return c.jsx(w.Container,{children:c.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 Ld({error:e}){return e?c.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[c.jsx(w.AlertIcon,{}),c.jsx(w.AlertDescription,{children:e})]}):null}function Md({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){const[o,a]=I.useState(!1),s=()=>a(!o),[u,p]=I.useState(""),g=y=>p(y.currentTarget.value),m=u.length>0,b=n||!m;return c.jsx(Bd,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Ld,{error:r}),c.jsx("br",{}),c.jsx(w.Stack,{spacing:4,children:c.jsxs(w.InputGroup,{size:"md",children:[c.jsx(w.Input,{onChange:g,pr:"4.5rem",type:o?"text":"password",placeholder:"API Key"}),c.jsx(w.InputRightElement,{width:"4.5rem",children:c.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:s,children:o?"Hide":"Show"})})]})}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:b,width:"100%",type:"submit",onClick:()=>{t(u)},children:"Next"})]})})}function $d({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,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(C=>{u(C)}).catch(C=>{console.error("Error loading provider info: ",C)})}},[v,e,g,r,t,o,n,p,u,b]);const x=S=>{y(S),m(!0)};return s===null?c.jsx(Md,{provider:e,handleSubmit:x,error:null}):a}function Ud({children:e}){return c.jsx(w.Container,{children:c.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 qd({error:e}){return e?c.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[c.jsx(w.AlertIcon,{}),c.jsx(w.AlertDescription,{children:e})]}):null}function Wd({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=C=>p(C.currentTarget.value),y=C=>m(C.currentTarget.value),v=u.length>0,x=g.length>0,S=n||!v||!x;return c.jsx(Ud,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(qd,{error:r}),c.jsx("br",{}),c.jsxs(w.Stack,{spacing:4,children:[c.jsx(w.Input,{placeholder:"Username",onChange:b}),c.jsxs(w.InputGroup,{size:"md",children:[c.jsx(w.Input,{onChange:y,pr:"4.5rem",type:o?"text":"password",placeholder:"Password"}),c.jsx(w.InputRightElement,{width:"4.5rem",children:c.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:s,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:S,width:"100%",type:"submit",onClick:()=>{t(u,g)},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,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(C=>{u(C)}).catch(C=>{console.error("Error loading provider info: ",C)})}},[v,e,g,r,t,o,n,p,b,u]);const x=(S,C)=>{y({user:S,pass:C}),m(!0)};return s===null?c.jsx(Wd,{provider:e,handleSubmit:x,error:null}):a}function Jd(e){const{selectedConnection:t}=St();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function Hd({onSuccess:e}){Jd(e)}function Kd({children:e}){return c.jsx(w.Container,{children:c.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 Gd({error:e}){return e?c.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[c.jsx(w.AlertIcon,{}),c.jsx(w.AlertDescription,{children:e})]}):null}function Vd({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return c.jsx(Kd,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Gd,{error:r}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function Xd({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 y=()=>{b(!0)};return s===null?c.jsx(Vd,{provider:e,handleSubmit:y,error:null}):a}function Vt({children:e}){return c.jsx(w.Container,{children:c.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?c.jsxs(w.Alert,{status:"error",marginTop:"2em",children:[c.jsx(w.AlertIcon,{}),c.jsx(w.AlertDescription,{children:e})]}):null}function Yd({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=C=>u(C.currentTarget.value),y=C=>g(C.currentTarget.value),v=s.length>0,x=p.length>0,S=n||!v||!x;return c.jsx(Vt,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsxs(w.Stack,{spacing:4,children:[c.jsx(w.Input,{placeholder:"Client ID",onChange:y}),c.jsxs(w.InputGroup,{size:"md",children:[c.jsx(w.Input,{onChange:b,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),c.jsx(w.InputRightElement,{width:"4.5rem",children:c.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:m,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:S,width:"100%",type:"submit",onClick:()=>{t({clientId:p,clientSecret:s})},children:"Next"})]})})}function Zd({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 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=>{s(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?c.jsx(Yd,{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 y={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:s,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,Co=600,Qd="AUTHORIZATION_SUCCEEDED",el="AUTHORIZATION_FAILED";function tl(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 rl(e,t,r,n){return I.useCallback(()=>{if(!n)return;const o=window.screenX+(window.outerWidth-xo)/2,a=window.screenY+(window.outerHeight-Co)/2.5,s=`width=${xo},height=${Co},left=${o},top=${a}`,u=window.open(n,e,s);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function nl(e){return I.useCallback(t=>{var r;if(t.origin===wc){if(t.data.eventType===Qd){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===el&&console.error("OAuth failed: ",{event:t})}},[e])}function Oi({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=nl(u),y=rl(r,g,b,t),v=tl(a,o,m);I.useEffect(()=>{t&&!p&&y()},[t,p,y,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 ol({provider:e,handleSubmit:t,error:r,isButtonDisabled:n}){return c.jsx(Vt,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}function il({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")}},y=I.useCallback(v=>{m(v),p(null)},[]);return c.jsx(Oi,{windowTitle:`Connect to ${de(e)}`,oauthUrl:u,onClose:y,children:c.jsx(ol,{provider:e,handleSubmit:b,error:g})})}function al({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(""),y=()=>a(!o),v=z=>u(z.currentTarget.value),x=z=>g(z.currentTarget.value),S=z=>b(z.currentTarget.value),C=s.length>0,j=p.length>0,T=m.length>0,D=n||!C||!j||!T;return c.jsx(Vt,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:`Set up ${de(e)} integration`})}),c.jsx(Xt,{error:r}),c.jsx("br",{}),c.jsxs(w.Stack,{spacing:4,children:[c.jsx(w.Input,{placeholder:"MyWorkspace",onChange:S}),c.jsx(w.Input,{placeholder:"Client ID",onChange:x}),c.jsxs(w.InputGroup,{size:"md",children:[c.jsx(w.Input,{onChange:v,pr:"4.5rem",type:o?"text":"password",placeholder:"Client Secret"}),c.jsx(w.InputRightElement,{width:"4.5rem",children:c.jsx(w.Button,{h:"1.75rem",size:"sm",onClick:y,children:o?"Hide":"Show"})})]})]}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:!D,width:"100%",type:"submit",onClick:()=>{t({workspace:m,clientId:p,clientSecret:s})},children:"Next"})]})})}function sl({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 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=>{s(x)}).catch(x=>{console.error("Error loading provider info: ",x),m("Error loading provider info")})};return a===null?c.jsx(al,{provider:e,handleSubmit:b,error:g}):c.jsx("em",{children:"Loading..."})}function cl(){const e=I.useContext(Bi.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var Ni=I.createContext({});Ni.displayName="ColorModeContext";function Ti(){const e=I.useContext(Ni);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function dl(){const e=Ti(),t=cl();return{...e,theme:t}}var ll=(...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 ul(e)?e(...t):e}var ul=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]",y="[object Error]",v="[object Function]",x="[object GeneratorFunction]",S="[object Map]",C="[object Number]",j="[object Null]",T="[object Object]",D="[object Proxy]",z="[object RegExp]",oe="[object Set]",ee="[object String]",J="[object Undefined]",ie="[object WeakMap]",be="[object ArrayBuffer]",he="[object DataView]",Te="[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*)$/,M={};M[Te]=M[st]=M[Br]=M[Lr]=M[Mr]=M[$r]=M[Ur]=M[qr]=M[Wr]=!0,M[u]=M[p]=M[be]=M[m]=M[he]=M[b]=M[y]=M[v]=M[S]=M[C]=M[T]=M[z]=M[oe]=M[ee]=M[ie]=!1;var Yt=typeof qe=="object"&&qe&&qe.Object===Object&&qe,$=typeof self=="object"&&self&&self.Object===Object&&self,De=Yt||$||Function("return this")(),Zt=t&&!t.nodeType&&t,te=Zt&&!0&&e&&!e.nodeType&&e,Ot=te&&te.exports===Zt,ct=Ot&&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,O=Array(i);++f<i;)O[f]=d(f);return O}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=Ot?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,Re=Date.now,At=Dt(De,"Map"),Ke=Dt(Object,"create"),en=function(){function i(){}return function(d){if(!je(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 O=i[d];this.set(O[0],O[1])}}function Ge(){this.__data__=Ke?Ke(null):{},this.size=0}function Et(i){var d=this.has(i)&&delete this.__data__[i];return this.size-=d?1:0,d}function kt(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=Et,ge.prototype.get=kt,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 O=i[d];this.set(O[0],O[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 O=d.length-1;return f==O?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__,O=ft(f,i);return O<0?(++this.size,f.push([i,d])):f[O][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 O=i[d];this.set(O[0],O[1])}}function _e(){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),O=f.size;return f.set(i,d),this.size+=f.size==O?0:1,this}xe.prototype.clear=_e,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 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 O=f.__data__;if(!At||O.length<r-1)return O.push([i,d]),this.size=++f.size,this;f=this.__data__=new xe(O)}return f.set(i,d),this.size=f.size,this}Le.prototype.clear=we,Le.prototype.delete=ln,Le.prototype.get=un,Le.prototype.has=pn,Le.prototype.set=fn;function hn(i,d){var f=Ie(i),O=!f&&Lt(i),N=!f&&!O&&Qe(i),A=!f&&!O&&!N&&$t(i),F=f||O||N||A,E=F?er(i.length,String):[],k=E.length;for(var U in i)F&&(U=="length"||N&&(U=="offset"||U=="parent")||A&&(U=="buffer"||U=="byteLength"||U=="byteOffset")||Bt(U,k))||E.push(U);return E}function ye(i,d,f){(f!==void 0&&!wt(i[d],f)||f===void 0&&!(d in i))&&Pt(i,d,f)}function gn(i,d,f){var O=i[d];(!(Se.call(i,d)&&wt(O,f))||f===void 0&&!(d in i))&&Pt(i,d,f)}function ft(i,d){for(var f=i.length;f--;)if(wt(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)?On(i):_n(i)}function Xe(i){return $e(i)&&ht(i)==u}function wn(i){if(!je(i)||lr(i))return!1;var d=Mt(i)?pt:Jr;return d.test(kn(i))}function yn(i){return $e(i)&&It(i.length)&&!!M[ht(i)]}function Ce(i){if(!je(i))return Me(i);var d=Ze(i),f=[];for(var O in i)O=="constructor"&&(d||!Se.call(i,O))||f.push(O);return f}function sr(i,d,f,O,N){i!==d&&mn(d,function(A,F){if(N||(N=new Le),je(A))In(i,d,F,f,sr,O,N);else{var E=O?O(ue(i,F),A,F+"",i,d,N):void 0;E===void 0&&(E=A),ye(i,F,E)}},Ut)}function In(i,d,f,O,N,A,F){var E=ue(i,f),k=ue(d,f),U=F.get(k);if(U){ye(i,f,U);return}var q=A?A(E,k,f+"",i,d,F):void 0,K=q===void 0;if(K){var Z=Ie(k),Q=!Z&&Qe(k),ve=!Z&&!Q&&$t(k);q=k,Z||Q||ve?Ie(E)?q=E:Fn(E)?q=Cn(E):Q?(K=!1,q=Sn(k)):ve?(K=!1,q=gt(k)):q=[]:ur(k)||Lt(k)?(q=E,Lt(E)?q=et(E):(!je(E)||Mt(E))&&(q=Nn(k))):K=!1}K&&(F.set(k,q),N(q,k,O,A,F),F.delete(k)),ye(i,f,q)}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 Cn(i,d){var f=-1,O=i.length;for(d||(d=Array(O));++f<O;)d[f]=i[f];return d}function Ye(i,d,f,O){var N=!f;f||(f={});for(var A=-1,F=d.length;++A<F;){var E=d[A],k=void 0;k===void 0&&(k=i[E]),N?Pt(f,E,k):gn(f,E,k)}return f}function cr(i){return vn(function(d,f){var O=-1,N=f.length,A=N>1?f[N-1]:void 0,F=N>2?f[2]:void 0;for(A=i.length>3&&typeof A=="function"?(N--,A):void 0,F&&Tn(f[0],f[1],F)&&(A=N<3?void 0:A,N=1),d=Object(d);++O<N;){var E=f[O];E&&i(d,E,O,A)}return d})}function dr(i){return function(d,f,O){for(var N=-1,A=Object(d),F=O(d),E=F.length;E--;){var k=F[++N];if(f(A[k],k,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 wn(f)?f:void 0}function On(i){var d=Se.call(i,le),f=i[le];try{i[le]=void 0;var O=!0}catch{}var N=rr.call(i);return O&&(d?i[le]=f:delete i[le]),N}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(!je(f))return!1;var O=typeof d;return(O=="number"?yt(f)&&Bt(d,f.length):O=="string"&&d in f)?wt(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 O=arguments,N=-1,A=ir(O.length-d,0),F=Array(A);++N<A;)F[N]=O[d+N];N=-1;for(var E=Array(d+1);++N<d;)E[N]=O[N];return E[d]=f(F),Qt(i,this,E)}}function ue(i,d){if(!(d==="constructor"&&typeof i[d]=="function")&&d!="__proto__")return i[d]}var An=En(bn);function En(i){var d=0,f=0;return function(){var O=Re(),N=a-(O-f);if(f=O,N>0){if(++d>=o)return arguments[0]}else d=0;return i.apply(void 0,arguments)}}function kn(i){if(i!=null){try{return ut.call(i)}catch{}try{return i+""}catch{}}return""}function wt(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 yt(i){return i!=null&&It(i.length)&&!Mt(i)}function Fn(i){return $e(i)&&yt(i)}var Qe=or||l;function Mt(i){if(!je(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 je(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)!=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&&ut.call(f)==Zr}var $t=dt?Kr(dt):yn;function et(i){return Ye(i,Ut(i))}function Ut(i){return yt(i)?hn(i):Ce(i)}var Pn=cr(function(i,d,f,O){sr(i,d,f,O)});function Dn(i){return function(){return i}}function pr(i){return i}function l(){return!1}e.exports=Pn})(Tr,Tr.exports);var pl=Tr.exports;const ke=eo(pl);var fl=e=>/!(important)?$/.test(e),Oo=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,hl=(e,t)=>r=>{const n=String(t),o=fl(n),a=Oo(n),s=e?`${e}.${a}`:a;let u=ot(r.__cssMap)&&s in r.__cssMap?r.__cssMap[s].varRef:t;return u=Oo(u),o?`${u} !important`:u};function ao(e){const{scale:t,transform:r,compose:n}=e;return(a,s)=>{var u;const p=hl(t,a)(s);let g=(u=r==null?void 0:r(p,s))!=null?u:p;return n&&(g=n(g,s)),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 gl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function ml(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:gl(t),transform:r?ao({scale:r,compose:n}):n}}var Ri=["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 wl(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...Ri].join(" ")}function yl(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...Ri].join(" ")}var Il={"--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(" ")},vl={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 bl(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 Sl={"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"},xl=new Set(Object.values(Gn)),Vn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),Cl=e=>e.trim();function Ol(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(Cl).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(xl.has(y))return y;const v=y.indexOf(" "),[x,S]=v!==-1?[y.substr(0,v),y.substr(v+1)]:[y],C=Xn(S)?S:S&&S.split(" "),j=`colors.${x}`,T=j in t.__cssMap?t.__cssMap[j].varRef:x;return C?[T,...Array.isArray(C)?C:[C]].join(" "):T});return`${u}(${b.join(", ")})`}var Xn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Nl=(e,t)=>Ol(e,t??{});function Tl(e){return/^var\(--.+\)$/.test(e)}var Rl=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Oe=e=>t=>`${e}(${t})`,P={filter(e){return e!=="auto"?e:Il},backdropFilter(e){return e!=="auto"?e:vl},ring(e){return bl(P.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?wl():e==="auto-gpu"?yl():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=Rl(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(Tl(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Nl,blur:Oe("blur"),opacity:Oe("opacity"),brightness:Oe("brightness"),contrast:Oe("contrast"),dropShadow:Oe("drop-shadow"),grayscale:Oe("grayscale"),hueRotate:e=>Oe("hue-rotate")(P.degree(e)),invert:Oe("invert"),saturate:Oe("saturate"),sepia:Oe("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=Sl[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",yr(P.vh,P.px)),spaceT:pe("space",yr(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",yr(P.vh,P.px)),sizesT:pe("sizes",yr(P.vh,P.fraction)),shadows:pe("shadows"),logical:ml,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 _l={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 jl={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 _i={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},Al={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 El={listStyleType:!0,listStylePosition:!0,listStylePos:h.prop("listStylePosition"),listStyleImage:!0,listStyleImg:h.prop("listStyleImage")};function kl(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 Fl=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}},Pl=Fl(kl),Dl={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Bl={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},$n=(e,t,r)=>{const n={},o=Pl(e,t,{});for(const a in o)a in r&&r[a]!=null||(n[a]=o[a]);return n},Ll={srOnly:{transform(e){return e===!0?Dl:e==="focusable"?Bl:{}}},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 Ml={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")},W={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(W,{m:W.margin,mt:W.marginTop,mr:W.marginRight,me:W.marginInlineEnd,marginEnd:W.marginInlineEnd,mb:W.marginBottom,ml:W.marginLeft,ms:W.marginInlineStart,marginStart:W.marginInlineStart,mx:W.marginX,my:W.marginY,p:W.padding,pt:W.paddingTop,py:W.paddingY,px:W.paddingX,pb:W.paddingBottom,pl:W.paddingLeft,ps:W.paddingInlineStart,paddingStart:W.paddingInlineStart,pr:W.paddingRight,pe:W.paddingInlineEnd,paddingEnd:W.paddingInlineEnd});var $l={textDecorationColor:h.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:h.shadows("textShadow")},Ul={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")},ql={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")},Wl={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"}},zl={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 ji(e){return ot(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(ji).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=ji(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 Jl(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}=Jl(e);return t||typeof e=="number"?`${e}px`:e}function Hl(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=>Ai(t=>e(t,"&"),"[role=group]","[data-group]",".group"),Ee=e=>Ai(t=>e(t,"~ &"),"[data-peer]",".peer"),Ai=(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:Ee(Y.hover),_groupFocus:Ue(Y.focus),_peerFocus:Ee(Y.focus),_groupFocusVisible:Ue(Y.focusVisible),_peerFocusVisible:Ee(Y.focusVisible),_groupActive:Ue(Y.active),_peerActive:Ee(Y.active),_groupDisabled:Ue(Y.disabled),_peerDisabled:Ee(Y.disabled),_groupInvalid:Ue(Y.invalid),_peerInvalid:Ee(Y.invalid),_groupChecked:Ue(Y.checked),_peerChecked:Ee(Y.checked),_groupFocusWithin:Ue(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]"},Kl=Object.keys(so),co=ke({},br,B,_l,Rr,fe,jl,Ml,Al,_i,Ll,Jt,Yn,W,zl,Wl,$l,Ul,El,ql);Object.assign({},W,fe,Rr,_i,Jt);var Gl=[...Object.keys(co),...Kl],Vl={...co,...so},Xl=e=>e in Vl,Yl=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 Zl(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 Ql(e){return/^var\(--.+\)$/.test(e)}var eu=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!Ql(t),tu=(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]=Zl(t);return t=(n=(r=o(s))!=null?r:a(u))!=null?n:a(t),t};function ru(e){const{configs:t={},pseudos:r={},theme:n}=e,o=(a,s=!1)=>{var u,p,g;const m=nt(a,n),b=Yl(m)(n);let y={};for(let v in b){const x=b[v];let S=nt(x,n);v in r&&(v=r[v]),eu(v,S)&&(S=tu(n,S));let C=t[v];if(C===!0&&(C={property:v}),ot(S)){y[v]=(u=y[v])!=null?u:{},y[v]=ke({},y[v],o(S,!0));continue}let j=(g=(p=C==null?void 0:C.transform)==null?void 0:p.call(C,S,n,m))!=null?g:S;j=C!=null&&C.processResult?o(j,!0):j;const T=nt(C==null?void 0:C.property,n);if(!s&&(C!=null&&C.static)){const D=nt(C.static,n);y=ke({},y,D)}if(T&&Array.isArray(T)){for(const D of T)y[D]=j;continue}if(T){T==="&"&&ot(j)?y=ke({},y,j):y[T]=j;continue}if(ot(j)){y=ke({},y,j);continue}y[v]=j}return y};return o}var nu=e=>t=>ru({theme:t,pseudos:so,configs:co})(e);function ou(e,t){if(Array.isArray(e))return e;if(ot(e))return t(e);if(e!=null)return[e]}function iu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function au(e){const t=e.__breakpoints;return function(n,o,a,s){var u,p;if(!t)return;const g={},m=ou(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],C=t.details[iu(m,x)],j=Hl(S.minW,C==null?void 0:C._minW),T=nt((u=n[o])==null?void 0:u[m[x]],s);if(T){if(v){(p=n.parts)==null||p.forEach(D=>{ke(g,{[D]:y?T[D]:{[j]:T[D]}})});continue}if(!v){y?ke(g,T):g[j]=T;continue}g[j]=T}}return g}}function su(e){return t=>{var r;const{variant:n,size:o,theme:a}=t,s=au(a);return ke({},nt((r=e.baseStyle)!=null?r:{},t),s(e,"sizes",o,t),s(e,"variants",n,t))}}function cu(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function du(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 lu=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}},uu=lu(du);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 ki=e=>Ei(e,t=>t!=null);function pu(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function fu(e,...t){return pu(e)?e(...t):e}var hu=typeof Element<"u",gu=typeof Map=="function",mu=typeof Set=="function",wu=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(gu&&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(mu&&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(wu&&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(hu&&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 yu=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 Iu=eo(yu);function vu(e,t={}){var r;const{styleConfig:n,...o}=t,{theme:a,colorMode:s}=dl(),u=uu(a,`components.${e}`),p=n||u,g=ke({theme:a,colorMode:s},(r=p==null?void 0:p.defaultProps)!=null?r:{},ki(cu(o,["children"]))),m=I.useRef({});if(p){const y=su(p)(g);Iu(m.current,y)||(m.current=y)}return m.current}function bu(e,t={}){return vu(e,t)}var Su=new Set([...Gl,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),xu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Cu(e){return xu.has(e)||!Su.has(e)}function Ou(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,Nu=(Ao=uo.default)!=null?Ao:uo,Tu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:o,sx:a,...s}=t,u=Ei(s,(b,y)=>Xl(y)),p=fu(e,t),g=Ou({},o,p,ki(u),a),m=nu(g)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Cu);const o=Tu({baseStyle:r}),a=Nu(e,n)(o);return I.forwardRef(function(p,g){const{colorMode:m,forced:b}=Ti();return I.createElement(a,{ref:g,"data-theme":b?m:void 0,...p})})}function Ru(){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 Eo=Ru();function Fi(e){return I.forwardRef(e)}var ko={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"},Pi=Fi((e,t)=>{const{as:r,viewBox:n,color:o="currentColor",focusable:a=!1,children:s,className:u,__css:p,...g}=e,m=ll("chakra-icon",u),b=bu("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??ko.viewBox;if(r&&typeof r!="string")return c.jsx(Eo.svg,{as:r,...v,...g});const S=s??ko.path;return c.jsx(Eo.svg,{verticalAlign:"middle",viewBox:x,...v,...g,children:S})});Pi.displayName="Icon";function _u(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:o={}}=e,a=I.Children.toArray(e.path),s=Fi((u,p)=>c.jsx(Pi,{ref:p,viewBox:t,...o,...u,children:a.length?a:c.jsx("path",{fill:"currentColor",d:r})}));return s.displayName=n,s}var ju=_u({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 Au="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function Eu({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return c.jsx(Vt,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsx(w.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),c.jsxs(w.Link,{href:Au,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",c.jsx(ju,{mx:"2px"})]}),c.jsx(Xt,{error:r}),c.jsxs(w.Flex,{marginTop:"1em",children:[c.jsx(w.Input,{placeholder:"MyDomain",onChange:o=>t(o.currentTarget.value)}),c.jsx(w.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function ku({provider:e,handleSubmit:t,setWorkspace:r,error:n,isButtonDisabled:o}){return c.jsx(Vt,{children:c.jsxs(w.FormControl,{children:[c.jsx(w.FormLabel,{marginTop:"16",marginBottom:"0",children:c.jsxs(w.Heading,{as:"h4",size:"md",children:["Enter your ",de(e)," workspace"]})}),c.jsx(Xt,{error:n}),c.jsx(w.Flex,{marginTop:"1em",children:c.jsx(w.Input,{placeholder:"MyWorkspace",onChange:a=>r(a.currentTarget.value)})}),c.jsx("br",{}),c.jsx(w.Button,{isDisabled:o,width:"100%",type:"submit",onClick:t,children:"Next"})]})})}const Fu="salesforce";function Pu({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,y]=I.useState(null),v=async()=>{if(y(null),!u){y("Workspace is required");return}try{const C=await Ci(a,t,n,s,e,u,r,o);m(C)}catch(C){console.error(C),y((C==null?void 0:C.message)??"Unexpected error")}},x=I.useCallback(C=>{y(C),m(null)},[]),S=e===Fu?c.jsx(Eu,{handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0}):c.jsx(ku,{provider:e,handleSubmit:v,setWorkspace:p,error:b,isButtonDisabled:u.length===0});return c.jsx(Oi,{windowTitle:`Connect to ${de(e)}`,oauthUrl:g,onClose:x,children:S})}function Du({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(Pu,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):c.jsx(il,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a}):p==="clientCredentials"?g?c.jsx(sl,{provider:e,consumerRef:r,consumerName:n,groupRef:o,groupName:a,setSelectedConnection:u,selectedConnection:s}):c.jsx(Zd,{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 Bu=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 Di({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:y,connections:v}=St();Hd({onSuccess:s});const x=e||m;if(I.useEffect(()=>{if(!b&&v&&v.length>0){const[S]=v;y(S)}Bu(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?c.jsx("strong",{children:"Provider not found"}):p.authType==="none"?c.jsx(Xd,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="basic"?c.jsx(zd,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):p.authType==="apiKey"?c.jsx($d,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:b,groupRef:n,groupName:o,children:a}):c.jsx(Du,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:o,setSelectedConnection:y,selectedConnection:b})}function Lu({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(Fe,{message:"Something went wrong, couldn't find integration information"}):c.jsx(Nc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onInstallSuccess:a,onUpdateSuccess:s,children:c.jsx(Zo,{groupRef:n,children:c.jsx(Di,{consumerRef:t,consumerName:r,groupRef:n,groupName:o,children:c.jsx(Kc,{projectId:u,children:c.jsx(Dd,{children:c.jsx(ad,{children:c.jsx(ud,{children:c.jsx(jd,{})})})})})})})})}function Mu({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?c.jsx(w.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:c.jsx(We,{message:"Redirecting..."})}):t}function $u({provider:e}){const{appName:t}=V(),r=`You have successfully connected your ${de(e)} account to ${t}.`;return c.jsx(xi,{text:r})}function Uu({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,redirectUrl:a,onSuccess:s}){return c.jsx(Zo,{provider:e,groupRef:n,children:c.jsx(Di,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:o,onSuccess:s,children:c.jsx(Mu,{redirectURL:a,children:c.jsx($u,{provider:e})})})})}const qu=(e,t)=>{const r=X(),{projectId:n}=V(),{integrations:o}=Ko(),[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=Vo;exports.AmpersandProvider=xc;exports.ConnectProvider=Uu;exports.InstallIntegration=Lu;exports.useAmpersandProvider=Cc;exports.useIsIntegrationInstalled=qu;
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;