@amp-labs/react 1.12.1 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/amp-react.cjs.js +43 -3
- package/build/amp-react.es.js +7563 -6281
- package/build/style.css +1 -0
- package/package.json +10 -3
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),I=require("react"),y=require("@chakra-ui/react"),$o=require("@emotion/react"),ui=require("@emotion/styled"),qo={primary:{bg:"black",color:"white",_hover:{bg:"gray.700",_disabled:{bg:"gray.600"}},_disabled:{bg:"gray.600",color:"gray.300",cursor:"not-allowed",opacity:1}},warning:{bg:"red.50",outline:"2px solid red.100",outlineOffset:"0",borderColor:"red.100",color:"red.800",_hover:{bg:"red.100"}}},Wo=y.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.200"},_selected:{color:"black",fontWeight:"500",bg:"gray.100",border:"none",_hover:{bg:"gray.200"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.100"},_selected:{color:"red.800",fontWeight:"500",bg:"red.50",border:"none",_hover:{bg:"red.100"}}}}},Button:{variants:qo}}}),zo=y.extendTheme(Wo);function Jo({children:e}){return s.jsx(y.ChakraProvider,{theme:zo,children:e})}const Fi=I.createContext(null),Ho=Fi.Provider,ee=()=>{const e=I.useContext(Fi);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var V=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e))(V||{});const Pi=I.createContext(void 0);function We(){const e=I.useContext(Pi);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Xo=(()=>{const e={};return Object.values(V).forEach(t=>{e[t]={}}),e})();function Go({children:e}){const[t,r]=I.useState(Xo),n=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},w[h][m]=!0,w})},[r]),i=I.useCallback((h,m)=>{var v;return!!((v=t[h])!=null&&v[m])},[t]),a=I.useCallback((h,m)=>{r(v=>{var b;const w={...v};return(b=w[h])==null||delete b[m],w})},[r]),c=I.useCallback(h=>{r(m=>{const v={...m};return v[h]={},v})},[r]),u=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},m.forEach(b=>{w[h][b]=!0}),w})},[r]),p=I.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:i,removeError:a,resetBoundary:c,setErrors:u}),[t,r,n,i,a,c,u]);return s.jsx(Pi.Provider,{value:p,children:e})}function Ce({message:e}){return s.jsx(y.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:s.jsxs(y.Stack,{alignItems:"center",children:[s.jsx(y.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&s.jsx(y.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Fe({message:e}){return s.jsxs(y.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(y.Box,{boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center","align-self":"stretch",padding:"12px 50px 12px 50px",borderRadius:"8px",border:"2px solid #FECACA",background:"#FEF2F2",children:s.jsx(y.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Vo="https://api.withampersand.com/v1".replace(/\/+$/,"");class Di{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Vo}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Bi}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 Yo=new Di,_r=class _r{constructor(t=Yo){this.configuration=t,this.fetchApi=async(r,n)=>{let i={url:r,init:n};for(const c of this.middleware)c.pre&&(i=await c.pre({fetch:this.fetchApi,...i})||i);let a;try{a=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(c){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:c,response:a?a.clone():void 0})||a);if(a===void 0)throw c instanceof Error?new ta(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:i.url,init:i.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:i}=await this.createFetchParams(t,r),a=await this.fetchApi(n,i);if(a&&a.status>=200&&a.status<300)return a;throw new ea(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 i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(h=>i[h]===void 0?delete i[h]:{});const a=typeof r=="function"?r:async()=>r,c={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},u={...c,...await a({init:c,context:t})},p={...u,body:Qo(u.body)||u.body instanceof URLSearchParams||Zo(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 ae=_r;function Zo(e){return typeof Blob<"u"&&e instanceof Blob}function Qo(e){return typeof FormData<"u"&&e instanceof FormData}class ea extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class ta 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 Bi(e,t=""){return Object.keys(e).map(r=>Li(r,e[r],t)).filter(r=>r.length>0).join("&")}function Li(e,t,r=""){const n=r+(r.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${i}`}if(t instanceof Set){const i=Array.from(t);return Li(e,i,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Bi(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function Qn(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class K{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class Pe{constructor(t){this.raw=t}async value(){}}class ra{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function na(e){return ia(e)}function ia(e,t){return e==null?e:{fieldUsed:N(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:N(e,"keyFormat")?e.keyFormat:void 0}}function oa(e){return aa(e)}function aa(e,t){return e==null?e:{name:e.name,valuePrefix:N(e,"valuePrefix")?e.valuePrefix:void 0}}function sa(e){return ca(e)}function ca(e,t){return e==null?e:{name:e.name}}function da(e){return la(e)}function la(e,t){return e==null?e:{attachmentType:e.attachmentType,query:N(e,"query")?sa(e.query):void 0,header:N(e,"header")?oa(e.header):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function ua(e){return pa(e)}function pa(e,t){return e}function fa(e){return ha(e)}function ha(e,t){return e==null?e:{days:N(e,"days")?e.days:void 0,fullHistory:N(e,"fullHistory")?e.fullHistory:void 0}}function Ki(e){return ga(e)}function ga(e,t){return e==null?e:{defaultPeriod:fa(e.defaultPeriod)}}function ma(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ya(e){if(e!==void 0)return e===null?null:{defaultPeriod:ma(e.defaultPeriod)}}function wa(e){return Ia(e)}function Ia(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Mi(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function va(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:ya(e.backfill)}}function ba(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,va)}}function Sa(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function xa(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,Sa)}}function Oa(e){return Ca(e)}function Ca(e,t){return e==null?e:{apiKeyAsBasic:N(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:N(e,"apiKeyAsBasicOpts")?na(e.apiKeyAsBasicOpts):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function Na(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function gr(e){return Ta(e)}function Ta(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 Ra(e){return _a(e)}function _a(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Aa(e){return ja(e)}function ja(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")?wa(e.proxy):void 0}}function Ui(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Mi(e.proxy)}}function ka(e){return Ea(e)}function Ea(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Aa(e.content)}}function Fa(e){return Pa(e)}function Pa(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 $i(e){return Da(e)}function Da(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 Ba(e)}function Ba(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 La(e)}function La(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:$i(e.group),consumer:Fa(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:N(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Ma(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Ua(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Ma(e.metadata)}}function $a(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function qa(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Ui(e.content)}}function Wa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:qa(e.config)}}function za(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Ja(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:za(e.latestRevision)}}function Ha(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Xa(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 Ga(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Va(e){return Ya(e)}function Ya(e,t){return e==null?e:{mode:N(e,"mode")?e.mode:void 0,pageSize:N(e,"pageSize")?e.pageSize:void 0}}function Za(e){return Qa(e)}function Qa(e,t){return e==null?e:{url:N(e,"url")?e.url:void 0,headers:N(e,"headers")?e.headers:void 0}}function es(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return ts(e)}function ts(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:Za(e.metadata),createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function rs(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function ns(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function is(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function os(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:rs(e.basicAuth),oauth2ClientCredentials:ns(e.oauth2ClientCredentials),oauth2Password:is(e.oauth2Password)}}function as(e){return ss(e)}function ss(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function cs(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function qi(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 ds(e)}function ds(e,t){return e==null?e:{...cs(e),...qi(e)}}function Wi(e){return ls(e)}function ls(e,t){return e}function us(e){return ps(e)}function ps(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")?Wi(e.optionalFieldsAuto):void 0,allFields:N(e,"allFields")?e.allFields.map(Bn):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0}}function fs(e){return hs(e)}function hs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(us):void 0}}function gs(e){return ms(e)}function ms(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ys(e){return ws(e)}function ws(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(gs):void 0}}function Is(e){return vs(e)}function vs(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?fs(e.read):void 0,write:N(e,"write")?ys(e.write):void 0,proxy:N(e,"proxy")?as(e.proxy):void 0}}function bs(e){return Ss(e)}function Ss(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Is(e.content)}}function xs(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 Os(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Ui(e.content)}}function Cs(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:xs(e.connection),config:Os(e.config)}}function $t(e){return Ns(e)}function Ns(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:N(e,"group")?$i(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:ka(e.config)}}function Ts(e){return Rs(e)}function Rs(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function _s(e,t){return e==null?e:{fieldName:e.fieldName}}function pi(e){return As(e)}function As(e,t){return e==null?e:{..._s(e),...qi(e)}}function js(e){return ks(e)}function ks(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(pi):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(pi):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Wi(e.optionalFieldsAuto):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0,delivery:N(e,"delivery")?Va(e.delivery):void 0}}function Es(e){return Fs(e)}function Fs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(js):void 0}}function Ps(e){return Ds(e)}function Ds(e,t){return e==null?e:{objectName:e.objectName}}function Bs(e){return Ls(e)}function Ls(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Ps):void 0}}function Ks(e){return Ms(e)}function Ms(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?Es(e.read):void 0,write:N(e,"write")?Bs(e.write):void 0,proxy:N(e,"proxy")?Ts(e.proxy):void 0}}function Us(e){return $s(e)}function $s(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ks(e.content)}}function fi(e){return qs(e)}function qs(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:Us(e.latestRevision)}}function Ws(e){return zs(e)}function zs(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 Js(e){return Hs(e)}function Hs(e,t){return e==null?e:{timestamp:e.timestamp,message:Ws(e.message),severity:e.severity}}function Xs(e){return Gs(e)}function Gs(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Vs(e){return Ys(e)}function Ys(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Zs(e){return Qs(e)}function Qs(e,t){return e==null?e:{regular:N(e,"regular")?Vs(e.regular):void 0,darkMode:N(e,"darkMode")?Xs(e.darkMode):void 0}}function ec(e){return tc(e)}function tc(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 rc(e){return nc(e)}function nc(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:ec(e.tokenMetadataFields),docsURL:N(e,"docsURL")?e.docsURL:void 0,authURLParams:N(e,"authURLParams")?e.authURLParams:void 0}}function ic(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 hi(e){return oc(e)}function oc(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 ac(e){return sc(e)}function sc(e,t){return e==null?e:{bulkWrite:Ra(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function gi(e){return cc(e)}function cc(e,t){return e==null?e:{name:e.name,authType:ua(e.authType),baseURL:e.baseURL,oauth2Opts:N(e,"oauth2Opts")?rc(e.oauth2Opts):void 0,apiKeyOpts:N(e,"apiKeyOpts")?da(e.apiKeyOpts):void 0,basicOpts:N(e,"basicOpts")?Oa(e.basicOpts):void 0,support:ac(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")?Zs(e.media):void 0,labels:N(e,"labels")?e.labels:void 0}}function dc(e){return lc(e)}function lc(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function uc(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:es(e.metadata)}}function pc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:uc(e.destination)}}function fc(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:ba(e.read),write:xa(e.write),proxy:Mi(e.proxy)}}function hc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:fc(e.content)}}function gc(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:hc(e.config)}}function mc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:gc(e.installation)}}function yc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function wc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:yc(e.project)}}function Ic(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 vc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:Ic(e.providerApp)}}class bc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:os(t.generateConnectionParams)},r);return new K(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:i,query:n},r);return new K(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 i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(vr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class Sc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/consumers".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ka(t.consumer)},r);return new Pe(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class xc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ua(t.destination)},r);return new K(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"DELETE",headers:i,query:n},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationName}",encodeURIComponent(String(t.destinationName))),method:"GET",headers:i,query:n},r);return new K(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:pc(t.destinationUpdate)},r);return new K(a,c=>mr(c))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class Oc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/groups".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:$a(t.group)},r);return new Pe(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class Cc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:Wa(t.installation)},r);return new K(a,c=>$t(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:"DELETE",headers:i,query:n},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:"GET",headers:i,query:n},r);return new K(a,c=>$t(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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:Cs(t.installation)},r);return new K(a,c=>$t(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 i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const 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:i,query:n},r);return new K(a,c=>c.map($t))}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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:mc(t.installationUpdate)},r);return new K(a,c=>$t(c))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class Nc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:n,body:Na(t.batchUpsertIntegrationsRequest)},r);return new K(a,c=>c.map(fi))}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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ja(t.integration)},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:i,query:n},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(fi))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class Tc extends ae{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={},i={};i["Content-Type"]="application/json";const a=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:n,body:ic(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new K(a):new ra(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class Rc extends ae{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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>hi(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const 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:i,query:n},r);return new K(a,c=>c.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 _("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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const 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:i,query:n},r);return new K(a,c=>c.map(hi))}async listOperations(t,r){return await(await this.listOperationsRaw(t,r)).value()}}class _c extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects",method:"POST",headers:i,query:n,body:Ha(t.project)},r);return new K(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:n},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>gr(c))}async getProject(t,r){return await(await this.getProjectRaw(t,r)).value()}async listProjectsRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:n,query:r},t);return new K(i,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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:n,body:wc(t.projectUpdate)},r);return new K(a,c=>gr(c))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class Ac extends ae{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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:n},r);return new K(a,c=>gi(c))}async getProvider(t,r){return await(await this.getProviderRaw(t,r)).value()}async listProvidersRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:n,query:r},t);return new K(i,a=>Qn(a,gi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class jc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Xa(t.providerApp)},r);return new K(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const 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:i,query:n},r);return new Pe(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={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:vc(t.providerAppUpdate)},r);return new K(a,c=>Ir(c))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class kc extends ae{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={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));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:i,query:n,body:Ga(t.revision)},r);return new Pe(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 i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const 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:i,query:n},r);return new K(a,c=>bs(c))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class Ec extends ae{async generateUploadUrlRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/generate-upload-url",method:"GET",headers:n,query:r},t);return new K(i,a=>dc(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class Fc{constructor(t){this.connectionApi=new bc(t),this.consumerApi=new Sc(t),this.destinationApi=new xc(t),this.groupApi=new Oc(t),this.installationApi=new Cc(t),this.integrationApi=new Nc(t),this.oAuthApi=new Tc(t),this.operationApi=new Rc(t),this.projectApi=new _c(t),this.providerApi=new Ac(t),this.providerAppApi=new jc(t),this.revisionApi=new kc(t),this.uploadURLApi=new Ec(t)}}const Pc="1.12.1",Dc="v1",yr="https://api.withampersand.com";function zi(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return yr;case"mock":return"http://127.0.0.1:4010";case"":return yr;default:return e??yr}}catch{return yr}}const Bc=(e,t)=>`${e}/${t}`;function Lc(){return Bc(zi(),Dc)}const Kc=zi(),Mc=Lc(),Uc=new Di({basePath:Mc,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Pc}});let $c=new Fc(Uc);const H=()=>$c,Ji=I.createContext({integrations:null}),Hi=()=>{const e=I.useContext(Ji);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function qc({projectIdOrName:e,children:t}){const r=ee(),{setError:n,isError:i}=We(),[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(V.INTEGRATION_LIST,e),console.error("Error retrieving integration information for : ",m)})},[e,r,n]);const h=I.useMemo(()=>({integrations:a}),[a]);return i(V.INTEGRATION_LIST,e)?s.jsx(Fe,{message:"Error retrieving integrations for the project, double check the API key"}):s.jsx(Ji.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}const Xi=I.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Z=()=>{const e=I.useContext(Xi);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Wc({projectIdOrName:e,children:t}){const r=ee(),{isError:n,setError:i}=We(),[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=>{i(V.PROJECT,e),p(!1),console.error("Error loading Ampersand project: ",m)})},[e,r,p,i]);const h=I.useMemo(()=>({projectId:(a==null?void 0:a.id)||"",projectIdOrName:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(V.PROJECT,e)?s.jsx(Fe,{message:`Error loading project ${e}`}):s.jsx(Xi.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}function zc(e){const{options:{apiKey:t,projectId:r,project:n},children:i}=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(Jo,{children:s.jsx(Go,{children:s.jsx(Ho,{value:t,children:s.jsx(Wc,{projectIdOrName:a,children:s.jsx(qc,{projectIdOrName:a,children:i})})})})})}const Gi=I.createContext(null);function Jc(){const e=I.useContext(Gi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
2
|
-
component is wrapped with AmpersandProvider`);return e}function Vi(e){return e.charAt(0).toUpperCase()+e.slice(1)}function st(e,t){return(t==null?void 0:t.displayName)??Vi(e)}const Yi=e=>e.split(`
|
|
3
|
-
`).filter(r=>r.trim()!==""),Hc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Xc=()=>{const[e,t]=I.useState(!1),r=I.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:r}},Zi=I.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function Ne(){const e=I.useContext(Zi);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Gc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p}){const h=ee(),{projectId:m}=Z(),{integrations:v}=Hi(),{setError:w,isError:b}=We(),{isIntegrationDeleted:x,setIntegrationDeleted:S}=Xc(),[O,T]=I.useState([]),[A,P]=I.useState(!0),$=(O==null?void 0:O[0])||null,k=I.useMemo(()=>Hc(t,v||[]),[t,v]);I.useEffect(()=>{k===null&&(v!=null&&v.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,k,v]);const Q=I.useCallback(Y=>{T([Y])},[T]),X=I.useCallback(()=>{k!=null&&k.id&&H().installationApi.listInstallations({projectIdOrName:m,integrationId:k.id,groupRef:i},{headers:{"X-Api-Key":h??""}}).then(Y=>{P(!1),T(Y||[])}).catch(Y=>{w(V.INSTALLATION_LIST,k.id),P(!1),console.error("Error retrieving installation information: ",Y)})},[k,m,h,w,i]),te=(k==null?void 0:k.id)||"";I.useEffect(()=>{X()},[X]);const J=I.useMemo(()=>({integrationId:(k==null?void 0:k.id)||"",provider:(k==null?void 0:k.provider)||"",integrationObj:k,consumerRef:r,consumerName:n,groupRef:i,groupName:a,installation:$,setInstallation:Q,resetInstallations:X,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p,isIntegrationDeleted:x,setIntegrationDeleted:S}),[k,r,n,i,a,$,Q,X,c,u,p,x,S]);if(k!==null){const Y=`Error retrieving installation information for integration "${(k==null?void 0:k.name)||"unknown"}"`;return b(V.INSTALLATION_LIST,te)?s.jsx(Fe,{message:Y}):s.jsx(Zi.Provider,{value:J,children:A?s.jsx(Ce,{}):e})}return s.jsx(Fe,{message:`Integration "${t}" not found`})}const Qi=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),xt=()=>{const e=I.useContext(Qi);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function eo({provider:e,groupRef:t,children:r}){const n=ee(),{projectId:i}=Z(),[a,c]=I.useState(null),[u,p]=I.useState(null),[h,m]=I.useState(!0),{setError:v,isError:w}=We(),{provider:b}=Ne();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const x=e||b;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");I.useEffect(()=>{H().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:x},{headers:{"X-Api-Key":n??""}}).then(O=>{m(!1),c(O)}).catch(O=>{m(!1),v(V.CONNECTION_LIST,i),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,O)})},[i,n,t,x,v]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:c,setSelectedConnection:p}),[a,u,c,p]);return w(V.CONNECTION_LIST,i)?s.jsx(Fe,{message:"Error retrieving existing connections"}):s.jsx(Qi.Provider,{value:S,children:h?s.jsx(Ce,{}):r})}var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(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__",i=1,a=2,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Promise]",$="[object Proxy]",k="[object RegExp]",Q="[object Set]",X="[object String]",te="[object Symbol]",J="[object Undefined]",Y="[object WeakMap]",Te="[object ArrayBuffer]",ct="[object DataView]",Br="[object Float32Array]",Lr="[object Float64Array]",Kr="[object Int8Array]",Mr="[object Int16Array]",Ur="[object Int32Array]",$r="[object Uint8Array]",qr="[object Uint8ClampedArray]",Wr="[object Uint16Array]",zr="[object Uint32Array]",Jr=/[\\^$.*+?()[\]{}|]/g,M=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,U={};U[Br]=U[Lr]=U[Kr]=U[Mr]=U[Ur]=U[$r]=U[qr]=U[Wr]=U[zr]=!0,U[u]=U[p]=U[Te]=U[m]=U[ct]=U[v]=U[w]=U[b]=U[S]=U[O]=U[A]=U[k]=U[Q]=U[X]=U[Y]=!1;var De=typeof $e=="object"&&$e&&$e.Object===Object&&$e,Zt=typeof self=="object"&&self&&self.Object===Object&&self,oe=De||Zt||Function("return this")(),Ct=t&&!t.nodeType&&t,dt=Ct&&!0&&e&&!e.nodeType&&e,Nt=dt&&dt.exports===Ct,lt=Nt&&De.process,Qt=function(){try{return lt&<.binding&<.binding("util")}catch{}}(),er=Qt&&Qt.isTypedArray;function Hr(l,o){for(var d=-1,f=l==null?0:l.length,C=0,R=[];++d<f;){var j=l[d];o(j,d,l)&&(R[C++]=j)}return R}function Xr(l,o){for(var d=-1,f=o.length,C=l.length;++d<f;)l[C+d]=o[d];return l}function Gr(l,o){for(var d=-1,f=l==null?0:l.length;++d<f;)if(o(l[d],d,l))return!0;return!1}function Vr(l,o){for(var d=-1,f=Array(l);++d<l;)f[d]=o(d);return f}function Yr(l){return function(o){return l(o)}}function ut(l,o){return l.has(o)}function Tt(l,o){return l==null?void 0:l[o]}function pt(l){var o=-1,d=Array(l.size);return l.forEach(function(f,C){d[++o]=[C,f]}),d}function be(l,o){return function(d){return l(o(d))}}function tr(l){var o=-1,d=Array(l.size);return l.forEach(function(f){d[++o]=f}),d}var rr=Array.prototype,Zr=Function.prototype,ft=Object.prototype,Be=oe["__core-js_shared__"],Rt=Zr.toString,ce=ft.hasOwnProperty,_t=function(){var l=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),At=ft.toString,Qr=RegExp("^"+Rt.call(ce).replace(Jr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Nt?oe.Buffer:void 0,ue=oe.Symbol,ze=oe.Uint8Array,ir=ft.propertyIsEnumerable,or=rr.splice,Re=ue?ue.toStringTag:void 0,jt=Object.getOwnPropertySymbols,Je=nr?nr.isBuffer:void 0,en=be(Object.keys,Object),ge=Ke(oe,"DataView"),He=Ke(oe,"Map"),kt=Ke(oe,"Promise"),Et=Ke(oe,"Set"),Ft=Ke(oe,"WeakMap"),Xe=Ke(Object,"create"),me=Ie(ge),tn=Ie(He),rn=Ie(kt),nn=Ie(Et),on=Ie(Ft),ar=ue?ue.prototype:void 0,Se=ar?ar.valueOf:void 0;function _e(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function an(){this.__data__=Xe?Xe(null):{},this.size=0}function sn(l){var o=this.has(l)&&delete this.__data__[l];return this.size-=o?1:0,o}function cn(l){var o=this.__data__;if(Xe){var d=o[l];return d===n?void 0:d}return ce.call(o,l)?o[l]:void 0}function dn(l){var o=this.__data__;return Xe?o[l]!==void 0:ce.call(o,l)}function Le(l,o){var d=this.__data__;return this.size+=this.has(l)?0:1,d[l]=Xe&&o===void 0?n:o,this}_e.prototype.clear=an,_e.prototype.delete=sn,_e.prototype.get=cn,_e.prototype.has=dn,_e.prototype.set=Le;function ye(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function ln(){this.__data__=[],this.size=0}function un(l){var o=this.__data__,d=mt(o,l);if(d<0)return!1;var f=o.length-1;return d==f?o.pop():or.call(o,d,1),--this.size,!0}function pn(l){var o=this.__data__,d=mt(o,l);return d<0?void 0:o[d][1]}function fn(l){return mt(this.__data__,l)>-1}function hn(l,o){var d=this.__data__,f=mt(d,l);return f<0?(++this.size,d.push([l,o])):d[f][1]=o,this}ye.prototype.clear=ln,ye.prototype.delete=un,ye.prototype.get=pn,ye.prototype.has=fn,ye.prototype.set=hn;function we(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function gn(){this.size=0,this.__data__={hash:new _e,map:new(He||ye),string:new _e}}function ht(l){var o=Ye(this,l).delete(l);return this.size-=o?1:0,o}function Pt(l){return Ye(this,l).get(l)}function mn(l){return Ye(this,l).has(l)}function gt(l,o){var d=Ye(this,l),f=d.size;return d.set(l,o),this.size+=d.size==f?0:1,this}we.prototype.clear=gn,we.prototype.delete=ht,we.prototype.get=Pt,we.prototype.has=mn,we.prototype.set=gt;function Ge(l){var o=-1,d=l==null?0:l.length;for(this.__data__=new we;++o<d;)this.add(l[o])}function yn(l){return this.__data__.set(l,n),this}function wn(l){return this.__data__.has(l)}Ge.prototype.add=Ge.prototype.push=yn,Ge.prototype.has=wn;function xe(l){var o=this.__data__=new ye(l);this.size=o.size}function sr(){this.__data__=new ye,this.size=0}function In(l){var o=this.__data__,d=o.delete(l);return this.size=o.size,d}function vn(l){return this.__data__.get(l)}function bn(l){return this.__data__.has(l)}function Sn(l,o){var d=this.__data__;if(d instanceof ye){var f=d.__data__;if(!He||f.length<r-1)return f.push([l,o]),this.size=++d.size,this;d=this.__data__=new we(f)}return d.set(l,o),this.size=d.size,this}xe.prototype.clear=sr,xe.prototype.delete=In,xe.prototype.get=vn,xe.prototype.has=bn,xe.prototype.set=Sn;function xn(l,o){var d=Ze(l),f=!d&&Fn(l),C=!d&&!f&&vt(l),R=!d&&!f&&!C&&Ut(l),j=d||f||C||R,D=j?Vr(l.length,String):[],E=D.length;for(var F in l)ce.call(l,F)&&!(j&&(F=="length"||C&&(F=="offset"||F=="parent")||R&&(F=="buffer"||F=="byteLength"||F=="byteOffset")||jn(F,E)))&&D.push(F);return D}function mt(l,o){for(var d=l.length;d--;)if(It(l[d][0],o))return d;return-1}function On(l,o,d){var f=o(l);return Ze(l)?f:Xr(f,d(l))}function Ve(l){return l==null?l===void 0?J:T:Re&&Re in Object(l)?_n(l):Lt(l)}function cr(l){return Qe(l)&&Ve(l)==u}function dr(l,o,d,f,C){return l===o?!0:l==null||o==null||!Qe(l)&&!Qe(o)?l!==l&&o!==o:yt(l,o,d,f,dr,C)}function yt(l,o,d,f,C,R){var j=Ze(l),D=Ze(o),E=j?p:pe(l),F=D?p:pe(o);E=E==u?A:E,F=F==u?A:F;var q=E==A,W=F==A,G=E==F;if(G&&vt(l)){if(!vt(o))return!1;j=!0,q=!1}if(G&&!q)return R||(R=new xe),j||Ut(l)?Bt(l,o,d,f,C,R):Tn(l,o,E,d,f,C,R);if(!(d&i)){var ne=q&&ce.call(l,"__wrapped__"),ie=W&&ce.call(o,"__wrapped__");if(ne||ie){var ve=ne?l.value():l,je=ie?o.value():o;return R||(R=new xe),C(ve,je,d,f,R)}}return G?(R||(R=new xe),Rn(l,o,d,f,C,R)):!1}function Dt(l){if(!Mt(l)||En(l))return!1;var o=Me(l)?Qr:M;return o.test(Ie(l))}function Cn(l){return Qe(l)&&ur(l.length)&&!!U[Ve(l)]}function Nn(l){if(!wt(l))return en(l);var o=[];for(var d in Object(l))ce.call(l,d)&&d!="constructor"&&o.push(d);return o}function Bt(l,o,d,f,C,R){var j=d&i,D=l.length,E=o.length;if(D!=E&&!(j&&E>D))return!1;var F=R.get(l);if(F&&R.get(o))return F==o;var q=-1,W=!0,G=d&a?new Ge:void 0;for(R.set(l,o),R.set(o,l);++q<D;){var ne=l[q],ie=o[q];if(f)var ve=j?f(ie,ne,q,o,l,R):f(ne,ie,q,l,o,R);if(ve!==void 0){if(ve)continue;W=!1;break}if(G){if(!Gr(o,function(je,et){if(!ut(G,et)&&(ne===je||C(ne,je,d,f,R)))return G.push(et)})){W=!1;break}}else if(!(ne===ie||C(ne,ie,d,f,R))){W=!1;break}}return R.delete(l),R.delete(o),W}function Tn(l,o,d,f,C,R,j){switch(d){case ct:if(l.byteLength!=o.byteLength||l.byteOffset!=o.byteOffset)return!1;l=l.buffer,o=o.buffer;case Te:return!(l.byteLength!=o.byteLength||!R(new ze(l),new ze(o)));case m:case v:case O:return It(+l,+o);case w:return l.name==o.name&&l.message==o.message;case k:case X:return l==o+"";case S:var D=pt;case Q:var E=f&i;if(D||(D=tr),l.size!=o.size&&!E)return!1;var F=j.get(l);if(F)return F==o;f|=a,j.set(l,o);var q=Bt(D(l),D(o),f,C,R,j);return j.delete(l),q;case te:if(Se)return Se.call(l)==Se.call(o)}return!1}function Rn(l,o,d,f,C,R){var j=d&i,D=lr(l),E=D.length,F=lr(o),q=F.length;if(E!=q&&!j)return!1;for(var W=E;W--;){var G=D[W];if(!(j?G in o:ce.call(o,G)))return!1}var ne=R.get(l);if(ne&&R.get(o))return ne==o;var ie=!0;R.set(l,o),R.set(o,l);for(var ve=j;++W<E;){G=D[W];var je=l[G],et=o[G];if(f)var li=j?f(et,je,G,o,l,R):f(je,et,G,l,o,R);if(!(li===void 0?je===et||C(je,et,d,f,R):li)){ie=!1;break}ve||(ve=G=="constructor")}if(ie&&!ve){var fr=l.constructor,hr=o.constructor;fr!=hr&&"constructor"in l&&"constructor"in o&&!(typeof fr=="function"&&fr instanceof fr&&typeof hr=="function"&&hr instanceof hr)&&(ie=!1)}return R.delete(l),R.delete(o),ie}function lr(l){return On(l,Pn,An)}function Ye(l,o){var d=l.__data__;return kn(o)?d[typeof o=="string"?"string":"hash"]:d.map}function Ke(l,o){var d=Tt(l,o);return Dt(d)?d:void 0}function _n(l){var o=ce.call(l,Re),d=l[Re];try{l[Re]=void 0;var f=!0}catch{}var C=At.call(l);return f&&(o?l[Re]=d:delete l[Re]),C}var An=jt?function(l){return l==null?[]:(l=Object(l),Hr(jt(l),function(o){return ir.call(l,o)}))}:Dn,pe=Ve;(ge&&pe(new ge(new ArrayBuffer(1)))!=ct||He&&pe(new He)!=S||kt&&pe(kt.resolve())!=P||Et&&pe(new Et)!=Q||Ft&&pe(new Ft)!=Y)&&(pe=function(l){var o=Ve(l),d=o==A?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 Q;case on:return Y}return o});function jn(l,o){return o=o??c,!!o&&(typeof l=="number"||Yt.test(l))&&l>-1&&l%1==0&&l<o}function kn(l){var o=typeof l;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?l!=="__proto__":l===null}function En(l){return!!_t&&_t in l}function wt(l){var o=l&&l.constructor,d=typeof o=="function"&&o.prototype||ft;return l===d}function Lt(l){return At.call(l)}function Ie(l){if(l!=null){try{return Rt.call(l)}catch{}try{return l+""}catch{}}return""}function It(l,o){return l===o||l!==l&&o!==o}var Fn=cr(function(){return arguments}())?cr:function(l){return Qe(l)&&ce.call(l,"callee")&&!ir.call(l,"callee")},Ze=Array.isArray;function Kt(l){return l!=null&&ur(l.length)&&!Me(l)}var vt=Je||pr;function Ae(l,o){return dr(l,o)}function Me(l){if(!Mt(l))return!1;var o=Ve(l);return o==b||o==x||o==h||o==$}function ur(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=c}function Mt(l){var o=typeof l;return l!=null&&(o=="object"||o=="function")}function Qe(l){return l!=null&&typeof l=="object"}var Ut=er?Yr(er):Cn;function Pn(l){return Kt(l)?xn(l):Nn(l)}function Dn(){return[]}function pr(){return!1}e.exports=Ae})(xr,xr.exports);var Vc=xr.exports;const Yc=ei(Vc),it="other";function qe(e){return e.mapToName!==void 0}function Zc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function Qc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}function ed(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>qe(n)&&!!n.mapToName))||[]}function td(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}const to=(e,t)=>{var r,n,i;return(i=(n=(r=e==null?void 0:e.content)==null?void 0:r.read)==null?void 0:n.objects)==null?void 0:i[t]};function rd(e){return qe(e)?e.mapToName:e.fieldName}const ro=(e,t)=>{var n,i,a;const r=[];return(a=(i=(n=t.content)==null?void 0:n.read)==null?void 0:i.objects)==null||a.forEach(c=>{r.push({name:c==null?void 0:c.objectName,completed:e?!!to(e,c.objectName):!1})}),r},no=e=>{var r;return{name:it,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function nd(e,t){var a;const r=ro(e,t),i=!!((a=t==null?void 0:t.content)!=null&&a.write)?no(e):void 0;return i&&r.push(i),r}function io(e,t,r){const n=(e==null?void 0:e.filter(a=>!(t!=null&&t[a==null?void 0:a.mapToName])))||[],i=n.map(a=>a.mapToName);return r(V.MAPPING,i),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:i}}function ti(e,t){return Yc(e,t)}const id=(e,t,r)=>{var b,x,S,O,T,A;if(!e)return null;const n=Zc(e,t),i=n&&Qc(n),a=n&&td(n),c=n&&ed(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,h=((S=(x=(b=p==null?void 0:p.read)==null?void 0:b.objects)==null?void 0:x[t])==null?void 0:S.selectedFields)||{},m=((A=(T=(O=p==null?void 0:p.read)==null?void 0:O.objects)==null?void 0:T[t])==null?void 0:A.selectedFieldMappings)||{},v={...h},w={...m};return{allFields:u,requiredFields:i,optionalFields:a,requiredMapFields:c,selectedOptionalFields:h,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:v,requiredMapFields:w}}},od=(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||{}),i={};n.forEach(p=>{i[p]=!0});const a={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:a}}};function oo(e,t,r){var a,c;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,i=(c=e==null?void 0:e.content)==null?void 0:c.write;return{read:id(n,t,r),write:od(i,r)}}const ao=(e,t,r,n)=>{const i=oo(e,r,t);n(r,i)},ad=(e,t,r)=>{const n=nd(t,e),i={};n.forEach(({name:a,completed:c})=>{c&&(i[a]=oo(e,a,t))}),r(i)},so=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(rd(a))),{...Array.from(n).reduce((a,c)=>({...a,[c]:!0}),{}),...r||{}}},co=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 lo(e,t){return t[e]||void 0}function ri({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:i,apiKey:a,setInstallation:c,onInstallSuccess:u}){const p={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:i,config:e}};return H().installationApi.createInstallation(p,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}function Ar(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const sd=(e,t)=>{const r=e.content.read,n=r==null?void 0:r.objects;return n==null?void 0:n.find(i=>i.objectName===t)},cd=(e,t,r,n)=>{const i=so(e),a=co(e),c=sd(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:i,selectedFieldMappings:a,backfill:c.backfill}}}}};return Ar(r)&&(u.content.proxy={enabled:!0}),u},dd=(e,t,r,n,i,a,c,u,p,h,m)=>{const v=cd(p,a,u,n);return v?ri({createConfig:v,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:c,setInstallation:h,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},uo=e=>{var a,c;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(c=e.write)==null?void 0:c.selectedNonConfigurableWriteFields,i=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;i.includes(p)&&(t[p]={objectName:p})}),t},ld=e=>{const t=e.content.write;return t==null?void 0:t.objects},ud=(e,t,r)=>{if(!ld(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=uo(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return Ar(t)&&(a.content.proxy={enabled:!0}),a},pd=(e,t,r,n,i,a,c,u,p,h)=>{const m=ud(u,c,n);return m?ri({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:p,onInstallSuccess:h}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};function fd(){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 po="uninstall-installation",hd=I.forwardRef(({text:e="Uninstall"},t)=>{const r=y.useTab({ref:t}),n=y.useMultiStyleConfig("Tabs",r);return s.jsxs(y.Button,{__css:n.warningTab,...r,minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[fd(),s.jsx(y.Box,{textAlign:"left",children:s.jsx(y.Text,{color:"red.800",children:e})})]}),r.children]})}),fo=I.createContext({hydratedRevision:null,loading:!1}),Xt=()=>{const e=I.useContext(fo);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function gd({projectId:e,children:t}){var P;const{selectedConnection:r}=xt(),{integrationId:n,integrationObj:i}=Ne(),[a,c]=I.useState(null),[u,p]=I.useState(!0),{isError:h,removeError:m,setError:v}=We(),w=ee(),b=r==null?void 0:r.id,x=(P=i==null?void 0:i.latestRevision)==null?void 0:P.id,S=(i==null?void 0:i.name)||n;I.useEffect(()=>{e&&n&&x&&b&&w&&H().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:x,connectionId:b},{headers:{"X-Api-Key":w??""}}).then($=>{c($),p(!1),m(V.HYDRATED_REVISION,S)}).catch($=>{console.error(`Error loading integration ${S}`,$),p(!1),v(V.HYDRATED_REVISION,S)})},[e,n,x,b,w,m,v,S]);const O=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),A=`Error retrieving integration details for '${(i==null?void 0:i.name)||n||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return s.jsx(fo.Provider,{value:O,children:h(V.HYDRATED_REVISION,S)?s.jsx(Fe,{message:A}):t})}function ho(){return s.jsxs("footer",{style:{backgroundColor:"#EFEFEF",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[s.jsx("p",{children:"Secured by"}),s.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:s.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}var go=Symbol.for("immer-nothing"),mi=Symbol.for("immer-draftable"),de=Symbol.for("immer-state"),md=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 se(e,...t){if(process.env.NODE_ENV!=="production"){const r=md[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[de]}function ot(e){var t;return e?mo(e)||Array.isArray(e)||!!e[mi]||!!((t=e.constructor)!=null&&t[mi])||kr(e)||Er(e):!1}var yd=Object.prototype.constructor.toString();function mo(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)===yd}function Or(e,t){jr(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function jr(e){const t=e[de];return t?t.type_:Array.isArray(e)?1:kr(e)?2:Er(e)?3:0}function $n(e,t){return jr(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yo(e,t,r){const n=jr(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function wd(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 tt(e){return e.copy_||e.base_}function qn(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=mo(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[de];let i=Reflect.ownKeys(n);for(let a=0;a<i.length;a++){const c=i[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 i=Object.create(n);return Object.assign(i,e)}}function ni(e,t=!1){return Fr(e)||St(e)||!ot(e)||(jr(e)>1&&(e.set=e.add=e.clear=e.delete=Id),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>ni(n,!0))),e}function Id(){se(2)}function Fr(e){return Object.isFrozen(e)}var vd={};function at(e){const t=vd[e];return t||se(0,e),t}var Jt;function wo(){return Jt}function bd(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yi(e,t){t&&(at("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Wn(e){zn(e),e.drafts_.forEach(Sd),e.drafts_=null}function zn(e){e===Jt&&(Jt=e.parent_)}function wi(e){return Jt=bd(Jt,e)}function Sd(e){const t=e[de];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ii(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[de].modified_&&(Wn(t),se(4)),ot(e)&&(e=Cr(t,e),t.parent_||Nr(t,e)),t.patches_&&at("Patches").generateReplacementPatches_(r[de].base_,e,t.patches_,t.inversePatches_)):e=Cr(t,r,[]),Wn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==go?e:void 0}function Cr(e,t,r){if(Fr(t))return t;const n=t[de];if(!n)return Or(t,(i,a)=>vi(e,n,t,i,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 i=n.copy_;let a=i,c=!1;n.type_===3&&(a=new Set(i),i.clear(),c=!0),Or(a,(u,p)=>vi(e,n,i,u,p,r,c)),Nr(e,i,!1),r&&e.patches_&&at("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function vi(e,t,r,n,i,a,c){if(process.env.NODE_ENV!=="production"&&i===r&&se(5),St(i)){const u=a&&t&&t.type_!==3&&!$n(t.assigned_,n)?a.concat(n):void 0,p=Cr(e,i,u);if(yo(r,n,p),St(p))e.canAutoFreeze_=!1;else return}else c&&r.add(i);if(ot(i)&&!Fr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Cr(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Nr(e,i)}}function Nr(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ni(t,r)}function xd(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:wo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,a=ii;r&&(i=[n],a=Ht);const{revoke:c,proxy:u}=Proxy.revocable(i,a);return n.draft_=u,n.revoke_=c,u}var ii={get(e,t){if(t===de)return e;const r=tt(e);if(!$n(r,t))return Od(e,r,t);const n=r[t];return e.finalized_||!ot(n)?n:n===Ln(e.base_,t)?(Kn(e),e.copy_[t]=Hn(n,e)):n},has(e,t){return t in tt(e)},ownKeys(e){return Reflect.ownKeys(tt(e))},set(e,t,r){const n=Io(tt(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=Ln(tt(e),t),a=i==null?void 0:i[de];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(wd(r,i)&&(r!==void 0||$n(e.base_,t)))return!0;Kn(e),Jn(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,Kn(e),Jn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=tt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){se(11)},getPrototypeOf(e){return bt(e.base_)},setPrototypeOf(){se(12)}},Ht={};Or(ii,(e,t)=>{Ht[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ht.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&se(13),Ht.set.call(this,e,t,void 0)};Ht.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&se(14),ii.set.call(this,e[0],t,r,e[0])};function Ln(e,t){const r=e[de];return(r?tt(r):e)[t]}function Od(e,t,r){var i;const n=Io(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function Io(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 Jn(e){e.modified_||(e.modified_=!0,e.parent_&&Jn(e.parent_))}function Kn(e){e.copy_||(e.copy_=qn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Cd=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,...h){return c.produce(p,m=>r.call(this,m,...h))}}typeof r!="function"&&se(6),n!==void 0&&typeof n!="function"&&se(7);let i;if(ot(t)){const a=wi(this),c=Hn(t,void 0);let u=!0;try{i=r(c),u=!1}finally{u?Wn(a):zn(a)}return yi(a,n),Ii(i,a)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===go&&(i=void 0),this.autoFreeze_&&ni(i,!0),n){const a=[],c=[];at("Patches").generateReplacementPatches_(t,i,a,c),n(a,c)}return i}else se(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,p=>t(p,...u));let n,i;return[this.produce(t,r,(c,u)=>{n=c,i=u}),n,i]},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){ot(e)||se(8),St(e)&&(e=Nd(e));const t=wi(this),r=Hn(e,void 0);return r[de].isManual_=!0,zn(t),r}finishDraft(e,t){const r=e&&e[de];(!r||!r.isManual_)&&se(9);const{scope_:n}=r;return yi(n,t),Ii(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 i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=at("Patches").applyPatches_;return St(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Hn(e,t){const r=kr(e)?at("MapSet").proxyMap_(e,t):Er(e)?at("MapSet").proxySet_(e,t):xd(e,t);return(t?t.scope_:wo()).drafts_.push(r),r}function Nd(e){return St(e)||se(10,e),vo(e)}function vo(e){if(!ot(e)||Fr(e))return e;const t=e[de];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=qn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=qn(e,!0);return Or(r,(n,i)=>{yo(r,n,vo(i))}),t&&(t.finalized_=!1),r}var le=new Cd,qt=le.produce;le.produceWithPatches.bind(le);le.setAutoFreeze.bind(le);le.setUseStrictShallowCopy.bind(le);le.applyPatches.bind(le);le.createDraft.bind(le);le.finishDraft.bind(le);const bo=I.createContext(void 0),Td={};function oi(){const e=I.useContext(bo);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Rd({children:e}){const{installation:t}=Ne(),{hydratedRevision:r,loading:n}=Xt(),[i,a]=I.useState(Td),c=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&c&&!(Object.entries(i).length>0)&&ad(r,c,a)},[r,n,c,i]);const u=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=qt(O[b],x)}))},[a]),p=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=x}))},[a]),h=I.useCallback(()=>{a(qt(b=>{const x=b.other.write;x&&(x.isWriteModified=!1)}))},[a]),m=I.useCallback(b=>{a(qt(x=>{var O;const S=(O=x[b])==null?void 0:O.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),v=I.useCallback(b=>{b===it?h():m(b)},[m,h]),w=I.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:v}),[i,p,v,u]);return s.jsx(bo.Provider,{value:w,children:e})}const _d=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 Ad(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?_d: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 So=I.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},i)=>{const a=y.useTab({ref:i}),c=y.useMultiStyleConfig("Tabs",a);return s.jsxs(y.Button,{__css:c.tab,...a,variant:"outline",minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[Ad(t,r),s.jsxs(y.Box,{textAlign:"left",children:[s.jsx(y.Text,{children:n||e}),r&&s.jsx(y.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function jd({pending:e,completed:t,displayName:r}){return s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginY:3}),s.jsx(So,{objectName:it,completed:t,pending:e,displayName:r},"other-write")]})}const xo=I.createContext(null);function Oo(){const e=I.useContext(xo);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function kd(e,t){return e!=null&&e[t]?e[t]:{name:po,completed:!1}}function Ed({children:e}){var O,T,A;const{project:t}=Z(),{installation:r,provider:n}=Ne(),{hydratedRevision:i}=Xt(),{objectConfigurationsState:a}=oi(),[c,u]=I.useState(0),p=(t==null?void 0:t.appName)||"",h=r==null?void 0:r.config,m=i&&ro(h,i),v=m!==null,w=!!((O=i==null?void 0:i.content)!=null&&O.write),b=w?no(h):void 0,x=[...m||[]];b&&w&&x.push(b);const S=kd(x,c);return s.jsx(xo.Provider,{value:S==null?void 0:S.name,children:s.jsxs(y.Container,{maxWidth:"55rem",children:[s.jsxs(y.Box,{p:8,borderRadius:4,margin:"auto",display:"flex",gap:"6",minHeight:"100%",fontSize:"md",backgroundColor:"#FCFCFC",border:"1px solid #EFEFEF",boxShadow:"0px 4px 8px rgba(0, 0, 0, 0.05)",children:[s.jsxs(y.Box,{width:"20rem",children:[s.jsxs(y.Text,{children:[st(n)," integration"]}),s.jsx(y.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),v&&s.jsxs(y.Tabs,{index:c,onChange:u,orientation:"horizontal",children:[m.map(P=>{var $,k,Q,X;return s.jsx(So,{objectName:P.name,completed:P.completed,pending:((k=($=a[P.name])==null?void 0:$.read)==null?void 0:k.isOptionalFieldsModified)||((X=(Q=a[P.name])==null?void 0:Q.read)==null?void 0:X.isRequiredMapFieldsModified)},P.name)}),w&&b&&s.jsx(jd,{completed:b.completed,pending:(A=(T=a==null?void 0:a.other)==null?void 0:T.write)==null?void 0:A.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginTop:10,marginBottom:3}),s.jsx(hd,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]}),s.jsx(ho,{})]})})}const Ot=()=>{const{appName:e}=Z(),{objectConfigurationsState:t,setConfigureState:r}=oi(),{selectedObjectName:n}=Oo(),i=lo(n||"",t);return{appName:e,configureState:i,setConfigureState:r,selectedObjectName:n}};function Fd(e,t,r){var i;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(n[t]=r,e!=null&&e.read){const a=e.read.savedConfig.requiredMapFields,u=!ti(a,n);e.read.isRequiredMapFieldsModified=u}}function Co(e,t,r,n){t(e,i=>Fd(i,r,n))}function Pd({field:e,onSelectChange:t,allFields:r}){var v;const{configureState:n,selectedObjectName:i,setConfigureState:a}=Ot(),[c,u]=I.useState(!0),p=(v=n==null?void 0:n.read)==null?void 0:v.selectedFieldMappings,h=p==null?void 0:p[e.mapToName];I.useEffect(()=>{e._default&&!h&&i&&n&&Co(i,a,e.mapToName,e._default),u(!1)},[e,a,i,h,n]);const m=I.useMemo(()=>r==null?void 0:r.map(w=>s.jsx("option",{value:w.fieldName,children:w.displayName},w.fieldName)),[r]);return s.jsxs(y.Stack,{children:[s.jsx(y.Text,{fontWeight:"500",children:e.mapToDisplayName}),s.jsx(y.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),s.jsx(y.Select,{name:e.mapToName,variant:"flushed",value:h||void 0,onChange:t,placeholder:h?void 0:"Please select one",disabled:c,children:m})]},e.mapToName)}function Pr({string:e}){return s.jsxs(y.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[s.jsx(y.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),s.jsx(y.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:s.jsx(y.Divider,{marginLeft:2})})]})}function Dd(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ot(),{isError:n,removeError:i}=We(),a=u=>{const{value:p,name:h}=u.target;p&&(e&&Co(e,r,h,p),n(V.MAPPING,h)&&i(V.MAPPING,h))},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(qe))||[]},[t]);return c.length?s.jsxs(y.Box,{children:[s.jsx(Pr,{string:"Map the following fields (required)"}),s.jsx(y.Stack,{children:c.map(u=>{var p;return s.jsxs(y.FormControl,{isInvalid:n(V.MAPPING,u.mapToName),children:[s.jsx(Pd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),s.jsx(y.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function Bd(e,t,r){var i,a;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(n[t]=r,r||delete n[t],(a=e.read)!=null&&a.savedConfig.optionalFields){const c=e.read.savedConfig.optionalFields,p=!ti(c,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function bi(e,t,r,n){t(e,i=>Bd(i,r,n))}function Ld(){var v,w;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ot(),i=(v=t==null?void 0:t.read)==null?void 0:v.selectedOptionalFields,a=b=>{const{name:x,checked:S}=b.target;n&&t&&bi(n,r,x,S)},c=(w=t==null?void 0:t.read)==null?void 0:w.optionalFields,u=b=>{const{checked:x}=b.target;n&&c&&c.forEach(S=>{qe(S)||bi(n,r,S.fieldName,x)})},p=!!(c&&c.length>0),h=Object.keys(i||{}).length===(c==null?void 0:c.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${e} reads the following optional fields`}),s.jsxs(y.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(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),c.map(b=>qe(b)?null:s.jsx(y.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:s.jsx(y.Checkbox,{name:b.fieldName,id:b.fieldName,isChecked:!!(i!=null&&i[b==null?void 0:b.fieldName]),onChange:a,children:b.displayName})},b.fieldName))]})]})}function Kd(){var n,i,a;const{configureState:e,selectedObjectName:t}=Ot(),{appName:r}=Z();return s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${r} reads the following ${t} fields`}),s.jsx(y.Box,{marginBottom:"20px",display:"flex",gap:1,children:(i=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&i.length?(a=e.read)==null?void 0:a.requiredFields.map(c=>qe(c)?null:s.jsx(y.Tag,{children:c.displayName},c.fieldName)):"There are no required fields."})]})}function Md(){return s.jsxs(s.Fragment,{children:[s.jsx(Kd,{}),s.jsx(Dd,{}),s.jsx(Ld,{})]})}function Ud(e,t,r){var n,i,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=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,h=!ti(u,c);e.write.isWriteModified=h}}}function Si(e,t,r,n){t(e,i=>{Ud(i,r,n)})}function $d(){var v,w,b,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ot(),i=(v=r==null?void 0:r.write)==null?void 0:v.selectedNonConfigurableWriteFields,a=(w=r==null?void 0:r.write)==null?void 0:w.writeObjects,c=S=>{const{name:O,checked:T}=S.target;t&&r&&Si(t,n,O,T)},u=S=>{var T,A;const{checked:O}=S.target;t&&r&&((A=(T=r==null?void 0:r.write)==null?void 0:T.writeObjects)==null||A.forEach(P=>{Si(t,n,P.objectName,O)}))},p=!!a,h=Object.keys(i||{}).length===((x=(b=r==null?void 0:r.write)==null?void 0:b.writeObjects)==null?void 0:x.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`Allow ${e} to write to these object`}),s.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((a==null?void 0:a.length)||0)>=2&&s.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),a.map(S=>s.jsx(y.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:S.objectName,id:S.objectName,onChange:c,isChecked:!!(i!=null&&i[S.objectName]),children:S.displayName})},S.objectName))]})]})}function qd(){const e=ee(),{projectId:t,appName:r}=Z(),{integrationId:n,installation:i,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:u}=Ne(),[p,h]=I.useState(!1),m=!t||!n||!(i!=null&&i.id)||p,v=async()=>{if(!m){h(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:i.id});try{await H().installationApi.deleteInstallation({projectIdOrName:t,integrationId:n,installationId:i.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation: ",i.id),u==null||u(i==null?void 0:i.id),a(),c()}catch(x){console.error("error uninstalling installation",x)}finally{h(!1)}}},w=p?"Uninstalling...":"Yes, uninstall",b=i!=null&&i.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(y.Stack,{children:[s.jsx(y.Text,{paddingBottom:3,children:b}),(i==null?void 0:i.id)&&s.jsx(y.Button,{onClick:v,variant:"warning",isDisabled:m,children:w})]})}function No({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var P,$,k;const{installation:i}=Ne(),{hydratedRevision:a,loading:c}=Xt(),{configureState:u,selectedObjectName:p}=Ot(),h=i==null?void 0:i.config,m=h&&p&&!!to(h,p)||!1,v=((P=u==null?void 0:u.read)==null?void 0:P.isOptionalFieldsModified)||(($=u==null?void 0:u.read)==null?void 0:$.isRequiredMapFieldsModified),w=(k=u==null?void 0:u.write)==null?void 0:k.isWriteModified,O=c||r||!u||!p||!(v||w||n||p!==it&&!m),T=p===it,A=p===po;return r?s.jsx(Ce,{}):s.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[s.jsxs(y.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[s.jsx(y.Button,{variant:"primary",type:"submit",isDisabled:O,children:n?"Install":"Save"}),s.jsx(y.Button,{isDisabled:O,onClick:t,children:"Reset"})]}),s.jsxs(y.Box,{p:8,borderRadius:4,boxShadow:"sm",margin:"auto",backgroundColor:"white",border:"1px solid gray.100",minHeight:300,children:[c&&s.jsx(Ce,{}),a&&!A&&!T&&s.jsx(Md,{}),a&&!A&&T&&s.jsx($d,{}),!c&&A&&s.jsx(qd,{})]})]})}const To=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:i,onUpdateSuccess:a}=Ne(),{hydratedRevision:c,loading:u}=Xt(),{selectedObjectName:p}=Oo(),{selectedConnection:h}=xt(),m=ee(),{projectId:v}=Z(),{resetBoundary:w,setErrors:b}=We(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O}=oi(),T=lo(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:c,loading:u,selectedObjectName:p,selectedConnection:h,apiKey:m,projectId:v,resetBoundary:w,setErrors:b,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O,configureState:T,onInstallSuccess:i,onUpdateSuccess:a}},Wd=void 0;function zd(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:i,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:p,projectId:h,resetBoundary:m,setErrors:v,resetConfigureState:w,objectConfigurationsState:b,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:O}=To(),[T,A]=I.useState(!1),P=c===it,$=I.useCallback(()=>{m(V.MAPPING),i!=null&&i.content&&!a&&c&&ao(i,Wd,c,w)},[m,i,a,c,w]);I.useEffect(()=>{!S&&(i!=null&&i.content)&&!a&&$()},[S,b,i,a,$]);const k=()=>{const{requiredMapFields:te,selectedFieldMappings:J}=(S==null?void 0:S.read)||{},{errorList:Y}=io(te,J,v);Y.length>0||(c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),dd(h,e,t,r,u.id,c,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},Q=()=>{c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),pd(h,e,t,r,u.id,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},X=te=>{te.preventDefault(),P?Q():k()};return s.jsx(No,{isCreateMode:!0,isLoading:T,onSave:X,onReset:$})}function Jd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:i,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":i,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}const Hd=(e,t,r,n,i,a)=>{const c=so(e),u=co(e),p={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:c,selectedFieldMappings:u,backfill:a}}}}};return Ar(i)&&(p.content||(p.content={}),p.content.proxy={enabled:!0}),p},Xd=(e,t,r,n,i,a,c,u,p,h)=>{const m=Hd(a,n||"",u,u.schedule,p,u.backfill);return m?Jd({updateConfig:m,projectId:e,integrationId:t,installationId:r,apiKey:i,selectedObjectName:n,setInstallation:c,onUpdateSuccess:h}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Gd=(e,t)=>{const n={content:{write:{objects:uo(e)}}};return Ar(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},Vd=(e,t,r,n,i,a,c,u)=>{const p=Gd(i,a);if(!p)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const h={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:p}}};return H().installationApi.updateInstallation(h,{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 Yd({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:i,selectedObjectName:a,apiKey:c,projectId:u,resetBoundary:p,setErrors:h,resetConfigureState:m,resetPendingConfigurationState:v,configureState:w,onUpdateSuccess:b}=To(),[x,S]=I.useState(!1),O=a===it,{config:T}=e,A=I.useCallback(()=>{p(V.MAPPING),n!=null&&n.content&&!i&&a&&ao(n,T,a,m)},[p,n,i,a,T,m]);I.useEffect(()=>{w||A()},[w,A]),I.useEffect(()=>{e&&A()},[e,A]);const P=I.useMemo(()=>{var te,J,Y;return(Y=(J=(te=n==null?void 0:n.content)==null?void 0:te.read)==null?void 0:J.objects)==null?void 0:Y.find(Te=>(Te==null?void 0:Te.objectName)===a)},[n,a]),$=()=>{const{requiredMapFields:X,selectedFieldMappings:te}=(w==null?void 0:w.read)||{},{errorList:J}=io(X,te,h);J.length>0||(n&&e&&a&&c&&u&&P?(S(!0),Xd(u,t.id,e.id,a,c,w,r,P,n,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},k=()=>{e&&a&&c&&u&&n?(S(!0),Vd(u,t.id,e.id,c,w,n,r,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},Q=X=>{X.preventDefault(),O?k():$()};return s.jsx(No,{onSave:Q,onReset:A,isLoading:x})}function Zd(){const{integrationObj:e,installation:t}=Ne();return e?t&&e?s.jsx(Yd,{installation:t,integrationObj:e}):s.jsx(zd,{}):s.jsx(Fe,{message:"We can't load the integration"})}function Qd(){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 ai({text:e}){return s.jsx(y.Container,{children:s.jsxs(y.Box,{p:8,maxWidth:"600px",minHeight:"290px",borderWidth:1,borderRadius:8,boxShadow:"lg",margin:"auto",marginTop:"40px",bgColor:"white",paddingTop:"100px",color:"gray.800",fontSize:"md",children:[s.jsx(y.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:s.jsx(y.Box,{margin:"auto",children:s.jsx(Qd,{})})}),s.jsx(y.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}const el=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function tl({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:i,apiKey:a,hydratedRevision:c,setInstallation:u,onInstallSuccess:p}){const h=el(c,n);return h?ri({createConfig:h,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:u,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function rl({provider:e}){const t=`You have successfully installed your ${st(e)} integration.`;return s.jsx(ai,{text:t})}const nl=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 il({children:e}){var A;const{projectId:t}=Z(),r=ee(),{hydratedRevision:n,loading:i}=Xt(),{integrationObj:a,installation:c,groupRef:u,consumerRef:p,setInstallation:h,onInstallSuccess:m,isIntegrationDeleted:v}=Ne(),{selectedConnection:w}=xt(),[b,x]=I.useState(!1),S=i||b,O=(A=n==null?void 0:n.content)==null?void 0:A.provider,T=nl(n);return I.useEffect(()=>{!S&&n&&T&&!c&&w&&r&&(a!=null&&a.id)&&(x(!0),tl({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:w==null?void 0:w.id,hydratedRevision:n,setInstallation:h,onInstallSuccess:m}).then(()=>{x(!1)}).catch(P=>{x(!1),console.error("Error when creating proxy installation:",P)}))},[n,T,c,w,r,t,a==null?void 0:a.id,u,p,h,S,m]),a?S?s.jsx(Ce,{}):T&&O&&c?s.jsx(rl,{provider:O}):v?s.jsx(ai,{text:"Integration successfully uninstalled."}):s.jsx("div",{children:e}):s.jsx(Fe,{message:"We can't load the integration"})}function ol({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function al({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function Ro({url:e,providerDisplayName:t,credentialName:r}){return s.jsxs(y.Text,{align:"left",color:"darkgray",children:[s.jsx(y.Link,{href:e,target:"_blank",rel:"noreferrer",color:"blackAlpha.600",isExternal:!0,children:s.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",r,"."]})}function sl({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var S;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),m=O=>h(O.currentTarget.value),v=p.length>0,w=i||!v,b=st(e,t),x=(S=t.apiKeyOpts)==null?void 0:S.docsURL;return s.jsx(ol,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{my:"6",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${b} integration`})}),s.jsx(al,{error:n}),s.jsxs(y.Stack,{spacing:4,children:[x&&s.jsx(Ro,{url:x,providerDisplayName:b,credentialName:"API key"}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:m,pr:"4.5rem",type:a?"text":"password",placeholder:"API Key"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:w,width:"100%",type:"submit",onClick:()=>{r(p)},children:"Next"})]})})}function cl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,apiKey:w};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,p,w]);const S=O=>{b(O),v(!0)};return u===null?s.jsx(sl,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function dl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:4,margin:"auto",marginTop:"40px",fontSize:"md",children:e})})}function ll({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function ul({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var A;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),[m,v]=I.useState(""),w=P=>h(P.currentTarget.value),b=P=>v(P.currentTarget.value),x=st(e,t),S=(A=t.basicOpts)==null?void 0:A.docsURL,O=p.length>0,T=i||!O;return s.jsx(dl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${x} integration`})}),s.jsx(ll,{error:n}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[S&&s.jsx(Ro,{url:S,providerDisplayName:x,credentialName:"credentials"}),s.jsx(y.Input,{placeholder:"Username",onChange:w}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:b,pr:"4.5rem",type:a?"text":"password",placeholder:"Password"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:T,width:"100%",type:"submit",onClick:()=>{r(p,m)},children:"Next"})]})})}function pl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,basicAuth:{username:w.user,password:w.pass}};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,w,p]);const S=(O,T)=>{b({user:O,pass:T}),v(!0)};return u===null?s.jsx(ul,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function fl(e){const{selectedConnection:t}=xt();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function hl({onSuccess:e}){fl(e)}function gl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function ml({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function yl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(gl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(ml,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function wl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,selectedConnection:c,setSelectedConnection:u,providerName:p}){const h=Z(),m=ee(),[v,w]=I.useState(!1);I.useEffect(()=>{if(e&&H&&v){const x={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:x},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(S=>{u(S)}).catch(S=>{console.error("Error loading provider info: ",S)})}},[m,e,v,r,t,i,n,u,h]);const b=()=>{w(!0)};return c===null?s.jsx(yl,{handleSubmit:b,error:null,providerName:p}):a}function Gt({children:e}){return s.jsx(y.Container,{children:s.jsxs(y.Box,{maxWidth:"600px",borderWidth:1,borderRadius:4,children:[s.jsx("div",{style:{padding:"3rem 2rem"},children:e}),s.jsx(ho,{})]})})}function Vt({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function Il({handleSubmit:e,error:t,explicitScopesRequired:r,isButtonDisabled:n,providerName:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),b=()=>c(!a),x=k=>p(k.currentTarget.value),S=k=>m(k.currentTarget.value),O=k=>w(k.currentTarget.value),T=u.length>0,A=h.length>0,P=n||!T||!A,$=()=>{const k={clientId:h,clientSecret:u};r&&v.length>0&&(k.scopes=Yi(v)),e(k)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"Client ID",onChange:S}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:x,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:b,children:a?"Hide":"Show"})})]}),r&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:O})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:P,width:"100%",type:"submit",onClick:$,children:"Next"})]})})}function vl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,explicitScopesRequired:a,providerName:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(Il,{providerName:c,handleSubmit:b,error:v,explicitScopesRequired:a}):s.jsx(Ce,{})}const _o=async(e,t,r,n,i,a,c,u)=>{var h;const p=await H().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${i} not found`);if(p.authType==="oauth2"&&((h=p.oauth2Opts)==null?void 0:h.grantType)==="authorizationCode"){const v=(await H().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(S=>S.provider===i),w=st(i,p);if(!v)throw new Error(`You must first set up a ${w} Provider App using the Ampersand Console.`);const b={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:c,providerAppId:v.id,provider:i}};return await H().oAuthApi.oauthConnect(b)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},xi=600,Oi=600,bl="AUTHORIZATION_SUCCEEDED",Sl="AUTHORIZATION_FAILED";function xl(e,t,r){return I.useCallback(async n=>{const i=await H().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(i)},[e,t,r])}function Ol(e,t,r,n){return I.useCallback(()=>{if(!n)return;const i=window.screenX+(window.outerWidth-xi)/2,a=window.screenY+(window.outerHeight-Oi)/2.5,c=`width=${xi},height=${Oi},left=${i},top=${a}`,u=window.open(n,e,c);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function Cl(e,t){return I.useCallback(r=>{var n,i;if(r.origin===Kc){if(r.data.eventType===bl){const a=(n=r.data.data)==null?void 0:n.connection;a?e(a):console.error("Connection ID not found in event data: ",{event:r})}r.data.eventType===Sl&&(console.error("OAuth failed: ",{event:r}),t==null||t(((i=r==null?void 0:r.data)==null?void 0:i.message)??"OAuth failed. Please try again."))}},[t,e])}function Ao({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onError:n,error:i}){const a=ee(),{projectId:c}=Z(),[u,p]=I.useState(null),[h,m]=I.useState(null),{setSelectedConnection:v}=xt(),w=Cl(p,n),b=Ol(r,m,w,t),x=xl(c,a,v);I.useEffect(()=>{t&&!h&&b()},[t,h,b,w,r]),I.useEffect(()=>{u&&x(u).then(()=>{h==null||h.close()}).catch(O=>{console.error("Error refreshing connection: ",O),n==null||n(O.message??"Unexpected error: not able to refresh connection")})},[u,a,v,x,h,n]);const S=h&&setInterval(()=>{(h!=null&&h.closed||!h)&&S&&(clearInterval(S),window.removeEventListener("message",w),m(null),!u&&!i?(console.error("OAuth failed. Please try again."),n==null||n("OAuth failed. Please try again.")):u&&n&&(n==null||n(null)))},500);return s.jsx("div",{children:e})}function Nl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Tl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(null),[m,v]=I.useState(null),w=async()=>{v(null);try{const x=await _o(c,t,n,u,e,void 0,r,i);h(x)}catch(x){console.error("Could not fetch OAuth popup URL",{err:x}),v(x.message??"Unexpected error")}},b=I.useCallback(x=>{v(x),h(null)},[]);return s.jsx(Ao,{windowTitle:`Connect to ${a}`,oauthUrl:p,onError:b,children:s.jsx(Nl,{handleSubmit:w,error:m,providerName:a})})}function Rl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n,explicitScopesRequired:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),[b,x]=I.useState(""),S=()=>c(!a),O=J=>p(J.currentTarget.value),T=J=>m(J.currentTarget.value),A=J=>w(J.currentTarget.value),P=J=>x(J.currentTarget.value),$=u.length>0,k=h.length>0,Q=v.length>0,X=r||!$||!k||!Q,te=()=>{const J={workspace:v,clientId:h,clientSecret:u};i&&b.length>0&&(J.scopes=Yi(b)),e(J)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:A}),s.jsx(y.Input,{placeholder:"Client ID",onChange:T}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:O,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:S,children:a?"Hide":"Show"})})]}),i&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:P})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:X,width:"100%",type:"submit",onClick:te,children:"Next"})]})})}function _l({provider:e,providerName:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,providerWorkspaceRef:x.workspace,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(Rl,{providerName:t,handleSubmit:b,error:v,explicitScopesRequired:c}):s.jsx(Ce,{})}function Al(){const e=I.useContext($o.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var jo=I.createContext({});jo.displayName="ColorModeContext";function ko(){const e=I.useContext(jo);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function jl(){const e=ko(),t=Al();return{...e,theme:t}}var kl=(...e)=>e.filter(Boolean).join(" ");function nt(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function rt(e,...t){return El(e)?e(...t):e}var El=e=>typeof e=="function",Tr={exports:{}};Tr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=800,a=16,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Proxy]",$="[object RegExp]",k="[object Set]",Q="[object String]",X="[object Undefined]",te="[object WeakMap]",J="[object ArrayBuffer]",Y="[object DataView]",Te="[object Float32Array]",ct="[object Float64Array]",Br="[object Int8Array]",Lr="[object Int16Array]",Kr="[object Int32Array]",Mr="[object Uint8Array]",Ur="[object Uint8ClampedArray]",$r="[object Uint16Array]",qr="[object Uint32Array]",Wr=/[\\^$.*+?()[\]{}|]/g,zr=/^\[object .+?Constructor\]$/,Jr=/^(?:0|[1-9]\d*)$/,M={};M[Te]=M[ct]=M[Br]=M[Lr]=M[Kr]=M[Mr]=M[Ur]=M[$r]=M[qr]=!0,M[u]=M[p]=M[J]=M[m]=M[Y]=M[v]=M[w]=M[b]=M[S]=M[O]=M[A]=M[$]=M[k]=M[Q]=M[te]=!1;var Yt=typeof $e=="object"&&$e&&$e.Object===Object&&$e,U=typeof self=="object"&&self&&self.Object===Object&&self,De=Yt||U||Function("return this")(),Zt=t&&!t.nodeType&&t,oe=Zt&&!0&&e&&!e.nodeType&&e,Ct=oe&&oe.exports===Zt,dt=Ct&&Yt.process,Nt=function(){try{var o=oe&&oe.require&&oe.require("util").types;return o||dt&&dt.binding&&dt.binding("util")}catch{}}(),lt=Nt&&Nt.isTypedArray;function Qt(o,d,f){switch(f.length){case 0:return o.call(d);case 1:return o.call(d,f[0]);case 2:return o.call(d,f[0],f[1]);case 3:return o.call(d,f[0],f[1],f[2])}return o.apply(d,f)}function er(o,d){for(var f=-1,C=Array(o);++f<o;)C[f]=d(f);return C}function Hr(o){return function(d){return o(d)}}function Xr(o,d){return o==null?void 0:o[d]}function Gr(o,d){return function(f){return o(d(f))}}var Vr=Array.prototype,Yr=Function.prototype,ut=Object.prototype,Tt=De["__core-js_shared__"],pt=Yr.toString,be=ut.hasOwnProperty,tr=function(){var o=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),rr=ut.toString,Zr=pt.call(Object),ft=RegExp("^"+pt.call(be).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Be=Ct?De.Buffer:void 0,Rt=De.Symbol,ce=De.Uint8Array;Be&&Be.allocUnsafe;var _t=Gr(Object.getPrototypeOf,Object),At=Object.create,Qr=ut.propertyIsEnumerable,nr=Vr.splice,ue=Rt?Rt.toStringTag:void 0,ze=function(){try{var o=Dt(Object,"defineProperty");return o({},"",{}),o}catch{}}(),ir=Be?Be.isBuffer:void 0,or=Math.max,Re=Date.now,jt=Dt(De,"Map"),Je=Dt(Object,"create"),en=function(){function o(){}return function(d){if(!Ae(d))return{};if(At)return At(d);o.prototype=d;var f=new o;return o.prototype=void 0,f}}();function ge(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function He(){this.__data__=Je?Je(null):{},this.size=0}function kt(o){var d=this.has(o)&&delete this.__data__[o];return this.size-=d?1:0,d}function Et(o){var d=this.__data__;if(Je){var f=d[o];return f===n?void 0:f}return be.call(d,o)?d[o]:void 0}function Ft(o){var d=this.__data__;return Je?d[o]!==void 0:be.call(d,o)}function Xe(o,d){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Je&&d===void 0?n:d,this}ge.prototype.clear=He,ge.prototype.delete=kt,ge.prototype.get=Et,ge.prototype.has=Ft,ge.prototype.set=Xe;function me(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function tn(){this.__data__=[],this.size=0}function rn(o){var d=this.__data__,f=ht(d,o);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(o){var d=this.__data__,f=ht(d,o);return f<0?void 0:d[f][1]}function on(o){return ht(this.__data__,o)>-1}function ar(o,d){var f=this.__data__,C=ht(f,o);return C<0?(++this.size,f.push([o,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 Se(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function _e(){this.size=0,this.__data__={hash:new ge,map:new(jt||me),string:new ge}}function an(o){var d=yt(this,o).delete(o);return this.size-=d?1:0,d}function sn(o){return yt(this,o).get(o)}function cn(o){return yt(this,o).has(o)}function dn(o,d){var f=yt(this,o),C=f.size;return f.set(o,d),this.size+=f.size==C?0:1,this}Se.prototype.clear=_e,Se.prototype.delete=an,Se.prototype.get=sn,Se.prototype.has=cn,Se.prototype.set=dn;function Le(o){var d=this.__data__=new me(o);this.size=d.size}function ye(){this.__data__=new me,this.size=0}function ln(o){var d=this.__data__,f=d.delete(o);return this.size=d.size,f}function un(o){return this.__data__.get(o)}function pn(o){return this.__data__.has(o)}function fn(o,d){var f=this.__data__;if(f instanceof me){var C=f.__data__;if(!jt||C.length<r-1)return C.push([o,d]),this.size=++f.size,this;f=this.__data__=new Se(C)}return f.set(o,d),this.size=f.size,this}Le.prototype.clear=ye,Le.prototype.delete=ln,Le.prototype.get=un,Le.prototype.has=pn,Le.prototype.set=fn;function hn(o,d){var f=Ie(o),C=!f&&Lt(o),R=!f&&!C&&Ze(o),j=!f&&!C&&!R&&Mt(o),D=f||C||R||j,E=D?er(o.length,String):[],F=E.length;for(var q in o)D&&(q=="length"||R&&(q=="offset"||q=="parent")||j&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||Bt(q,F))||E.push(q);return E}function we(o,d,f){(f!==void 0&&!wt(o[d],f)||f===void 0&&!(d in o))&&Pt(o,d,f)}function gn(o,d,f){var C=o[d];(!(be.call(o,d)&&wt(C,f))||f===void 0&&!(d in o))&&Pt(o,d,f)}function ht(o,d){for(var f=o.length;f--;)if(wt(o[f][0],d))return f;return-1}function Pt(o,d,f){d=="__proto__"&&ze?ze(o,d,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[d]=f}var mn=dr();function gt(o){return o==null?o===void 0?X:T:ue&&ue in Object(o)?Cn(o):_n(o)}function Ge(o){return Me(o)&>(o)==u}function yn(o){if(!Ae(o)||lr(o))return!1;var d=Kt(o)?ft:zr;return d.test(En(o))}function wn(o){return Me(o)&&vt(o.length)&&!!M[gt(o)]}function xe(o){if(!Ae(o))return Ke(o);var d=Ye(o),f=[];for(var C in o)C=="constructor"&&(d||!be.call(o,C))||f.push(C);return f}function sr(o,d,f,C,R){o!==d&&mn(d,function(j,D){if(R||(R=new Le),Ae(j))In(o,d,D,f,sr,C,R);else{var E=C?C(pe(o,D),j,D+"",o,d,R):void 0;E===void 0&&(E=j),we(o,D,E)}},Ut)}function In(o,d,f,C,R,j,D){var E=pe(o,f),F=pe(d,f),q=D.get(F);if(q){we(o,f,q);return}var W=j?j(E,F,f+"",o,d,D):void 0,G=W===void 0;if(G){var ne=Ie(F),ie=!ne&&Ze(F),ve=!ne&&!ie&&Mt(F);W=F,ne||ie||ve?Ie(E)?W=E:Fn(E)?W=On(E):ie?(G=!1,W=Sn(F)):ve?(G=!1,W=mt(F)):W=[]:ur(F)||Lt(F)?(W=E,Lt(E)?W=Qe(E):(!Ae(E)||Kt(E))&&(W=Nn(F))):G=!1}G&&(D.set(F,W),R(W,F,C,j,D),D.delete(F)),we(o,f,W)}function vn(o,d){return jn(An(o,d,pr),o+"")}var bn=ze?function(o,d){return ze(o,"toString",{configurable:!0,enumerable:!1,value:Dn(d),writable:!0})}:pr;function Sn(o,d){return o.slice()}function xn(o){var d=new o.constructor(o.byteLength);return new ce(d).set(new ce(o)),d}function mt(o,d){var f=xn(o.buffer);return new o.constructor(f,o.byteOffset,o.length)}function On(o,d){var f=-1,C=o.length;for(d||(d=Array(C));++f<C;)d[f]=o[f];return d}function Ve(o,d,f,C){var R=!f;f||(f={});for(var j=-1,D=d.length;++j<D;){var E=d[j],F=void 0;F===void 0&&(F=o[E]),R?Pt(f,E,F):gn(f,E,F)}return f}function cr(o){return vn(function(d,f){var C=-1,R=f.length,j=R>1?f[R-1]:void 0,D=R>2?f[2]:void 0;for(j=o.length>3&&typeof j=="function"?(R--,j):void 0,D&&Tn(f[0],f[1],D)&&(j=R<3?void 0:j,R=1),d=Object(d);++C<R;){var E=f[C];E&&o(d,E,C,j)}return d})}function dr(o){return function(d,f,C){for(var R=-1,j=Object(d),D=C(d),E=D.length;E--;){var F=D[++R];if(f(j[F],F,j)===!1)break}return d}}function yt(o,d){var f=o.__data__;return Rn(d)?f[typeof d=="string"?"string":"hash"]:f.map}function Dt(o,d){var f=Xr(o,d);return yn(f)?f:void 0}function Cn(o){var d=be.call(o,ue),f=o[ue];try{o[ue]=void 0;var C=!0}catch{}var R=rr.call(o);return C&&(d?o[ue]=f:delete o[ue]),R}function Nn(o){return typeof o.constructor=="function"&&!Ye(o)?en(_t(o)):{}}function Bt(o,d){var f=typeof o;return d=d??c,!!d&&(f=="number"||f!="symbol"&&Jr.test(o))&&o>-1&&o%1==0&&o<d}function Tn(o,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)?wt(f[d],o):!1}function Rn(o){var d=typeof o;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?o!=="__proto__":o===null}function lr(o){return!!tr&&tr in o}function Ye(o){var d=o&&o.constructor,f=typeof d=="function"&&d.prototype||ut;return o===f}function Ke(o){var d=[];if(o!=null)for(var f in Object(o))d.push(f);return d}function _n(o){return rr.call(o)}function An(o,d,f){return d=or(d===void 0?o.length-1:d,0),function(){for(var C=arguments,R=-1,j=or(C.length-d,0),D=Array(j);++R<j;)D[R]=C[d+R];R=-1;for(var E=Array(d+1);++R<d;)E[R]=C[R];return E[d]=f(D),Qt(o,this,E)}}function pe(o,d){if(!(d==="constructor"&&typeof o[d]=="function")&&d!="__proto__")return o[d]}var jn=kn(bn);function kn(o){var d=0,f=0;return function(){var C=Re(),R=a-(C-f);if(f=C,R>0){if(++d>=i)return arguments[0]}else d=0;return o.apply(void 0,arguments)}}function En(o){if(o!=null){try{return pt.call(o)}catch{}try{return o+""}catch{}}return""}function wt(o,d){return o===d||o!==o&&d!==d}var Lt=Ge(function(){return arguments}())?Ge:function(o){return Me(o)&&be.call(o,"callee")&&!Qr.call(o,"callee")},Ie=Array.isArray;function It(o){return o!=null&&vt(o.length)&&!Kt(o)}function Fn(o){return Me(o)&&It(o)}var Ze=ir||l;function Kt(o){if(!Ae(o))return!1;var d=gt(o);return d==b||d==x||d==h||d==P}function vt(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=c}function Ae(o){var d=typeof o;return o!=null&&(d=="object"||d=="function")}function Me(o){return o!=null&&typeof o=="object"}function ur(o){if(!Me(o)||gt(o)!=A)return!1;var d=_t(o);if(d===null)return!0;var f=be.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&pt.call(f)==Zr}var Mt=lt?Hr(lt):wn;function Qe(o){return Ve(o,Ut(o))}function Ut(o){return It(o)?hn(o):xe(o)}var Pn=cr(function(o,d,f,C){sr(o,d,f,C)});function Dn(o){return function(){return o}}function pr(o){return o}function l(){return!1}e.exports=Pn})(Tr,Tr.exports);var Fl=Tr.exports;const Ee=ei(Fl);var Pl=e=>/!(important)?$/.test(e),Ci=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,Dl=(e,t)=>r=>{const n=String(t),i=Pl(n),a=Ci(n),c=e?`${e}.${a}`:a;let u=nt(r.__cssMap)&&c in r.__cssMap?r.__cssMap[c].varRef:t;return u=Ci(u),i?`${u} !important`:u};function si(e){const{scale:t,transform:r,compose:n}=e;return(a,c)=>{var u;const p=Dl(t,a)(c);let h=(u=r==null?void 0:r(p,c))!=null?u:p;return n&&(h=n(h,c)),h}}var wr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function fe(e,t){return r=>{const n={property:r,scale:e};return n.transform=si({scale:e,transform:t}),n}}var Bl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Ll(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Bl(t),transform:r?si({scale:r,compose:n}):n}}var Eo=["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 Kl(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...Eo].join(" ")}function Ml(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...Eo].join(" ")}var Ul={"--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(" ")},$l={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 ql(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 Wl={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Xn={"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"},zl=new Set(Object.values(Xn)),Gn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),Jl=e=>e.trim();function Hl(e,t){if(e==null||Gn.has(e))return e;if(!(Vn(e)||Gn.has(e)))return`url('${e}')`;const i=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=i==null?void 0:i[1],c=i==null?void 0:i[2];if(!a||!c)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...h]=c.split(",").map(Jl).filter(Boolean);if((h==null?void 0:h.length)===0)return e;const m=p in Xn?Xn[p]:p;h.unshift(m);const v=h.map(w=>{if(zl.has(w))return w;const b=w.indexOf(" "),[x,S]=b!==-1?[w.substr(0,b),w.substr(b+1)]:[w],O=Vn(S)?S:S&&S.split(" "),T=`colors.${x}`,A=T in t.__cssMap?t.__cssMap[T].varRef:x;return O?[A,...Array.isArray(O)?O:[O]].join(" "):A});return`${u}(${v.join(", ")})`}var Vn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Xl=(e,t)=>Hl(e,t??{});function Gl(e){return/^var\(--.+\)$/.test(e)}var Vl=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Oe=e=>t=>`${e}(${t})`,B={filter(e){return e!=="auto"?e:Ul},backdropFilter(e){return e!=="auto"?e:$l},ring(e){return ql(B.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?Kl():e==="auto-gpu"?Ml():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=Vl(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(Gl(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Xl,blur:Oe("blur"),opacity:Oe("opacity"),brightness:Oe("brightness"),contrast:Oe("contrast"),dropShadow:Oe("drop-shadow"),grayscale:Oe("grayscale"),hueRotate:e=>Oe("hue-rotate")(B.degree(e)),invert:Oe("invert"),saturate:Oe("saturate"),sepia:Oe("sepia"),bgImage(e){return e==null||Vn(e)||Gn.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=Wl[e])!=null?t:{},i={flexDirection:e};return r&&(i[r]=1),n&&(i[n]=1),i}},g={borderWidths:fe("borderWidths"),borderStyles:fe("borderStyles"),colors:fe("colors"),borders:fe("borders"),gradients:fe("gradients",B.gradient),radii:fe("radii",B.px),space:fe("space",wr(B.vh,B.px)),spaceT:fe("space",wr(B.vh,B.px)),degreeT(e){return{property:e,transform:B.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:si({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:fe("sizes",wr(B.vh,B.px)),sizesT:fe("sizes",wr(B.vh,B.fraction)),shadows:fe("shadows"),logical:Ll,blur:fe("blur",B.blur)},br={background:g.colors("background"),backgroundColor:g.colors("backgroundColor"),backgroundImage:g.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:B.bgClip},bgSize:g.prop("backgroundSize"),bgPosition:g.prop("backgroundPosition"),bg:g.colors("background"),bgColor:g.colors("backgroundColor"),bgPos:g.prop("backgroundPosition"),bgRepeat:g.prop("backgroundRepeat"),bgAttachment:g.prop("backgroundAttachment"),bgGradient:g.gradients("backgroundImage"),bgClip:{transform:B.bgClip}};Object.assign(br,{bgImage:br.backgroundImage,bgImg:br.backgroundImage});var L={border:g.borders("border"),borderWidth:g.borderWidths("borderWidth"),borderStyle:g.borderStyles("borderStyle"),borderColor:g.colors("borderColor"),borderRadius:g.radii("borderRadius"),borderTop:g.borders("borderTop"),borderBlockStart:g.borders("borderBlockStart"),borderTopLeftRadius:g.radii("borderTopLeftRadius"),borderStartStartRadius:g.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:g.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:g.radii("borderTopRightRadius"),borderStartEndRadius:g.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:g.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:g.borders("borderRight"),borderInlineEnd:g.borders("borderInlineEnd"),borderBottom:g.borders("borderBottom"),borderBlockEnd:g.borders("borderBlockEnd"),borderBottomLeftRadius:g.radii("borderBottomLeftRadius"),borderBottomRightRadius:g.radii("borderBottomRightRadius"),borderLeft:g.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:g.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:g.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:g.borders(["borderLeft","borderRight"]),borderInline:g.borders("borderInline"),borderY:g.borders(["borderTop","borderBottom"]),borderBlock:g.borders("borderBlock"),borderTopWidth:g.borderWidths("borderTopWidth"),borderBlockStartWidth:g.borderWidths("borderBlockStartWidth"),borderTopColor:g.colors("borderTopColor"),borderBlockStartColor:g.colors("borderBlockStartColor"),borderTopStyle:g.borderStyles("borderTopStyle"),borderBlockStartStyle:g.borderStyles("borderBlockStartStyle"),borderBottomWidth:g.borderWidths("borderBottomWidth"),borderBlockEndWidth:g.borderWidths("borderBlockEndWidth"),borderBottomColor:g.colors("borderBottomColor"),borderBlockEndColor:g.colors("borderBlockEndColor"),borderBottomStyle:g.borderStyles("borderBottomStyle"),borderBlockEndStyle:g.borderStyles("borderBlockEndStyle"),borderLeftWidth:g.borderWidths("borderLeftWidth"),borderInlineStartWidth:g.borderWidths("borderInlineStartWidth"),borderLeftColor:g.colors("borderLeftColor"),borderInlineStartColor:g.colors("borderInlineStartColor"),borderLeftStyle:g.borderStyles("borderLeftStyle"),borderInlineStartStyle:g.borderStyles("borderInlineStartStyle"),borderRightWidth:g.borderWidths("borderRightWidth"),borderInlineEndWidth:g.borderWidths("borderInlineEndWidth"),borderRightColor:g.colors("borderRightColor"),borderInlineEndColor:g.colors("borderInlineEndColor"),borderRightStyle:g.borderStyles("borderRightStyle"),borderInlineEndStyle:g.borderStyles("borderInlineEndStyle"),borderTopRadius:g.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:g.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:g.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:g.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(L,{rounded:L.borderRadius,roundedTop:L.borderTopRadius,roundedTopLeft:L.borderTopLeftRadius,roundedTopRight:L.borderTopRightRadius,roundedTopStart:L.borderStartStartRadius,roundedTopEnd:L.borderStartEndRadius,roundedBottom:L.borderBottomRadius,roundedBottomLeft:L.borderBottomLeftRadius,roundedBottomRight:L.borderBottomRightRadius,roundedBottomStart:L.borderEndStartRadius,roundedBottomEnd:L.borderEndEndRadius,roundedLeft:L.borderLeftRadius,roundedRight:L.borderRightRadius,roundedStart:L.borderInlineStartRadius,roundedEnd:L.borderInlineEndRadius,borderStart:L.borderInlineStart,borderEnd:L.borderInlineEnd,borderTopStartRadius:L.borderStartStartRadius,borderTopEndRadius:L.borderStartEndRadius,borderBottomStartRadius:L.borderEndStartRadius,borderBottomEndRadius:L.borderEndEndRadius,borderStartRadius:L.borderInlineStartRadius,borderEndRadius:L.borderInlineEndRadius,borderStartWidth:L.borderInlineStartWidth,borderEndWidth:L.borderInlineEndWidth,borderStartColor:L.borderInlineStartColor,borderEndColor:L.borderInlineEndColor,borderStartStyle:L.borderInlineStartStyle,borderEndStyle:L.borderInlineEndStyle});var Yl={color:g.colors("color"),textColor:g.colors("color"),fill:g.colors("fill"),stroke:g.colors("stroke")},Yn={boxShadow:g.shadows("boxShadow"),mixBlendMode:!0,blendMode:g.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:g.prop("backgroundBlendMode"),opacity:!0};Object.assign(Yn,{shadow:Yn.boxShadow});var Zl={filter:{transform:B.filter},blur:g.blur("--chakra-blur"),brightness:g.propT("--chakra-brightness",B.brightness),contrast:g.propT("--chakra-contrast",B.contrast),hueRotate:g.propT("--chakra-hue-rotate",B.hueRotate),invert:g.propT("--chakra-invert",B.invert),saturate:g.propT("--chakra-saturate",B.saturate),dropShadow:g.propT("--chakra-drop-shadow",B.dropShadow),backdropFilter:{transform:B.backdropFilter},backdropBlur:g.blur("--chakra-backdrop-blur"),backdropBrightness:g.propT("--chakra-backdrop-brightness",B.brightness),backdropContrast:g.propT("--chakra-backdrop-contrast",B.contrast),backdropHueRotate:g.propT("--chakra-backdrop-hue-rotate",B.hueRotate),backdropInvert:g.propT("--chakra-backdrop-invert",B.invert),backdropSaturate:g.propT("--chakra-backdrop-saturate",B.saturate)},Rr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:B.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:g.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:g.space("gap"),rowGap:g.space("rowGap"),columnGap:g.space("columnGap")};Object.assign(Rr,{flexDir:Rr.flexDirection});var Fo={gridGap:g.space("gridGap"),gridColumnGap:g.space("gridColumnGap"),gridRowGap:g.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},Ql={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:B.outline},outlineOffset:!0,outlineColor:g.colors("outlineColor")},he={width:g.sizesT("width"),inlineSize:g.sizesT("inlineSize"),height:g.sizes("height"),blockSize:g.sizes("blockSize"),boxSize:g.sizes(["width","height"]),minWidth:g.sizes("minWidth"),minInlineSize:g.sizes("minInlineSize"),minHeight:g.sizes("minHeight"),minBlockSize:g.sizes("minBlockSize"),maxWidth:g.sizes("maxWidth"),maxInlineSize:g.sizes("maxInlineSize"),maxHeight:g.sizes("maxHeight"),maxBlockSize:g.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,i;return{[`@media screen and (min-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n.minW)!=null?i:e})`]:{display:"none"}}}},hideBelow:{scale:"breakpoints",transform:(e,t)=>{var r,n,i;return{[`@media screen and (max-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n._minW)!=null?i:e})`]:{display:"none"}}}},verticalAlign:!0,boxSizing:!0,boxDecorationBreak:!0,float:g.propT("float",B.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(he,{w:he.width,h:he.height,minW:he.minWidth,maxW:he.maxWidth,minH:he.minHeight,maxH:he.maxHeight,overscroll:he.overscrollBehavior,overscrollX:he.overscrollBehaviorX,overscrollY:he.overscrollBehaviorY});var eu={listStyleType:!0,listStylePosition:!0,listStylePos:g.prop("listStylePosition"),listStyleImage:!0,listStyleImg:g.prop("listStyleImage")};function tu(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var ru=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},nu=ru(tu),iu={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},ou={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},Mn=(e,t,r)=>{const n={},i=nu(e,t,{});for(const a in i)a in r&&r[a]!=null||(n[a]=i[a]);return n},au={srOnly:{transform(e){return e===!0?iu:e==="focusable"?ou:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>Mn(t,e,r)}},zt={position:!0,pos:g.prop("position"),zIndex:g.prop("zIndex","zIndices"),inset:g.spaceT("inset"),insetX:g.spaceT(["left","right"]),insetInline:g.spaceT("insetInline"),insetY:g.spaceT(["top","bottom"]),insetBlock:g.spaceT("insetBlock"),top:g.spaceT("top"),insetBlockStart:g.spaceT("insetBlockStart"),bottom:g.spaceT("bottom"),insetBlockEnd:g.spaceT("insetBlockEnd"),left:g.spaceT("left"),insetInlineStart:g.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:g.spaceT("right"),insetInlineEnd:g.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(zt,{insetStart:zt.insetInlineStart,insetEnd:zt.insetInlineEnd});var su={ring:{transform:B.ring},ringColor:g.colors("--chakra-ring-color"),ringOffset:g.prop("--chakra-ring-offset-width"),ringOffsetColor:g.colors("--chakra-ring-offset-color"),ringInset:g.prop("--chakra-ring-inset")},z={margin:g.spaceT("margin"),marginTop:g.spaceT("marginTop"),marginBlockStart:g.spaceT("marginBlockStart"),marginRight:g.spaceT("marginRight"),marginInlineEnd:g.spaceT("marginInlineEnd"),marginBottom:g.spaceT("marginBottom"),marginBlockEnd:g.spaceT("marginBlockEnd"),marginLeft:g.spaceT("marginLeft"),marginInlineStart:g.spaceT("marginInlineStart"),marginX:g.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:g.spaceT("marginInline"),marginY:g.spaceT(["marginTop","marginBottom"]),marginBlock:g.spaceT("marginBlock"),padding:g.space("padding"),paddingTop:g.space("paddingTop"),paddingBlockStart:g.space("paddingBlockStart"),paddingRight:g.space("paddingRight"),paddingBottom:g.space("paddingBottom"),paddingBlockEnd:g.space("paddingBlockEnd"),paddingLeft:g.space("paddingLeft"),paddingInlineStart:g.space("paddingInlineStart"),paddingInlineEnd:g.space("paddingInlineEnd"),paddingX:g.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:g.space("paddingInline"),paddingY:g.space(["paddingTop","paddingBottom"]),paddingBlock:g.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 cu={textDecorationColor:g.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:g.shadows("textShadow")},du={clipPath:!0,transform:g.propT("transform",B.transform),transformOrigin:!0,translateX:g.spaceT("--chakra-translate-x"),translateY:g.spaceT("--chakra-translate-y"),skewX:g.degreeT("--chakra-skew-x"),skewY:g.degreeT("--chakra-skew-y"),scaleX:g.prop("--chakra-scale-x"),scaleY:g.prop("--chakra-scale-y"),scale:g.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:g.degreeT("--chakra-rotate")},lu={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:g.prop("transitionDuration","transition.duration"),transitionProperty:g.prop("transitionProperty","transition.property"),transitionTimingFunction:g.prop("transitionTimingFunction","transition.easing")},uu={fontFamily:g.prop("fontFamily","fonts"),fontSize:g.prop("fontSize","fontSizes",B.px),fontWeight:g.prop("fontWeight","fontWeights"),lineHeight:g.prop("lineHeight","lineHeights"),letterSpacing:g.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"}},pu={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:g.spaceT("scrollMargin"),scrollMarginTop:g.spaceT("scrollMarginTop"),scrollMarginBottom:g.spaceT("scrollMarginBottom"),scrollMarginLeft:g.spaceT("scrollMarginLeft"),scrollMarginRight:g.spaceT("scrollMarginRight"),scrollMarginX:g.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:g.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:g.spaceT("scrollPadding"),scrollPaddingTop:g.spaceT("scrollPaddingTop"),scrollPaddingBottom:g.spaceT("scrollPaddingBottom"),scrollPaddingLeft:g.spaceT("scrollPaddingLeft"),scrollPaddingRight:g.spaceT("scrollPaddingRight"),scrollPaddingX:g.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:g.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function Po(e){return nt(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(Po).join(` ${e} `).replace(/calc/g,""),Ni=(...e)=>`calc(${Dr("+",...e)})`,Ti=(...e)=>`calc(${Dr("-",...e)})`,Zn=(...e)=>`calc(${Dr("*",...e)})`,Ri=(...e)=>`calc(${Dr("/",...e)})`,_i=e=>{const t=Po(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Zn(t,-1)},Wt=Object.assign(e=>({add:(...t)=>Wt(Ni(e,...t)),subtract:(...t)=>Wt(Ti(e,...t)),multiply:(...t)=>Wt(Zn(e,...t)),divide:(...t)=>Wt(Ri(e,...t)),negate:()=>Wt(_i(e)),toString:()=>e.toString()}),{add:Ni,subtract:Ti,multiply:Zn,divide:Ri,negate:_i});function fu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function Ai(e){if(e==null)return e;const{unitless:t}=fu(e);return t||typeof e=="number"?`${e}px`:e}function hu(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${Ai(e)})`),t&&r.push("and",`(max-width: ${Ai(t)})`),r.join(" ")}var re={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=>Do(t=>e(t,"&"),"[role=group]","[data-group]",".group"),ke=e=>Do(t=>e(t,"~ &"),"[data-peer]",".peer"),Do=(e,...t)=>t.map(e).join(", "),ci={_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(re.hover),_peerHover:ke(re.hover),_groupFocus:Ue(re.focus),_peerFocus:ke(re.focus),_groupFocusVisible:Ue(re.focusVisible),_peerFocusVisible:ke(re.focusVisible),_groupActive:Ue(re.active),_peerActive:ke(re.active),_groupDisabled:Ue(re.disabled),_peerDisabled:ke(re.disabled),_groupInvalid:Ue(re.invalid),_peerInvalid:ke(re.invalid),_groupChecked:Ue(re.checked),_peerChecked:ke(re.checked),_groupFocusWithin:Ue(re.focusWithin),_peerFocusWithin:ke(re.focusWithin),_peerPlaceholderShown:ke(re.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]"},gu=Object.keys(ci),di=Ee({},br,L,Yl,Rr,he,Zl,su,Ql,Fo,au,zt,Yn,z,pu,uu,cu,du,eu,lu);Object.assign({},z,he,Rr,Fo,zt);var mu=[...Object.keys(di),...gu],yu={...di,...ci},wu=e=>e in yu,Iu=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:i}=t.__breakpoints,a={};for(const c in e){let u=rt(e[c],t);if(u==null)continue;if(u=nt(u)&&r(u)?n(u):u,!Array.isArray(u)){a[c]=u;continue}const p=u.slice(0,i.length).length;for(let h=0;h<p;h+=1){const m=i==null?void 0:i[h];if(!m){a[c]=u[h];continue}a[m]=a[m]||{},u[h]!=null&&(a[m][c]=u[h])}}return a};function vu(e){const t=[];let r="",n=!1;for(let i=0;i<e.length;i++){const a=e[i];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 bu(e){return/^var\(--.+\)$/.test(e)}var Su=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!bu(t),xu=(e,t)=>{var r,n;if(t==null)return t;const i=p=>{var h,m;return(m=(h=e.__cssMap)==null?void 0:h[p])==null?void 0:m.varRef},a=p=>{var h;return(h=i(p))!=null?h:p},[c,u]=vu(t);return t=(n=(r=i(c))!=null?r:a(u))!=null?n:a(t),t};function Ou(e){const{configs:t={},pseudos:r={},theme:n}=e,i=(a,c=!1)=>{var u,p,h;const m=rt(a,n),v=Iu(m)(n);let w={};for(let b in v){const x=v[b];let S=rt(x,n);b in r&&(b=r[b]),Su(b,S)&&(S=xu(n,S));let O=t[b];if(O===!0&&(O={property:b}),nt(S)){w[b]=(u=w[b])!=null?u:{},w[b]=Ee({},w[b],i(S,!0));continue}let T=(h=(p=O==null?void 0:O.transform)==null?void 0:p.call(O,S,n,m))!=null?h:S;T=O!=null&&O.processResult?i(T,!0):T;const A=rt(O==null?void 0:O.property,n);if(!c&&(O!=null&&O.static)){const P=rt(O.static,n);w=Ee({},w,P)}if(A&&Array.isArray(A)){for(const P of A)w[P]=T;continue}if(A){A==="&"&&nt(T)?w=Ee({},w,T):w[A]=T;continue}if(nt(T)){w=Ee({},w,T);continue}w[b]=T}return w};return i}var Cu=e=>t=>Ou({theme:t,pseudos:ci,configs:di})(e);function Nu(e,t){if(Array.isArray(e))return e;if(nt(e))return t(e);if(e!=null)return[e]}function Tu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function Ru(e){const t=e.__breakpoints;return function(n,i,a,c){var u,p;if(!t)return;const h={},m=Nu(a,t.toArrayValue);if(!m)return h;const v=m.length,w=v===1,b=!!n.parts;for(let x=0;x<v;x++){const S=t.details[x],O=t.details[Tu(m,x)],T=hu(S.minW,O==null?void 0:O._minW),A=rt((u=n[i])==null?void 0:u[m[x]],c);if(A){if(b){(p=n.parts)==null||p.forEach(P=>{Ee(h,{[P]:w?A[P]:{[T]:A[P]}})});continue}if(!b){w?Ee(h,A):h[T]=A;continue}h[T]=A}}return h}}function _u(e){return t=>{var r;const{variant:n,size:i,theme:a}=t,c=Ru(a);return Ee({},rt((r=e.baseStyle)!=null?r:{},t),c(e,"sizes",i,t),c(e,"variants",n,t))}}function Au(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function ju(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var ku=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},Eu=ku(ju);function Bo(e,t){const r={};return Object.keys(e).forEach(n=>{const i=e[n];t(i,n,e)&&(r[n]=i)}),r}var Lo=e=>Bo(e,t=>t!=null);function Fu(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Pu(e,...t){return Fu(e)?e(...t):e}var Du=typeof Element<"u",Bu=typeof Map=="function",Lu=typeof Set=="function",Ku=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,i;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(Bu&&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(Lu&&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(Ku&&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(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[n]))return!1;if(Du&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((i[n]==="_owner"||i[n]==="__v"||i[n]==="__o")&&e.$$typeof)&&!Sr(e[i[n]],t[i[n]]))return!1;return!0}return e!==e&&t!==t}var Mu=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 Uu=ei(Mu);function $u(e,t={}){var r;const{styleConfig:n,...i}=t,{theme:a,colorMode:c}=jl(),u=Eu(a,`components.${e}`),p=n||u,h=Ee({theme:a,colorMode:c},(r=p==null?void 0:p.defaultProps)!=null?r:{},Lo(Au(i,["children"]))),m=I.useRef({});if(p){const w=_u(p)(h);Uu(m.current,w)||(m.current=w)}return m.current}function qu(e,t={}){return $u(e,t)}var Wu=new Set([...mu,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),zu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Ju(e){return zu.has(e)||!Wu.has(e)}function Hu(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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(i in r&&delete r[i],r[i]=n[i]);return r}var ji,Xu=(ji=ui.default)!=null?ji:ui,Gu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:i,sx:a,...c}=t,u=Bo(c,(v,w)=>wu(w)),p=Pu(e,t),h=Hu({},i,p,Lo(u),a),m=Cu(h)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Ju);const i=Gu({baseStyle:r}),a=Xu(e,n)(i);return I.forwardRef(function(p,h){const{colorMode:m,forced:v}=ko();return I.createElement(a,{ref:h,"data-theme":v?m:void 0,...p})})}function Vu(){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 ki=Vu();function Ko(e){return I.forwardRef(e)}var Ei={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"},Mo=Ko((e,t)=>{const{as:r,viewBox:n,color:i="currentColor",focusable:a=!1,children:c,className:u,__css:p,...h}=e,m=kl("chakra-icon",u),v=qu("Icon",e),w={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:i,...p,...v},b={ref:t,focusable:a,className:m,__css:w},x=n??Ei.viewBox;if(r&&typeof r!="string")return s.jsx(ki.svg,{as:r,...b,...h});const S=c??Ei.path;return s.jsx(ki.svg,{verticalAlign:"middle",viewBox:x,...b,...h,children:S})});Mo.displayName="Icon";function Yu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:i={}}=e,a=I.Children.toArray(e.path),c=Ko((u,p)=>s.jsx(Mo,{ref:p,viewBox:t,...i,...u,children:a.length?a:s.jsx("path",{fill:"currentColor",d:r})}));return c.displayName=n,c}var Zu=Yu({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 Qu="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function ep({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{children:s.jsx(y.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),s.jsxs(y.Link,{href:Qu,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",s.jsx(Zu,{mx:"2px"})]}),s.jsx(Vt,{error:r}),s.jsxs(y.Flex,{marginTop:"1em",children:[s.jsx(y.Input,{placeholder:"MyDomain",onChange:i=>t(i.currentTarget.value)}),s.jsx(y.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function tp({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n,providerName:i}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsxs(y.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),s.jsx(Vt,{error:r}),s.jsx(y.Flex,{marginTop:"1em",children:s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:a=>t(a.currentTarget.value)})}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}const rp="salesforce";function np({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(""),[m,v]=I.useState(null),[w,b]=I.useState(null),x=async()=>{if(b(null),!p){b("Workspace is required");return}try{const T=await _o(c,t,n,u,e,p,r,i);v(T)}catch(T){console.error(T),b((T==null?void 0:T.message)??"Unexpected error")}},S=I.useCallback(T=>{b(T),v(null)},[]),O=e===rp?s.jsx(ep,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0}):s.jsx(tp,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0,providerName:a});return s.jsx(Ao,{windowTitle:`Connect to ${a}`,oauthUrl:m,onError:S,children:O})}const ip="authorizationCode",op="clientCredentials";function ap({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,selectedConnection:c,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return s.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p,explicitScopesRequired:h,explicitWorkspaceRequired:m}=t.oauth2Opts,v=st(e,t);return p===ip?m?s.jsx(np,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):s.jsx(Tl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):p===op?m?s.jsx(_l,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):s.jsx(vl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):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 sp=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 Uo({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,onSuccess:c}){const u=ee(),[p,h]=I.useState(null),{provider:m}=Ne(),{selectedConnection:v,setSelectedConnection:w,connections:b}=xt();hl({onSuccess:c});const x=e||m,S=(p==null?void 0:p.displayName)??Vi(x);if(I.useEffect(()=>{if(!v&&b&&b.length>0){const[O]=b;w(O)}sp(u,x).then(O=>{h(O)}).catch(O=>{console.error("Error loading provider info: ",O)})},[b,v,w,u,x]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");return v?a:p==null?s.jsx("strong",{children:"Provider not found"}):p.authType==="none"?s.jsx(wl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,providerName:S,children:a}):p.authType==="basic"?s.jsx(pl,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):p.authType==="apiKey"?s.jsx(cl,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):s.jsx(ap,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:i,setSelectedConnection:w,selectedConnection:v})}function cp({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u}){var m;const{projectId:p}=Z(),{errorState:h}=We();return(m=h[V.INTEGRATION_LIST])!=null&&m.apiError?s.jsx(Fe,{message:"Something went wrong, couldn't find integration information"}):s.jsx(Gc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u,children:s.jsx(eo,{groupRef:n,children:s.jsx(Uo,{consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:s.jsx(gd,{projectId:p,children:s.jsx(il,{children:s.jsx(Rd,{children:s.jsx(Ed,{children:s.jsx(Zd,{})})})})})})})})}function dp({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?s.jsx(y.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:s.jsx(Ce,{message:"Redirecting..."})}):t}function lp({provider:e}){const{appName:t}=Z(),r=`You have successfully connected your ${st(e)} account to ${t}.`;return s.jsx(ai,{text:r})}function up({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,redirectUrl:a,onSuccess:c}){return s.jsx(eo,{provider:e,groupRef:n,children:s.jsx(Uo,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onSuccess:c,children:s.jsx(dp,{redirectURL:a,children:s.jsx(lp,{provider:e})})})})}const pp=(e,t)=>{const r=ee(),{projectId:n}=Z(),{integrations:i}=Hi(),[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 h=I.useMemo(()=>i==null?void 0:i.reduce((m,v)=>(v==null?void 0:v.name)===e?v:m,{}),[i,e]);return I.useEffect(()=>{h&&H().installationApi.listInstallations({projectIdOrName:n,integrationId:h.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,h]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Gi;exports.AmpersandProvider=zc;exports.ConnectProvider=up;exports.InstallIntegration=cp;exports.useAmpersandProvider=Jc;exports.useIsIntegrationInstalled=pp;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react"),S=require("@chakra-ui/react");require("react-dom");function Xa(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const X=Xa(y),Ya={primary:{bg:"black",color:"white",_hover:{bg:"gray.700",_disabled:{bg:"gray.600"}},_disabled:{bg:"gray.600",color:"gray.300",cursor:"not-allowed",opacity:1}},warning:{bg:"red.50",outline:"2px solid red.100",outlineOffset:"0",borderColor:"red.100",color:"red.800",_hover:{bg:"red.100"}}},Ga=S.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.200"},_selected:{color:"black",fontWeight:"500",bg:"gray.100",border:"none",_hover:{bg:"gray.200"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.100"},_selected:{color:"red.800",fontWeight:"500",bg:"red.50",border:"none",_hover:{bg:"red.100"}}}}},Button:{variants:Ya}}}),Za=S.extendTheme(Ga);function Qa({children:e}){return a.jsx(S.ChakraProvider,{theme:Za,children:e})}const Xo=y.createContext(null),ec=Xo.Provider,xe=()=>{const e=y.useContext(Xo);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var me=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e.INSTALLATION_MUTATION="installationMutationError",e))(me||{});const Yo=y.createContext(void 0);function dt(){const e=y.useContext(Yo);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const tc=(()=>{const e={};return Object.values(me).forEach(t=>{e[t]={}}),e})();function nc({children:e}){const[t,n]=y.useState(tc),o=y.useCallback((p,h,v=!0)=>{n(f=>{const g={...f};return g[p]=g[p]||{},g[p][h]=v,g})},[n]),i=y.useCallback((p,h)=>{var v;return!!((v=t[p])!=null&&v[h])},[t]),r=y.useCallback((p,h)=>{var v;return(v=t[p])==null?void 0:v[h]},[t]),s=y.useCallback((p,h)=>{n(v=>{var g;const f={...v};return(g=f[p])==null||delete g[h],f})},[n]),c=y.useCallback(p=>{n(h=>{const v={...h};return v[p]={},v})},[n]),u=y.useCallback((p,h)=>{n(v=>{const f={...v};return f[p]=f[p]||{},h.forEach(g=>{f[p][g]=!0}),f})},[n]),d=y.useMemo(()=>({errorState:t,setErrorState:n,setError:o,isError:i,removeError:s,resetBoundary:c,setErrors:u,getError:r}),[t,n,o,i,s,c,u,r]);return a.jsx(Yo.Provider,{value:d,children:e})}function ho(){return a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function rc(e,t){try{return process.env[e]}catch{return t}}function Go(e){return e.charAt(0).toUpperCase()+e.slice(1)}function it(e,t){return(t==null?void 0:t.displayName)??Go(e)}const Ir=e=>e.split(`
|
|
2
|
+
`).filter(n=>n.trim()!==""),oc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,ve=rc("REACT_APP_ENABLE_CSS",!1),ic="_box_3e1nt_1",mo={box:ic};function Dt({children:e,className:t,style:n}){return ve?a.jsx("div",{className:t?`${mo.box} ${t}`:mo.box,style:n,children:e}):a.jsx(S.Box,{className:t,style:n,borderWidth:1,borderRadius:4,children:e})}const sc="_container_1wvzr_1",go={container:sc};function Gt({children:e,className:t,style:n}){return ve?a.jsx("div",{className:t?`${go.container} ${t}`:go.container,style:n,children:e}):a.jsx(S.Container,{className:t,style:n,children:e})}const ac="_errorBoxContainer_1qhwq_1",cc="_errorBox_1qhwq_1",uc="_errorText_1qhwq_20",qn={errorBoxContainer:ac,errorBox:cc,errorText:uc};function ot({message:e}){return ve?a.jsxs(Gt,{className:qn.errorBoxContainer,children:[a.jsx(ho,{}),a.jsx(Dt,{className:qn.errorBox,children:a.jsx("p",{className:qn.errorText,children:e})})]}):a.jsxs(S.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[a.jsx(ho,{}),a.jsx(S.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:a.jsx(S.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const lc="https://api.withampersand.com/v1".replace(/\/+$/,"");class Zo{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:lc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ei}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 dc=new Zo,An=class An{constructor(t=dc){this.configuration=t,this.fetchApi=async(n,o)=>{let i={url:n,init:o};for(const s of this.middleware)s.pre&&(i=await s.pre({fetch:this.fetchApi,...i})||i);let r;try{r=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(s){for(const c of this.middleware)c.onError&&(r=await c.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:s,response:r?r.clone():void 0})||r);if(r===void 0)throw s instanceof Error?new hc(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(r=await s.post({fetch:this.fetchApi,url:i.url,init:i.init,response:r.clone()})||r);return r},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(o=>({pre:o}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(o=>({post:o}));return this.withMiddleware(...n)}isJsonMime(t){return t?An.jsonRegex.test(t):!1}async request(t,n){const{url:o,init:i}=await this.createFetchParams(t,n),r=await this.fetchApi(o,i);if(r&&r.status>=200&&r.status<300)return r;throw new Qo(r,"Response returned an error code")}async createFetchParams(t,n){let o=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(o+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(d=>i[d]===void 0?delete i[d]:{});const r=typeof n=="function"?n:async()=>n,s={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},c={...s,...await r({init:s,context:t})},u={...c,body:fc(c.body)||c.body instanceof URLSearchParams||pc(c.body)?c.body:JSON.stringify(c.body)};return{url:o,init:u}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};An.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let ze=An;function pc(e){return typeof Blob<"u"&&e instanceof Blob}function fc(e){return typeof FormData<"u"&&e instanceof FormData}class Qo extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class hc extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class Y extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function M(e,t){const n=e[t];return n!=null}function ei(e,t=""){return Object.keys(e).map(n=>ti(n,e[n],t)).filter(n=>n.length>0).join("&")}function ti(e,t,n=""){const o=n+(n.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(r=>encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${i}`}if(t instanceof Set){const i=Array.from(t);return ti(e,i,n)}return t instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ei(t,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`}function wr(e,t){return Object.keys(e).reduce((n,o)=>({...n,[o]:t(e[o])}),{})}class ye{constructor(t,n=o=>o){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Nt{constructor(t){this.raw=t}async value(){}}class mc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function gc(e){return yc(e)}function yc(e,t){return e==null?e:{fieldUsed:M(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:M(e,"keyFormat")?e.keyFormat:void 0}}function vc(e){return Ic(e)}function Ic(e,t){return e==null?e:{name:e.name,valuePrefix:M(e,"valuePrefix")?e.valuePrefix:void 0}}function wc(e){return xc(e)}function xc(e,t){return e==null?e:{name:e.name}}function _c(e){return bc(e)}function bc(e,t){return e==null?e:{attachmentType:e.attachmentType,query:M(e,"query")?wc(e.query):void 0,header:M(e,"header")?vc(e.header):void 0,docsURL:M(e,"docsURL")?e.docsURL:void 0}}function Cc(e){return Oc(e)}function Oc(e,t){return e}function Sc(e){return Ec(e)}function Ec(e,t){return e==null?e:{days:M(e,"days")?e.days:void 0,fullHistory:M(e,"fullHistory")?e.fullHistory:void 0}}function ni(e){return Nc(e)}function Nc(e,t){return e==null?e:{defaultPeriod:Sc(e.defaultPeriod)}}function Rc(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Tc(e){if(e!==void 0)return e===null?null:{defaultPeriod:Rc(e.defaultPeriod)}}function Ac(e){return jc(e)}function jc(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function ri(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Pc(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:Tc(e.backfill)}}function Dc(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:wr(e.objects,Pc)}}function kc(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function Fc(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:wr(e.objects,kc)}}function Mc(e){return Kc(e)}function Kc(e,t){return e==null?e:{apiKeyAsBasic:M(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:M(e,"apiKeyAsBasicOpts")?gc(e.apiKeyAsBasicOpts):void 0,docsURL:M(e,"docsURL")?e.docsURL:void 0}}function Lc(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function un(e){return $c(e)}function $c(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:M(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function Hc(e){return Vc(e)}function Vc(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Uc(e){return Bc(e)}function Bc(e,t){return e==null?e:{provider:e.provider,read:M(e,"read")?e.read:void 0,write:M(e,"write")?e.write:void 0,proxy:M(e,"proxy")?Ac(e.proxy):void 0}}function oi(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:ri(e.proxy)}}function qc(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Uc(e.content)}}function Jc(e){return zc(e)}function zc(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function ii(e){return Xc(e)}function Xc(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function gn(e){return Yc(e)}function Yc(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:M(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:M(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function yn(e){return Gc(e)}function Gc(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:gn(e.providerApp),group:ii(e.group),consumer:Jc(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:M(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function Zc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:oi(e.content)}}function Qc(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Zc(e.config)}}function eu(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function tu(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:eu(e.latestRevision)}}function nu(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function ru(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 ou(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function iu(e){return su(e)}function su(e,t){return e==null?e:{mode:M(e,"mode")?e.mode:void 0,pageSize:M(e,"pageSize")?e.pageSize:void 0}}function au(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function cu(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function uu(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function lu(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:au(e.basicAuth),oauth2ClientCredentials:cu(e.oauth2ClientCredentials),oauth2Password:uu(e.oauth2Password)}}function du(e){return pu(e)}function pu(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function fu(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function si(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:M(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:M(e,"default")?e.default:void 0,prompt:M(e,"prompt")?e.prompt:void 0}}function Wn(e){return hu(e)}function hu(e,t){return e==null?e:{...fu(e),...si(e)}}function ai(e){return mu(e)}function mu(e,t){return e}function gu(e){return yu(e)}function yu(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:M(e,"requiredFields")?e.requiredFields.map(Wn):void 0,optionalFields:M(e,"optionalFields")?e.optionalFields.map(Wn):void 0,optionalFieldsAuto:M(e,"optionalFieldsAuto")?ai(e.optionalFieldsAuto):void 0,allFields:M(e,"allFields")?e.allFields.map(Wn):void 0,backfill:M(e,"backfill")?ni(e.backfill):void 0}}function vu(e){return Iu(e)}function Iu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(gu):void 0}}function wu(e){return xu(e)}function xu(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function _u(e){return bu(e)}function bu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(wu):void 0}}function Cu(e){return Ou(e)}function Ou(e,t){return e==null?e:{name:e.name,displayName:M(e,"displayName")?e.displayName:void 0,provider:e.provider,read:M(e,"read")?vu(e.read):void 0,write:M(e,"write")?_u(e.write):void 0,proxy:M(e,"proxy")?du(e.proxy):void 0}}function Su(e){return Eu(e)}function Eu(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Cu(e.content)}}function Nu(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 Ru(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:oi(e.content)}}function Tu(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:Nu(e.connection),config:Ru(e.config)}}function Ut(e){return Au(e)}function Au(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:M(e,"group")?ii(e.group):void 0,healthStatus:e.healthStatus,connection:yn(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0,config:qc(e.config)}}function ju(e){return Pu(e)}function Pu(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function Du(e,t){return e==null?e:{fieldName:e.fieldName}}function yo(e){return ku(e)}function ku(e,t){return e==null?e:{...Du(e),...si(e)}}function Fu(e){return Mu(e)}function Mu(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:M(e,"requiredFields")?e.requiredFields.map(yo):void 0,optionalFields:M(e,"optionalFields")?e.optionalFields.map(yo):void 0,optionalFieldsAuto:M(e,"optionalFieldsAuto")?ai(e.optionalFieldsAuto):void 0,backfill:M(e,"backfill")?ni(e.backfill):void 0,delivery:M(e,"delivery")?iu(e.delivery):void 0}}function Ku(e){return Lu(e)}function Lu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(Fu):void 0}}function $u(e){return Hu(e)}function Hu(e,t){return e==null?e:{objectName:e.objectName}}function Vu(e){return Uu(e)}function Uu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map($u):void 0}}function Bu(e){return qu(e)}function qu(e,t){return e==null?e:{name:e.name,displayName:M(e,"displayName")?e.displayName:void 0,provider:e.provider,read:M(e,"read")?Ku(e.read):void 0,write:M(e,"write")?Vu(e.write):void 0,proxy:M(e,"proxy")?ju(e.proxy):void 0}}function Wu(e){return Ju(e)}function Ju(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Bu(e.content)}}function vo(e){return zu(e)}function zu(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Wu(e.latestRevision)}}function Xu(e){return Yu(e)}function Yu(e,t){return e==null?e:{iconURL:M(e,"iconURL")?e.iconURL:void 0,logoURL:M(e,"logoURL")?e.logoURL:void 0}}function Gu(e){return Zu(e)}function Zu(e,t){return e==null?e:{iconURL:M(e,"iconURL")?e.iconURL:void 0,logoURL:M(e,"logoURL")?e.logoURL:void 0}}function Qu(e){return el(e)}function el(e,t){return e==null?e:{regular:M(e,"regular")?Gu(e.regular):void 0,darkMode:M(e,"darkMode")?Xu(e.darkMode):void 0}}function tl(e){return nl(e)}function nl(e,t){return e==null?e:{workspaceRefField:M(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:M(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:M(e,"scopesField")?e.scopesField:void 0}}function rl(e){return ol(e)}function ol(e,t){return e==null?e:{grantType:e.grantType,authURL:M(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:M(e,"audience")?e.audience:void 0,tokenMetadataFields:tl(e.tokenMetadataFields),docsURL:M(e,"docsURL")?e.docsURL:void 0,authURLParams:M(e,"authURLParams")?e.authURLParams:void 0}}function il(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 sl(e){return al(e)}function al(e,t){return e==null?e:{bulkWrite:Hc(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Io(e){return cl(e)}function cl(e,t){return e==null?e:{name:e.name,authType:Cc(e.authType),baseURL:e.baseURL,oauth2Opts:M(e,"oauth2Opts")?rl(e.oauth2Opts):void 0,apiKeyOpts:M(e,"apiKeyOpts")?_c(e.apiKeyOpts):void 0,basicOpts:M(e,"basicOpts")?Mc(e.basicOpts):void 0,support:sl(e.support),providerOpts:e.providerOpts,displayName:M(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:M(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:M(e,"media")?Qu(e.media):void 0,labels:M(e,"labels")?e.labels:void 0}}function ul(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Dc(e.read),write:Fc(e.write),proxy:ri(e.proxy)}}function ll(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:ul(e.content)}}function dl(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:ll(e.config)}}function pl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:dl(e.installation)}}function fl(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function hl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:fl(e.project)}}function ml(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 gl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:ml(e.providerApp)}}class yl extends ze{async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:lu(t.generateConnectionParams)},n);return new ye(r,s=>yn(s))}async generateConnection(t,n){return await(await this.generateConnectionRaw(t,n)).value()}async getConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new Y("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:i,query:o},n);return new ye(r,s=>yn(s))}async getConnection(t,n){return await(await this.getConnectionRaw(t,n)).value()}async listConnectionsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const o={};t.provider!==void 0&&(o.provider=t.provider),t.groupRef!==void 0&&(o.groupRef=t.groupRef),t.consumerRef!==void 0&&(o.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(yn))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class vl extends ze{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new Y("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:o,body:Qc(t.installation)},n);return new ye(r,s=>Ut(s))}async createInstallation(t,n){return await(await this.createInstallationRaw(t,n)).value()}async deleteInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:i,query:o},n);return new Nt(r)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:i,query:o},n);return new ye(r,s=>Ut(s))}async getInstallation(t,n){return await(await this.getInstallationRaw(t,n)).value()}async importInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new Y("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:i,query:o,body:Tu(t.installation)},n);return new ye(r,s=>Ut(s))}async importInstallation(t,n){return await(await this.importInstallationRaw(t,n)).value()}async listInstallationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const o={};t.groupRef!==void 0&&(o.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(Ut))}async listInstallations(t,n){return await(await this.listInstallationsRaw(t,n)).value()}async updateInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new Y("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:i,query:o,body:pl(t.installationUpdate)},n);return new ye(r,s=>Ut(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Il extends ze{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:o,body:Lc(t.batchUpsertIntegrationsRequest)},n);return new ye(r,s=>s.map(vo))}async batchUpsertIntegrations(t,n){return await(await this.batchUpsertIntegrationsRaw(t,n)).value()}async createIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new Y("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:tu(t.integration)},n);return new Nt(r)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:i,query:o},n);return new Nt(r)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(vo))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class wl extends ze{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new Y("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const o={},i={};i["Content-Type"]="application/json";const r=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:o,body:il(t.connectOAuthParams)},n);return this.isJsonMime(r.headers.get("content-type"))?new ye(r):new mc(r)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class xl extends ze{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new Y("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects",method:"POST",headers:i,query:o,body:nu(t.project)},n);return new ye(r,s=>un(s))}async createProject(t,n){return await(await this.createProjectRaw(t,n)).value()}async deleteProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:o},n);return new Nt(r)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>un(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:o,query:n},t);return new ye(i,r=>r.map(un))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new Y("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:o,body:hl(t.projectUpdate)},n);return new ye(r,s=>un(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class _l extends ze{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new Y("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:o},n);return new ye(r,s=>Io(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:o,query:n},t);return new ye(i,r=>wr(r,Io))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class bl extends ze{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new Y("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:ru(t.providerApp)},n);return new ye(r,s=>gn(s))}async createProviderApp(t,n){return await(await this.createProviderAppRaw(t,n)).value()}async deleteProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new Y("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:i,query:o},n);return new Nt(r)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(gn))}async listProviderApps(t,n){return await(await this.listProviderAppsRaw(t,n)).value()}async updateProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new Y("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new Y("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:i,query:o,body:gl(t.providerAppUpdate)},n);return new ye(r,s=>gn(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Cl extends ze{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:o,body:ou(t.revision)},n);return new Nt(r)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new Y("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new Y("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const o={};t.connectionId!==void 0&&(o.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:i,query:o},n);return new ye(r,s=>Su(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class Ol{constructor(t){this.connectionApi=new yl(t),this.installationApi=new vl(t),this.integrationApi=new Il(t),this.oAuthApi=new wl(t),this.projectApi=new xl(t),this.providerApi=new _l(t),this.providerAppApi=new bl(t),this.revisionApi=new Cl(t)}}const Sl="1.14.1",El="v1",ln="https://api.withampersand.com";function ci(){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 ln;case"mock":return"http://127.0.0.1:4010";case"":return ln;default:return e??ln}}catch{return ln}}const Nl=(e,t)=>`${e}/${t}`;function Rl(){return Nl(ci(),El)}const Tl=ci(),Al=Rl(),jl=new Zo({basePath:Al,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Sl}});let Pl=new Ol(jl);const fe=()=>Pl;function Dl(){return a.jsx(S.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:a.jsx(S.Stack,{alignItems:"center",children:a.jsx(S.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"})})})}const kl="_loader_h78nh_1",Fl="_rotate_h78nh_1",Ml="_ball1_h78nh_1",Kl="_ball2_h78nh_1",Ll={loader:kl,rotate:Fl,ball1:Ml,ball2:Kl};function $l(){return a.jsx("span",{className:Ll.loader})}function qe(){return ve?a.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:a.jsx($l,{})}):a.jsx(Dl,{})}const Ce=async(e,t)=>{var n;if(e instanceof Qo){const{status:o,statusText:i}=e.response;console.error(o===500?"Internal Server Error (500):":o===400?"Bad Request (400):":`Error (${o}):`,i);const r=await e.response.json(),s=((n=r==null?void 0:r.causes)==null?void 0:n.join(`
|
|
3
|
+
`))||"[ERROR] Creating installation failed.";console.error("[Error Message]",s),t&&t(s)}else console.error("Unexpected error:",e.message)},ui=y.createContext({integrations:null}),li=()=>{const e=y.useContext(ui);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Hl({projectIdOrName:e,children:t}){const n=xe(),{setError:o,isError:i}=dt(),[r,s]=y.useState(null),[c,u]=y.useState(!0);y.useEffect(()=>{fe().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(p=>{u(!1),s(p||[])}).catch(p=>{console.error("Error retrieving integration information."),Ce(p),u(!1),o(me.INTEGRATION_LIST,e)})},[e,n,o]);const d=y.useMemo(()=>({integrations:r}),[r]);return i(me.INTEGRATION_LIST,e)?a.jsx(ot,{message:"Error retrieving integrations for the project, double check the API key"}):a.jsx(ui.Provider,{value:d,children:c?a.jsx(qe,{}):t})}const di=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Ie=()=>{const e=y.useContext(di);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Vl({projectIdOrName:e,children:t}){const n=xe(),{isError:o,setError:i}=dt(),[r,s]=y.useState(null),[c,u]=y.useState(!0);y.useEffect(()=>{fe().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(p=>{u(!1),s(p)}).catch(p=>{console.error("Error loading Ampersand project."),Ce(p),i(me.PROJECT,e),u(!1)})},[e,n,u,i]);const d=y.useMemo(()=>({projectId:(r==null?void 0:r.id)||"",projectIdOrName:e,project:r,appName:(r==null?void 0:r.appName)||""}),[e,r]);return o(me.PROJECT,e)?a.jsx(ot,{message:`Error loading project ${e}`}):a.jsx(di.Provider,{value:d,children:c?a.jsx(qe,{}):t})}function Ul(e){const{options:{apiKey:t,projectId:n,project:o},children:i}=e,r=o||n;if(n&&o)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!r)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return a.jsx(Qa,{children:a.jsx(nc,{children:a.jsx(ec,{value:t,children:a.jsx(Vl,{projectIdOrName:r,children:a.jsx(Hl,{projectIdOrName:r,children:i})})})})})}const pi=y.createContext(null);function Bl(){const e=y.useContext(pi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
4
|
+
component is wrapped with AmpersandProvider`);return e}const ql=()=>{const[e,t]=y.useState(!1),n=y.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n}},fi=y.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function Ye(){const e=y.useContext(fi);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Wl({children:e,integration:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,onInstallSuccess:s,onUpdateSuccess:c,onUninstallSuccess:u}){const d=xe(),{projectId:p}=Ie(),{integrations:h}=li(),{setError:v,isError:f}=dt(),{isIntegrationDeleted:g,setIntegrationDeleted:x}=ql(),[w,O]=y.useState([]),[I,C]=y.useState(!0),b=(w==null?void 0:w[0])||null,m=y.useMemo(()=>oc(t,h||[]),[t,h]);y.useEffect(()=>{m===null&&(h!=null&&h.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,m,h]);const j=y.useCallback(B=>{O([B])},[O]),$=y.useCallback(()=>{m!=null&&m.id&&fe().installationApi.listInstallations({projectIdOrName:p,integrationId:m.id,groupRef:i},{headers:{"X-Api-Key":d??""}}).then(B=>{C(!1),O(B||[])}).catch(B=>{v(me.INSTALLATION_LIST,m.id),C(!1),console.error("Error retrieving installation information: ",B)})},[m,p,d,v,i]),F=(m==null?void 0:m.id)||"";y.useEffect(()=>{$()},[$]);const V=y.useMemo(()=>({integrationId:(m==null?void 0:m.id)||"",provider:(m==null?void 0:m.provider)||"",integrationObj:m,consumerRef:n,consumerName:o,groupRef:i,groupName:r,installation:b,setInstallation:j,resetInstallations:$,onInstallSuccess:s,onUpdateSuccess:c,onUninstallSuccess:u,isIntegrationDeleted:g,setIntegrationDeleted:x}),[m,n,o,i,r,b,j,$,s,c,u,g,x]);if(m!==null){const B=`Error retrieving installation information for integration "${(m==null?void 0:m.name)||"unknown"}"`;return f(me.INSTALLATION_LIST,F)?a.jsx(ot,{message:B}):a.jsx(fi.Provider,{value:V,children:I?a.jsx(qe,{}):e})}return a.jsx(ot,{message:`Integration "${t}" not found`})}const hi=y.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),kt=()=>{const e=y.useContext(hi);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function mi({provider:e,groupRef:t,children:n}){const o=xe(),{projectId:i}=Ie(),[r,s]=y.useState(null),[c,u]=y.useState(null),[d,p]=y.useState(!0),{setError:h,isError:v}=dt(),{provider:f}=Ye();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const g=e||f;if(!g)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");y.useEffect(()=>{fe().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:g},{headers:{"X-Api-Key":o??""}}).then(w=>{p(!1),s(w)}).catch(w=>{console.error(`Error retrieving existing OAuth connections for group ID ${t}.`),Ce(w),p(!1),h(me.CONNECTION_LIST,i)})},[i,o,t,g,h]);const x=y.useMemo(()=>({connections:r,selectedConnection:c,setConnections:s,setSelectedConnection:u}),[r,c,s,u]);return v(me.CONNECTION_LIST,i)?a.jsx(ot,{message:"Error retrieving existing connections"}):a.jsx(hi.Provider,{value:x,children:d?a.jsx(qe,{}):n})}var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xn={exports:{}};xn.exports;(function(e,t){var n=200,o="__lodash_hash_undefined__",i=1,r=2,s=9007199254740991,c="[object Arguments]",u="[object Array]",d="[object AsyncFunction]",p="[object Boolean]",h="[object Date]",v="[object Error]",f="[object Function]",g="[object GeneratorFunction]",x="[object Map]",w="[object Number]",O="[object Null]",I="[object Object]",C="[object Promise]",b="[object Proxy]",m="[object RegExp]",j="[object Set]",$="[object String]",F="[object Symbol]",V="[object Undefined]",B="[object WeakMap]",Z="[object ArrayBuffer]",G="[object DataView]",te="[object Float32Array]",Q="[object Float64Array]",ue="[object Int8Array]",le="[object Int16Array]",re="[object Int32Array]",Oe="[object Uint8Array]",Ee="[object Uint8ClampedArray]",N="[object Uint16Array]",K="[object Uint32Array]",k=/[\\^$.*+?()[\]{}|]/g,D=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,R={};R[te]=R[Q]=R[ue]=R[le]=R[re]=R[Oe]=R[Ee]=R[N]=R[K]=!0,R[c]=R[u]=R[Z]=R[p]=R[G]=R[h]=R[v]=R[f]=R[x]=R[w]=R[I]=R[m]=R[j]=R[$]=R[B]=!1;var q=typeof dn=="object"&&dn&&dn.Object===Object&&dn,J=typeof self=="object"&&self&&self.Object===Object&&self,U=q||J||Function("return this")(),z=t&&!t.nodeType&&t,W=z&&!0&&e&&!e.nodeType&&e,oe=W&&W.exports===z,A=oe&&q.process,de=function(){try{return A&&A.binding&&A.binding("util")}catch{}}(),L=de&&de.isTypedArray;function Ne(l,_){for(var E=-1,H=l==null?0:l.length,pe=0,ee=[];++E<H;){var ge=l[E];_(ge,E,l)&&(ee[pe++]=ge)}return ee}function Re(l,_){for(var E=-1,H=_.length,pe=l.length;++E<H;)l[pe+E]=_[E];return l}function Ge(l,_){for(var E=-1,H=l==null?0:l.length;++E<H;)if(_(l[E],E,l))return!0;return!1}function Ve(l,_){for(var E=-1,H=Array(l);++E<l;)H[E]=_(E);return H}function Ct(l){return function(_){return l(_)}}function Mt(l,_){return l.has(_)}function Ue(l,_){return l==null?void 0:l[_]}function ft(l){var _=-1,E=Array(l.size);return l.forEach(function(H,pe){E[++_]=[pe,H]}),E}function Kt(l,_){return function(E){return l(_(E))}}function Ot(l){var _=-1,E=Array(l.size);return l.forEach(function(H){E[++_]=H}),E}var We=Array.prototype,Ze=Function.prototype,je=Object.prototype,Te=U["__core-js_shared__"],en=Ze.toString,Je=je.hasOwnProperty,Yr=function(){var l=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),Gr=je.toString,Gs=RegExp("^"+en.call(Je).replace(k,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Zr=oe?U.Buffer:void 0,tn=U.Symbol,Qr=U.Uint8Array,eo=je.propertyIsEnumerable,Zs=We.splice,ht=tn?tn.toStringTag:void 0,to=Object.getOwnPropertySymbols,Qs=Zr?Zr.isBuffer:void 0,ea=Kt(Object.keys,Object),Ln=St(U,"DataView"),Lt=St(U,"Map"),$n=St(U,"Promise"),Hn=St(U,"Set"),Vn=St(U,"WeakMap"),$t=St(Object,"create"),ta=yt(Ln),na=yt(Lt),ra=yt($n),oa=yt(Hn),ia=yt(Vn),no=tn?tn.prototype:void 0,Un=no?no.valueOf:void 0;function mt(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function sa(){this.__data__=$t?$t(null):{},this.size=0}function aa(l){var _=this.has(l)&&delete this.__data__[l];return this.size-=_?1:0,_}function ca(l){var _=this.__data__;if($t){var E=_[l];return E===o?void 0:E}return Je.call(_,l)?_[l]:void 0}function ua(l){var _=this.__data__;return $t?_[l]!==void 0:Je.call(_,l)}function la(l,_){var E=this.__data__;return this.size+=this.has(l)?0:1,E[l]=$t&&_===void 0?o:_,this}mt.prototype.clear=sa,mt.prototype.delete=aa,mt.prototype.get=ca,mt.prototype.has=ua,mt.prototype.set=la;function Qe(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function da(){this.__data__=[],this.size=0}function pa(l){var _=this.__data__,E=rn(_,l);if(E<0)return!1;var H=_.length-1;return E==H?_.pop():Zs.call(_,E,1),--this.size,!0}function fa(l){var _=this.__data__,E=rn(_,l);return E<0?void 0:_[E][1]}function ha(l){return rn(this.__data__,l)>-1}function ma(l,_){var E=this.__data__,H=rn(E,l);return H<0?(++this.size,E.push([l,_])):E[H][1]=_,this}Qe.prototype.clear=da,Qe.prototype.delete=pa,Qe.prototype.get=fa,Qe.prototype.has=ha,Qe.prototype.set=ma;function gt(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function ga(){this.size=0,this.__data__={hash:new mt,map:new(Lt||Qe),string:new mt}}function ya(l){var _=on(this,l).delete(l);return this.size-=_?1:0,_}function va(l){return on(this,l).get(l)}function Ia(l){return on(this,l).has(l)}function wa(l,_){var E=on(this,l),H=E.size;return E.set(l,_),this.size+=E.size==H?0:1,this}gt.prototype.clear=ga,gt.prototype.delete=ya,gt.prototype.get=va,gt.prototype.has=Ia,gt.prototype.set=wa;function nn(l){var _=-1,E=l==null?0:l.length;for(this.__data__=new gt;++_<E;)this.add(l[_])}function xa(l){return this.__data__.set(l,o),this}function _a(l){return this.__data__.has(l)}nn.prototype.add=nn.prototype.push=xa,nn.prototype.has=_a;function st(l){var _=this.__data__=new Qe(l);this.size=_.size}function ba(){this.__data__=new Qe,this.size=0}function Ca(l){var _=this.__data__,E=_.delete(l);return this.size=_.size,E}function Oa(l){return this.__data__.get(l)}function Sa(l){return this.__data__.has(l)}function Ea(l,_){var E=this.__data__;if(E instanceof Qe){var H=E.__data__;if(!Lt||H.length<n-1)return H.push([l,_]),this.size=++E.size,this;E=this.__data__=new gt(H)}return E.set(l,_),this.size=E.size,this}st.prototype.clear=ba,st.prototype.delete=Ca,st.prototype.get=Oa,st.prototype.has=Sa,st.prototype.set=Ea;function Na(l,_){var E=sn(l),H=!E&&Ua(l),pe=!E&&!H&&Bn(l),ee=!E&&!H&&!pe&&po(l),ge=E||H||pe||ee,_e=ge?Ve(l.length,String):[],be=_e.length;for(var he in l)Je.call(l,he)&&!(ge&&(he=="length"||pe&&(he=="offset"||he=="parent")||ee&&(he=="buffer"||he=="byteLength"||he=="byteOffset")||Ka(he,be)))&&_e.push(he);return _e}function rn(l,_){for(var E=l.length;E--;)if(ao(l[E][0],_))return E;return-1}function Ra(l,_,E){var H=_(l);return sn(l)?H:Re(H,E(l))}function Ht(l){return l==null?l===void 0?V:O:ht&&ht in Object(l)?Fa(l):Va(l)}function ro(l){return Vt(l)&&Ht(l)==c}function oo(l,_,E,H,pe){return l===_?!0:l==null||_==null||!Vt(l)&&!Vt(_)?l!==l&&_!==_:Ta(l,_,E,H,oo,pe)}function Ta(l,_,E,H,pe,ee){var ge=sn(l),_e=sn(_),be=ge?u:at(l),he=_e?u:at(_);be=be==c?I:be,he=he==c?I:he;var Pe=be==I,Be=he==I,Se=be==he;if(Se&&Bn(l)){if(!Bn(_))return!1;ge=!0,Pe=!1}if(Se&&!Pe)return ee||(ee=new st),ge||po(l)?io(l,_,E,H,pe,ee):Da(l,_,be,E,H,pe,ee);if(!(E&i)){var Le=Pe&&Je.call(l,"__wrapped__"),$e=Be&&Je.call(_,"__wrapped__");if(Le||$e){var ct=Le?l.value():l,et=$e?_.value():_;return ee||(ee=new st),pe(ct,et,E,H,ee)}}return Se?(ee||(ee=new st),ka(l,_,E,H,pe,ee)):!1}function Aa(l){if(!lo(l)||$a(l))return!1;var _=co(l)?Gs:D;return _.test(yt(l))}function ja(l){return Vt(l)&&uo(l.length)&&!!R[Ht(l)]}function Pa(l){if(!Ha(l))return ea(l);var _=[];for(var E in Object(l))Je.call(l,E)&&E!="constructor"&&_.push(E);return _}function io(l,_,E,H,pe,ee){var ge=E&i,_e=l.length,be=_.length;if(_e!=be&&!(ge&&be>_e))return!1;var he=ee.get(l);if(he&&ee.get(_))return he==_;var Pe=-1,Be=!0,Se=E&r?new nn:void 0;for(ee.set(l,_),ee.set(_,l);++Pe<_e;){var Le=l[Pe],$e=_[Pe];if(H)var ct=ge?H($e,Le,Pe,_,l,ee):H(Le,$e,Pe,l,_,ee);if(ct!==void 0){if(ct)continue;Be=!1;break}if(Se){if(!Ge(_,function(et,vt){if(!Mt(Se,vt)&&(Le===et||pe(Le,et,E,H,ee)))return Se.push(vt)})){Be=!1;break}}else if(!(Le===$e||pe(Le,$e,E,H,ee))){Be=!1;break}}return ee.delete(l),ee.delete(_),Be}function Da(l,_,E,H,pe,ee,ge){switch(E){case G:if(l.byteLength!=_.byteLength||l.byteOffset!=_.byteOffset)return!1;l=l.buffer,_=_.buffer;case Z:return!(l.byteLength!=_.byteLength||!ee(new Qr(l),new Qr(_)));case p:case h:case w:return ao(+l,+_);case v:return l.name==_.name&&l.message==_.message;case m:case $:return l==_+"";case x:var _e=ft;case j:var be=H&i;if(_e||(_e=Ot),l.size!=_.size&&!be)return!1;var he=ge.get(l);if(he)return he==_;H|=r,ge.set(l,_);var Pe=io(_e(l),_e(_),H,pe,ee,ge);return ge.delete(l),Pe;case F:if(Un)return Un.call(l)==Un.call(_)}return!1}function ka(l,_,E,H,pe,ee){var ge=E&i,_e=so(l),be=_e.length,he=so(_),Pe=he.length;if(be!=Pe&&!ge)return!1;for(var Be=be;Be--;){var Se=_e[Be];if(!(ge?Se in _:Je.call(_,Se)))return!1}var Le=ee.get(l);if(Le&&ee.get(_))return Le==_;var $e=!0;ee.set(l,_),ee.set(_,l);for(var ct=ge;++Be<be;){Se=_e[Be];var et=l[Se],vt=_[Se];if(H)var fo=ge?H(vt,et,Se,_,l,ee):H(et,vt,Se,l,_,ee);if(!(fo===void 0?et===vt||pe(et,vt,E,H,ee):fo)){$e=!1;break}ct||(ct=Se=="constructor")}if($e&&!ct){var an=l.constructor,cn=_.constructor;an!=cn&&"constructor"in l&&"constructor"in _&&!(typeof an=="function"&&an instanceof an&&typeof cn=="function"&&cn instanceof cn)&&($e=!1)}return ee.delete(l),ee.delete(_),$e}function so(l){return Ra(l,Wa,Ma)}function on(l,_){var E=l.__data__;return La(_)?E[typeof _=="string"?"string":"hash"]:E.map}function St(l,_){var E=Ue(l,_);return Aa(E)?E:void 0}function Fa(l){var _=Je.call(l,ht),E=l[ht];try{l[ht]=void 0;var H=!0}catch{}var pe=Gr.call(l);return H&&(_?l[ht]=E:delete l[ht]),pe}var Ma=to?function(l){return l==null?[]:(l=Object(l),Ne(to(l),function(_){return eo.call(l,_)}))}:Ja,at=Ht;(Ln&&at(new Ln(new ArrayBuffer(1)))!=G||Lt&&at(new Lt)!=x||$n&&at($n.resolve())!=C||Hn&&at(new Hn)!=j||Vn&&at(new Vn)!=B)&&(at=function(l){var _=Ht(l),E=_==I?l.constructor:void 0,H=E?yt(E):"";if(H)switch(H){case ta:return G;case na:return x;case ra:return C;case oa:return j;case ia:return B}return _});function Ka(l,_){return _=_??s,!!_&&(typeof l=="number"||P.test(l))&&l>-1&&l%1==0&&l<_}function La(l){var _=typeof l;return _=="string"||_=="number"||_=="symbol"||_=="boolean"?l!=="__proto__":l===null}function $a(l){return!!Yr&&Yr in l}function Ha(l){var _=l&&l.constructor,E=typeof _=="function"&&_.prototype||je;return l===E}function Va(l){return Gr.call(l)}function yt(l){if(l!=null){try{return en.call(l)}catch{}try{return l+""}catch{}}return""}function ao(l,_){return l===_||l!==l&&_!==_}var Ua=ro(function(){return arguments}())?ro:function(l){return Vt(l)&&Je.call(l,"callee")&&!eo.call(l,"callee")},sn=Array.isArray;function Ba(l){return l!=null&&uo(l.length)&&!co(l)}var Bn=Qs||za;function qa(l,_){return oo(l,_)}function co(l){if(!lo(l))return!1;var _=Ht(l);return _==f||_==g||_==d||_==b}function uo(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=s}function lo(l){var _=typeof l;return l!=null&&(_=="object"||_=="function")}function Vt(l){return l!=null&&typeof l=="object"}var po=L?Ct(L):ja;function Wa(l){return Ba(l)?Na(l):Pa(l)}function Ja(){return[]}function za(){return!1}e.exports=qa})(xn,xn.exports);var Jl=xn.exports;const zl=xr(Jl),xt="other";function Xe(e){return e.mapToName!==void 0}function Xl(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(o=>o.objectName===t))||null}function Yl(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Xe(n)&&!!n.fieldName))||null}function Gl(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(o=>Xe(o)&&!!o.mapToName))||[]}function Zl(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Xe(n)&&!!n.fieldName))||null}const gi=(e,t)=>{var n,o,i;return(i=(o=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:o.objects)==null?void 0:i[t]};function Ql(e){return Xe(e)?e.mapToName:e.fieldName}const yi=(e,t)=>{var o,i,r;const n=[];return(r=(i=(o=t.content)==null?void 0:o.read)==null?void 0:i.objects)==null||r.forEach(s=>{n.push({name:s==null?void 0:s.objectName,completed:e?!!gi(e,s.objectName):!1})}),n},vi=e=>{var n;return{name:xt,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function ed(e,t){var r;const n=yi(e,t),i=!!((r=t==null?void 0:t.content)!=null&&r.write)?vi(e):void 0;return i&&n.push(i),n}function Ii(e,t,n){const o=(e==null?void 0:e.filter(r=>!(t!=null&&t[r==null?void 0:r.mapToName])))||[],i=o.map(r=>r.mapToName);return n(me.MAPPING,i),o!=null&&o.length&&console.error("required fields not met",o.map(r=>r.mapToDisplayName)),{errorList:i}}function _r(e,t){return zl(e,t)}const td=(e,t,n)=>{var f,g,x,w,O,I;if(!e)return null;const o=Xl(e,t),i=o&&Yl(o),r=o&&Zl(o),s=o&&Gl(o),c=(o==null?void 0:o.allFields)||[],u=n==null?void 0:n.content,d=((x=(g=(f=u==null?void 0:u.read)==null?void 0:f.objects)==null?void 0:g[t])==null?void 0:x.selectedFields)||{},p=((I=(O=(w=u==null?void 0:u.read)==null?void 0:w.objects)==null?void 0:O[t])==null?void 0:I.selectedFieldMappings)||{},h={...d},v={...p};return{allFields:c,requiredFields:i,optionalFields:r,requiredMapFields:s,selectedOptionalFields:d,selectedFieldMappings:p,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:h,requiredMapFields:v}}},nd=(e,t)=>{var s,c;if(!e)return null;const n=(c=(s=t==null?void 0:t.content)==null?void 0:s.write)==null?void 0:c.objects,o=Object.keys(n||{}),i={};o.forEach(u=>{i[u]=!0});const r={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:r}}};function wi(e,t,n){var r,s;const o=(r=e==null?void 0:e.content)==null?void 0:r.read,i=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:td(o,t,n),write:nd(i,n)}}const xi=(e,t,n,o)=>{const i=wi(e,n,t);o(n,i)},rd=(e,t,n)=>{const o=ed(t,e),i={};o.forEach(({name:r,completed:s})=>{s&&(i[r]=wi(e,r,t))}),n(i)},_i=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},o=new Set;return t==null||t.forEach(r=>o.add(Ql(r))),{...Array.from(o).reduce((r,s)=>({...r,[s]:!0}),{}),...n||{}}},bi=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(o=>{t[o]!==void 0?n[o]=t[o]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${o}`)}),n};function Ci(e,t){return t[e]||void 0}async function br({createConfig:e,projectId:t,integrationId:n,groupRef:o,connectionId:i,apiKey:r,setError:s,setInstallation:c,onInstallSuccess:u}){const d={projectIdOrName:t,integrationId:n,installation:{groupRef:o,connectionId:i,config:e}};try{const p=await fe().installationApi.createInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}});c(p),u==null||u(p.id,p.config)}catch(p){Ce(p,s)}}function jn(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const od=(e,t)=>{const n=e.content.read,o=n==null?void 0:n.objects;return o==null?void 0:o.find(i=>i.objectName===t)},id=(e,t,n,o)=>{const i=_i(e),r=bi(e),s=od(n,t);if(!s)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const c={revisionId:n.id,createdBy:`consumer:${o}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:s.schedule,destination:s.destination,selectedFields:i,selectedFieldMappings:r,backfill:s.backfill}}}}};return jn(n)&&(c.content.proxy={enabled:!0}),c},sd=(e,t,n,o,i,r,s,c,u,d,p,h)=>{const v=id(u,r,c,o);return v?br({createConfig:v,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:s,setError:d,setInstallation:p,onInstallSuccess:h}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},Oi=e=>{var r,s;const t={},n=(r=e.write)==null?void 0:r.writeObjects,o=(s=e.write)==null?void 0:s.selectedNonConfigurableWriteFields,i=o?Object.keys(o):[];return n&&n.forEach(c=>{const u=c.objectName;i.includes(u)&&(t[u]={objectName:u})}),t},ad=e=>{const t=e.content.write;return t==null?void 0:t.objects},cd=(e,t,n)=>{if(!ad(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=Oi(e),r={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return jn(t)&&(r.content.proxy={enabled:!0}),r},ud=(e,t,n,o,i,r,s,c,u,d,p)=>{const h=cd(c,s,o);return h?br({createConfig:h,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:r,setError:u,setInstallation:d,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ld=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-background").trim()||"#FEF2F2",dd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-border").trim()||"#FECACA",pd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-text").trim()||"#991B1B",fd={backgroundColor:ld,borderColor:dd,color:pd,padding:".5rem 1rem"};function Si({children:e,style:t}){return a.jsx(Dt,{style:{...fd,...t},children:e})}var Ei={exports:{}};/*!
|
|
5
|
+
Copyright (c) 2018 Jed Watson.
|
|
6
|
+
Licensed under the MIT License (MIT), see
|
|
7
|
+
http://jedwatson.github.io/classnames
|
|
8
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",s=0;s<arguments.length;s++){var c=arguments[s];c&&(r=i(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var s="";for(var c in r)t.call(r,c)&&r[c]&&(s=i(s,c));return s}function i(r,s){return s?r?r+" "+s:r+s:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Ei);var hd=Ei.exports;const zt=xr(hd),md="_button_rchgn_1",gd="_buttonError_rchgn_21",yd="_danger_rchgn_40",vd="_ghost_rchgn_50",Jn={button:md,buttonError:gd,danger:yd,ghost:vd};function He({className:e,style:t,type:n,children:o,variant:i,...r}){const s=zt(Jn.button,{[Jn.danger]:i==="danger",[Jn.ghost]:i==="ghost",[e||""]:!!e});return a.jsx("button",{type:n,className:s,style:t,...r,children:o})}function Id(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.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"}),a.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Ni="uninstall-installation",wd=y.forwardRef(({text:e="Uninstall"},t)=>{const n=S.useTab({ref:t}),o=S.useMultiStyleConfig("Tabs",n);return a.jsxs(S.Button,{__css:o.warningTab,...n,minHeight:15,children:[a.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[Id(),a.jsx(S.Box,{textAlign:"left",children:a.jsx(S.Text,{color:"red.800",children:e})})]}),n.children]})}),Ri=y.createContext({hydratedRevision:null,loading:!1}),Zt=()=>{const e=y.useContext(Ri);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function xd({projectId:e,children:t}){var C;const{selectedConnection:n}=kt(),{integrationId:o,integrationObj:i}=Ye(),[r,s]=y.useState(null),[c,u]=y.useState(!0),{isError:d,removeError:p,setError:h}=dt(),v=xe(),f=n==null?void 0:n.id,g=(C=i==null?void 0:i.latestRevision)==null?void 0:C.id,x=(i==null?void 0:i.name)||o;y.useEffect(()=>{e&&o&&g&&f&&v&&fe().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:o,revisionId:g,connectionId:f},{headers:{"X-Api-Key":v??""}}).then(b=>{s(b),u(!1),p(me.HYDRATED_REVISION,x)}).catch(b=>{console.error(`Error loading integration ${x}.`),Ce(b),u(!1),h(me.HYDRATED_REVISION,x)})},[e,o,g,f,v,p,h,x]);const w=y.useMemo(()=>({hydratedRevision:r,loading:c}),[r,c]),I=`Error retrieving integration details for '${(i==null?void 0:i.name)||o||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return a.jsx(Ri.Provider,{value:w,children:d(me.HYDRATED_REVISION,x)?a.jsx(ot,{message:I}):t})}function nt(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function ne(){return ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},ne.apply(null,arguments)}function ir(e,t){return ir=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},ir(e,t)}function _d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ir(e,t)}var sr={exports:{}},pn={exports:{}},ie={};/** @license React v16.13.1
|
|
9
|
+
* react-is.production.min.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/var wo;function bd(){if(wo)return ie;wo=1;var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,r=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,d=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,w=e?Symbol.for("react.fundamental"):60117,O=e?Symbol.for("react.responder"):60118,I=e?Symbol.for("react.scope"):60119;function C(m){if(typeof m=="object"&&m!==null){var j=m.$$typeof;switch(j){case t:switch(m=m.type,m){case u:case d:case o:case r:case i:case h:return m;default:switch(m=m&&m.$$typeof,m){case c:case p:case g:case f:case s:return m;default:return j}}case n:return j}}}function b(m){return C(m)===d}return ie.AsyncMode=u,ie.ConcurrentMode=d,ie.ContextConsumer=c,ie.ContextProvider=s,ie.Element=t,ie.ForwardRef=p,ie.Fragment=o,ie.Lazy=g,ie.Memo=f,ie.Portal=n,ie.Profiler=r,ie.StrictMode=i,ie.Suspense=h,ie.isAsyncMode=function(m){return b(m)||C(m)===u},ie.isConcurrentMode=b,ie.isContextConsumer=function(m){return C(m)===c},ie.isContextProvider=function(m){return C(m)===s},ie.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===t},ie.isForwardRef=function(m){return C(m)===p},ie.isFragment=function(m){return C(m)===o},ie.isLazy=function(m){return C(m)===g},ie.isMemo=function(m){return C(m)===f},ie.isPortal=function(m){return C(m)===n},ie.isProfiler=function(m){return C(m)===r},ie.isStrictMode=function(m){return C(m)===i},ie.isSuspense=function(m){return C(m)===h},ie.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===o||m===d||m===r||m===i||m===h||m===v||typeof m=="object"&&m!==null&&(m.$$typeof===g||m.$$typeof===f||m.$$typeof===s||m.$$typeof===c||m.$$typeof===p||m.$$typeof===w||m.$$typeof===O||m.$$typeof===I||m.$$typeof===x)},ie.typeOf=C,ie}var se={};/** @license React v16.13.1
|
|
16
|
+
* react-is.development.js
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/var xo;function Cd(){return xo||(xo=1,process.env.NODE_ENV!=="production"&&function(){var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,r=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,d=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,w=e?Symbol.for("react.fundamental"):60117,O=e?Symbol.for("react.responder"):60118,I=e?Symbol.for("react.scope"):60119;function C(A){return typeof A=="string"||typeof A=="function"||A===o||A===d||A===r||A===i||A===h||A===v||typeof A=="object"&&A!==null&&(A.$$typeof===g||A.$$typeof===f||A.$$typeof===s||A.$$typeof===c||A.$$typeof===p||A.$$typeof===w||A.$$typeof===O||A.$$typeof===I||A.$$typeof===x)}function b(A){if(typeof A=="object"&&A!==null){var de=A.$$typeof;switch(de){case t:var L=A.type;switch(L){case u:case d:case o:case r:case i:case h:return L;default:var Ne=L&&L.$$typeof;switch(Ne){case c:case p:case g:case f:case s:return Ne;default:return de}}case n:return de}}}var m=u,j=d,$=c,F=s,V=t,B=p,Z=o,G=g,te=f,Q=n,ue=r,le=i,re=h,Oe=!1;function Ee(A){return Oe||(Oe=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),N(A)||b(A)===u}function N(A){return b(A)===d}function K(A){return b(A)===c}function k(A){return b(A)===s}function D(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function P(A){return b(A)===p}function R(A){return b(A)===o}function q(A){return b(A)===g}function J(A){return b(A)===f}function U(A){return b(A)===n}function z(A){return b(A)===r}function W(A){return b(A)===i}function oe(A){return b(A)===h}se.AsyncMode=m,se.ConcurrentMode=j,se.ContextConsumer=$,se.ContextProvider=F,se.Element=V,se.ForwardRef=B,se.Fragment=Z,se.Lazy=G,se.Memo=te,se.Portal=Q,se.Profiler=ue,se.StrictMode=le,se.Suspense=re,se.isAsyncMode=Ee,se.isConcurrentMode=N,se.isContextConsumer=K,se.isContextProvider=k,se.isElement=D,se.isForwardRef=P,se.isFragment=R,se.isLazy=q,se.isMemo=J,se.isPortal=U,se.isProfiler=z,se.isStrictMode=W,se.isSuspense=oe,se.isValidElementType=C,se.typeOf=b}()),se}var _o;function Ti(){return _o||(_o=1,process.env.NODE_ENV==="production"?pn.exports=bd():pn.exports=Cd()),pn.exports}/*
|
|
23
|
+
object-assign
|
|
24
|
+
(c) Sindre Sorhus
|
|
25
|
+
@license MIT
|
|
26
|
+
*/var zn,bo;function Od(){if(bo)return zn;bo=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function i(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var s={},c=0;c<10;c++)s["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(s).map(function(p){return s[p]});if(u.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(p){d[p]=p}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return zn=i()?Object.assign:function(r,s){for(var c,u=o(r),d,p=1;p<arguments.length;p++){c=Object(arguments[p]);for(var h in c)t.call(c,h)&&(u[h]=c[h]);if(e){d=e(c);for(var v=0;v<d.length;v++)n.call(c,d[v])&&(u[d[v]]=c[d[v]])}}return u},zn}var Xn,Co;function Cr(){if(Co)return Xn;Co=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xn=e,Xn}var Yn,Oo;function Ai(){return Oo||(Oo=1,Yn=Function.call.bind(Object.prototype.hasOwnProperty)),Yn}var Gn,So;function Sd(){if(So)return Gn;So=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=Cr(),n={},o=Ai();e=function(r){var s="Warning: "+r;typeof console<"u"&&console.error(s);try{throw new Error(s)}catch{}}}function i(r,s,c,u,d){if(process.env.NODE_ENV!=="production"){for(var p in r)if(o(r,p)){var h;try{if(typeof r[p]!="function"){var v=Error((u||"React class")+": "+c+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}h=r[p](s,p,u,c,null,t)}catch(g){h=g}if(h&&!(h instanceof Error)&&e((u||"React class")+": type specification of "+c+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var f=d?d():"";e("Failed "+c+" type: "+h.message+(f??""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Gn=i,Gn}var Zn,Eo;function Ed(){if(Eo)return Zn;Eo=1;var e=Ti(),t=Od(),n=Cr(),o=Ai(),i=Sd(),r=function(){};process.env.NODE_ENV!=="production"&&(r=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function s(){return null}return Zn=function(c,u){var d=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function h(N){var K=N&&(d&&N[d]||N[p]);if(typeof K=="function")return K}var v="<<anonymous>>",f={array:O("array"),bigint:O("bigint"),bool:O("boolean"),func:O("function"),number:O("number"),object:O("object"),string:O("string"),symbol:O("symbol"),any:I(),arrayOf:C,element:b(),elementType:m(),instanceOf:j,node:B(),objectOf:F,oneOf:$,oneOfType:V,shape:G,exact:te};function g(N,K){return N===K?N!==0||1/N===1/K:N!==N&&K!==K}function x(N,K){this.message=N,this.data=K&&typeof K=="object"?K:{},this.stack=""}x.prototype=Error.prototype;function w(N){if(process.env.NODE_ENV!=="production")var K={},k=0;function D(R,q,J,U,z,W,oe){if(U=U||v,W=W||J,oe!==n){if(u){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=U+":"+J;!K[de]&&k<3&&(r("You are manually calling a React.PropTypes validation function for the `"+W+"` prop on `"+U+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),K[de]=!0,k++)}}return q[J]==null?R?q[J]===null?new x("The "+z+" `"+W+"` is marked as required "+("in `"+U+"`, but its value is `null`.")):new x("The "+z+" `"+W+"` is marked as required in "+("`"+U+"`, but its value is `undefined`.")):null:N(q,J,U,z,W)}var P=D.bind(null,!1);return P.isRequired=D.bind(null,!0),P}function O(N){function K(k,D,P,R,q,J){var U=k[D],z=le(U);if(z!==N){var W=re(U);return new x("Invalid "+R+" `"+q+"` of type "+("`"+W+"` supplied to `"+P+"`, expected ")+("`"+N+"`."),{expectedType:N})}return null}return w(K)}function I(){return w(s)}function C(N){function K(k,D,P,R,q){if(typeof N!="function")return new x("Property `"+q+"` of component `"+P+"` has invalid PropType notation inside arrayOf.");var J=k[D];if(!Array.isArray(J)){var U=le(J);return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected an array."))}for(var z=0;z<J.length;z++){var W=N(J,z,P,R,q+"["+z+"]",n);if(W instanceof Error)return W}return null}return w(K)}function b(){function N(K,k,D,P,R){var q=K[k];if(!c(q)){var J=le(q);return new x("Invalid "+P+" `"+R+"` of type "+("`"+J+"` supplied to `"+D+"`, expected a single ReactElement."))}return null}return w(N)}function m(){function N(K,k,D,P,R){var q=K[k];if(!e.isValidElementType(q)){var J=le(q);return new x("Invalid "+P+" `"+R+"` of type "+("`"+J+"` supplied to `"+D+"`, expected a single ReactElement type."))}return null}return w(N)}function j(N){function K(k,D,P,R,q){if(!(k[D]instanceof N)){var J=N.name||v,U=Ee(k[D]);return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected ")+("instance of `"+J+"`."))}return null}return w(K)}function $(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&(arguments.length>1?r("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):r("Invalid argument supplied to oneOf, expected an array.")),s;function K(k,D,P,R,q){for(var J=k[D],U=0;U<N.length;U++)if(g(J,N[U]))return null;var z=JSON.stringify(N,function(oe,A){var de=re(A);return de==="symbol"?String(A):A});return new x("Invalid "+R+" `"+q+"` of value `"+String(J)+"` "+("supplied to `"+P+"`, expected one of "+z+"."))}return w(K)}function F(N){function K(k,D,P,R,q){if(typeof N!="function")return new x("Property `"+q+"` of component `"+P+"` has invalid PropType notation inside objectOf.");var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected an object."));for(var z in J)if(o(J,z)){var W=N(J,z,P,R,q+"."+z,n);if(W instanceof Error)return W}return null}return w(K)}function V(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&r("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var K=0;K<N.length;K++){var k=N[K];if(typeof k!="function")return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Oe(k)+" at index "+K+"."),s}function D(P,R,q,J,U){for(var z=[],W=0;W<N.length;W++){var oe=N[W],A=oe(P,R,q,J,U,n);if(A==null)return null;A.data&&o(A.data,"expectedType")&&z.push(A.data.expectedType)}var de=z.length>0?", expected one of type ["+z.join(", ")+"]":"";return new x("Invalid "+J+" `"+U+"` supplied to "+("`"+q+"`"+de+"."))}return w(D)}function B(){function N(K,k,D,P,R){return Q(K[k])?null:new x("Invalid "+P+" `"+R+"` supplied to "+("`"+D+"`, expected a ReactNode."))}return w(N)}function Z(N,K,k,D,P){return new x((N||"React class")+": "+K+" type `"+k+"."+D+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+P+"`.")}function G(N){function K(k,D,P,R,q){var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type `"+U+"` "+("supplied to `"+P+"`, expected `object`."));for(var z in N){var W=N[z];if(typeof W!="function")return Z(P,R,q,z,re(W));var oe=W(J,z,P,R,q+"."+z,n);if(oe)return oe}return null}return w(K)}function te(N){function K(k,D,P,R,q){var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type `"+U+"` "+("supplied to `"+P+"`, expected `object`."));var z=t({},k[D],N);for(var W in z){var oe=N[W];if(o(N,W)&&typeof oe!="function")return Z(P,R,q,W,re(oe));if(!oe)return new x("Invalid "+R+" `"+q+"` key `"+W+"` supplied to `"+P+"`.\nBad object: "+JSON.stringify(k[D],null," ")+`
|
|
27
|
+
Valid keys: `+JSON.stringify(Object.keys(N),null," "));var A=oe(J,W,P,R,q+"."+W,n);if(A)return A}return null}return w(K)}function Q(N){switch(typeof N){case"number":case"string":case"undefined":return!0;case"boolean":return!N;case"object":if(Array.isArray(N))return N.every(Q);if(N===null||c(N))return!0;var K=h(N);if(K){var k=K.call(N),D;if(K!==N.entries){for(;!(D=k.next()).done;)if(!Q(D.value))return!1}else for(;!(D=k.next()).done;){var P=D.value;if(P&&!Q(P[1]))return!1}}else return!1;return!0;default:return!1}}function ue(N,K){return N==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function le(N){var K=typeof N;return Array.isArray(N)?"array":N instanceof RegExp?"object":ue(K,N)?"symbol":K}function re(N){if(typeof N>"u"||N===null)return""+N;var K=le(N);if(K==="object"){if(N instanceof Date)return"date";if(N instanceof RegExp)return"regexp"}return K}function Oe(N){var K=re(N);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function Ee(N){return!N.constructor||!N.constructor.name?v:N.constructor.name}return f.checkPropTypes=i,f.resetWarningCache=i.resetWarningCache,f.PropTypes=f,f},Zn}var Qn,No;function Nd(){if(No)return Qn;No=1;var e=Cr();function t(){}function n(){}return n.resetWarningCache=t,Qn=function(){function o(s,c,u,d,p,h){if(h!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}o.isRequired=o;function i(){return o}var r={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:i,element:o,elementType:o,instanceOf:i,node:o,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r},Qn}if(process.env.NODE_ENV!=="production"){var Rd=Ti(),Td=!0;sr.exports=Ed()(Rd.isElement,Td)}else sr.exports=Nd()();var Ad=sr.exports;const T=xr(Ad);var ar={exports:{}},ae={};/**
|
|
28
|
+
* @license React
|
|
29
|
+
* react-is.production.min.js
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the MIT license found in the
|
|
34
|
+
* LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/var Ro;function jd(){if(Ro)return ae;Ro=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),g;g=Symbol.for("react.module.reference");function x(w){if(typeof w=="object"&&w!==null){var O=w.$$typeof;switch(O){case e:switch(w=w.type,w){case n:case i:case o:case d:case p:return w;default:switch(w=w&&w.$$typeof,w){case c:case s:case u:case v:case h:case r:return w;default:return O}}case t:return O}}}return ae.ContextConsumer=s,ae.ContextProvider=r,ae.Element=e,ae.ForwardRef=u,ae.Fragment=n,ae.Lazy=v,ae.Memo=h,ae.Portal=t,ae.Profiler=i,ae.StrictMode=o,ae.Suspense=d,ae.SuspenseList=p,ae.isAsyncMode=function(){return!1},ae.isConcurrentMode=function(){return!1},ae.isContextConsumer=function(w){return x(w)===s},ae.isContextProvider=function(w){return x(w)===r},ae.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},ae.isForwardRef=function(w){return x(w)===u},ae.isFragment=function(w){return x(w)===n},ae.isLazy=function(w){return x(w)===v},ae.isMemo=function(w){return x(w)===h},ae.isPortal=function(w){return x(w)===t},ae.isProfiler=function(w){return x(w)===i},ae.isStrictMode=function(w){return x(w)===o},ae.isSuspense=function(w){return x(w)===d},ae.isSuspenseList=function(w){return x(w)===p},ae.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===n||w===i||w===o||w===d||w===p||w===f||typeof w=="object"&&w!==null&&(w.$$typeof===v||w.$$typeof===h||w.$$typeof===r||w.$$typeof===s||w.$$typeof===u||w.$$typeof===g||w.getModuleId!==void 0)},ae.typeOf=x,ae}var ce={};/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-is.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/var To;function Pd(){return To||(To=1,process.env.NODE_ENV!=="production"&&function(){var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),g=!1,x=!1,w=!1,O=!1,I=!1,C;C=Symbol.for("react.module.reference");function b(L){return!!(typeof L=="string"||typeof L=="function"||L===n||L===i||I||L===o||L===d||L===p||O||L===f||g||x||w||typeof L=="object"&&L!==null&&(L.$$typeof===v||L.$$typeof===h||L.$$typeof===r||L.$$typeof===s||L.$$typeof===u||L.$$typeof===C||L.getModuleId!==void 0))}function m(L){if(typeof L=="object"&&L!==null){var Ne=L.$$typeof;switch(Ne){case e:var Re=L.type;switch(Re){case n:case i:case o:case d:case p:return Re;default:var Ge=Re&&Re.$$typeof;switch(Ge){case c:case s:case u:case v:case h:case r:return Ge;default:return Ne}}case t:return Ne}}}var j=s,$=r,F=e,V=u,B=n,Z=v,G=h,te=t,Q=i,ue=o,le=d,re=p,Oe=!1,Ee=!1;function N(L){return Oe||(Oe=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function K(L){return Ee||(Ee=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function k(L){return m(L)===s}function D(L){return m(L)===r}function P(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function R(L){return m(L)===u}function q(L){return m(L)===n}function J(L){return m(L)===v}function U(L){return m(L)===h}function z(L){return m(L)===t}function W(L){return m(L)===i}function oe(L){return m(L)===o}function A(L){return m(L)===d}function de(L){return m(L)===p}ce.ContextConsumer=j,ce.ContextProvider=$,ce.Element=F,ce.ForwardRef=V,ce.Fragment=B,ce.Lazy=Z,ce.Memo=G,ce.Portal=te,ce.Profiler=Q,ce.StrictMode=ue,ce.Suspense=le,ce.SuspenseList=re,ce.isAsyncMode=N,ce.isConcurrentMode=K,ce.isContextConsumer=k,ce.isContextProvider=D,ce.isElement=P,ce.isForwardRef=R,ce.isFragment=q,ce.isLazy=J,ce.isMemo=U,ce.isPortal=z,ce.isProfiler=W,ce.isStrictMode=oe,ce.isSuspense=A,ce.isSuspenseList=de,ce.isValidElementType=b,ce.typeOf=m}()),ce}process.env.NODE_ENV==="production"?ar.exports=jd():ar.exports=Pd();var Ao=ar.exports;const jo=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Po=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",er=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Po(n.overflowY,t)||Po(n.overflowX,t)||(o=>{const i=(r=>{if(!r.ownerDocument||!r.ownerDocument.defaultView)return null;try{return r.ownerDocument.defaultView.frameElement}catch{return null}})(o);return!!i&&(i.clientHeight<o.scrollHeight||i.clientWidth<o.scrollWidth)})(e)}return!1},fn=(e,t,n,o,i,r,s,c)=>r<e&&s>t||r>e&&s<t?0:r<=e&&c<=n||s>=t&&c>=n?r-e-o:s>t&&c<n||r<e&&c>n?s-t+i:0,Dd=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},kd=(e,t)=>{var n,o,i,r;if(typeof document>"u")return[];const{scrollMode:s,block:c,inline:u,boundary:d,skipOverflowHiddenElements:p}=t,h=typeof d=="function"?d:le=>le!==d;if(!jo(e))throw new TypeError("Invalid target");const v=document.scrollingElement||document.documentElement,f=[];let g=e;for(;jo(g)&&h(g);){if(g=Dd(g),g===v){f.push(g);break}g!=null&&g===document.body&&er(g)&&!er(document.documentElement)||g!=null&&er(g,p)&&f.push(g)}const x=(o=(n=window.visualViewport)==null?void 0:n.width)!=null?o:innerWidth,w=(r=(i=window.visualViewport)==null?void 0:i.height)!=null?r:innerHeight,{scrollX:O,scrollY:I}=window,{height:C,width:b,top:m,right:j,bottom:$,left:F}=e.getBoundingClientRect(),{top:V,right:B,bottom:Z,left:G}=(le=>{const re=window.getComputedStyle(le);return{top:parseFloat(re.scrollMarginTop)||0,right:parseFloat(re.scrollMarginRight)||0,bottom:parseFloat(re.scrollMarginBottom)||0,left:parseFloat(re.scrollMarginLeft)||0}})(e);let te=c==="start"||c==="nearest"?m-V:c==="end"?$+Z:m+C/2-V+Z,Q=u==="center"?F+b/2-G+B:u==="end"?j+B:F-G;const ue=[];for(let le=0;le<f.length;le++){const re=f[le],{height:Oe,width:Ee,top:N,right:K,bottom:k,left:D}=re.getBoundingClientRect();if(s==="if-needed"&&m>=0&&F>=0&&$<=w&&j<=x&&m>=N&&$<=k&&F>=D&&j<=K)return ue;const P=getComputedStyle(re),R=parseInt(P.borderLeftWidth,10),q=parseInt(P.borderTopWidth,10),J=parseInt(P.borderRightWidth,10),U=parseInt(P.borderBottomWidth,10);let z=0,W=0;const oe="offsetWidth"in re?re.offsetWidth-re.clientWidth-R-J:0,A="offsetHeight"in re?re.offsetHeight-re.clientHeight-q-U:0,de="offsetWidth"in re?re.offsetWidth===0?0:Ee/re.offsetWidth:0,L="offsetHeight"in re?re.offsetHeight===0?0:Oe/re.offsetHeight:0;if(v===re)z=c==="start"?te:c==="end"?te-w:c==="nearest"?fn(I,I+w,w,q,U,I+te,I+te+C,C):te-w/2,W=u==="start"?Q:u==="center"?Q-x/2:u==="end"?Q-x:fn(O,O+x,x,R,J,O+Q,O+Q+b,b),z=Math.max(0,z+I),W=Math.max(0,W+O);else{z=c==="start"?te-N-q:c==="end"?te-k+U+A:c==="nearest"?fn(N,k,Oe,q,U+A,te,te+C,C):te-(N+Oe/2)+A/2,W=u==="start"?Q-D-R:u==="center"?Q-(D+Ee/2)+oe/2:u==="end"?Q-K+J+oe:fn(D,K,Ee,R,J+oe,Q,Q+b,b);const{scrollLeft:Ne,scrollTop:Re}=re;z=L===0?0:Math.max(0,Math.min(Re+z/L,re.scrollHeight-Oe/L+A)),W=de===0?0:Math.max(0,Math.min(Ne+W/de,re.scrollWidth-Ee/de+oe)),te+=Re-z,Q+=Ne-W}ue.push({el:re,top:z,left:W})}return ue};var Rt=function(){return Rt=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Rt.apply(this,arguments)};var Fd=0;function Do(e){return typeof e=="function"?e:De}function De(){}function ji(e,t){if(e){var n=kd(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach(function(o){var i=o.el,r=o.top,s=o.left;i.scrollTop=r,i.scrollLeft=s})}}function ko(e,t,n){var o=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return o}function Or(e,t){var n;function o(){n&&clearTimeout(n)}function i(){for(var r=arguments.length,s=new Array(r),c=0;c<r;c++)s[c]=arguments[c];o(),n=setTimeout(function(){n=null,e.apply(void 0,s)},t)}return i.cancel=o,i}function we(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return t.some(function(c){return c&&c.apply(void 0,[o].concat(r)),o.preventDownshiftDefault||o.hasOwnProperty("nativeEvent")&&o.nativeEvent.preventDownshiftDefault})}}function Et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){t.forEach(function(i){typeof i=="function"?i(o):i&&(i.current=o)})}}function Pi(){return String(Fd++)}function Md(e){var t=e.isOpen,n=e.resultCount,o=e.previousResultCount;return t?n?n!==o?n+" result"+(n===1?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function Fo(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Di(e){return typeof e.type=="string"}function ki(e){return e.props}function Kd(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var Ld=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function hn(e){e===void 0&&(e={});var t={};return Ld.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function _n(e,t){return!e||!t?e:Object.keys(e).reduce(function(n,o){return n[o]=bn(t,o)?t[o]:e[o],n},{})}function bn(e,t){return e[t]!==void 0}function cr(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function $d(e){return Object.prototype.toString.call(e)==="[object Object]"}function wt(e,t,n,o,i){var r=n.length;if(r===0)return-1;var s=r-1;(typeof e!="number"||e<0||e>s)&&(e=t>0?-1:s+1);var c=e+t;c<0?c=s:c>s&&(c=0);var u=Tt(c,t<0,n,o,i);return u===-1?e>=r?-1:e:u}function Tt(e,t,n,o,i){i===void 0&&(i=!1);var r=n.length;if(t){for(var s=e;s>=0;s--)if(!o(n[s],s))return s}else for(var c=e;c<r;c++)if(!o(n[c],c))return c;return i?Tt(t?r-1:0,t,n,o):-1}function Cn(e,t,n,o){return o===void 0&&(o=!0),n&&t.some(function(i){return i&&(ko(i,e,n)||o&&ko(i,n.document.activeElement,n))})}var Sr=De;process.env.NODE_ENV!=="production"&&(Sr=function(t,n,o){var i="This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props";Object.keys(t).forEach(function(r){n[r]!==void 0&&o[r]===void 0?console.error('downshift: A component has changed the controlled prop "'+r+'" to be uncontrolled. '+i):n[r]===void 0&&o[r]!==void 0&&console.error('downshift: A component has changed the uncontrolled prop "'+r+'" to be controlled. '+i)})});var Hd=Or(function(e){Fi(e).textContent=""},500);function Fi(e){var t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}function Mi(e,t){if(!(!e||!t)){var n=Fi(t);n.textContent=e,Hd(t)}}function Vd(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Ki=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Li=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,$i=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,vn=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,In=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Hi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Vi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Ui=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,Bi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,qi=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,Wi=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,Ji=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,zi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,ur=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,Xi=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,Yi=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,Gi=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,Ud=Object.freeze({__proto__:null,blurButton:Xi,blurInput:Wi,changeInput:Ji,clickButton:ur,clickItem:qi,controlledPropUpdatedSelectedItem:Yi,itemMouseEnter:$i,keyDownArrowDown:In,keyDownArrowUp:vn,keyDownEnd:Bi,keyDownEnter:Vi,keyDownEscape:Hi,keyDownHome:Ui,keyDownSpaceButton:zi,mouseUp:Li,touchEnd:Gi,unknown:Ki}),Bd=["refKey","ref"],qd=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],Wd=["onKeyDown","onBlur","onChange","onInput","onChangeText"],Jd=["refKey","ref"],zd=["onMouseMove","onMouseDown","onClick","onPress","index","item"],Xd=function(){var e=function(t){function n(i){var r;r=t.call(this,i)||this,r.id=r.props.id||"downshift-"+Pi(),r.menuId=r.props.menuId||r.id+"-menu",r.labelId=r.props.labelId||r.id+"-label",r.inputId=r.props.inputId||r.id+"-input",r.getItemId=r.props.getItemId||function(I){return r.id+"-item-"+I},r.items=[],r.itemCount=null,r.previousResultCount=0,r.timeoutIds=[],r.internalSetTimeout=function(I,C){var b=setTimeout(function(){r.timeoutIds=r.timeoutIds.filter(function(m){return m!==b}),I()},C);r.timeoutIds.push(b)},r.setItemCount=function(I){r.itemCount=I},r.unsetItemCount=function(){r.itemCount=null},r.isItemDisabled=function(I,C){var b=r.getItemNodeFromIndex(C);return b&&b.hasAttribute("disabled")},r.setHighlightedIndex=function(I,C){I===void 0&&(I=r.props.defaultHighlightedIndex),C===void 0&&(C={}),C=hn(C),r.internalSetState(ne({highlightedIndex:I},C))},r.clearSelection=function(I){r.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen},I)},r.selectItem=function(I,C,b){C=hn(C),r.internalSetState(ne({isOpen:r.props.defaultIsOpen,highlightedIndex:r.props.defaultHighlightedIndex,selectedItem:I,inputValue:r.props.itemToString(I)},C),b)},r.selectItemAtIndex=function(I,C,b){var m=r.items[I];m!=null&&r.selectItem(m,C,b)},r.selectHighlightedItem=function(I,C){return r.selectItemAtIndex(r.getState().highlightedIndex,I,C)},r.internalSetState=function(I,C){var b,m,j={},$=typeof I=="function";return!$&&I.hasOwnProperty("inputValue")&&r.props.onInputValueChange(I.inputValue,ne({},r.getStateAndHelpers(),I)),r.setState(function(F){var V;F=r.getState(F);var B=$?I(F):I;B=r.props.stateReducer(F,B),b=B.hasOwnProperty("selectedItem");var Z={};return b&&B.selectedItem!==F.selectedItem&&(m=B.selectedItem),(V=B).type||(V.type=Ki),Object.keys(B).forEach(function(G){F[G]!==B[G]&&(j[G]=B[G]),G!=="type"&&(B[G],bn(r.props,G)||(Z[G]=B[G]))}),$&&B.hasOwnProperty("inputValue")&&r.props.onInputValueChange(B.inputValue,ne({},r.getStateAndHelpers(),B)),Z},function(){Do(C)();var F=Object.keys(j).length>1;F&&r.props.onStateChange(j,r.getStateAndHelpers()),b&&r.props.onSelect(I.selectedItem,r.getStateAndHelpers()),m!==void 0&&r.props.onChange(m,r.getStateAndHelpers()),r.props.onUserAction(j,r.getStateAndHelpers())})},r.rootRef=function(I){return r._rootNode=I},r.getRootProps=function(I,C){var b,m=I===void 0?{}:I,j=m.refKey,$=j===void 0?"ref":j,F=m.ref,V=nt(m,Bd),B=C===void 0?{}:C,Z=B.suppressRefError,G=Z===void 0?!1:Z;r.getRootProps.called=!0,r.getRootProps.refKey=$,r.getRootProps.suppressRefError=G;var te=r.getState(),Q=te.isOpen;return ne((b={},b[$]=Et(F,r.rootRef),b.role="combobox",b["aria-expanded"]=Q,b["aria-haspopup"]="listbox",b["aria-owns"]=Q?r.menuId:void 0,b["aria-labelledby"]=r.labelId,b),V)},r.keyDownHandlers={ArrowDown:function(C){var b=this;if(C.preventDefault(),this.getState().isOpen){var m=C.shiftKey?5:1;this.moveHighlightedIndex(m,{type:In})}else this.internalSetState({isOpen:!0,type:In},function(){var j=b.getItemCount();if(j>0){var $=b.getState(),F=$.highlightedIndex,V=wt(F,1,{length:j},b.isItemDisabled,!0);b.setHighlightedIndex(V,{type:In})}})},ArrowUp:function(C){var b=this;if(C.preventDefault(),this.getState().isOpen){var m=C.shiftKey?-5:-1;this.moveHighlightedIndex(m,{type:vn})}else this.internalSetState({isOpen:!0,type:vn},function(){var j=b.getItemCount();if(j>0){var $=b.getState(),F=$.highlightedIndex,V=wt(F,-1,{length:j},b.isItemDisabled,!0);b.setHighlightedIndex(V,{type:vn})}})},Enter:function(C){if(C.which!==229){var b=this.getState(),m=b.isOpen,j=b.highlightedIndex;if(m&&j!=null){C.preventDefault();var $=this.items[j],F=this.getItemNodeFromIndex(j);if($==null||F&&F.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Vi})}}},Escape:function(C){C.preventDefault(),this.reset(ne({type:Hi},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},r.buttonKeyDownHandlers=ne({},r.keyDownHandlers,{" ":function(C){C.preventDefault(),this.toggleMenu({type:zi})}}),r.inputKeyDownHandlers=ne({},r.keyDownHandlers,{Home:function(C){var b=this.getState(),m=b.isOpen;if(m){C.preventDefault();var j=this.getItemCount();if(!(j<=0||!m)){var $=Tt(0,!1,{length:j},this.isItemDisabled);this.setHighlightedIndex($,{type:Ui})}}},End:function(C){var b=this.getState(),m=b.isOpen;if(m){C.preventDefault();var j=this.getItemCount();if(!(j<=0||!m)){var $=Tt(j-1,!0,{length:j},this.isItemDisabled);this.setHighlightedIndex($,{type:Bi})}}}}),r.getToggleButtonProps=function(I){var C=I===void 0?{}:I,b=C.onClick;C.onPress;var m=C.onKeyDown,j=C.onKeyUp,$=C.onBlur,F=nt(C,qd),V=r.getState(),B=V.isOpen,Z={onClick:we(b,r.buttonHandleClick),onKeyDown:we(m,r.buttonHandleKeyDown),onKeyUp:we(j,r.buttonHandleKeyUp),onBlur:we($,r.buttonHandleBlur)},G=F.disabled?{}:Z;return ne({type:"button",role:"button","aria-label":B?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},G,F)},r.buttonHandleKeyUp=function(I){I.preventDefault()},r.buttonHandleKeyDown=function(I){var C=cr(I);r.buttonKeyDownHandlers[C]&&r.buttonKeyDownHandlers[C].call(r,I)},r.buttonHandleClick=function(I){if(I.preventDefault(),r.props.environment){var C=r.props.environment.document,b=C.body,m=C.activeElement;b&&b===m&&I.target.focus()}process.env.NODE_ENV==="test"?r.toggleMenu({type:ur}):r.internalSetTimeout(function(){return r.toggleMenu({type:ur})})},r.buttonHandleBlur=function(I){var C=I.target;r.internalSetTimeout(function(){if(!(r.isMouseDown||!r.props.environment)){var b=r.props.environment.document.activeElement;(b==null||b.id!==r.inputId)&&b!==C&&r.reset({type:Xi})}})},r.getLabelProps=function(I){return ne({htmlFor:r.inputId,id:r.labelId},I)},r.getInputProps=function(I){var C=I===void 0?{}:I,b=C.onKeyDown,m=C.onBlur,j=C.onChange,$=C.onInput;C.onChangeText;var F=nt(C,Wd),V,B={};V="onChange";var Z=r.getState(),G=Z.inputValue,te=Z.isOpen,Q=Z.highlightedIndex;if(!F.disabled){var ue;B=(ue={},ue[V]=we(j,$,r.inputHandleChange),ue.onKeyDown=we(b,r.inputHandleKeyDown),ue.onBlur=we(m,r.inputHandleBlur),ue)}return ne({"aria-autocomplete":"list","aria-activedescendant":te&&typeof Q=="number"&&Q>=0?r.getItemId(Q):void 0,"aria-controls":te?r.menuId:void 0,"aria-labelledby":F&&F["aria-label"]?void 0:r.labelId,autoComplete:"off",value:G,id:r.inputId},B,F)},r.inputHandleKeyDown=function(I){var C=cr(I);C&&r.inputKeyDownHandlers[C]&&r.inputKeyDownHandlers[C].call(r,I)},r.inputHandleChange=function(I){r.internalSetState({type:Ji,isOpen:!0,inputValue:I.target.value,highlightedIndex:r.props.defaultHighlightedIndex})},r.inputHandleBlur=function(){r.internalSetTimeout(function(){var I;if(!(r.isMouseDown||!r.props.environment)){var C=r.props.environment.document.activeElement,b=(C==null||(I=C.dataset)==null?void 0:I.toggle)&&r._rootNode&&r._rootNode.contains(C);b||r.reset({type:Wi})}})},r.menuRef=function(I){r._menuNode=I},r.getMenuProps=function(I,C){var b,m=I===void 0?{}:I,j=m.refKey,$=j===void 0?"ref":j,F=m.ref,V=nt(m,Jd),B=C===void 0?{}:C,Z=B.suppressRefError,G=Z===void 0?!1:Z;return r.getMenuProps.called=!0,r.getMenuProps.refKey=$,r.getMenuProps.suppressRefError=G,ne((b={},b[$]=Et(F,r.menuRef),b.role="listbox",b["aria-labelledby"]=V&&V["aria-label"]?void 0:r.labelId,b.id=r.menuId,b),V)},r.getItemProps=function(I){var C,b=I===void 0?{}:I,m=b.onMouseMove,j=b.onMouseDown,$=b.onClick;b.onPress;var F=b.index,V=b.item,B=V===void 0?process.env.NODE_ENV==="production"?void 0:Kd("getItemProps","item"):V,Z=nt(b,zd);F===void 0?(r.items.push(B),F=r.items.indexOf(B)):r.items[F]=B;var G="onClick",te=$,Q=(C={onMouseMove:we(m,function(){F!==r.getState().highlightedIndex&&(r.setHighlightedIndex(F,{type:$i}),r.avoidScrolling=!0,r.internalSetTimeout(function(){return r.avoidScrolling=!1},250))}),onMouseDown:we(j,function(le){le.preventDefault()})},C[G]=we(te,function(){r.selectItemAtIndex(F,{type:qi})}),C),ue=Z.disabled?{onMouseDown:Q.onMouseDown}:Q;return ne({id:r.getItemId(F),role:"option","aria-selected":r.getState().highlightedIndex===F},ue,Z)},r.clearItems=function(){r.items=[]},r.reset=function(I,C){I===void 0&&(I={}),I=hn(I),r.internalSetState(function(b){var m=b.selectedItem;return ne({isOpen:r.props.defaultIsOpen,highlightedIndex:r.props.defaultHighlightedIndex,inputValue:r.props.itemToString(m)},I)},C)},r.toggleMenu=function(I,C){I===void 0&&(I={}),I=hn(I),r.internalSetState(function(b){var m=b.isOpen;return ne({isOpen:!m},m&&{highlightedIndex:r.props.defaultHighlightedIndex},I)},function(){var b=r.getState(),m=b.isOpen,j=b.highlightedIndex;m&&r.getItemCount()>0&&typeof j=="number"&&r.setHighlightedIndex(j,I),Do(C)()})},r.openMenu=function(I){r.internalSetState({isOpen:!0},I)},r.closeMenu=function(I){r.internalSetState({isOpen:!1},I)},r.updateStatus=Or(function(){var I;if((I=r.props)!=null&&(I=I.environment)!=null&&I.document){var C=r.getState(),b=r.items[C.highlightedIndex],m=r.getItemCount(),j=r.props.getA11yStatusMessage(ne({itemToString:r.props.itemToString,previousResultCount:r.previousResultCount,resultCount:m,highlightedItem:b},C));r.previousResultCount=m,Mi(j,r.props.environment.document)}},200);var s=r.props,c=s.defaultHighlightedIndex,u=s.initialHighlightedIndex,d=u===void 0?c:u,p=s.defaultIsOpen,h=s.initialIsOpen,v=h===void 0?p:h,f=s.initialInputValue,g=f===void 0?"":f,x=s.initialSelectedItem,w=x===void 0?null:x,O=r.getState({highlightedIndex:d,isOpen:v,inputValue:g,selectedItem:w});return O.selectedItem!=null&&r.props.initialInputValue===void 0&&(O.inputValue=r.props.itemToString(O.selectedItem)),r.state=O,r}_d(n,t);var o=n.prototype;return o.internalClearTimeouts=function(){this.timeoutIds.forEach(function(r){clearTimeout(r)}),this.timeoutIds=[]},o.getState=function(r){return r===void 0&&(r=this.state),_n(r,this.props)},o.getItemCount=function(){var r=this.items.length;return this.itemCount!=null?r=this.itemCount:this.props.itemCount!==void 0&&(r=this.props.itemCount),r},o.getItemNodeFromIndex=function(r){return this.props.environment?this.props.environment.document.getElementById(this.getItemId(r)):null},o.scrollHighlightedItemIntoView=function(){{var r=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(r,this._menuNode)}},o.moveHighlightedIndex=function(r,s){var c=this.getItemCount(),u=this.getState(),d=u.highlightedIndex;if(c>0){var p=wt(d,r,{length:c},this.isItemDisabled,!0);this.setHighlightedIndex(p,s)}},o.getStateAndHelpers=function(){var r=this.getState(),s=r.highlightedIndex,c=r.inputValue,u=r.selectedItem,d=r.isOpen,p=this.props.itemToString,h=this.id,v=this.getRootProps,f=this.getToggleButtonProps,g=this.getLabelProps,x=this.getMenuProps,w=this.getInputProps,O=this.getItemProps,I=this.openMenu,C=this.closeMenu,b=this.toggleMenu,m=this.selectItem,j=this.selectItemAtIndex,$=this.selectHighlightedItem,F=this.setHighlightedIndex,V=this.clearSelection,B=this.clearItems,Z=this.reset,G=this.setItemCount,te=this.unsetItemCount,Q=this.internalSetState;return{getRootProps:v,getToggleButtonProps:f,getLabelProps:g,getMenuProps:x,getInputProps:w,getItemProps:O,reset:Z,openMenu:I,closeMenu:C,toggleMenu:b,selectItem:m,selectItemAtIndex:j,selectHighlightedItem:$,setHighlightedIndex:F,clearSelection:V,clearItems:B,setItemCount:G,unsetItemCount:te,setState:Q,itemToString:p,id:h,highlightedIndex:s,inputValue:c,isOpen:d,selectedItem:u}},o.componentDidMount=function(){var r=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&Mo(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){r.internalClearTimeouts()};else{var s=function(){r.isMouseDown=!0},c=function(f){r.isMouseDown=!1;var g=Cn(f.target,[r._rootNode,r._menuNode],r.props.environment);!g&&r.getState().isOpen&&r.reset({type:Li},function(){return r.props.onOuterClick(r.getStateAndHelpers())})},u=function(){r.isTouchMove=!1},d=function(){r.isTouchMove=!0},p=function(f){var g=Cn(f.target,[r._rootNode,r._menuNode],r.props.environment,!1);!r.isTouchMove&&!g&&r.getState().isOpen&&r.reset({type:Gi},function(){return r.props.onOuterClick(r.getStateAndHelpers())})},h=this.props.environment;h.addEventListener("mousedown",s),h.addEventListener("mouseup",c),h.addEventListener("touchstart",u),h.addEventListener("touchmove",d),h.addEventListener("touchend",p),this.cleanup=function(){r.internalClearTimeouts(),r.updateStatus.cancel(),h.removeEventListener("mousedown",s),h.removeEventListener("mouseup",c),h.removeEventListener("touchstart",u),h.removeEventListener("touchmove",d),h.removeEventListener("touchend",p)}}},o.shouldScroll=function(r,s){var c=this.props.highlightedIndex===void 0?this.getState():this.props,u=c.highlightedIndex,d=s.highlightedIndex===void 0?r:s,p=d.highlightedIndex,h=u&&this.getState().isOpen&&!r.isOpen,v=u!==p;return h||v},o.componentDidUpdate=function(r,s){process.env.NODE_ENV!=="production"&&(Sr(this.state,r,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&Mo(this._menuNode,this.getMenuProps)),bn(this.props,"selectedItem")&&this.props.selectedItemChanged(r.selectedItem,this.props.selectedItem)&&this.internalSetState({type:Yi,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(s,r)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},o.componentWillUnmount=function(){this.cleanup()},o.render=function(){var r=Fo(this.props.children,De);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var s=Fo(r(this.getStateAndHelpers()));if(!s)return null;if(this.getRootProps.called||this.props.suppressRefError)return process.env.NODE_ENV!=="production"&&!this.getRootProps.suppressRefError&&!this.props.suppressRefError&&Yd(s,this.getRootProps),s;if(Di(s))return y.cloneElement(s,this.getRootProps(ki(s)));if(process.env.NODE_ENV!=="production")throw new Error("downshift: If you return a non-DOM element, you must apply the getRootProps function")},n}(y.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:Md,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&$d(n)&&!n.hasOwnProperty("toString")&&console.warn("downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.","The object that was passed:",n),String(n))},onStateChange:De,onInputValueChange:De,onUserAction:De,onChange:De,onSelect:De,onOuterClick:De,selectedItemChanged:function(n,o){return n!==o},environment:typeof window>"u"?void 0:window,stateReducer:function(n,o){return o},suppressRefError:!1,scrollIntoView:ji},e.stateChangeTypes=Ud,e}();process.env.NODE_ENV!=="production"&&(Xd.propTypes={children:T.func,defaultHighlightedIndex:T.number,defaultIsOpen:T.bool,initialHighlightedIndex:T.number,initialSelectedItem:T.any,initialInputValue:T.string,initialIsOpen:T.bool,getA11yStatusMessage:T.func,itemToString:T.func,onChange:T.func,onSelect:T.func,onStateChange:T.func,onInputValueChange:T.func,onUserAction:T.func,onOuterClick:T.func,selectedItemChanged:T.func,stateReducer:T.func,itemCount:T.number,id:T.string,environment:T.shape({addEventListener:T.func.isRequired,removeEventListener:T.func.isRequired,document:T.shape({createElement:T.func.isRequired,getElementById:T.func.isRequired,activeElement:T.any.isRequired,body:T.any.isRequired}).isRequired,Node:T.func.isRequired}),suppressRefError:T.bool,scrollIntoView:T.func,selectedItem:T.any,isOpen:T.bool,inputValue:T.string,highlightedIndex:T.number,labelId:T.string,inputId:T.string,menuId:T.string,getItemId:T.func});function Mo(e,t){var n=t.refKey;e||console.error('downshift: The ref prop "'+n+'" from getMenuProps was not applied correctly on your menu element.')}function Yd(e,t){var n=t.refKey,o=n!=="ref",i=!Di(e);i&&!o&&!Ao.isForwardRef(e)?console.error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps"):!i&&o&&console.error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"'),!Ao.isForwardRef(e)&&!ki(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var Zi={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function Gd(e,t,n){var o=e.props,i=e.type,r={};Object.keys(t).forEach(function(s){Zd(s,e,t,n),n[s]!==t[s]&&(r[s]=n[s])}),o.onStateChange&&Object.keys(r).length&&o.onStateChange(ne({type:i},r))}function Zd(e,t,n,o){var i=t.props,r=t.type,s="on"+Er(e)+"Change";i[s]&&o[e]!==void 0&&o[e]!==n[e]&&i[s](ne({type:r},o))}function Qd(e,t){return t.changes}var Ko=Or(function(e,t){Mi(e,t)},200),ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?y.useLayoutEffect:y.useEffect,tp="useId"in y?function(t){var n=t.id,o=t.labelId,i=t.menuId,r=t.getItemId,s=t.toggleButtonId,c=t.inputId,u="downshift-"+y.useId();n||(n=u);var d=y.useRef({labelId:o||n+"-label",menuId:i||n+"-menu",getItemId:r||function(p){return n+"-item-"+p},toggleButtonId:s||n+"-toggle-button",inputId:c||n+"-input"});return d.current}:function(t){var n=t.id,o=n===void 0?"downshift-"+Pi():n,i=t.labelId,r=t.menuId,s=t.getItemId,c=t.toggleButtonId,u=t.inputId,d=y.useRef({labelId:i||o+"-label",menuId:r||o+"-menu",getItemId:s||function(p){return o+"-item-"+p},toggleButtonId:c||o+"-toggle-button",inputId:u||o+"-input"});return d.current};function np(e,t,n,o){var i,r;if(e===void 0){if(t===void 0)throw new Error(o);i=n[t],r=t}else r=t===void 0?n.indexOf(e):t,i=e;return[i,r]}function Er(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function Qi(e){var t=y.useRef(e);return t.current=e,t}function rp(e,t,n,o){var i=y.useRef(),r=y.useRef(),s=y.useCallback(function(f,g){r.current=g,f=_n(f,g.props);var x=e(f,g),w=g.props.stateReducer(f,ne({},g,{changes:x}));return w},[e]),c=y.useReducer(s,t,n),u=c[0],d=c[1],p=Qi(t),h=y.useCallback(function(f){return d(ne({props:p.current},f))},[p]),v=r.current;return y.useEffect(function(){var f=_n(i.current,v==null?void 0:v.props),g=v&&i.current&&!o(f,u);g&&Gd(v,f,u),i.current=u},[u,v,o]),[u,h]}var qt={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:Qd,scrollIntoView:ji,environment:typeof window>"u"?void 0:window};function ut(e,t,n){n===void 0&&(n=Zi);var o=e["default"+Er(t)];return o!==void 0?o:n[t]}function Wt(e,t,n){n===void 0&&(n=Zi);var o=e[t];if(o!==void 0)return o;var i=e["initial"+Er(t)];return i!==void 0?i:ut(e,t,n)}function op(e){var t=Wt(e,"selectedItem"),n=Wt(e,"isOpen"),o=up(e),i=Wt(e,"inputValue");return{highlightedIndex:o<0&&t&&n?e.items.findIndex(function(r){return e.itemToKey(r)===e.itemToKey(t)}):o,isOpen:n,selectedItem:t,inputValue:i}}function Jt(e,t,n){var o=e.items,i=e.initialHighlightedIndex,r=e.defaultHighlightedIndex,s=e.isItemDisabled,c=e.itemToKey,u=t.selectedItem,d=t.highlightedIndex;return o.length===0?-1:i!==void 0&&d===i&&!s(o[i],i)?i:r!==void 0&&!s(o[r],r)?r:u?o.findIndex(function(p){return c(u)===c(p)}):n<0&&!s(o[o.length-1],o.length-1)?o.length-1:n>0&&!s(o[0],0)?0:-1}function ip(e,t,n){var o=y.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return y.useEffect(function(){if(!e)return De;var i=n.map(function(p){return p.current});function r(){o.current.isTouchEnd=!1,o.current.isMouseDown=!0}function s(p){o.current.isMouseDown=!1,Cn(p.target,i,e)||t()}function c(){o.current.isTouchEnd=!1,o.current.isTouchMove=!1}function u(){o.current.isTouchMove=!0}function d(p){o.current.isTouchEnd=!0,!o.current.isTouchMove&&!Cn(p.target,i,e,!1)&&t()}return e.addEventListener("mousedown",r),e.addEventListener("mouseup",s),e.addEventListener("touchstart",c),e.addEventListener("touchmove",u),e.addEventListener("touchend",d),function(){e.removeEventListener("mousedown",r),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",c),e.removeEventListener("touchmove",u),e.removeEventListener("touchend",d)}},[n,e,t]),o.current}var es=function(){return De};process.env.NODE_ENV!=="production"&&(es=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=y.useRef(n.reduce(function(s,c){return s[c]={},s},{}));y.useEffect(function(){Object.keys(i.current).forEach(function(s){var c=i.current[s];if(!Object.keys(c).length){console.error("downshift: You forgot to call the "+s+" getter function on your component / element.");return}var u=c.suppressRefError,d=c.refKey,p=c.elementRef;u||p!=null&&p.current||console.error('downshift: The ref prop "'+d+'" from '+s+" was not applied correctly on your element.")})},[]);var r=y.useCallback(function(s,c,u,d){i.current[s]={suppressRefError:c,refKey:u,elementRef:d}},[]);return r});function sp(e,t,n,o){o===void 0&&(o={});var i=o.document,r=Pn();y.useEffect(function(){if(!(!e||r||!i)){var s=e(t);Ko(s,i)}},n),y.useEffect(function(){return function(){Ko.cancel(),Vd(i)}},[i])}function ap(e){var t=e.highlightedIndex,n=e.isOpen,o=e.itemRefs,i=e.getItemNodeFromIndex,r=e.menuElement,s=e.scrollIntoView,c=y.useRef(!0);return ep(function(){t<0||!n||!Object.keys(o.current).length||(c.current===!1?c.current=!0:s(i(t),r))},[t]),c}var ts=De;process.env.NODE_ENV!=="production"&&(ts=function(t){var n=t.props,o=t.state,i=y.useRef(n),r=Pn();y.useEffect(function(){r||(Sr(o,i.current,n),i.current=n)},[o,n,r])});function Lo(e,t,n){var o;n===void 0&&(n=!0);var i=((o=e.items)==null?void 0:o.length)&&t>=0;return ne({isOpen:!1,highlightedIndex:-1},i&&ne({selectedItem:e.items[t],isOpen:ut(e,"isOpen"),highlightedIndex:ut(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function cp(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Pn(){var e=y.useRef(!0);return y.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function lr(e){var t=ut(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function up(e){var t=Wt(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var wn={environment:T.shape({addEventListener:T.func.isRequired,removeEventListener:T.func.isRequired,document:T.shape({createElement:T.func.isRequired,getElementById:T.func.isRequired,activeElement:T.any.isRequired,body:T.any.isRequired}).isRequired,Node:T.func.isRequired}),itemToString:T.func,itemToKey:T.func,stateReducer:T.func},ns=ne({},wn,{getA11yStatusMessage:T.func,highlightedIndex:T.number,defaultHighlightedIndex:T.number,initialHighlightedIndex:T.number,isOpen:T.bool,defaultIsOpen:T.bool,initialIsOpen:T.bool,selectedItem:T.any,initialSelectedItem:T.any,defaultSelectedItem:T.any,id:T.string,labelId:T.string,menuId:T.string,getItemId:T.func,toggleButtonId:T.string,onSelectedItemChange:T.func,onHighlightedIndexChange:T.func,onStateChange:T.func,onIsOpenChange:T.func,scrollIntoView:T.func});function lp(e,t,n){var o=t.type,i=t.props,r;switch(o){case n.ItemMouseMove:r={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Jt(i,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:Jt(i,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:i.isItemDisabled(i.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:lr(i),isOpen:ut(i,"isOpen"),selectedItem:ut(i,"selectedItem"),inputValue:ut(i,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return ne({},e,r)}Rt(Rt({},ns),{items:T.array.isRequired,isItemDisabled:T.func});Rt(Rt({},qt),{isItemDisabled:function(){return!1}});process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;var Nr=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,Rr=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,Tr=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Ar=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,jr=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,Pr=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,Dr=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,kr=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,Fr=process.env.NODE_ENV!=="production"?"__input_change__":8,On=process.env.NODE_ENV!=="production"?"__input_blur__":9,Mr=process.env.NODE_ENV!=="production"?"__input_click__":10,rs=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,os=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,Kr=process.env.NODE_ENV!=="production"?"__item_click__":13,is=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,ss=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,as=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,cs=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,us=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,Lr=process.env.NODE_ENV!=="production"?"__function_select_item__":19,ls=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,ds=process.env.NODE_ENV!=="production"?"__function_reset__":21,$r=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,ps=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:$r,FunctionCloseMenu:cs,FunctionOpenMenu:as,FunctionReset:ds,FunctionSelectItem:Lr,FunctionSetHighlightedIndex:us,FunctionSetInputValue:ls,FunctionToggleMenu:ss,InputBlur:On,InputChange:Fr,InputClick:Mr,InputKeyDownArrowDown:Nr,InputKeyDownArrowUp:Rr,InputKeyDownEnd:jr,InputKeyDownEnter:kr,InputKeyDownEscape:Tr,InputKeyDownHome:Ar,InputKeyDownPageDown:Dr,InputKeyDownPageUp:Pr,ItemClick:Kr,ItemMouseMove:os,MenuMouseLeave:rs,ToggleButtonClick:is});function dp(e){var t=op(e),n=t.selectedItem,o=t.inputValue;return o===""&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(o=e.itemToString(n)),ne({},t,{inputValue:o})}var pp=ne({},ns,{items:T.array.isRequired,isItemDisabled:T.func,inputValue:T.string,defaultInputValue:T.string,initialInputValue:T.string,inputId:T.string,onInputValueChange:T.func});function fp(e,t,n,o){var i=y.useRef(),r=rp(e,t,n,o),s=r[0],c=r[1],u=Pn();return y.useEffect(function(){if(bn(t,"selectedItem")){if(!u){var d=t.itemToKey(t.selectedItem)!==t.itemToKey(i.current);d&&c({type:$r,inputValue:t.itemToString(t.selectedItem)})}i.current=s.selectedItem===i.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[_n(s,t),c]}var fs=De;process.env.NODE_ENV!=="production"&&(fs=function(t,n){T.checkPropTypes(pp,t,"prop",n.name)});var hp=ne({},qt,{isItemDisabled:function(){return!1}});function mp(e,t){var n,o=t.type,i=t.props,r=t.altKey,s;switch(o){case Kr:s={isOpen:ut(i,"isOpen"),highlightedIndex:lr(i),selectedItem:i.items[t.index],inputValue:i.itemToString(i.items[t.index])};break;case Nr:e.isOpen?s={highlightedIndex:wt(e.highlightedIndex,1,i.items,i.isItemDisabled,!0)}:s={highlightedIndex:r&&e.selectedItem==null?-1:Jt(i,e,1),isOpen:i.items.length>=0};break;case Rr:e.isOpen?r?s=Lo(i,e.highlightedIndex):s={highlightedIndex:wt(e.highlightedIndex,-1,i.items,i.isItemDisabled,!0)}:s={highlightedIndex:Jt(i,e,-1),isOpen:i.items.length>=0};break;case kr:s=Lo(i,e.highlightedIndex);break;case Tr:s=ne({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case Pr:s={highlightedIndex:wt(e.highlightedIndex,-10,i.items,i.isItemDisabled,!0)};break;case Dr:s={highlightedIndex:wt(e.highlightedIndex,10,i.items,i.isItemDisabled,!0)};break;case Ar:s={highlightedIndex:Tt(0,!1,i.items,i.isItemDisabled)};break;case jr:s={highlightedIndex:Tt(i.items.length-1,!0,i.items,i.isItemDisabled)};break;case On:s=ne({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&((n=i.items)==null?void 0:n.length)&&t.selectItem&&{selectedItem:i.items[e.highlightedIndex],inputValue:i.itemToString(i.items[e.highlightedIndex])});break;case Fr:s={isOpen:!0,highlightedIndex:lr(i),inputValue:t.inputValue};break;case Mr:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Jt(i,e,0)};break;case Lr:s={selectedItem:t.selectedItem,inputValue:i.itemToString(t.selectedItem)};break;case $r:s={inputValue:t.inputValue};break;default:return lp(e,t,ps)}return ne({},e,s)}var gp=["onMouseLeave","refKey","ref"],yp=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],vp=["onClick","onPress","refKey","ref"],Ip=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];Hr.stateChangeTypes=ps;function Hr(e){e===void 0&&(e={}),fs(e,Hr);var t=ne({},hp,e),n=t.items,o=t.scrollIntoView,i=t.environment,r=t.getA11yStatusMessage,s=fp(mp,t,dp,cp),c=s[0],u=s[1],d=c.isOpen,p=c.highlightedIndex,h=c.selectedItem,v=c.inputValue,f=y.useRef(null),g=y.useRef({}),x=y.useRef(null),w=y.useRef(null),O=Pn(),I=tp(t),C=y.useRef(),b=Qi({state:c,props:t}),m=y.useCallback(function(k){return g.current[I.getItemId(k)]},[I]);sp(r,c,[d,p,h,v],i);var j=ap({menuElement:f.current,highlightedIndex:p,isOpen:d,itemRefs:g,scrollIntoView:o,getItemNodeFromIndex:m});ts({props:t,state:c}),y.useEffect(function(){var k=Wt(t,"isOpen");k&&x.current&&x.current.focus()},[]),y.useEffect(function(){O||(C.current=n.length)});var $=ip(i,y.useCallback(function(){b.current.state.isOpen&&u({type:On,selectItem:!1})},[u,b]),y.useMemo(function(){return[f,w,x]},[f.current,w.current,x.current])),F=es("getInputProps","getMenuProps");y.useEffect(function(){d||(g.current={})},[d]),y.useEffect(function(){var k;!d||!(i!=null&&i.document)||!(x!=null&&(k=x.current)!=null&&k.focus)||i.document.activeElement!==x.current&&x.current.focus()},[d,i]);var V=y.useMemo(function(){return{ArrowDown:function(D){D.preventDefault(),u({type:Nr,altKey:D.altKey})},ArrowUp:function(D){D.preventDefault(),u({type:Rr,altKey:D.altKey})},Home:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Ar}))},End:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:jr}))},Escape:function(D){var P=b.current.state;(P.isOpen||P.inputValue||P.selectedItem||P.highlightedIndex>-1)&&(D.preventDefault(),u({type:Tr}))},Enter:function(D){var P=b.current.state;!P.isOpen||D.which===229||(D.preventDefault(),u({type:kr}))},PageUp:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Pr}))},PageDown:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Dr}))}}},[u,b]),B=y.useCallback(function(k){return ne({id:I.labelId,htmlFor:I.inputId},k)},[I]),Z=y.useCallback(function(k,D){var P,R=k===void 0?{}:k,q=R.onMouseLeave,J=R.refKey,U=J===void 0?"ref":J,z=R.ref,W=nt(R,gp),oe=D===void 0?{}:D,A=oe.suppressRefError,de=A===void 0?!1:A;return F("getMenuProps",de,U,f),ne((P={},P[U]=Et(z,function(L){f.current=L}),P.id=I.menuId,P.role="listbox",P["aria-labelledby"]=W&&W["aria-label"]?void 0:""+I.labelId,P.onMouseLeave=we(q,function(){u({type:rs})}),P),W)},[u,F,I]),G=y.useCallback(function(k){var D,P,R=k===void 0?{}:k,q=R.item,J=R.index,U=R.refKey,z=U===void 0?"ref":U,W=R.ref,oe=R.onMouseMove,A=R.onMouseDown,de=R.onClick;R.onPress;var L=R.disabled,Ne=nt(R,yp);L!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var Re=b.current,Ge=Re.props,Ve=Re.state,Ct=np(q,J,Ge.items,"Pass either item or index to getItemProps!"),Mt=Ct[0],Ue=Ct[1],ft=Ge.isItemDisabled(Mt,Ue),Kt="onClick",Ot=de,We=function(){$.isTouchEnd||Ue===Ve.highlightedIndex||(j.current=!1,u({type:os,index:Ue,disabled:ft}))},Ze=function(){u({type:Kr,index:Ue})},je=function(en){return en.preventDefault()};return ne((D={},D[z]=Et(W,function(Te){Te&&(g.current[I.getItemId(Ue)]=Te)}),D["aria-disabled"]=ft,D["aria-selected"]=Ue===Ve.highlightedIndex,D.id=I.getItemId(Ue),D.role="option",D),!ft&&(P={},P[Kt]=we(Ot,Ze),P),{onMouseMove:we(oe,We),onMouseDown:we(A,je)},Ne)},[u,I,b,$,j]),te=y.useCallback(function(k){var D,P=k===void 0?{}:k,R=P.onClick;P.onPress;var q=P.refKey,J=q===void 0?"ref":q,U=P.ref,z=nt(P,vp),W=b.current.state,oe=function(){u({type:is})};return ne((D={},D[J]=Et(U,function(A){w.current=A}),D["aria-controls"]=I.menuId,D["aria-expanded"]=W.isOpen,D.id=I.toggleButtonId,D.tabIndex=-1,D),!z.disabled&&ne({},{onClick:we(R,oe)}),z)},[u,b,I]),Q=y.useCallback(function(k,D){var P,R=k===void 0?{}:k,q=R.onKeyDown,J=R.onChange,U=R.onInput,z=R.onBlur;R.onChangeText;var W=R.onClick,oe=R.refKey,A=oe===void 0?"ref":oe,de=R.ref,L=nt(R,Ip),Ne=D===void 0?{}:D,Re=Ne.suppressRefError,Ge=Re===void 0?!1:Re;F("getInputProps",Ge,A,x);var Ve=b.current.state,Ct=function(je){var Te=cr(je);Te&&V[Te]&&V[Te](je)},Mt=function(je){u({type:Fr,inputValue:je.target.value})},Ue=function(je){if(i!=null&&i.document&&Ve.isOpen&&!$.isMouseDown){var Te=je.relatedTarget===null&&i.document.activeElement!==i.document.body;u({type:On,selectItem:!Te})}},ft=function(){u({type:Mr})},Kt="onChange",Ot={};if(!L.disabled){var We;Ot=(We={},We[Kt]=we(J,U,Mt),We.onKeyDown=we(q,Ct),We.onBlur=we(z,Ue),We.onClick=we(W,ft),We)}return ne((P={},P[A]=Et(de,function(Ze){x.current=Ze}),P["aria-activedescendant"]=Ve.isOpen&&Ve.highlightedIndex>-1?I.getItemId(Ve.highlightedIndex):"",P["aria-autocomplete"]="list",P["aria-controls"]=I.menuId,P["aria-expanded"]=Ve.isOpen,P["aria-labelledby"]=L&&L["aria-label"]?void 0:I.labelId,P.autoComplete="off",P.id=I.inputId,P.role="combobox",P.value=Ve.inputValue,P),Ot,L)},[u,I,i,V,b,$,F]),ue=y.useCallback(function(){u({type:ss})},[u]),le=y.useCallback(function(){u({type:cs})},[u]),re=y.useCallback(function(){u({type:as})},[u]),Oe=y.useCallback(function(k){u({type:us,highlightedIndex:k})},[u]),Ee=y.useCallback(function(k){u({type:Lr,selectedItem:k})},[u]),N=y.useCallback(function(k){u({type:ls,inputValue:k})},[u]),K=y.useCallback(function(){u({type:ds})},[u]);return{getItemProps:G,getLabelProps:B,getMenuProps:Z,getInputProps:Q,getToggleButtonProps:te,toggleMenu:ue,openMenu:re,closeMenu:le,setHighlightedIndex:Oe,setInputValue:N,selectItem:Ee,reset:K,highlightedIndex:p,isOpen:d,selectedItem:h,inputValue:v}}wn.stateReducer,wn.itemToKey,wn.environment,T.array,T.array,T.array,T.func,T.number,T.number,T.number,T.func,T.func,T.string,T.string;qt.itemToKey,qt.stateReducer,qt.environment;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;const wp="_comboboxContainer_12y8e_1",xp="_label_12y8e_8",_p="_inputContainer_12y8e_12",bp="_input_12y8e_12",Cp="_toggleButton_12y8e_25",Op="_menu_12y8e_30",Sp="_menuItem_12y8e_43",Ep="_highlighted_12y8e_50",Np="_selected_12y8e_54",Rp="_hidden_12y8e_58",tt={comboboxContainer:wp,label:xp,inputContainer:_p,input:bp,toggleButton:Cp,menu:Op,menuItem:Sp,highlighted:Ep,selected:Np,hidden:Rp};function Tp(e){const t=e.toLowerCase();return function(o){return!e||o.label.toLowerCase().includes(t)||o.value.toLowerCase().includes(t)}}function Ap({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:o}){const[i,r]=y.useState(e),s=f=>{r(e.filter(Tp(f)))},{isOpen:c,getToggleButtonProps:u,getMenuProps:d,getInputProps:p,highlightedIndex:h,getItemProps:v}=Hr({items:i,selectedItem:t?e.find(f=>f.value===t):null,itemToString:f=>(f==null?void 0:f.label)||"",onInputValueChange:({inputValue:f})=>s(f),onSelectedItemChange:({selectedItem:f})=>n(f)});return a.jsxs("div",{children:[a.jsx("div",{className:tt.comboboxContainer,children:a.jsxs("div",{className:tt.inputContainer,children:[a.jsx("input",{placeholder:o,className:tt.input,...p()}),a.jsx("button",{"aria-label":"toggle menu",className:tt.toggleButton,type:"button",...u(),children:c?a.jsx(a.Fragment,{children:"↑"}):a.jsx(a.Fragment,{children:"↓"})})]})}),a.jsx("ul",{className:`${tt.menu} ${c&&e.length?"":tt.hidden}`,...d(),children:c&&i.map((f,g)=>a.jsx("li",{className:`${tt.menuItem} ${h===g?tt.highlighted:""} ${t===(f==null?void 0:f.value)?tt.selected:""}`,...v({item:f,index:g}),children:a.jsx("span",{children:f.label})},f.id))})]})}const hs=y.createContext(null);function ms(){const e=y.useContext(hs);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const gs=y.createContext(()=>{});function jp(){const e=y.useContext(gs);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var ys=Symbol.for("immer-nothing"),$o=Symbol.for("immer-draftable"),ke=Symbol.for("immer-state"),Pp=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 Ae(e,...t){if(process.env.NODE_ENV!=="production"){const n=Pp[e],o=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var At=Object.getPrototypeOf;function jt(e){return!!e&&!!e[ke]}function _t(e){var t;return e?vs(e)||Array.isArray(e)||!!e[$o]||!!((t=e.constructor)!=null&&t[$o])||kn(e)||Fn(e):!1}var Dp=Object.prototype.constructor.toString();function vs(e){if(!e||typeof e!="object")return!1;const t=At(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Dp}function Sn(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){const t=e[ke];return t?t.type_:Array.isArray(e)?1:kn(e)?2:Fn(e)?3:0}function dr(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Is(e,t,n){const o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function kp(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kn(e){return e instanceof Map}function Fn(e){return e instanceof Set}function It(e){return e.copy_||e.base_}function pr(e,t){if(kn(e))return new Map(e);if(Fn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=vs(e);if(t===!0||t==="class_only"&&!n){const o=Object.getOwnPropertyDescriptors(e);delete o[ke];let i=Reflect.ownKeys(o);for(let r=0;r<i.length;r++){const s=i[r],c=o[s];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(o[s]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[s]})}return Object.create(At(e),o)}else{const o=At(e);if(o!==null&&n)return{...e};const i=Object.create(o);return Object.assign(i,e)}}function Vr(e,t=!1){return Mn(e)||jt(e)||!_t(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Fp),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Vr(o,!0))),e}function Fp(){Ae(2)}function Mn(e){return Object.isFrozen(e)}var Mp={};function bt(e){const t=Mp[e];return t||Ae(0,e),t}var Xt;function ws(){return Xt}function Kp(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ho(e,t){t&&(bt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fr(e){hr(e),e.drafts_.forEach(Lp),e.drafts_=null}function hr(e){e===Xt&&(Xt=e.parent_)}function Vo(e){return Xt=Kp(Xt,e)}function Lp(e){const t=e[ke];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Uo(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ke].modified_&&(fr(t),Ae(4)),_t(e)&&(e=En(t,e),t.parent_||Nn(t,e)),t.patches_&&bt("Patches").generateReplacementPatches_(n[ke].base_,e,t.patches_,t.inversePatches_)):e=En(t,n,[]),fr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ys?e:void 0}function En(e,t,n){if(Mn(t))return t;const o=t[ke];if(!o)return Sn(t,(i,r)=>Bo(e,o,t,i,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return Nn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const i=o.copy_;let r=i,s=!1;o.type_===3&&(r=new Set(i),i.clear(),s=!0),Sn(r,(c,u)=>Bo(e,o,i,c,u,n,s)),Nn(e,i,!1),n&&e.patches_&&bt("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Bo(e,t,n,o,i,r,s){if(process.env.NODE_ENV!=="production"&&i===n&&Ae(5),jt(i)){const c=r&&t&&t.type_!==3&&!dr(t.assigned_,o)?r.concat(o):void 0,u=En(e,i,c);if(Is(n,o,u),jt(u))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(_t(i)&&!Mn(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;En(e,i),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Nn(e,i)}}function Nn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Vr(t,n)}function $p(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:ws(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=Ur;n&&(i=[o],r=Yt);const{revoke:s,proxy:c}=Proxy.revocable(i,r);return o.draft_=c,o.revoke_=s,c}var Ur={get(e,t){if(t===ke)return e;const n=It(e);if(!dr(n,t))return Hp(e,n,t);const o=n[t];return e.finalized_||!_t(o)?o:o===tr(e.base_,t)?(nr(e),e.copy_[t]=gr(o,e)):o},has(e,t){return t in It(e)},ownKeys(e){return Reflect.ownKeys(It(e))},set(e,t,n){const o=xs(It(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const i=tr(It(e),t),r=i==null?void 0:i[ke];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(kp(n,i)&&(n!==void 0||dr(e.base_,t)))return!0;nr(e),mr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return tr(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,nr(e),mr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=It(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){Ae(11)},getPrototypeOf(e){return At(e.base_)},setPrototypeOf(){Ae(12)}},Yt={};Sn(Ur,(e,t)=>{Yt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Yt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ae(13),Yt.set.call(this,e,t,void 0)};Yt.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ae(14),Ur.set.call(this,e[0],t,n,e[0])};function tr(e,t){const n=e[ke];return(n?It(n):e)[t]}function Hp(e,t,n){var i;const o=xs(t,n);return o?"value"in o?o.value:(i=o.get)==null?void 0:i.call(e.draft_):void 0}function xs(e,t){if(!(t in e))return;let n=At(e);for(;n;){const o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=At(n)}}function mr(e){e.modified_||(e.modified_=!0,e.parent_&&mr(e.parent_))}function nr(e){e.copy_||(e.copy_=pr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Vp=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){const r=n;n=t;const s=this;return function(u=r,...d){return s.produce(u,p=>n.call(this,p,...d))}}typeof n!="function"&&Ae(6),o!==void 0&&typeof o!="function"&&Ae(7);let i;if(_t(t)){const r=Vo(this),s=gr(t,void 0);let c=!0;try{i=n(s),c=!1}finally{c?fr(r):hr(r)}return Ho(r,o),Uo(i,r)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===ys&&(i=void 0),this.autoFreeze_&&Vr(i,!0),o){const r=[],s=[];bt("Patches").generateReplacementPatches_(t,i,r,s),o(r,s)}return i}else Ae(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...c)=>this.produceWithPatches(s,u=>t(u,...c));let o,i;return[this.produce(t,n,(s,c)=>{o=s,i=c}),o,i]},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){_t(e)||Ae(8),jt(e)&&(e=Up(e));const t=Vo(this),n=gr(e,void 0);return n[ke].isManual_=!0,hr(t),n}finishDraft(e,t){const n=e&&e[ke];(!n||!n.isManual_)&&Ae(9);const{scope_:o}=n;return Ho(o,t),Uo(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const o=bt("Patches").applyPatches_;return jt(e)?o(e,t):this.produce(e,i=>o(i,t))}};function gr(e,t){const n=kn(e)?bt("MapSet").proxyMap_(e,t):Fn(e)?bt("MapSet").proxySet_(e,t):$p(e,t);return(t?t.scope_:ws()).drafts_.push(n),n}function Up(e){return jt(e)||Ae(10,e),_s(e)}function _s(e){if(!_t(e)||Mn(e))return e;const t=e[ke];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=pr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=pr(e,!0);return Sn(n,(o,i)=>{Is(n,o,_s(i))}),t&&(t.finalized_=!1),n}var Fe=new Vp,Bt=Fe.produce;Fe.produceWithPatches.bind(Fe);Fe.setAutoFreeze.bind(Fe);Fe.setUseStrictShallowCopy.bind(Fe);Fe.applyPatches.bind(Fe);Fe.createDraft.bind(Fe);Fe.finishDraft.bind(Fe);const bs=y.createContext(void 0),Bp={};function Br(){const e=y.useContext(bs);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function qp({children:e}){const{installation:t}=Ye(),{hydratedRevision:n,loading:o}=Zt(),[i,r]=y.useState(Bp),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!o&&s&&!(Object.entries(i).length>0)&&rd(n,s,r)},[n,o,s,i]);const c=y.useCallback((f,g)=>{r(x=>Bt(x,w=>{w[f]=Bt(w[f],g)}))},[r]),u=y.useCallback((f,g)=>{r(x=>Bt(x,w=>{w[f]=g}))},[r]),d=y.useCallback(()=>{r(Bt(f=>{const g=f.other.write;g&&(g.isWriteModified=!1)}))},[r]),p=y.useCallback(f=>{r(Bt(g=>{var w;const x=(w=g[f])==null?void 0:w.read;x&&(x.isOptionalFieldsModified=!1,x.isRequiredMapFieldsModified=!1)}))},[r]),h=y.useCallback(f=>{f===xt?d():p(f)},[p,d]),v=y.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:r,setConfigureState:c,resetConfigureState:u,resetPendingConfigurationState:h}),[i,u,h,c]);return a.jsx(bs.Provider,{value:v,children:e})}const pt=()=>{const{appName:e}=Ie(),{objectConfigurationsState:t,setConfigureState:n}=Br(),{selectedObjectName:o}=ms(),i=Ci(o||"",t);return{appName:e,configureState:i,setConfigureState:n,selectedObjectName:o}};function Wp(e,t,n){var i;const o=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(o[t]=n,e!=null&&e.read){const r=e.read.savedConfig.requiredMapFields,c=!_r(r,o);e.read.isRequiredMapFieldsModified=c}}function Cs(e,t,n,o){t(e,i=>Wp(i,n,o))}function Jp({field:e,onSelectChange:t,allFields:n}){var f;const{configureState:o,selectedObjectName:i,setConfigureState:r}=pt(),[s,c]=y.useState(!0),u=(f=o==null?void 0:o.read)==null?void 0:f.selectedFieldMappings,d=u==null?void 0:u[e.mapToName];y.useEffect(()=>{e._default&&!d&&i&&o&&Cs(i,r,e.mapToName,e._default),c(!1)},[e,r,i,d,o]);const p=y.useMemo(()=>n==null?void 0:n.map(g=>a.jsx("option",{value:g.fieldName,children:g.displayName},g.fieldName)),[n]),h=y.useMemo(()=>n.map(g=>({id:g.fieldName,label:g.displayName,value:g.fieldName})),[n]),v=ve?a.jsx(Ap,{items:h,selectedValue:d||null,onSelectedItemChange:g=>{t({target:{name:e.mapToName,value:g==null?void 0:g.value}})},placeholder:"Please select one"}):a.jsx(S.Select,{name:e.mapToName,variant:"flushed",value:d||void 0,onChange:t,placeholder:d?void 0:"Please select one",disabled:s,children:p});return a.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[a.jsx("h3",{style:{fontWeight:500},children:e.mapToDisplayName}),a.jsx("p",{style:{paddingBottom:"1rem"},children:e==null?void 0:e.prompt}),v]},e.mapToName)}const zp="_divider_j6suu_1",qo={divider:zp};function qr({className:e,style:t}){return ve?a.jsx("hr",{className:e?`${qo.divider} ${e}`:qo.divider,style:t}):a.jsx(S.Divider,{className:e,style:t})}const Xp=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-text-secondary").trim()||"#737373";function Ft({string:e}){return a.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"2rem",paddingBottom:"1rem"},children:[a.jsx("h3",{style:{color:Xp,fontSize:"1rem",fontWeight:"500"},children:e}),a.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:a.jsx(qr,{style:{marginLeft:"1rem"}})})]})}function Yp(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=pt(),{isError:o,removeError:i}=dt(),r=c=>{const{value:u,name:d}=c.target;u&&(e&&Cs(e,n,d,u),o(me.MAPPING,d)&&i(me.MAPPING,d))},s=y.useMemo(()=>{var c,u;return((u=(c=t==null?void 0:t.read)==null?void 0:c.requiredMapFields)==null?void 0:u.filter(Xe))||[]},[t]);return s.length?a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:"Map the following fields (required)"}),a.jsx("div",{style:{display:"flex",gap:"2rem",flexDirection:"column"},children:s.map(c=>{var u;return a.jsxs(S.FormControl,{isInvalid:o(me.MAPPING,c.mapToName),children:[a.jsx(Jp,{allFields:((u=t.read)==null?void 0:u.allFields)||[],field:c,onSelectChange:r}),a.jsx(S.FormErrorMessage,{children:" * required"})]},c.mapToName)})})]}):null}function Gp(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Os(...e){return t=>e.forEach(n=>Gp(n,t))}function Ss(...e){return X.useCallback(Os(...e),e)}function Zp(e,t=[]){let n=[];function o(r,s){const c=X.createContext(s),u=n.length;n=[...n,s];const d=h=>{var O;const{scope:v,children:f,...g}=h,x=((O=v==null?void 0:v[e])==null?void 0:O[u])||c,w=X.useMemo(()=>g,Object.values(g));return a.jsx(x.Provider,{value:w,children:f})};d.displayName=r+"Provider";function p(h,v){var x;const f=((x=v==null?void 0:v[e])==null?void 0:x[u])||c,g=X.useContext(f);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${r}\``)}return[d,p]}const i=()=>{const r=n.map(s=>X.createContext(s));return function(c){const u=(c==null?void 0:c[e])||r;return X.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return i.scopeName=e,[o,Qp(i,...t)]}function Qp(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(r){const s=o.reduce((c,{useScope:u,scopeName:d})=>{const h=u(r)[`__scope${d}`];return{...c,...h}},{});return X.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function Es(e){const t=X.useRef(e);return X.useEffect(()=>{t.current=e}),X.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function ef({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,i]=tf({defaultProp:t,onChange:n}),r=e!==void 0,s=r?e:o,c=Es(n),u=X.useCallback(d=>{if(r){const h=typeof d=="function"?d(e):d;h!==e&&c(h)}else i(d)},[r,e,i,c]);return[s,u]}function tf({defaultProp:e,onChange:t}){const n=X.useState(e),[o]=n,i=X.useRef(o),r=Es(t);return X.useEffect(()=>{i.current!==o&&(r(o),i.current=o)},[o,i,r]),n}function nf(e){const t=X.useRef({value:e,previous:e});return X.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var yr=globalThis!=null&&globalThis.document?X.useLayoutEffect:()=>{};function rf(e){const[t,n]=X.useState(void 0);return yr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const r=i[0];let s,c;if("borderBoxSize"in r){const u=r.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,c=d.blockSize}else s=e.offsetWidth,c=e.offsetHeight;n({width:s,height:c})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function of(e,t){return X.useReducer((n,o)=>t[n][o]??n,e)}var Ns=e=>{const{present:t,children:n}=e,o=sf(t),i=typeof n=="function"?n({present:o.isPresent}):X.Children.only(n),r=Ss(o.ref,af(i));return typeof n=="function"||o.isPresent?X.cloneElement(i,{ref:r}):null};Ns.displayName="Presence";function sf(e){const[t,n]=X.useState(),o=X.useRef({}),i=X.useRef(e),r=X.useRef("none"),s=e?"mounted":"unmounted",[c,u]=of(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return X.useEffect(()=>{const d=mn(o.current);r.current=c==="mounted"?d:"none"},[c]),yr(()=>{const d=o.current,p=i.current;if(p!==e){const v=r.current,f=mn(d);e?u("MOUNT"):f==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(p&&v!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),yr(()=>{if(t){let d;const p=t.ownerDocument.defaultView??window,h=f=>{const x=mn(o.current).includes(f.animationName);if(f.target===t&&x&&(u("ANIMATION_END"),!i.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",d=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},v=f=>{f.target===t&&(r.current=mn(o.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{p.clearTimeout(d),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:X.useCallback(d=>{d&&(o.current=getComputedStyle(d)),n(d)},[])}}function mn(e){return(e==null?void 0:e.animationName)||"none"}function af(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Rs=X.forwardRef((e,t)=>{const{children:n,...o}=e,i=X.Children.toArray(n),r=i.find(uf);if(r){const s=r.props.children,c=i.map(u=>u===r?X.Children.count(s)>1?X.Children.only(null):X.isValidElement(s)?s.props.children:null:u);return a.jsx(vr,{...o,ref:t,children:X.isValidElement(s)?X.cloneElement(s,void 0,c):null})}return a.jsx(vr,{...o,ref:t,children:n})});Rs.displayName="Slot";var vr=X.forwardRef((e,t)=>{const{children:n,...o}=e;if(X.isValidElement(n)){const i=df(n);return X.cloneElement(n,{...lf(o,n.props),ref:t?Os(t,i):i})}return X.Children.count(n)>1?X.Children.only(null):null});vr.displayName="SlotClone";var cf=({children:e})=>a.jsx(a.Fragment,{children:e});function uf(e){return X.isValidElement(e)&&e.type===cf}function lf(e,t){const n={...t};for(const o in t){const i=e[o],r=t[o];/^on[A-Z]/.test(o)?i&&r?n[o]=(...c)=>{r(...c),i(...c)}:i&&(n[o]=i):o==="style"?n[o]={...i,...r}:o==="className"&&(n[o]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}function df(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ts=pf.reduce((e,t)=>{const n=X.forwardRef((o,i)=>{const{asChild:r,...s}=o,c=r?Rs:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...s,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wr="Checkbox",[ff,pm]=Zp(Wr),[hf,mf]=ff(Wr),As=X.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:s,disabled:c,value:u="on",onCheckedChange:d,form:p,...h}=e,[v,f]=X.useState(null),g=Ss(t,b=>f(b)),x=X.useRef(!1),w=v?p||!!v.closest("form"):!0,[O=!1,I]=ef({prop:i,defaultProp:r,onChange:d}),C=X.useRef(O);return X.useEffect(()=>{const b=v==null?void 0:v.form;if(b){const m=()=>I(C.current);return b.addEventListener("reset",m),()=>b.removeEventListener("reset",m)}},[v,I]),a.jsxs(hf,{scope:n,state:O,disabled:c,children:[a.jsx(Ts.button,{type:"button",role:"checkbox","aria-checked":lt(O)?"mixed":O,"aria-required":s,"data-state":Ds(O),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:g,onKeyDown:Wo(e.onKeyDown,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Wo(e.onClick,b=>{I(m=>lt(m)?!0:!m),w&&(x.current=b.isPropagationStopped(),x.current||b.stopPropagation())})}),w&&a.jsx(gf,{control:v,bubbles:!x.current,name:o,value:u,checked:O,required:s,disabled:c,form:p,style:{transform:"translateX(-100%)"},defaultChecked:lt(r)?!1:r})]})});As.displayName=Wr;var js="CheckboxIndicator",Ps=X.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:o,...i}=e,r=mf(js,n);return a.jsx(Ns,{present:o||lt(r.state)||r.state===!0,children:a.jsx(Ts.span,{"data-state":Ds(r.state),"data-disabled":r.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});Ps.displayName=js;var gf=e=>{const{control:t,checked:n,bubbles:o=!0,defaultChecked:i,...r}=e,s=X.useRef(null),c=nf(n),u=rf(t);X.useEffect(()=>{const p=s.current,h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==n&&f){const g=new Event("click",{bubbles:o});p.indeterminate=lt(n),f.call(p,lt(n)?!1:n),p.dispatchEvent(g)}},[c,n,o]);const d=X.useRef(lt(n)?!1:n);return a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??d.current,...r,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function lt(e){return e==="indeterminate"}function Ds(e){return lt(e)?"indeterminate":e?"checked":"unchecked"}var ks=As,Fs=Ps;function Ms(e,t){if(e==null)return{};var n={},o=Object.keys(e),i,r;for(r=0;r<o.length;r++)i=o[r],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var yf=["color"],Ks=y.forwardRef(function(e,t){var n=e.color,o=n===void 0?"currentColor":n,i=Ms(e,yf);return y.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),y.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:o,fillRule:"evenodd",clipRule:"evenodd"}))}),vf=["color"],If=y.forwardRef(function(e,t){var n=e.color,o=n===void 0?"currentColor":n,i=Ms(e,vf);return y.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),y.createElement("path",{d:"M2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5Z",fill:o,fillRule:"evenodd",clipRule:"evenodd"}))});const wf="_checkboxGroupContainer_j54z7_1",xf="_stack_j54z7_6",_f="_selectAllContainer_j54z7_11",bf="_fieldContainer_j54z7_18",Cf="_checkbox_j54z7_1",Pt={checkboxGroupContainer:wf,stack:xf,selectAllContainer:_f,fieldContainer:bf,checkbox:Cf};function Ls({id:e,isChecked:t,label:n,onCheckedChange:o}){return a.jsxs("div",{className:Pt.fieldContainer,children:[a.jsx(ks,{className:Pt.checkbox,id:e,onCheckedChange:o,checked:t,children:a.jsx(Fs,{children:a.jsx(Ks,{})})}),a.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function $s({id:e,isChecked:t,label:n,onCheckedChange:o,isIndeterminate:i}){return a.jsxs("div",{className:Pt.selectAllContainer,children:[a.jsx(ks,{className:Pt.checkbox,id:e,onCheckedChange:o,children:a.jsxs(Fs,{children:[i&&a.jsx(If,{}),t===!0&&a.jsx(Ks,{})]})}),a.jsx("label",{htmlFor:e,children:n})]})}function Hs({children:e}){return a.jsx("div",{className:Pt.checkboxGroupContainer,children:e})}function Vs({children:e}){return a.jsx("div",{className:Pt.stack,children:e})}function Of(e,t,n){var i,r;const o=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(o[t]=n,n||delete o[t],(r=e.read)!=null&&r.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,u=!_r(s,o);e.read.isOptionalFieldsModified=u}else console.warn("read.savedConfig.optionalFields is undefined")}function Rn(e,t,n,o){t(e,i=>Of(i,n,o))}function Sf(){var h,v;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:o}=pt(),i=(h=t==null?void 0:t.read)==null?void 0:h.selectedOptionalFields,r=(f,g)=>{f!=="indeterminate"&&o&&t&&Rn(o,n,g,f)},s=(v=t==null?void 0:t.read)==null?void 0:v.optionalFields,c=f=>{o&&s&&s.forEach(g=>{Xe(g)||Rn(o,n,g.fieldName,f)})},u=!!(s&&s.length>0),d=Object.keys(i||{}).length===(s==null?void 0:s.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${e} reads the following optional fields`}),a.jsxs(Hs,{children:[((s==null?void 0:s.length)||0)>=2&&a.jsx($s,{id:"select-all-fields",isChecked:d,label:"Select all",onCheckedChange:c,isIndeterminate:p}),a.jsx(Vs,{children:s.map(f=>Xe(f)?null:a.jsx(Ls,{id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),label:f.displayName,onCheckedChange:g=>r(g,f.fieldName)},f.fieldName))})]})]})}function Ef(){var h,v;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:o}=pt(),i=(h=t==null?void 0:t.read)==null?void 0:h.selectedOptionalFields,r=f=>{const{name:g,checked:x}=f.target;o&&t&&Rn(o,n,g,x)},s=(v=t==null?void 0:t.read)==null?void 0:v.optionalFields,c=f=>{const{checked:g}=f.target;o&&s&&s.forEach(x=>{Xe(x)||Rn(o,n,x.fieldName,g)})},u=!!(s&&s.length>0),d=Object.keys(i||{}).length===(s==null?void 0:s.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${e} reads the following optional fields`}),a.jsxs(S.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((s==null?void 0:s.length)||0)>=2&&a.jsx(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:c,isIndeterminate:p,isChecked:d,children:"Select all"})}),s.map(f=>Xe(f)?null:a.jsx(S.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:a.jsx(S.Checkbox,{name:f.fieldName,id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),onChange:r,children:a.jsx("p",{style:{overflowWrap:"anywhere"},children:f.displayName})})},f.fieldName))]})]})}function Nf(){return ve?a.jsx(Sf,{}):a.jsx(Ef,{})}const Rf=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge").trim()||"#e5e5e5",Tf=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge-text").trim()||"#404040",Af={color:Tf,backgroundColor:Rf,borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function jf({children:e,style:t,...n}){return a.jsx("span",{style:{...Af,...t},...n,children:e})}function Pf(){var o,i,r;const{configureState:e,selectedObjectName:t}=pt(),{appName:n}=Ie();return a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${n} reads the following ${t} fields`}),a.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:"2rem"},children:(i=(o=e==null?void 0:e.read)==null?void 0:o.requiredFields)!=null&&i.length?(r=e.read)==null?void 0:r.requiredFields.map(s=>Xe(s)?null:a.jsx(jf,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function Df(){return a.jsxs(a.Fragment,{children:[a.jsx(Pf,{}),a.jsx(Yp,{}),a.jsx(Nf,{})]})}function kf(e,t,n){var o,i,r;if(((o=e==null?void 0:e.write)==null?void 0:o.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const s=e.write.selectedNonConfigurableWriteFields;if(s[t]=n,n||delete s[t],(r=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&r.selectedNonConfigurableWriteFields){const c=e.write.savedConfig.selectedNonConfigurableWriteFields,d=!_r(c,s);e.write.isWriteModified=d}}}function Tn(e,t,n,o){t(e,i=>{kf(i,n,o)})}function Ff(){var h,v,f,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:o}=pt(),i=(h=n==null?void 0:n.write)==null?void 0:h.selectedNonConfigurableWriteFields,r=(v=n==null?void 0:n.write)==null?void 0:v.writeObjects,s=(x,w)=>{x!=="indeterminate"&&t&&n&&Tn(t,o,w,x)},c=x=>{var w,O;t&&n&&((O=(w=n==null?void 0:n.write)==null?void 0:w.writeObjects)==null||O.forEach(I=>{Tn(t,o,I.objectName,x)}))},u=!!r,d=Object.keys(i||{}).length===((g=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:g.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`Allow ${e} to write to these object`}),a.jsxs(Hs,{children:[((r==null?void 0:r.length)||0)>=2&&a.jsx($s,{id:"select-all-fields",onCheckedChange:c,isIndeterminate:p,isChecked:d,label:"Select all"}),a.jsx(Vs,{children:r.map(x=>a.jsx(Ls,{id:x.objectName,onCheckedChange:w=>s(w,x.objectName),isChecked:!!(i!=null&&i[x.objectName]),label:x.displayName},x.objectName))})]})]})}function Mf(){var h,v,f,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:o}=pt(),i=(h=n==null?void 0:n.write)==null?void 0:h.selectedNonConfigurableWriteFields,r=(v=n==null?void 0:n.write)==null?void 0:v.writeObjects,s=x=>{const{name:w,checked:O}=x.target;t&&n&&Tn(t,o,w,O)},c=x=>{var O,I;const{checked:w}=x.target;t&&n&&((I=(O=n==null?void 0:n.write)==null?void 0:O.writeObjects)==null||I.forEach(C=>{Tn(t,o,C.objectName,w)}))},u=!!r,d=Object.keys(i||{}).length===((g=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:g.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`Allow ${e} to write to these object`}),a.jsxs(S.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((r==null?void 0:r.length)||0)>=2&&a.jsx(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:c,isIndeterminate:p,isChecked:d,children:"Select all"})}),r.map(x=>a.jsx(S.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:x.objectName,id:x.objectName,onChange:s,isChecked:!!(i!=null&&i[x.objectName]),children:a.jsx("p",{style:{overflowWrap:"anywhere"},children:x.displayName})})},x.objectName))]})]})}function Kf(){return ve?a.jsx(Ff,{}):a.jsx(Mf,{})}function Lf(){const e=xe(),{projectId:t,appName:n}=Ie(),{integrationId:o,installation:i,resetInstallations:r,setIntegrationDeleted:s,onUninstallSuccess:c}=Ye(),[u,d]=y.useState(!1),p=!t||!o||!(i!=null&&i.id)||u,h=async()=>{if(!p){d(!0),console.warn("uninstalling installation",{projectId:t,integrationId:o,installationId:i.id});try{await fe().installationApi.deleteInstallation({projectIdOrName:t,integrationId:o,installationId:i.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation: ",i.id),c==null||c(i==null?void 0:i.id),r(),s()}catch(x){console.error("Error uninstalling installation."),Ce(x)}finally{d(!1)}}},v=u?"Uninstalling...":"Yes, uninstall",f=i!=null&&i.id?`Once you uninstall this integration, all your configuration will be lost, and "${n}" may stop working.`:"You've successfully uninstalled the integration.",g=ve?a.jsx(He,{type:"button",onClick:h,disabled:p,variant:"danger",children:v}):a.jsx(S.Button,{onClick:h,variant:"warning",isDisabled:p,children:v});return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[a.jsx("p",{children:f}),(i==null?void 0:i.id)&&g]})}const $f=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-neutral-100").trim()||"#f5f5f5",Hf=getComputedStyle(document.documentElement).getPropertyValue("--amp-shadows-sm").trim()||"0 1px 2px 0 rgba(0, 0, 0, 0.05)";function Us({onSave:e,onReset:t,isLoading:n,isCreateMode:o=!1,errorMsg:i}){var j,$,F;const{installation:r}=Ye(),{hydratedRevision:s,loading:c}=Zt(),{configureState:u,selectedObjectName:d}=pt(),p=r==null?void 0:r.config,h=p&&d&&!!gi(p,d)||!1,v=((j=u==null?void 0:u.read)==null?void 0:j.isOptionalFieldsModified)||(($=u==null?void 0:u.read)==null?void 0:$.isRequiredMapFieldsModified),f=(F=u==null?void 0:u.write)==null?void 0:F.isWriteModified,O=c||n||!u||!d||!(v||f||o||d!==xt&&!h),I=d===xt,C=d===Ni,b=ve?a.jsx(He,{type:"submit",disabled:O,children:o?"Install":"Save"}):a.jsx(S.Button,{type:"submit",variant:"primary",isDisabled:O,children:o?"Install":"Save"}),m=ve?a.jsx(He,{type:"button",onClick:t,disabled:O,variant:"ghost",children:"Reset"}):a.jsx(S.Button,{isDisabled:O,onClick:t,children:"Reset"});return n?a.jsx(qe,{}):a.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[a.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:"1rem",marginBottom:"2rem"},children:[b,m]}),a.jsxs(Dt,{style:{padding:"2rem",minHeight:"300px",backgroundColor:"white",borderColor:$f,boxShadow:Hf},children:[i&&a.jsx(Si,{children:typeof i=="string"?i:"Installation Failed."}),c&&a.jsx(qe,{}),s&&!C&&!I&&a.jsx(Df,{}),s&&!C&&I&&a.jsx(Kf,{}),!c&&C&&a.jsx(Lf,{})]})]})}const Bs=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,onInstallSuccess:i,onUpdateSuccess:r}=Ye(),{hydratedRevision:s,loading:c}=Zt(),{selectedObjectName:u}=ms(),{selectedConnection:d}=kt(),p=xe(),{projectId:h}=Ie(),{resetBoundary:v,setErrors:f,setError:g,getError:x}=dt(),{resetConfigureState:w,objectConfigurationsState:O,resetPendingConfigurationState:I}=Br(),C=Ci(u||"",O),{onNextIncompleteTab:b}=jp(),m=y.useCallback(()=>{v(me.INSTALLATION_MUTATION)},[v]),j=y.useCallback(F=>F?V=>{g(me.INSTALLATION_MUTATION,F,V)}:V=>{console.error("objectName is required to set installation error: ",V)},[g]),$=y.useCallback(F=>F?x(me.INSTALLATION_MUTATION,F):"",[x]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,hydratedRevision:s,loading:c,selectedObjectName:u,selectedConnection:d,apiKey:p,projectId:h,resetBoundary:v,setErrors:f,setMutateInstallationError:j,getMutateInstallationError:$,resetMutateInstallationErrorState:m,resetConfigureState:w,objectConfigurationsState:O,resetPendingConfigurationState:I,configureState:C,onInstallSuccess:i,onUpdateSuccess:r,onNextIncompleteTab:b}},Vf=void 0;function Uf(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,hydratedRevision:i,loading:r,selectedObjectName:s,selectedConnection:c,apiKey:u,projectId:d,resetBoundary:p,setErrors:h,setMutateInstallationError:v,getMutateInstallationError:f,resetMutateInstallationErrorState:g,resetConfigureState:x,objectConfigurationsState:w,resetPendingConfigurationState:O,configureState:I,onInstallSuccess:C,onNextIncompleteTab:b}=Bs(),[m,j]=y.useState(!1),$=s===xt,F=f(s),V=y.useCallback(()=>{p(me.MAPPING),i!=null&&i.content&&!r&&s&&xi(i,Vf,s,x)},[p,i,r,s,x]);y.useEffect(()=>{!I&&(i!=null&&i.content)&&!r&&V()},[I,w,i,r,V]);const B=()=>{g();const{requiredMapFields:te,selectedFieldMappings:Q}=(I==null?void 0:I.read)||{},{errorList:ue}=Ii(te,Q,h);ue.length>0||(s&&(c!=null&&c.id)&&u&&d&&e&&t&&n&&i?(j(!0),sd(d,e,t,n,c.id,s,u,i,I,v(s),o,C).finally(()=>{j(!1),O(s),b()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},Z=()=>{g(),s&&(c!=null&&c.id)&&u&&d&&e&&t&&n&&i?(j(!0),ud(d,e,t,n,c.id,u,i,I,v(s),o,C).finally(()=>{j(!1),O(s),b()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},G=te=>{te.preventDefault(),$?Z():B()};return a.jsx(Us,{errorMsg:F,isCreateMode:!0,isLoading:m,onSave:G,onReset:V})}function Bf({updateConfig:e,projectId:t,integrationId:n,installationId:o,apiKey:i,selectedObjectName:r,setInstallation:s,onUpdateSuccess:c,setError:u}){const d={projectIdOrName:t,installationId:o,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${r}`],installation:{config:e}}};return fe().installationApi.updateInstallation(d,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(p=>{s(p),c==null||c(p.id,p.config)}).catch(p=>{Ce(p,u)})}const qf=(e,t,n,o,i,r)=>{const s=_i(e),c=bi(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:o,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:c,backfill:r}}}}};return jn(i)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Wf=(e,t,n,o,i,r,s,c,u,d,p)=>{const h=qf(r,o||"",c,c.schedule,u,c.backfill);return h?Bf({updateConfig:h,projectId:e,integrationId:t,installationId:n,apiKey:i,selectedObjectName:o,setError:d,setInstallation:s,onUpdateSuccess:p}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Jf=(e,t)=>{const o={content:{write:{objects:Oi(e)}}};return jn(t)&&(o.content||(o.content={}),o.content.proxy={enabled:!0}),o},zf=(e,t,n,o,i,r,s,c,u)=>{const d=Jf(i,r);if(!d)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const p={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:d}}};return fe().installationApi.updateInstallation(p,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{Ce(h,s)})};function Xf({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:o,loading:i,selectedObjectName:r,apiKey:s,projectId:c,resetBoundary:u,setErrors:d,setMutateInstallationError:p,getMutateInstallationError:h,resetConfigureState:v,resetPendingConfigurationState:f,configureState:g,onUpdateSuccess:x,onNextIncompleteTab:w}=Bs(),[O,I]=y.useState(!1),C=r===xt,b=h(r),{config:m}=e,j=y.useCallback(()=>{u(me.MAPPING),o!=null&&o.content&&!i&&r&&xi(o,m,r,v)},[u,o,i,r,m,v]);y.useEffect(()=>{g||j()},[g,j]),y.useEffect(()=>{e&&j()},[e,j]);const $=y.useMemo(()=>{var G,te,Q;return(Q=(te=(G=o==null?void 0:o.content)==null?void 0:G.read)==null?void 0:te.objects)==null?void 0:Q.find(ue=>(ue==null?void 0:ue.objectName)===r)},[o,r]),F=()=>{const{requiredMapFields:Z,selectedFieldMappings:G}=(g==null?void 0:g.read)||{},{errorList:te}=Ii(Z,G,d);te.length>0||(o&&e&&r&&s&&c&&$?(I(!0),Wf(c,t.id,e.id,r,s,g,n,$,o,p(r),x).finally(()=>{I(!1),f(r),w()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},V=()=>{e&&r&&s&&c&&o?(I(!0),zf(c,t.id,e.id,s,g,o,p(r),n,x).finally(()=>{I(!1),f(r),w()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},B=Z=>{Z.preventDefault(),C?V():F()};return a.jsx(Us,{errorMsg:b,onSave:B,onReset:j,isLoading:O})}function Yf(){const{integrationObj:e,installation:t}=Ye();return e?t&&e?a.jsx(Xf,{installation:t,integrationObj:e}):a.jsx(Uf,{}):a.jsx(ot,{message:"We can't load the integration"})}function Gf(){return a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),a.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Jr({text:e,children:t}){return a.jsx(Gt,{children:a.jsxs(Dt,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},children:[a.jsx(Gf,{}),a.jsx("p",{children:e}),t]})})}const Zf=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Qf({projectId:e,integrationId:t,groupRef:n,consumerRef:o,connectionId:i,apiKey:r,hydratedRevision:s,setError:c,setInstallation:u,onInstallSuccess:d}){const p=Zf(s,o);return p?br({createConfig:p,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:r,setError:c,setInstallation:u,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function eh({provider:e}){const t=`You have successfully installed your ${it(e)} integration.`;return a.jsx(Jr,{text:t})}const th=e=>{const{read:t,write:n,proxy:o}=(e==null?void 0:e.content)??{};return!t&&!n&&(o==null?void 0:o.enabled)||!1};function nh({children:e,resetComponent:t}){var b;const{projectId:n}=Ie(),o=xe(),{hydratedRevision:i,loading:r}=Zt(),{integrationObj:s,installation:c,groupRef:u,consumerRef:d,setInstallation:p,onInstallSuccess:h,isIntegrationDeleted:v}=Ye(),{selectedConnection:f}=kt(),[g,x]=y.useState(!1),w=r||g,O=(b=i==null?void 0:i.content)==null?void 0:b.provider,I=th(i),C=m=>{console.error("Error when creating proxy installation:",m)};return y.useEffect(()=>{!w&&i&&I&&!c&&f&&o&&(s!=null&&s.id)&&(x(!0),Qf({apiKey:o,projectId:n,integrationId:s==null?void 0:s.id,groupRef:u,consumerRef:d,connectionId:f==null?void 0:f.id,hydratedRevision:i,setError:C,setInstallation:p,onInstallSuccess:h}).then(()=>{x(!1)}).catch(m=>{x(!1),console.error("Error when creating proxy installation:",m)}))},[i,I,c,f,o,n,s==null?void 0:s.id,u,d,p,w,h]),s?w?a.jsx(qe,{}):I&&O&&c?a.jsx(eh,{provider:O}):v?a.jsx(Jr,{text:"Integration successfully uninstalled.",children:ve&&a.jsx(He,{type:"button",onClick:t,style:{width:"100%"},children:"Reinstall Integration"})}):a.jsx("div",{children:e}):a.jsx(ot,{message:"We can't load the integration"})}function qs(){return a.jsxs("footer",{style:{backgroundColor:"#EFEFEF",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[a.jsx("p",{children:"Secured by"}),a.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:a.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}function Me({children:e}){return a.jsx(Gt,{children:a.jsxs(Dt,{children:[a.jsx("div",{style:{padding:"3rem 2rem"},children:e}),a.jsx(qs,{})]})})}function Qt({children:e}){return a.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function Ke({error:e}){return e?a.jsx(Si,{style:{marginTop:"2em"},children:e}):null}function zr({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,children:i,title:r}){if(!r&&!o)throw new Error("Either title or providerName is required");return a.jsxs(Me,{children:[a.jsx(Qt,{children:r||`Set up ${o} integration`}),a.jsx(Ke,{error:t}),i,a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const rh="_link_oo2kv_1",oh={link:rh};function Xr({href:e,className:t,style:n,label:o,children:i,newTab:r=!1}){return ve?a.jsx("a",{className:oh.link,style:n,href:e,"aria-label":o||void 0,target:r?"_blank":"_self",rel:r?"noopener noreferrer":void 0,children:i}):a.jsx(S.Link,{href:e,className:t,style:n,"aria-label":o||void 0,target:r?"_blank":"_self",rel:r?"noopener noreferrer":void 0,color:"#737373",children:i})}const ih=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-text-secondary").trim()||"#737373";function Kn({url:e,providerDisplayName:t,credentialName:n}){return a.jsxs("p",{style:{color:ih},children:[a.jsx(Xr,{href:e,newTab:!0,children:a.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const sh="_input_19woe_1",ah="_inputError_19woe_17",ch="_error_19woe_31",rr={input:sh,inputError:ah,error:ch};function uh({id:e,type:t,className:n,isError:o=!1,...i}){const r=o?zt(rr.inputError,rr.input):rr.input;return a.jsx("input",{id:e,type:t,className:zt(r,n),...i})}const lh="_textarea_1efhx_1",dh="_textareaError_1efhx_13",ph="_error_1efhx_27",or={textarea:lh,textareaError:dh,error:ph};function fh({className:e,isError:t=!1,...n}){const o=t?zt(or.textareaError,or.textarea):or.textarea;return a.jsx("textarea",{className:zt(e,o),...n})}const rt={Input:uh,Textarea:fh};function hh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var x;const[r,s]=y.useState(!1),c=()=>s(!r),[u,d]=y.useState(""),p=w=>d(w.currentTarget.value),h=u.length>0,v=i||!h,f=it(e,t),g=(x=t.apiKeyOpts)==null?void 0:x.docsURL;return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{my:"6",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${f} integration`})}),a.jsx(Ke,{error:o}),a.jsxs(S.Stack,{spacing:4,children:[g&&a.jsx(Kn,{url:g,providerDisplayName:f,credentialName:"API key"}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:p,pr:"4.5rem",type:r?"text":"password",placeholder:"API Key"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:c,children:r?"Hide":"Show"})})]})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:v,width:"100%",type:"submit",onClick:()=>{n({apiKey:u})},children:"Next"})]})})}function mh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var x;const[r,s]=y.useState(!1),c=()=>s(w=>!w),[u,d]=y.useState(""),p=w=>d(w.currentTarget.value),h=u.length>0,v=i||!h,f=it(e,t),g=(x=t.apiKeyOpts)==null?void 0:x.docsURL;return a.jsx(zr,{providerName:f,handleSubmit:()=>{n({apiKey:u})},error:o,isButtonDisabled:v,children:a.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[g&&a.jsx(Kn,{url:g,providerDisplayName:f,credentialName:"API key"}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"password",name:"password",type:r?"text":"password",placeholder:"Password",onChange:w=>p(w)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,children:r?"Hide":"Show"})]})]})})}function gh({...e}){return ve?a.jsx(mh,{...e}):a.jsx(hh,{...e})}function yh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,children:s,selectedConnection:c,setSelectedConnection:u}){const d=Ie(),[p,h]=y.useState(!1),[v,f]=y.useState(null),g=xe();y.useEffect(()=>{if(e&&fe&&p&&v!=null){const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,apiKey:v};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:w},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})}},[g,e,p,o,n,r,i,d,u,v]);const x=w=>{f(w.apiKey),h(!0)};return c===null?a.jsx(gh,{provider:e,providerInfo:t,handleSubmit:x,error:null}):s}function vh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var I;const[r,s]=y.useState(!1),c=()=>s(!r),[u,d]=y.useState(""),[p,h]=y.useState(""),v=C=>d(C.currentTarget.value),f=C=>h(C.currentTarget.value),g=it(e,t),x=(I=t.basicOpts)==null?void 0:I.docsURL,w=u.length>0,O=i||!w;return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${g} integration`})}),a.jsx(Ke,{error:o}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[x&&a.jsx(Kn,{url:x,providerDisplayName:g,credentialName:"credentials"}),a.jsx(S.Input,{placeholder:"Username",onChange:v}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:f,pr:"4.5rem",type:r?"text":"password",placeholder:"Password"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:c,children:r?"Hide":"Show"})})]})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:O,width:"100%",type:"submit",onClick:()=>{n({user:u,pass:p})},children:"Next"})]})})}function Ih({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var O;const[r,s]=y.useState(!1),c=()=>s(I=>!I),[u,d]=y.useState({username:"",password:""}),{username:p,password:h}=u,v=it(e,t),f=(O=t.basicOpts)==null?void 0:O.docsURL,g=p.length>0,x=i||!g,w=I=>{const{name:C,value:b}=I.currentTarget;d(m=>({...m,[C]:b}))};return a.jsx(zr,{providerName:v,handleSubmit:()=>{n({user:p,pass:h})},error:o,isButtonDisabled:x,children:a.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[f&&a.jsx(Kn,{url:f,providerDisplayName:v,credentialName:"credentials"}),a.jsx(rt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:I=>w(I)}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"password",name:"password",type:r?"text":"password",placeholder:"Password",onChange:I=>w(I)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,children:r?"Hide":"Show"})]})]})})}function wh({...e}){return ve?a.jsx(Ih,{...e}):a.jsx(vh,{...e})}function xh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,children:s,selectedConnection:c,setSelectedConnection:u}){const d=Ie(),[p,h]=y.useState(!1),[v,f]=y.useState(null),g=xe();y.useEffect(()=>{if(e&&fe&&p&&v!=null){const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,basicAuth:{username:v.user,password:v.pass}};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:w},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})}},[g,e,p,o,n,r,i,d,v,u]);const x=w=>{const{user:O,pass:I}=w;f({user:O,pass:I}),h(!0)};return c===null?a.jsx(wh,{provider:e,providerInfo:t,handleSubmit:x,error:null}):s}function _h({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function bh({...e}){return ve?a.jsx(zr,{...e}):a.jsx(_h,{...e})}function Ch({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:r,selectedConnection:s,setSelectedConnection:c,providerName:u}){const d=Ie(),p=xe(),[h,v]=y.useState(!1);y.useEffect(()=>{if(e&&fe&&h){const g={groupName:i,groupRef:o,consumerName:n,consumerRef:t,provider:e};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:g},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),Ce(x)})}},[p,e,h,n,t,i,o,c,d]);const f=()=>{v(!0)};return s===null?a.jsx(bh,{handleSubmit:f,error:null,providerName:u}):r}const Ws=async(e,t,n,o,i,r,s,c)=>{var d;const u=await fe().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":o??""}});if(!u)throw new Error(`Provider ${i} not found`);if(u.authType==="oauth2"&&((d=u.oauth2Opts)==null?void 0:d.grantType)==="authorizationCode"){const h=(await fe().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":o??""}})).find(x=>x.provider===i),v=it(i,u);if(!h)throw new Error(`You must first set up a ${v} Provider App using the Ampersand Console.`);const f={connectOAuthParams:{providerWorkspaceRef:r,projectId:e,groupRef:n,groupName:c,consumerRef:t,consumerName:s,providerAppId:h.id,provider:i}};return await fe().oAuthApi.oauthConnect(f)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},Jo=600,zo=600,Oh="AUTHORIZATION_SUCCEEDED",Sh="AUTHORIZATION_FAILED";function Eh(e,t,n){return y.useCallback(async o=>{const i=await fe().connectionApi.getConnection({projectIdOrName:e,connectionId:o},{headers:{"X-Api-Key":t??""}});n(i)},[e,t,n])}function Nh(e,t,n,o){return y.useCallback(()=>{if(!o)return;const i=window.screenX+(window.outerWidth-Jo)/2,r=window.screenY+(window.outerHeight-zo)/2.5,s=`width=${Jo},height=${zo},left=${i},top=${r}`,c=window.open(o,e,s);t(c),window.addEventListener("message",n,!1)},[o,e,t,n])}function Rh(e,t){return y.useCallback(n=>{var o,i;if(n.origin===Tl){if(n.data.eventType===Oh){const r=(o=n.data.data)==null?void 0:o.connection;r?e(r):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===Sh&&(console.error("OAuth failed: ",{event:n}),t==null||t(((i=n==null?void 0:n.data)==null?void 0:i.message)??"OAuth failed. Please try again."))}},[t,e])}function Js({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:o,error:i}){const r=xe(),{projectId:s}=Ie(),[c,u]=y.useState(null),[d,p]=y.useState(null),{setSelectedConnection:h}=kt(),v=Rh(u,o),f=Nh(n,p,v,t),g=Eh(s,r,h);y.useEffect(()=>{t&&!d&&f()},[t,d,f,v,n]),y.useEffect(()=>{c&&g(c).then(()=>{d==null||d.close()}).catch(w=>{console.error("Error refreshing connection: ",w),o==null||o(w.message??"Unexpected error: not able to refresh connection")})},[c,r,h,g,d,o]);const x=d&&setInterval(()=>{(d!=null&&d.closed||!d)&&x&&(clearInterval(x),window.removeEventListener("message",v),p(null),!c&&!i?(console.error("OAuth failed. Please try again."),o==null||o("OAuth failed. Please try again.")):c&&o&&(o==null||o(null)))},500);return a.jsx("div",{children:e})}function Th({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Ah({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return ve?a.jsxs(Me,{children:[a.jsx(Qt,{children:`Set up ${o} integration`}),a.jsx(Ke,{error:t}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]}):a.jsx(Th,{handleSubmit:e,error:t,isButtonDisabled:n,providerName:o})}function jh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,providerName:r}){const{projectId:s}=Ie(),c=xe(),[u,d]=y.useState(null),[p,h]=y.useState(null),v=async()=>{h(null);try{const g=await Ws(s,t,o,c,e,void 0,n,i);d(g)}catch(g){console.error("Could not fetch OAuth popup URL."),Ce(g),h(g.message??"Unexpected error")}},f=y.useCallback(g=>{h(g),d(null)},[]);return a.jsx(Js,{windowTitle:`Connect to ${r}`,oauthUrl:u,onError:f,children:a.jsx(Ah,{handleSubmit:v,error:p,providerName:r})})}const Ph=S.createIcon({displayName:"ExternalLinkIcon",path:a.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[a.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),a.jsx("path",{d:"M15 3h6v6"}),a.jsx("path",{d:"M10 14L21 3"})]})}),zs="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function Dh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{children:a.jsx(S.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),a.jsxs(Xr,{href:zs,newTab:!0,children:["What is my Salesforce subdomain? ",a.jsx(Ph,{})]}),a.jsx(Ke,{error:n}),a.jsxs("div",{style:{display:"flex",marginTop:"1em"},children:[a.jsx(S.Input,{placeholder:"my-domain",onChange:i=>t(i.currentTarget.value)}),a.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:o,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function kh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o}){const i={handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o};return ve?a.jsxs(Me,{children:[a.jsx(Qt,{children:"Enter your Salesforce subdomain"}),a.jsx(Xr,{href:zs,newTab:!0,children:"What is my Salesforce subdomain?"}),a.jsx(Ke,{error:n}),a.jsxs("div",{style:{display:"flex",marginTop:"1em"},children:[a.jsx(rt.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:r=>t(r.currentTarget.value)}),a.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:o,type:"submit",onClick:e,children:"Next"})]}):a.jsx(Dh,{...i})}function Fh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsxs(S.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),a.jsx(Ke,{error:n}),a.jsx(S.Flex,{marginTop:"1em",children:a.jsx(S.Input,{placeholder:"MyWorkspace",onChange:r=>t(r.currentTarget.value)})}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:o,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Mh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i}){if(!ve){const r={handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i};return a.jsx(Fh,{...r})}return a.jsxs(Me,{children:[a.jsxs(Qt,{children:["Enter your ",i," workspace"]}),a.jsx(Ke,{error:n}),a.jsx("br",{}),a.jsx(rt.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:r=>t(r.currentTarget.value)}),a.jsx("br",{}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:o,type:"submit",onClick:e,children:"Next"})]})}const Kh="salesforce";function Lh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,providerName:r}){const{projectId:s}=Ie(),c=xe(),[u,d]=y.useState(""),[p,h]=y.useState(null),[v,f]=y.useState(null),g=async()=>{if(f(null),!u){f("Workspace is required");return}try{const O=await Ws(s,t,o,c,e,u,n,i);h(O)}catch(O){console.error(O),f((O==null?void 0:O.message)??"Unexpected error")}},x=y.useCallback(O=>{f(O),h(null)},[]),w=e===Kh?a.jsx(kh,{handleSubmit:g,setWorkspace:d,error:v,isButtonDisabled:u.length===0}):a.jsx(Mh,{handleSubmit:g,setWorkspace:d,error:v,isButtonDisabled:u.length===0,providerName:r});return a.jsx(Js,{windowTitle:`Connect to ${r}`,oauthUrl:p,onError:x,children:w})}function $h({handleSubmit:e,error:t,explicitScopesRequired:n,isButtonDisabled:o,providerName:i}){const[r,s]=y.useState(!1),[c,u]=y.useState(""),[d,p]=y.useState(""),[h,v]=y.useState(""),f=()=>s(!r),g=m=>u(m.currentTarget.value),x=m=>p(m.currentTarget.value),w=m=>v(m.currentTarget.value),O=c.length>0,I=d.length>0,C=o||!O||!I,b=()=>{const m={clientId:d,clientSecret:c};n&&h.length>0&&(m.scopes=Ir(h)),e(m)};return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[a.jsx(S.Input,{placeholder:"Client ID",onChange:x}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:g,pr:"4.5rem",type:r?"text":"password",placeholder:"Client Secret"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:f,children:r?"Hide":"Show"})})]}),n&&a.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:w})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:C,width:"100%",type:"submit",onClick:b,children:"Next"})]})})}function Hh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,explicitScopesRequired:r,providerName:s,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Ie(),p=xe(),[h,v]=y.useState(null),f=async g=>{v(null);const x={groupName:i,groupRef:o,consumerName:n,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes}};fe().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:x},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(w=>{u(w)}).catch(w=>{console.error("Error loading provider info."),Ce(w),v("Error loading provider info")})};return c===null?a.jsx($h,{providerName:s,handleSubmit:f,error:h,explicitScopesRequired:r}):a.jsx(qe,{})}function Vh({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,explicitScopesRequired:i}){const[r,s]=y.useState(!1),[c,u]=y.useState(""),[d,p]=y.useState(""),[h,v]=y.useState(""),[f,g]=y.useState(""),x=()=>s(!r),w=V=>u(V.currentTarget.value),O=V=>p(V.currentTarget.value),I=V=>v(V.currentTarget.value),C=V=>g(V.currentTarget.value),b=c.length>0,m=d.length>0,j=h.length>0,$=n||!b||!m||!j,F=()=>{const V={workspace:h,clientId:d,clientSecret:c};i&&f.length>0&&(V.scopes=Ir(f)),e(V)};return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[a.jsx(S.Input,{placeholder:"MyWorkspace",onChange:I}),a.jsx(S.Input,{placeholder:"Client ID",onChange:O}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:w,pr:"4.5rem",type:r?"text":"password",placeholder:"Client Secret"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:x,children:r?"Hide":"Show"})})]}),i&&a.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:C})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:$,width:"100%",type:"submit",onClick:F,children:"Next"})]})})}function Uh({provider:e,providerName:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,explicitScopesRequired:s,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Ie(),p=xe(),[h,v]=y.useState(null),f=async g=>{v(null);const x={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,providerWorkspaceRef:g.workspace,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes}};fe().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:x},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(w=>{u(w)}).catch(w=>{console.error("Error loading provider info."),Ce(w),v("Error loading provider info")})};return c===null?a.jsx(Vh,{providerName:t,handleSubmit:f,error:h,explicitScopesRequired:s}):a.jsx(qe,{})}function Bh({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,explicitScopesRequired:i,explicitWorkspaceRequired:r}){const[s,c]=y.useState(!1),[u,d]=y.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),p=()=>c(m=>!m),h=m=>{const{name:j,value:$}=m.currentTarget;d(F=>({...F,[j]:$}))},{clientSecret:v,clientId:f,workspace:g,scopes:x}=u,w=v.length>0,O=f.length>0,I=r?g.length>0:!0,C=n||!w||!O||!I,b=()=>{const m={clientId:f,clientSecret:v};r&&(m.workspace=g),i&&x.length>0&&(m.scopes=Ir(x)),e(m)};return a.jsxs(Me,{children:[a.jsx(Qt,{children:`Set up ${o} integration`}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[r&&a.jsx(rt.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:m=>h(m)}),a.jsx(rt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:m=>h(m)}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:m=>h(m)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:p,children:s?"Hide":"Show"})]}),i&&a.jsx(rt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:m=>h(m)})]}),a.jsx("br",{}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:C,type:"submit",onClick:b,children:"Next"})]})}function qh({provider:e,providerName:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,explicitScopesRequired:s,explicitWorkspaceRequired:c,selectedConnection:u,setSelectedConnection:d}){const{projectId:p}=Ie(),h=xe(),[v,f]=y.useState(null),g=async x=>{f(null);const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,providerWorkspaceRef:x.workspace,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};fe().connectionApi.generateConnection({projectIdOrName:p,generateConnectionParams:w},{headers:{"X-Api-Key":h??"","Content-Type":"application/json"}}).then(O=>{d(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O),f("Error loading provider info")})};return u===null?a.jsx(Bh,{providerName:t,handleSubmit:g,error:v,explicitScopesRequired:s,explicitWorkspaceRequired:c}):a.jsx(qe,{})}function Wh({...e}){return ve?a.jsx(qh,{...e}):e.explicitWorkspaceRequired?a.jsx(Uh,{...e}):a.jsx(Hh,{...e})}const Jh="authorizationCode",zh="clientCredentials";function Xh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,selectedConnection:s,setSelectedConnection:c}){if(t.oauth2Opts===void 0)return a.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:u,explicitScopesRequired:d,explicitWorkspaceRequired:p}=t.oauth2Opts,h=it(e,t),v={provider:e,consumerRef:n,consumerName:o,groupRef:i,groupName:r,providerName:h};return u===Jh?p?a.jsx(Lh,{...v}):a.jsx(jh,{...v}):u===zh?a.jsx(Wh,{...v,explicitWorkspaceRequired:p,explicitScopesRequired:d,selectedConnection:s,setSelectedConnection:c}):u==="password"?a.jsx("em",{children:"Password flow not supported yet"}):u==="PKCE"?a.jsx("em",{children:"PKCE flow not supported yet"}):a.jsxs("em",{children:["Unsupported grant type: ",u]})}function Yh(e){const{selectedConnection:t}=kt();y.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function Gh({onSuccess:e}){Yh(e)}const Zh=async(e,t)=>{const n=await fe().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function Xs({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:r,onSuccess:s}){const c=xe(),[u,d]=y.useState(null),{provider:p}=Ye(),{selectedConnection:h,setSelectedConnection:v,connections:f}=kt();Gh({onSuccess:s});const g=e||p,x=(u==null?void 0:u.displayName)??Go(g);if(y.useEffect(()=>{if(!h&&f&&f.length>0){const[O]=f;v(O)}Zh(c,g).then(O=>{d(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})},[f,h,v,c,g]),!e&&!p)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(h)return r;if(u==null)return a.jsx("strong",{children:"Provider not found"});const w={provider:g,consumerRef:t,consumerName:n,groupRef:o,groupName:i,selectedConnection:h,setSelectedConnection:v,providerName:x,providerInfo:u};return u.authType==="none"?a.jsx(Ch,{...w,children:r}):u.authType==="basic"?a.jsx(xh,{...w,children:r}):u.authType==="apiKey"?a.jsx(yh,{...w,children:r}):a.jsx(Xh,{...w})}const Qh=a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[a.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),a.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function em(e,t){return t?y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},y.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Qh:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:a.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const Ys=y.forwardRef(({objectName:e,completed:t,pending:n,displayName:o},i)=>{const r=S.useTab({ref:i}),s=S.useMultiStyleConfig("Tabs",r);return a.jsxs(S.Button,{__css:s.tab,...r,variant:"outline",minHeight:15,children:[a.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[em(t,n),a.jsxs(S.Box,{textAlign:"left",children:[a.jsx(S.Text,{children:o||e}),n&&a.jsx(S.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),r.children]})});function tm({pending:e,completed:t,displayName:n}){return a.jsxs(a.Fragment,{children:[a.jsx(qr,{style:{margin:"1rem 0"}}),a.jsx(Ys,{objectName:xt,completed:t,pending:e,displayName:n},"other-write")]})}function nm(e,t){return e!=null&&e[t]?e[t]:{name:Ni,completed:!1}}const rm=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-background-secondary").trim()||"#FCFCFC";function om({children:e}){var O,I,C;const{project:t}=Ie(),{installation:n,provider:o}=Ye(),{hydratedRevision:i}=Zt(),{objectConfigurationsState:r}=Br(),[s,c]=y.useState(0),u=(t==null?void 0:t.appName)||"",d=n==null?void 0:n.config,p=i&&yi(d,i),h=p!==null,v=!!((O=i==null?void 0:i.content)!=null&&O.write),f=v?vi(d):void 0,g=y.useMemo(()=>{const b=[...p||[]];return f&&v&&b.push(f),b},[p,f,v]),x=nm(g,s),w=y.useCallback(()=>{const b=g.find(m=>x!==m&&!m.completed);b&&c(g.indexOf(b))},[g,x]);return a.jsx(gs.Provider,{value:w,children:a.jsx(hs.Provider,{value:x==null?void 0:x.name,children:a.jsxs(Gt,{style:{maxWidth:"55rem"},children:[a.jsxs(Dt,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:rm},children:[a.jsxs("div",{style:{width:"20rem"},children:[a.jsxs(S.Text,{children:[it(o)," integration"]}),a.jsx(S.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:u}),h&&a.jsxs(S.Tabs,{index:s,onChange:c,orientation:"horizontal",children:[p.map(b=>{var m,j,$,F;return a.jsx(Ys,{objectName:b.name,completed:b.completed,pending:((j=(m=r[b.name])==null?void 0:m.read)==null?void 0:j.isOptionalFieldsModified)||((F=($=r[b.name])==null?void 0:$.read)==null?void 0:F.isRequiredMapFieldsModified)},b.name)}),v&&f&&a.jsx(tm,{completed:f.completed,pending:(C=(I=r==null?void 0:r.other)==null?void 0:I.write)==null?void 0:C.isWriteModified,displayName:p!=null&&p.length?"other":"write"}),n&&a.jsxs(a.Fragment,{children:[a.jsx(qr,{style:{margin:"3rem 0 1rem 0"}}),a.jsx(wd,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]}),a.jsx(qs,{})]})})})}function im(){const[e,t]=y.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}function sm({integration:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onInstallSuccess:r,onUpdateSuccess:s,onUninstallSuccess:c}){var v;const{projectId:u}=Ie(),{errorState:d}=dt(),{seed:p,reset:h}=im();return(v=d[me.INTEGRATION_LIST])!=null&&v.apiError?a.jsx(ot,{message:"Something went wrong, couldn't find integration information"}):a.jsx(Wl,{integration:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onInstallSuccess:r,onUpdateSuccess:s,onUninstallSuccess:c,children:a.jsx(mi,{groupRef:o,children:a.jsx(Xs,{consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:a.jsx(xd,{projectId:u,children:a.jsx(nh,{resetComponent:h,children:a.jsx(qp,{children:a.jsx(om,{children:a.jsx(Yf,{})})})})})})})},p)}function am(){return a.jsxs(Gt,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[a.jsx(qe,{}),a.jsx("p",{children:"Redirecting"})]})}function cm({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?a.jsx(am,{}):t}function um({provider:e}){const{appName:t}=Ie(),n=`You have successfully connected your ${it(e)} account to ${t}.`;return a.jsx(Jr,{text:n})}function lm({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,redirectUrl:r,onSuccess:s}){return a.jsx(mi,{provider:e,groupRef:o,children:a.jsx(Xs,{provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onSuccess:s,children:a.jsx(cm,{redirectURL:r,children:a.jsx(um,{provider:e})})})})}const dm=(e,t)=>{const n=xe(),{projectId:o}=Ie(),{integrations:i}=li(),[r,s]=y.useState(!1),[c,u]=y.useState(null);if(!n||!o)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 d=y.useMemo(()=>i==null?void 0:i.reduce((p,h)=>(h==null?void 0:h.name)===e?h:p,{}),[i,e]);return y.useEffect(()=>{d&&fe().installationApi.listInstallations({projectIdOrName:o,integrationId:d.id,groupRef:t},{headers:{"x-api-key":n}}).then(p=>{s(!0),u(p.length>0)}).catch(p=>{console.error("Error listing installations."),Ce(p),s(!0)})},[t,n,o,d]),{isLoaded:r,isIntegrationInstalled:c}};exports.AmpersandContext=pi;exports.AmpersandProvider=Ul;exports.ConnectProvider=lm;exports.InstallIntegration=sm;exports.useAmpersandProvider=Bl;exports.useIsIntegrationInstalled=dm;
|