@amp-labs/react 2.0.2 → 2.0.3
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 +2 -2
- package/build/amp-react.es.js +3 -3
- package/package.json +1 -1
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),g=require("react");require("react-dom");function Tl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const k=Tl(g),Os=g.createContext(null),Rl=Os.Provider,Je=()=>{const e=g.useContext(Os);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var Se=(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))(Se||{});const Es=g.createContext(void 0);function Zt(){const e=g.useContext(Es);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Al=(()=>{const e={};return Object.values(Se).forEach(t=>{e[t]={}}),e})();function Pl({children:e}){const[t,n]=g.useState(Al),r=g.useCallback((d,p,m=!0)=>{n(f=>{const v={...f};return v[d]=v[d]||{},v[d][p]=m,v})},[n]),i=g.useCallback((d,p)=>{var m;return!!((m=t[d])!=null&&m[p])},[t]),o=g.useCallback((d,p)=>{var m;return(m=t[d])==null?void 0:m[p]},[t]),s=g.useCallback((d,p)=>{n(m=>{var v;const f={...m};return(v=f[d])==null||delete v[p],f})},[n]),a=g.useCallback(d=>{n(p=>{const m={...p};return m[d]={},m})},[n]),c=g.useCallback((d,p)=>{n(m=>{const f={...m};return f[d]=f[d]||{},p.forEach(v=>{f[d][v]=!0}),f})},[n]),l=g.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:i,removeError:s,resetBoundary:a,setErrors:c,getError:o}),[t,n,r,i,s,a,c,o]);return u.jsx(Es.Provider,{value:l,children:e})}function Dl(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Fl="_box_1p7c5_1",Ai={box:Fl};function vn({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${Ai.box} ${t}`:Ai.box,style:n,children:e})}const jl="_container_1wvzr_1",Pi={container:jl};function Xn({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${Pi.container} ${t}`:Pi.container,style:n,children:e})}const Ml="_errorBoxContainer_4sdb2_1",kl="_errorBox_4sdb2_1",Ll="_errorText_4sdb2_20",Qr={errorBoxContainer:Ml,errorBox:kl,errorText:Ll};function Lt({message:e}){return u.jsxs(Xn,{className:Qr.errorBoxContainer,children:[u.jsx(Dl,{}),u.jsx(vn,{className:Qr.errorBox,children:u.jsx("p",{className:Qr.errorText,children:e})})]})}const $l="https://api.withampersand.com/v1".replace(/\/+$/,"");class Ss{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:$l}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ts}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 Kl=new Ss,Lr=class Lr{constructor(t=Kl){this.configuration=t,this.fetchApi=async(n,r)=>{let i={url:n,init:r};for(const s of this.middleware)s.pre&&(i=await s.pre({fetch:this.fetchApi,...i})||i);let o;try{o=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(s){for(const a of this.middleware)a.onError&&(o=await a.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:s,response:o?o.clone():void 0})||o);if(o===void 0)throw s instanceof Error?new Ul(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(o=await s.post({fetch:this.fetchApi,url:i.url,init:i.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(r=>({pre:r}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(r=>({post:r}));return this.withMiddleware(...n)}isJsonMime(t){return t?Lr.jsonRegex.test(t):!1}async request(t,n){const{url:r,init:i}=await this.createFetchParams(t,n),o=await this.fetchApi(r,i);if(o&&o.status>=200&&o.status<300)return o;throw new Ns(o,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(l=>i[l]===void 0?delete i[l]:{});const o=typeof n=="function"?n:async()=>n,s={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},a={...s,...await o({init:s,context:t})},c={...a,body:Hl(a.body)||a.body instanceof URLSearchParams||Vl(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Lr.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let Et=Lr;function Vl(e){return typeof Blob<"u"&&e instanceof Blob}function Hl(e){return typeof FormData<"u"&&e instanceof FormData}class Ns extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class Ul extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class oe extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function L(e,t){const n=e[t];return n!=null}function Ts(e,t=""){return Object.keys(e).map(n=>Rs(n,e[n],t)).filter(n=>n.length>0).join("&")}function Rs(e,t,n=""){const r=n+(n.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(r)}=`);return`${encodeURIComponent(r)}=${i}`}if(t instanceof Set){const i=Array.from(t);return Rs(e,i,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ts(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Mo(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Ae{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class xn{constructor(t){this.raw=t}async value(){}}class Bl{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function ql(e){return Wl(e)}function Wl(e,t){return e==null?e:{fieldUsed:L(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:L(e,"keyFormat")?e.keyFormat:void 0}}function Jl(e){return zl(e)}function zl(e,t){return e==null?e:{name:e.name,valuePrefix:L(e,"valuePrefix")?e.valuePrefix:void 0}}function Xl(e){return Gl(e)}function Gl(e,t){return e==null?e:{name:e.name}}function Yl(e){return Zl(e)}function Zl(e,t){return e==null?e:{attachmentType:e.attachmentType,query:L(e,"query")?Xl(e.query):void 0,header:L(e,"header")?Jl(e.header):void 0,docsURL:L(e,"docsURL")?e.docsURL:void 0}}function Ql(e){return eu(e)}function eu(e,t){return e}function tu(e){return nu(e)}function nu(e,t){return e==null?e:{days:L(e,"days")?e.days:void 0,fullHistory:L(e,"fullHistory")?e.fullHistory:void 0}}function ru(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function As(e){return ou(e)}function ou(e,t){return e==null?e:{defaultPeriod:tu(e.defaultPeriod)}}function iu(e){if(e!==void 0)return e===null?null:{defaultPeriod:ru(e.defaultPeriod)}}function su(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function au(e){if(e!==void 0)return e===null?null:{defaultPeriod:su(e.defaultPeriod)}}function cu(e){return lu(e)}function lu(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function Ps(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function uu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:e.selectedFieldsAuto,backfill:au(e.backfill)}}function du(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Mo(e.objects,uu)}}function pu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function fu(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Mo(e.objects,pu)}}function mu(e){return hu(e)}function hu(e,t){return e==null?e:{apiKeyAsBasic:L(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:L(e,"apiKeyAsBasicOpts")?ql(e.apiKeyAsBasicOpts):void 0,docsURL:L(e,"docsURL")?e.docsURL:void 0}}function gu(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function dr(e){return vu(e)}function vu(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:L(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function yu(e){return wu(e)}function wu(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Iu(e){return _u(e)}function _u(e,t){return e==null?e:{provider:e.provider,read:L(e,"read")?e.read:void 0,write:L(e,"write")?e.write:void 0,proxy:L(e,"proxy")?cu(e.proxy):void 0}}function Ds(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Ps(e.proxy)}}function bu(e){return xu(e)}function xu(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Iu(e.content)}}function Cu(e){return Ou(e)}function Ou(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Fs(e){return Eu(e)}function Eu(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function wr(e){return Su(e)}function Su(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:L(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:L(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Nu(e)}function Nu(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:wr(e.providerApp),group:Fs(e.group),consumer:Cu(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:L(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Tu(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Ds(e.content)}}function Ru(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Tu(e.config)}}function Au(e){return Pu(e)}function Pu(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function Du(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Fu(e){return ju(e)}function ju(e,t){return e==null?e:{mode:L(e,"mode")?e.mode:void 0,pageSize:L(e,"pageSize")?e.pageSize:void 0}}function Mu(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function ku(e){let t=!0;return t=t&&"fieldName"in e,t}function Lu(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function $u(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Ku(e){let t=!0;return t=t&&"mapToName"in e,t}function js(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:L(e,"default")?e.default:void 0,prompt:L(e,"prompt")?e.prompt:void 0}}function Vu(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Di(e){return Hu(e)}function Hu(e,t){return e==null?e:{...Lu(e),...js(e)}}function Fi(e){if(e!==void 0)return e===null?null:ku(e)?$u(e):Ku(e)?Vu(e):{}}function Ms(e){return Uu(e)}function Uu(e,t){return e}function Bu(e){return qu(e)}function qu(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:L(e,"requiredFields")?e.requiredFields.map(Di):void 0,optionalFields:L(e,"optionalFields")?e.optionalFields.map(Di):void 0,optionalFieldsAuto:L(e,"optionalFieldsAuto")?Ms(e.optionalFieldsAuto):void 0,backfill:L(e,"backfill")?As(e.backfill):void 0,delivery:L(e,"delivery")?Fu(e.delivery):void 0}}function Wu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,requiredFields:e.requiredFields===void 0?void 0:e.requiredFields.map(Fi),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Fi),optionalFieldsAuto:e.optionalFieldsAuto,backfill:iu(e.backfill),delivery:Mu(e.delivery)}}function Ju(e){return zu(e)}function zu(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(Bu):void 0}}function Xu(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Wu)}}function Gu(e){return Yu(e)}function Yu(e,t){return e==null?e:{objectName:e.objectName,inheritMappingFromRead:L(e,"inheritMappingFromRead")?e.inheritMappingFromRead:void 0}}function Zu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMappingFromRead:e.inheritMappingFromRead}}function Qu(e){return ed(e)}function ed(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(Gu):void 0}}function td(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zu)}}function nd(e){return rd(e)}function rd(e,t){return e==null?e:{name:e.name,displayName:L(e,"displayName")?e.displayName:void 0,provider:e.provider,read:L(e,"read")?Ju(e.read):void 0,write:L(e,"write")?Qu(e.write):void 0,proxy:L(e,"proxy")?Au(e.proxy):void 0}}function od(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:Xu(e.read),write:td(e.write),proxy:Du(e.proxy)}}function id(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:od(e.content)}}function sd(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:id(e.latestRevision)}}function ad(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function cd(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 ld(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function ud(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function dd(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function pd(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 fd(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:ud(e.basicAuth),oauth2ClientCredentials:dd(e.oauth2ClientCredentials),oauth2Password:pd(e.oauth2Password)}}function md(e){return hd(e)}function hd(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function gd(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,displayName:e.displayName}}function eo(e){return vd(e)}function vd(e,t){return e==null?e:{...gd(e),...js(e)}}function yd(e){return wd(e)}function wd(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:L(e,"requiredFields")?e.requiredFields.map(eo):void 0,optionalFields:L(e,"optionalFields")?e.optionalFields.map(eo):void 0,optionalFieldsAuto:L(e,"optionalFieldsAuto")?Ms(e.optionalFieldsAuto):void 0,allFields:L(e,"allFields")?e.allFields.map(eo):void 0,backfill:L(e,"backfill")?As(e.backfill):void 0}}function Id(e){return _d(e)}function _d(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(yd):void 0}}function bd(e){return xd(e)}function xd(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function Cd(e){return Od(e)}function Od(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(bd):void 0}}function Ed(e){return Sd(e)}function Sd(e,t){return e==null?e:{name:e.name,displayName:L(e,"displayName")?e.displayName:void 0,provider:e.provider,read:L(e,"read")?Id(e.read):void 0,write:L(e,"write")?Cd(e.write):void 0,proxy:L(e,"proxy")?md(e.proxy):void 0}}function Nd(e){return Td(e)}function Td(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ed(e.content)}}function Rd(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 Ad(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Ds(e.content)}}function Pd(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:Rd(e.connection),config:Ad(e.config)}}function Ln(e){return Dd(e)}function Dd(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:L(e,"group")?Fs(e.group):void 0,healthStatus:e.healthStatus,connection:Ir(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0,config:bu(e.config)}}function Fd(e){return jd(e)}function jd(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:nd(e.content)}}function ji(e){return Md(e)}function Md(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Fd(e.latestRevision)}}function kd(e){return Ld(e)}function Ld(e,t){return e==null?e:{iconURL:L(e,"iconURL")?e.iconURL:void 0,logoURL:L(e,"logoURL")?e.logoURL:void 0}}function $d(e){return Kd(e)}function Kd(e,t){return e==null?e:{iconURL:L(e,"iconURL")?e.iconURL:void 0,logoURL:L(e,"logoURL")?e.logoURL:void 0}}function Vd(e){return Hd(e)}function Hd(e,t){return e==null?e:{regular:L(e,"regular")?$d(e.regular):void 0,darkMode:L(e,"darkMode")?kd(e.darkMode):void 0}}function Ud(e){return Bd(e)}function Bd(e,t){return e==null?e:{workspaceRefField:L(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:L(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:L(e,"scopesField")?e.scopesField:void 0}}function qd(e){return Wd(e)}function Wd(e,t){return e==null?e:{grantType:e.grantType,authURL:L(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:L(e,"audience")?e.audience:void 0,tokenMetadataFields:Ud(e.tokenMetadataFields),docsURL:L(e,"docsURL")?e.docsURL:void 0,authURLParams:L(e,"authURLParams")?e.authURLParams:void 0}}function Jd(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,enableCSRFProtection:e.enableCSRFProtection}}function zd(e){return Xd(e)}function Xd(e,t){return e==null?e:{bulkWrite:yu(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Mi(e){return Gd(e)}function Gd(e,t){return e==null?e:{name:e.name,authType:Ql(e.authType),baseURL:e.baseURL,oauth2Opts:L(e,"oauth2Opts")?qd(e.oauth2Opts):void 0,apiKeyOpts:L(e,"apiKeyOpts")?Yl(e.apiKeyOpts):void 0,basicOpts:L(e,"basicOpts")?mu(e.basicOpts):void 0,support:zd(e.support),providerOpts:e.providerOpts,displayName:L(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:L(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:L(e,"media")?Vd(e.media):void 0,labels:L(e,"labels")?e.labels:void 0}}function Yd(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:du(e.read),write:fu(e.write),proxy:Ps(e.proxy)}}function Zd(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Yd(e.content)}}function Qd(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:Zd(e.config)}}function ep(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:Qd(e.installation)}}function tp(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function np(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:tp(e.project)}}function rp(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 op(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:rp(e.providerApp)}}class ip extends Et{async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:fd(t.generateConnectionParams)},n);return new Ae(o,s=>Ir(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new oe("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Ir(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(Ir))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class sp extends Et{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new oe("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:Ru(t.installation)},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new oe("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:Pd(t.installation)},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>s.map(Ln))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new oe("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:ep(t.installationUpdate)},n);return new Ae(o,s=>Ln(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class ap extends Et{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:r,body:gu(t.batchUpsertIntegrationsRequest)},n);return new Ae(o,s=>s.map(ji))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new oe("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:sd(t.integration)},n);return new xn(o)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(ji))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class cp extends Et{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new oe("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},i={};i["Content-Type"]="application/json";const o=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:r,body:Jd(t.connectOAuthParams)},n);return this.isJsonMime(o.headers.get("content-type"))?new Ae(o):new Bl(o)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class lp extends Et{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new oe("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects",method:"POST",headers:i,query:r,body:ad(t.project)},n);return new Ae(o,s=>dr(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:r},n);return new xn(o)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>dr(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new Ae(i,o=>o.map(dr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new oe("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:r,body:np(t.projectUpdate)},n);return new Ae(o,s=>dr(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class up extends Et{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new oe("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>Mi(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new Ae(i,o=>Mo(o,Mi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class dp extends Et{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new oe("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:cd(t.providerApp)},n);return new Ae(o,s=>wr(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new oe("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(wr))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new oe("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new oe("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:op(t.providerAppUpdate)},n);return new Ae(o,s=>wr(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class pp extends Et{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:ld(t.revision)},n);return new xn(o)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new oe("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new oe("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Nd(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class fp{constructor(t){this.connectionApi=new ip(t),this.installationApi=new sp(t),this.integrationApi=new ap(t),this.oAuthApi=new cp(t),this.projectApi=new lp(t),this.providerApi=new up(t),this.providerAppApi=new dp(t),this.revisionApi=new pp(t)}}const mp="2.0.2",hp="v1",pr="https://api.withampersand.com";function ks(){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 pr;case"mock":return"http://127.0.0.1:4010";case"":return pr;default:return e??pr}}catch{return pr}}const gp=(e,t)=>`${e}/${t}`;function vp(){return gp(ks(),hp)}const yp=ks(),wp=vp(),Ip=new Ss({basePath:wp,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":mp}});let _p=new fp(Ip);const Te=()=>_p,bp="_loader_6ubm6_1",xp="_rotate_6ubm6_1",Cp="_ball1_6ubm6_1",Op="_ball2_6ubm6_1",Ep={loader:bp,rotate:xp,ball1:Cp,ball2:Op};function Sp(){return u.jsx("span",{className:Ep.loader})}function $t(){return u.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:u.jsx(Sp,{})})}const Ye=async(e,t)=>{var n;if(e instanceof Ns){const{status:r,statusText:i}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,i);const o=await e.response.json(),s=((n=o==null?void 0:o.causes)==null?void 0:n.join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),g=require("react");require("react-dom");function Tl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const k=Tl(g),Os=g.createContext(null),Rl=Os.Provider,Je=()=>{const e=g.useContext(Os);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var Se=(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))(Se||{});const Es=g.createContext(void 0);function Zt(){const e=g.useContext(Es);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Al=(()=>{const e={};return Object.values(Se).forEach(t=>{e[t]={}}),e})();function Pl({children:e}){const[t,n]=g.useState(Al),r=g.useCallback((d,p,m=!0)=>{n(f=>{const v={...f};return v[d]=v[d]||{},v[d][p]=m,v})},[n]),i=g.useCallback((d,p)=>{var m;return!!((m=t[d])!=null&&m[p])},[t]),o=g.useCallback((d,p)=>{var m;return(m=t[d])==null?void 0:m[p]},[t]),s=g.useCallback((d,p)=>{n(m=>{var v;const f={...m};return(v=f[d])==null||delete v[p],f})},[n]),a=g.useCallback(d=>{n(p=>{const m={...p};return m[d]={},m})},[n]),c=g.useCallback((d,p)=>{n(m=>{const f={...m};return f[d]=f[d]||{},p.forEach(v=>{f[d][v]=!0}),f})},[n]),l=g.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:i,removeError:s,resetBoundary:a,setErrors:c,getError:o}),[t,n,r,i,s,a,c,o]);return u.jsx(Es.Provider,{value:l,children:e})}function Dl(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Fl="_box_1p7c5_1",Ai={box:Fl};function vn({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${Ai.box} ${t}`:Ai.box,style:n,children:e})}const jl="_container_1wvzr_1",Pi={container:jl};function Xn({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${Pi.container} ${t}`:Pi.container,style:n,children:e})}const Ml="_errorBoxContainer_4sdb2_1",kl="_errorBox_4sdb2_1",Ll="_errorText_4sdb2_20",Qr={errorBoxContainer:Ml,errorBox:kl,errorText:Ll};function Lt({message:e}){return u.jsxs(Xn,{className:Qr.errorBoxContainer,children:[u.jsx(Dl,{}),u.jsx(vn,{className:Qr.errorBox,children:u.jsx("p",{className:Qr.errorText,children:e})})]})}const $l="https://api.withampersand.com/v1".replace(/\/+$/,"");class Ss{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:$l}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Ts}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 Kl=new Ss,Lr=class Lr{constructor(t=Kl){this.configuration=t,this.fetchApi=async(n,r)=>{let i={url:n,init:r};for(const s of this.middleware)s.pre&&(i=await s.pre({fetch:this.fetchApi,...i})||i);let o;try{o=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(s){for(const a of this.middleware)a.onError&&(o=await a.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:s,response:o?o.clone():void 0})||o);if(o===void 0)throw s instanceof Error?new Ul(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(o=await s.post({fetch:this.fetchApi,url:i.url,init:i.init,response:o.clone()})||o);return o},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(r=>({pre:r}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(r=>({post:r}));return this.withMiddleware(...n)}isJsonMime(t){return t?Lr.jsonRegex.test(t):!1}async request(t,n){const{url:r,init:i}=await this.createFetchParams(t,n),o=await this.fetchApi(r,i);if(o&&o.status>=200&&o.status<300)return o;throw new Ns(o,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(l=>i[l]===void 0?delete i[l]:{});const o=typeof n=="function"?n:async()=>n,s={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},a={...s,...await o({init:s,context:t})},c={...a,body:Hl(a.body)||a.body instanceof URLSearchParams||Vl(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Lr.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let Et=Lr;function Vl(e){return typeof Blob<"u"&&e instanceof Blob}function Hl(e){return typeof FormData<"u"&&e instanceof FormData}class Ns extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class Ul extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class oe extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function L(e,t){const n=e[t];return n!=null}function Ts(e,t=""){return Object.keys(e).map(n=>Rs(n,e[n],t)).filter(n=>n.length>0).join("&")}function Rs(e,t,n=""){const r=n+(n.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(r)}=`);return`${encodeURIComponent(r)}=${i}`}if(t instanceof Set){const i=Array.from(t);return Rs(e,i,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Ts(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Mo(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Ae{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class xn{constructor(t){this.raw=t}async value(){}}class Bl{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function ql(e){return Wl(e)}function Wl(e,t){return e==null?e:{fieldUsed:L(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:L(e,"keyFormat")?e.keyFormat:void 0}}function Jl(e){return zl(e)}function zl(e,t){return e==null?e:{name:e.name,valuePrefix:L(e,"valuePrefix")?e.valuePrefix:void 0}}function Xl(e){return Gl(e)}function Gl(e,t){return e==null?e:{name:e.name}}function Yl(e){return Zl(e)}function Zl(e,t){return e==null?e:{attachmentType:e.attachmentType,query:L(e,"query")?Xl(e.query):void 0,header:L(e,"header")?Jl(e.header):void 0,docsURL:L(e,"docsURL")?e.docsURL:void 0}}function Ql(e){return eu(e)}function eu(e,t){return e}function tu(e){return nu(e)}function nu(e,t){return e==null?e:{days:L(e,"days")?e.days:void 0,fullHistory:L(e,"fullHistory")?e.fullHistory:void 0}}function ru(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function As(e){return ou(e)}function ou(e,t){return e==null?e:{defaultPeriod:tu(e.defaultPeriod)}}function iu(e){if(e!==void 0)return e===null?null:{defaultPeriod:ru(e.defaultPeriod)}}function su(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function au(e){if(e!==void 0)return e===null?null:{defaultPeriod:su(e.defaultPeriod)}}function cu(e){return lu(e)}function lu(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function Ps(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function uu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:e.selectedFieldsAuto,backfill:au(e.backfill)}}function du(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Mo(e.objects,uu)}}function pu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function fu(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Mo(e.objects,pu)}}function mu(e){return hu(e)}function hu(e,t){return e==null?e:{apiKeyAsBasic:L(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:L(e,"apiKeyAsBasicOpts")?ql(e.apiKeyAsBasicOpts):void 0,docsURL:L(e,"docsURL")?e.docsURL:void 0}}function gu(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function dr(e){return vu(e)}function vu(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:L(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function yu(e){return wu(e)}function wu(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Iu(e){return _u(e)}function _u(e,t){return e==null?e:{provider:e.provider,read:L(e,"read")?e.read:void 0,write:L(e,"write")?e.write:void 0,proxy:L(e,"proxy")?cu(e.proxy):void 0}}function Ds(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Ps(e.proxy)}}function bu(e){return xu(e)}function xu(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Iu(e.content)}}function Cu(e){return Ou(e)}function Ou(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Fs(e){return Eu(e)}function Eu(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function wr(e){return Su(e)}function Su(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:L(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:L(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Nu(e)}function Nu(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:wr(e.providerApp),group:Fs(e.group),consumer:Cu(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:L(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0}}function Tu(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Ds(e.content)}}function Ru(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Tu(e.config)}}function Au(e){return Pu(e)}function Pu(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function Du(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Fu(e){return ju(e)}function ju(e,t){return e==null?e:{mode:L(e,"mode")?e.mode:void 0,pageSize:L(e,"pageSize")?e.pageSize:void 0}}function Mu(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function ku(e){let t=!0;return t=t&&"fieldName"in e,t}function Lu(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function $u(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Ku(e){let t=!0;return t=t&&"mapToName"in e,t}function js(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:L(e,"default")?e.default:void 0,prompt:L(e,"prompt")?e.prompt:void 0}}function Vu(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Di(e){return Hu(e)}function Hu(e,t){return e==null?e:{...Lu(e),...js(e)}}function Fi(e){if(e!==void 0)return e===null?null:ku(e)?$u(e):Ku(e)?Vu(e):{}}function Ms(e){return Uu(e)}function Uu(e,t){return e}function Bu(e){return qu(e)}function qu(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:L(e,"requiredFields")?e.requiredFields.map(Di):void 0,optionalFields:L(e,"optionalFields")?e.optionalFields.map(Di):void 0,optionalFieldsAuto:L(e,"optionalFieldsAuto")?Ms(e.optionalFieldsAuto):void 0,backfill:L(e,"backfill")?As(e.backfill):void 0,delivery:L(e,"delivery")?Fu(e.delivery):void 0}}function Wu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,requiredFields:e.requiredFields===void 0?void 0:e.requiredFields.map(Fi),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Fi),optionalFieldsAuto:e.optionalFieldsAuto,backfill:iu(e.backfill),delivery:Mu(e.delivery)}}function Ju(e){return zu(e)}function zu(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(Bu):void 0}}function Xu(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Wu)}}function Gu(e){return Yu(e)}function Yu(e,t){return e==null?e:{objectName:e.objectName,inheritMappingFromRead:L(e,"inheritMappingFromRead")?e.inheritMappingFromRead:void 0}}function Zu(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMappingFromRead:e.inheritMappingFromRead}}function Qu(e){return ed(e)}function ed(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(Gu):void 0}}function td(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zu)}}function nd(e){return rd(e)}function rd(e,t){return e==null?e:{name:e.name,displayName:L(e,"displayName")?e.displayName:void 0,provider:e.provider,read:L(e,"read")?Ju(e.read):void 0,write:L(e,"write")?Qu(e.write):void 0,proxy:L(e,"proxy")?Au(e.proxy):void 0}}function od(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:Xu(e.read),write:td(e.write),proxy:Du(e.proxy)}}function id(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:od(e.content)}}function sd(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:id(e.latestRevision)}}function ad(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function cd(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 ld(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function ud(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function dd(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function pd(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 fd(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:ud(e.basicAuth),oauth2ClientCredentials:dd(e.oauth2ClientCredentials),oauth2Password:pd(e.oauth2Password)}}function md(e){return hd(e)}function hd(e,t){return e==null?e:{enabled:L(e,"enabled")?e.enabled:void 0}}function gd(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,displayName:e.displayName}}function eo(e){return vd(e)}function vd(e,t){return e==null?e:{...gd(e),...js(e)}}function yd(e){return wd(e)}function wd(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,mapToName:L(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:L(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:L(e,"requiredFields")?e.requiredFields.map(eo):void 0,optionalFields:L(e,"optionalFields")?e.optionalFields.map(eo):void 0,optionalFieldsAuto:L(e,"optionalFieldsAuto")?Ms(e.optionalFieldsAuto):void 0,allFields:L(e,"allFields")?e.allFields.map(eo):void 0,backfill:L(e,"backfill")?As(e.backfill):void 0}}function Id(e){return _d(e)}function _d(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(yd):void 0}}function bd(e){return xd(e)}function xd(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function Cd(e){return Od(e)}function Od(e,t){return e==null?e:{objects:L(e,"objects")?e.objects.map(bd):void 0}}function Ed(e){return Sd(e)}function Sd(e,t){return e==null?e:{name:e.name,displayName:L(e,"displayName")?e.displayName:void 0,provider:e.provider,read:L(e,"read")?Id(e.read):void 0,write:L(e,"write")?Cd(e.write):void 0,proxy:L(e,"proxy")?md(e.proxy):void 0}}function Nd(e){return Td(e)}function Td(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ed(e.content)}}function Rd(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 Ad(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Ds(e.content)}}function Pd(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:Rd(e.connection),config:Ad(e.config)}}function Ln(e){return Dd(e)}function Dd(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:L(e,"group")?Fs(e.group):void 0,healthStatus:e.healthStatus,connection:Ir(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0,config:bu(e.config)}}function Fd(e){return jd(e)}function jd(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:nd(e.content)}}function ji(e){return Md(e)}function Md(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:L(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Fd(e.latestRevision)}}function kd(e){return Ld(e)}function Ld(e,t){return e==null?e:{iconURL:L(e,"iconURL")?e.iconURL:void 0,logoURL:L(e,"logoURL")?e.logoURL:void 0}}function $d(e){return Kd(e)}function Kd(e,t){return e==null?e:{iconURL:L(e,"iconURL")?e.iconURL:void 0,logoURL:L(e,"logoURL")?e.logoURL:void 0}}function Vd(e){return Hd(e)}function Hd(e,t){return e==null?e:{regular:L(e,"regular")?$d(e.regular):void 0,darkMode:L(e,"darkMode")?kd(e.darkMode):void 0}}function Ud(e){return Bd(e)}function Bd(e,t){return e==null?e:{workspaceRefField:L(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:L(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:L(e,"scopesField")?e.scopesField:void 0}}function qd(e){return Wd(e)}function Wd(e,t){return e==null?e:{grantType:e.grantType,authURL:L(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:L(e,"audience")?e.audience:void 0,tokenMetadataFields:Ud(e.tokenMetadataFields),docsURL:L(e,"docsURL")?e.docsURL:void 0,authURLParams:L(e,"authURLParams")?e.authURLParams:void 0}}function Jd(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,enableCSRFProtection:e.enableCSRFProtection}}function zd(e){return Xd(e)}function Xd(e,t){return e==null?e:{bulkWrite:yu(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Mi(e){return Gd(e)}function Gd(e,t){return e==null?e:{name:e.name,authType:Ql(e.authType),baseURL:e.baseURL,oauth2Opts:L(e,"oauth2Opts")?qd(e.oauth2Opts):void 0,apiKeyOpts:L(e,"apiKeyOpts")?Yl(e.apiKeyOpts):void 0,basicOpts:L(e,"basicOpts")?mu(e.basicOpts):void 0,support:zd(e.support),providerOpts:e.providerOpts,displayName:L(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:L(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:L(e,"media")?Vd(e.media):void 0,labels:L(e,"labels")?e.labels:void 0}}function Yd(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:du(e.read),write:fu(e.write),proxy:Ps(e.proxy)}}function Zd(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Yd(e.content)}}function Qd(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:Zd(e.config)}}function ep(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:Qd(e.installation)}}function tp(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function np(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:tp(e.project)}}function rp(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 op(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:rp(e.providerApp)}}class ip extends Et{async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:fd(t.generateConnectionParams)},n);return new Ae(o,s=>Ir(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new oe("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Ir(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(Ir))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class sp extends Et{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new oe("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:Ru(t.installation)},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new oe("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:Pd(t.installation)},n);return new Ae(o,s=>Ln(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>s.map(Ln))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new oe("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new oe("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:ep(t.installationUpdate)},n);return new Ae(o,s=>Ln(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class ap extends Et{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:r,body:gu(t.batchUpsertIntegrationsRequest)},n);return new Ae(o,s=>s.map(ji))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new oe("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:sd(t.integration)},n);return new xn(o)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(ji))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class cp extends Et{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new oe("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},i={};i["Content-Type"]="application/json";const o=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:r,body:Jd(t.connectOAuthParams)},n);return this.isJsonMime(o.headers.get("content-type"))?new Ae(o):new Bl(o)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class lp extends Et{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new oe("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects",method:"POST",headers:i,query:r,body:ad(t.project)},n);return new Ae(o,s=>dr(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:r},n);return new xn(o)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>dr(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new Ae(i,o=>o.map(dr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new oe("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:r,body:np(t.projectUpdate)},n);return new Ae(o,s=>dr(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class up extends Et{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new oe("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>Mi(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new Ae(i,o=>Mo(o,Mi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class dp extends Et{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new oe("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:r,body:cd(t.providerApp)},n);return new Ae(o,s=>wr(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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new oe("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new xn(o)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:r},n);return new Ae(o,s=>s.map(wr))}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 oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new oe("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new oe("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:op(t.providerAppUpdate)},n);return new Ae(o,s=>wr(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class pp extends Et{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const r={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r,body:ld(t.revision)},n);return new xn(o)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new oe("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new oe("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new oe("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new oe("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=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:r},n);return new Ae(o,s=>Nd(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class fp{constructor(t){this.connectionApi=new ip(t),this.installationApi=new sp(t),this.integrationApi=new ap(t),this.oAuthApi=new cp(t),this.projectApi=new lp(t),this.providerApi=new up(t),this.providerAppApi=new dp(t),this.revisionApi=new pp(t)}}const mp="2.0.3",hp="v1",pr="https://api.withampersand.com";function ks(){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 pr;case"mock":return"http://127.0.0.1:4010";case"":return pr;default:return e??pr}}catch{return pr}}const gp=(e,t)=>`${e}/${t}`;function vp(){return gp(ks(),hp)}const yp=ks(),wp=vp(),Ip=new Ss({basePath:wp,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":mp}});let _p=new fp(Ip);const Te=()=>_p,bp="_loader_6ubm6_1",xp="_rotate_6ubm6_1",Cp="_ball1_6ubm6_1",Op="_ball2_6ubm6_1",Ep={loader:bp,rotate:xp,ball1:Cp,ball2:Op};function Sp(){return u.jsx("span",{className:Ep.loader})}function $t(){return u.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:u.jsx(Sp,{})})}const Ye=async(e,t)=>{var n;if(e instanceof Ns){const{status:r,statusText:i}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,i);const o=await e.response.json(),s=((n=o==null?void 0:o.causes)==null?void 0:n.join(`
|
|
2
2
|
`))||"[ERROR] Creating installation failed.";console.error("[Error Message]",s),t&&t(s)}else console.error("Unexpected error:",e.message)},Ls=g.createContext({integrations:null}),$s=()=>{const e=g.useContext(Ls);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Np({projectIdOrName:e,children:t}){const n=Je(),{setError:r,isError:i}=Zt(),[o,s]=g.useState(null),[a,c]=g.useState(!0);g.useEffect(()=>{Te().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(d=>{c(!1),s(d||[])}).catch(d=>{console.error("Error retrieving integration information."),Ye(d),c(!1),r(Se.INTEGRATION_LIST,e)})},[e,n,r]);const l=g.useMemo(()=>({integrations:o}),[o]);return i(Se.INTEGRATION_LIST,e)?u.jsx(Lt,{message:"Error retrieving integrations for the project, double check the API key"}):u.jsx(Ls.Provider,{value:l,children:a?u.jsx($t,{}):t})}const Ks=g.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),De=()=>{const e=g.useContext(Ks);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Tp({projectIdOrName:e,children:t}){const n=Je(),{isError:r,setError:i}=Zt(),[o,s]=g.useState(null),[a,c]=g.useState(!0);g.useEffect(()=>{Te().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(d=>{c(!1),s(d)}).catch(d=>{console.error("Error loading Ampersand project."),Ye(d),i(Se.PROJECT,e),c(!1)})},[e,n,c,i]);const l=g.useMemo(()=>({projectId:(o==null?void 0:o.id)||"",projectIdOrName:e,project:o,appName:(o==null?void 0:o.appName)||""}),[e,o]);return r(Se.PROJECT,e)?u.jsx(Lt,{message:`Error loading project ${e}`}):u.jsx(Ks.Provider,{value:l,children:a?u.jsx($t,{}):t})}function Rp(e){const{options:{apiKey:t,projectId:n,project:r},children:i}=e,o=r||n;if(n&&r)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!o)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return u.jsx(Pl,{children:u.jsx(Rl,{value:t,children:u.jsx(Tp,{projectIdOrName:o,children:u.jsx(Np,{projectIdOrName:o,children:i})})})})}const Vs=g.createContext(null);function Ap(){const e=g.useContext(Vs);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
3
3
|
component is wrapped with AmpersandProvider`);return e}function Un(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qt(e,t){return(t==null?void 0:t.displayName)??Un(e)}const Pp=e=>e.split(`
|
|
4
4
|
`).filter(n=>n.trim()!==""),Dp=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,Fp=()=>{const[e,t]=g.useState(!1),n=g.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n}},Hs=g.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 ut(){const e=g.useContext(Hs);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function jp({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,fieldMapping:l}){const d=Je(),{projectId:p}=De(),{integrations:m}=$s(),{setError:f,isError:v}=Zt(),{isIntegrationDeleted:w,setIntegrationDeleted:I}=Fp(),[O,y]=g.useState([]),[x,b]=g.useState(!0),_=(O==null?void 0:O[0])||null,E=g.useMemo(()=>Dp(t,m||[]),[t,m]);g.useEffect(()=>{E===null&&(m!=null&&m.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,E,m]);const $=g.useCallback(z=>{y([z])},[y]),T=g.useCallback(()=>{E!=null&&E.id&&Te().installationApi.listInstallations({projectIdOrName:p,integrationId:E.id,groupRef:i},{headers:{"X-Api-Key":d??""}}).then(z=>{b(!1),y(z||[])}).catch(z=>{f(Se.INSTALLATION_LIST,E.id),b(!1),console.error("Error retrieving installation information: ",z)})},[E,p,d,f,i]),J=(E==null?void 0:E.id)||"";g.useEffect(()=>{T()},[T]);const q=g.useMemo(()=>({integrationId:(E==null?void 0:E.id)||"",provider:(E==null?void 0:E.provider)||"",integrationObj:E,consumerRef:n,consumerName:r,groupRef:i,groupName:o,installation:_,setInstallation:$,resetInstallations:T,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,isIntegrationDeleted:w,setIntegrationDeleted:I,fieldMapping:l}),[E,n,r,i,o,_,$,T,s,a,c,w,I,l]);if(E!==null){const z=`Error retrieving installation information for integration "${(E==null?void 0:E.name)||"unknown"}"`;return v(Se.INSTALLATION_LIST,J)?u.jsx(Lt,{message:z}):u.jsx(Hs.Provider,{value:q,children:x?u.jsx($t,{}):e})}return u.jsx(Lt,{message:`Integration "${t}" not found`})}const Us=g.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),Pn=()=>{const e=g.useContext(Us);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Bs({provider:e,groupRef:t,children:n}){const r=Je(),{projectId:i}=De(),[o,s]=g.useState(null),[a,c]=g.useState(null),[l,d]=g.useState(!0),{setError:p,isError:m}=Zt(),{provider:f}=ut();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const v=e||f;if(!v)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");g.useEffect(()=>{Te().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:v},{headers:{"X-Api-Key":r??""}}).then(I=>{d(!1),s(I)}).catch(I=>{console.error(`Error retrieving existing OAuth connections for group ID ${t}.`),Ye(I),d(!1),p(Se.CONNECTION_LIST,i)})},[i,r,t,v,p]);const w=g.useMemo(()=>({connections:o,selectedConnection:a,setConnections:s,setSelectedConnection:c}),[o,a,s,c]);return m(Se.CONNECTION_LIST,i)?u.jsx(Lt,{message:"Error retrieving existing connections"}):u.jsx(Us.Provider,{value:w,children:l?u.jsx($t,{}):n})}const Mp="_resetContainer_lkwv9_4",qs={resetContainer:Mp};var fr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ko(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cr={exports:{}};Cr.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",i=1,o=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",d="[object Boolean]",p="[object Date]",m="[object Error]",f="[object Function]",v="[object GeneratorFunction]",w="[object Map]",I="[object Number]",O="[object Null]",y="[object Object]",x="[object Promise]",b="[object Proxy]",_="[object RegExp]",E="[object Set]",$="[object String]",T="[object Symbol]",J="[object Undefined]",q="[object WeakMap]",z="[object ArrayBuffer]",Y="[object DataView]",ee="[object Float32Array]",U="[object Float64Array]",se="[object Int8Array]",ne="[object Int16Array]",Q="[object Int32Array]",de="[object Uint8Array]",fe="[object Uint8ClampedArray]",S="[object Uint16Array]",P="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,F=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,R={};R[ee]=R[U]=R[se]=R[ne]=R[Q]=R[de]=R[fe]=R[S]=R[P]=!0,R[a]=R[c]=R[z]=R[d]=R[Y]=R[p]=R[m]=R[f]=R[w]=R[I]=R[y]=R[_]=R[E]=R[$]=R[q]=!1;var X=typeof fr=="object"&&fr&&fr.Object===Object&&fr,G=typeof self=="object"&&self&&self.Object===Object&&self,K=X||G||Function("return this")(),Z=t&&!t.nodeType&&t,B=Z&&!0&&e&&!e.nodeType&&e,ae=B&&B.exports===Z,A=ae&&X.process,pe=function(){try{return A&&A.binding&&A.binding("util")}catch{}}(),V=pe&&pe.isTypedArray;function we(h,C){for(var N=-1,W=h==null?0:h.length,be=0,ce=[];++N<W;){var Ne=h[N];C(Ne,N,h)&&(ce[be++]=Ne)}return ce}function Pe(h,C){for(var N=-1,W=C.length,be=h.length;++N<W;)h[be+N]=C[N];return h}function He(h,C){for(var N=-1,W=h==null?0:h.length;++N<W;)if(C(h[N],N,h))return!0;return!1}function Fe(h,C){for(var N=-1,W=Array(h);++N<h;)W[N]=C(N);return W}function me(h){return function(C){return h(C)}}function gt(h,C){return h.has(C)}function Ue(h,C){return h==null?void 0:h[C]}function nt(h){var C=-1,N=Array(h.size);return h.forEach(function(W,be){N[++C]=[be,W]}),N}function vt(h,C){return function(N){return h(C(N))}}function yt(h){var C=-1,N=Array(h.size);return h.forEach(function(W){N[++C]=W}),N}var Be=Array.prototype,$e=Function.prototype,je=Object.prototype,Ce=K["__core-js_shared__"],wt=$e.toString,ze=je.hasOwnProperty,Tt=function(){var h=/[^.]+$/.exec(Ce&&Ce.keys&&Ce.keys.IE_PROTO||"");return h?"Symbol(src)_1."+h:""}(),Kt=je.toString,rt=RegExp("^"+wt.call(ze).replace(M,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oe=ae?K.Buffer:void 0,Rt=K.Symbol,Vt=K.Uint8Array,At=je.propertyIsEnumerable,tn=Be.splice,Ze=Rt?Rt.toStringTag:void 0,Pt=Object.getOwnPropertySymbols,Ht=Oe?Oe.isBuffer:void 0,nn=vt(Object.keys,Object),Ut=wn(K,"DataView"),xe=wn(K,"Map"),Xe=wn(K,"Promise"),te=wn(K,"Set"),ue=wn(K,"WeakMap"),Me=wn(Object,"create"),Dt=sn(Ut),H=sn(xe),re=sn(Xe),ie=sn(te),Re=sn(ue),ke=Rt?Rt.prototype:void 0,Qe=ke?ke.valueOf:void 0;function Ke(h){var C=-1,N=h==null?0:h.length;for(this.clear();++C<N;){var W=h[C];this.set(W[0],W[1])}}function qe(){this.__data__=Me?Me(null):{},this.size=0}function et(h){var C=this.has(h)&&delete this.__data__[h];return this.size-=C?1:0,C}function _e(h){var C=this.__data__;if(Me){var N=C[h];return N===r?void 0:N}return ze.call(C,h)?C[h]:void 0}function rn(h){var C=this.__data__;return Me?C[h]!==void 0:ze.call(C,h)}function Gr(h,C){var N=this.__data__;return this.size+=this.has(h)?0:1,N[h]=Me&&C===void 0?r:C,this}Ke.prototype.clear=qe,Ke.prototype.delete=et,Ke.prototype.get=_e,Ke.prototype.has=rn,Ke.prototype.set=Gr;function dt(h){var C=-1,N=h==null?0:h.length;for(this.clear();++C<N;){var W=h[C];this.set(W[0],W[1])}}function nr(){this.__data__=[],this.size=0}function rr(h){var C=this.__data__,N=sr(C,h);if(N<0)return!1;var W=C.length-1;return N==W?C.pop():tn.call(C,N,1),--this.size,!0}function or(h){var C=this.__data__,N=sr(C,h);return N<0?void 0:C[N][1]}function Ie(h){return sr(this.__data__,h)>-1}function It(h,C){var N=this.__data__,W=sr(N,h);return W<0?(++this.size,N.push([h,C])):N[W][1]=C,this}dt.prototype.clear=nr,dt.prototype.delete=rr,dt.prototype.get=or,dt.prototype.has=Ie,dt.prototype.set=It;function _t(h){var C=-1,N=h==null?0:h.length;for(this.clear();++C<N;){var W=h[C];this.set(W[0],W[1])}}function on(){this.size=0,this.__data__={hash:new Ke,map:new(xe||dt),string:new Ke}}function Yr(h){var C=ar(this,h).delete(h);return this.size-=C?1:0,C}function jn(h){return ar(this,h).get(h)}function Qc(h){return ar(this,h).has(h)}function el(h,C){var N=ar(this,h),W=N.size;return N.set(h,C),this.size+=N.size==W?0:1,this}_t.prototype.clear=on,_t.prototype.delete=Yr,_t.prototype.get=jn,_t.prototype.has=Qc,_t.prototype.set=el;function ir(h){var C=-1,N=h==null?0:h.length;for(this.__data__=new _t;++C<N;)this.add(h[C])}function tl(h){return this.__data__.set(h,r),this}function nl(h){return this.__data__.has(h)}ir.prototype.add=ir.prototype.push=tl,ir.prototype.has=nl;function Bt(h){var C=this.__data__=new dt(h);this.size=C.size}function rl(){this.__data__=new dt,this.size=0}function ol(h){var C=this.__data__,N=C.delete(h);return this.size=C.size,N}function il(h){return this.__data__.get(h)}function sl(h){return this.__data__.has(h)}function al(h,C){var N=this.__data__;if(N instanceof dt){var W=N.__data__;if(!xe||W.length<n-1)return W.push([h,C]),this.size=++N.size,this;N=this.__data__=new _t(W)}return N.set(h,C),this.size=N.size,this}Bt.prototype.clear=rl,Bt.prototype.delete=ol,Bt.prototype.get=il,Bt.prototype.has=sl,Bt.prototype.set=al;function cl(h,C){var N=cr(h),W=!N&&xl(h),be=!N&&!W&&Zr(h),ce=!N&&!W&&!be&&Ti(h),Ne=N||W||be||ce,Ve=Ne?Fe(h.length,String):[],We=Ve.length;for(var Ee in h)ze.call(h,Ee)&&!(Ne&&(Ee=="length"||be&&(Ee=="offset"||Ee=="parent")||ce&&(Ee=="buffer"||Ee=="byteLength"||Ee=="byteOffset")||yl(Ee,We)))&&Ve.push(Ee);return Ve}function sr(h,C){for(var N=h.length;N--;)if(Oi(h[N][0],C))return N;return-1}function ll(h,C,N){var W=C(h);return cr(h)?W:Pe(W,N(h))}function Mn(h){return h==null?h===void 0?J:O:Ze&&Ze in Object(h)?gl(h):bl(h)}function _i(h){return kn(h)&&Mn(h)==a}function bi(h,C,N,W,be){return h===C?!0:h==null||C==null||!kn(h)&&!kn(C)?h!==h&&C!==C:ul(h,C,N,W,bi,be)}function ul(h,C,N,W,be,ce){var Ne=cr(h),Ve=cr(C),We=Ne?c:qt(h),Ee=Ve?c:qt(C);We=We==a?y:We,Ee=Ee==a?y:Ee;var ot=We==y,bt=Ee==y,Ge=We==Ee;if(Ge&&Zr(h)){if(!Zr(C))return!1;Ne=!0,ot=!1}if(Ge&&!ot)return ce||(ce=new Bt),Ne||Ti(h)?xi(h,C,N,W,be,ce):ml(h,C,We,N,W,be,ce);if(!(N&i)){var pt=ot&&ze.call(h,"__wrapped__"),ft=bt&&ze.call(C,"__wrapped__");if(pt||ft){var Wt=pt?h.value():h,Ft=ft?C.value():C;return ce||(ce=new Bt),be(Wt,Ft,N,W,ce)}}return Ge?(ce||(ce=new Bt),hl(h,C,N,W,be,ce)):!1}function dl(h){if(!Ni(h)||Il(h))return!1;var C=Ei(h)?rt:F;return C.test(sn(h))}function pl(h){return kn(h)&&Si(h.length)&&!!R[Mn(h)]}function fl(h){if(!_l(h))return nn(h);var C=[];for(var N in Object(h))ze.call(h,N)&&N!="constructor"&&C.push(N);return C}function xi(h,C,N,W,be,ce){var Ne=N&i,Ve=h.length,We=C.length;if(Ve!=We&&!(Ne&&We>Ve))return!1;var Ee=ce.get(h);if(Ee&&ce.get(C))return Ee==C;var ot=-1,bt=!0,Ge=N&o?new ir:void 0;for(ce.set(h,C),ce.set(C,h);++ot<Ve;){var pt=h[ot],ft=C[ot];if(W)var Wt=Ne?W(ft,pt,ot,C,h,ce):W(pt,ft,ot,h,C,ce);if(Wt!==void 0){if(Wt)continue;bt=!1;break}if(Ge){if(!He(C,function(Ft,an){if(!gt(Ge,an)&&(pt===Ft||be(pt,Ft,N,W,ce)))return Ge.push(an)})){bt=!1;break}}else if(!(pt===ft||be(pt,ft,N,W,ce))){bt=!1;break}}return ce.delete(h),ce.delete(C),bt}function ml(h,C,N,W,be,ce,Ne){switch(N){case Y:if(h.byteLength!=C.byteLength||h.byteOffset!=C.byteOffset)return!1;h=h.buffer,C=C.buffer;case z:return!(h.byteLength!=C.byteLength||!ce(new Vt(h),new Vt(C)));case d:case p:case I:return Oi(+h,+C);case m:return h.name==C.name&&h.message==C.message;case _:case $:return h==C+"";case w:var Ve=nt;case E:var We=W&i;if(Ve||(Ve=yt),h.size!=C.size&&!We)return!1;var Ee=Ne.get(h);if(Ee)return Ee==C;W|=o,Ne.set(h,C);var ot=xi(Ve(h),Ve(C),W,be,ce,Ne);return Ne.delete(h),ot;case T:if(Qe)return Qe.call(h)==Qe.call(C)}return!1}function hl(h,C,N,W,be,ce){var Ne=N&i,Ve=Ci(h),We=Ve.length,Ee=Ci(C),ot=Ee.length;if(We!=ot&&!Ne)return!1;for(var bt=We;bt--;){var Ge=Ve[bt];if(!(Ne?Ge in C:ze.call(C,Ge)))return!1}var pt=ce.get(h);if(pt&&ce.get(C))return pt==C;var ft=!0;ce.set(h,C),ce.set(C,h);for(var Wt=Ne;++bt<We;){Ge=Ve[bt];var Ft=h[Ge],an=C[Ge];if(W)var Ri=Ne?W(an,Ft,Ge,C,h,ce):W(Ft,an,Ge,h,C,ce);if(!(Ri===void 0?Ft===an||be(Ft,an,N,W,ce):Ri)){ft=!1;break}Wt||(Wt=Ge=="constructor")}if(ft&&!Wt){var lr=h.constructor,ur=C.constructor;lr!=ur&&"constructor"in h&&"constructor"in C&&!(typeof lr=="function"&&lr instanceof lr&&typeof ur=="function"&&ur instanceof ur)&&(ft=!1)}return ce.delete(h),ce.delete(C),ft}function Ci(h){return ll(h,El,vl)}function ar(h,C){var N=h.__data__;return wl(C)?N[typeof C=="string"?"string":"hash"]:N.map}function wn(h,C){var N=Ue(h,C);return dl(N)?N:void 0}function gl(h){var C=ze.call(h,Ze),N=h[Ze];try{h[Ze]=void 0;var W=!0}catch{}var be=Kt.call(h);return W&&(C?h[Ze]=N:delete h[Ze]),be}var vl=Pt?function(h){return h==null?[]:(h=Object(h),we(Pt(h),function(C){return At.call(h,C)}))}:Sl,qt=Mn;(Ut&&qt(new Ut(new ArrayBuffer(1)))!=Y||xe&&qt(new xe)!=w||Xe&&qt(Xe.resolve())!=x||te&&qt(new te)!=E||ue&&qt(new ue)!=q)&&(qt=function(h){var C=Mn(h),N=C==y?h.constructor:void 0,W=N?sn(N):"";if(W)switch(W){case Dt:return Y;case H:return w;case re:return x;case ie:return E;case Re:return q}return C});function yl(h,C){return C=C??s,!!C&&(typeof h=="number"||D.test(h))&&h>-1&&h%1==0&&h<C}function wl(h){var C=typeof h;return C=="string"||C=="number"||C=="symbol"||C=="boolean"?h!=="__proto__":h===null}function Il(h){return!!Tt&&Tt in h}function _l(h){var C=h&&h.constructor,N=typeof C=="function"&&C.prototype||je;return h===N}function bl(h){return Kt.call(h)}function sn(h){if(h!=null){try{return wt.call(h)}catch{}try{return h+""}catch{}}return""}function Oi(h,C){return h===C||h!==h&&C!==C}var xl=_i(function(){return arguments}())?_i:function(h){return kn(h)&&ze.call(h,"callee")&&!At.call(h,"callee")},cr=Array.isArray;function Cl(h){return h!=null&&Si(h.length)&&!Ei(h)}var Zr=Ht||Nl;function Ol(h,C){return bi(h,C)}function Ei(h){if(!Ni(h))return!1;var C=Mn(h);return C==f||C==v||C==l||C==b}function Si(h){return typeof h=="number"&&h>-1&&h%1==0&&h<=s}function Ni(h){var C=typeof h;return h!=null&&(C=="object"||C=="function")}function kn(h){return h!=null&&typeof h=="object"}var Ti=V?me(V):pl;function El(h){return Cl(h)?cl(h):fl(h)}function Sl(){return[]}function Nl(){return!1}e.exports=Ol})(Cr,Cr.exports);var kp=Cr.exports;const Lp=ko(kp),pn="other",Or="uninstall-installation";function Xt(e){return!e.fieldName}function $p(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function Kp(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Xt(n)&&!!n.fieldName))||null}function Vp(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>Xt(r)&&!!r.mapToName))||[]}function Hp(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Xt(n)&&!!n.fieldName))||null}const Ws=(e,t)=>{var n,r,i;return(i=(r=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:r.objects)==null?void 0:i[t]};function Up(e){return Xt(e)?e.mapToName:e.fieldName}const Js=(e,t)=>{var r,i,o;const n=[];return(o=(i=(r=t.content)==null?void 0:r.read)==null?void 0:i.objects)==null||o.forEach(s=>{n.push({name:s==null?void 0:s.objectName,displayName:(s==null?void 0:s.mapToDisplayName)||(s==null?void 0:s.displayName)||(s==null?void 0:s.objectName)&&Un(s==null?void 0:s.objectName),completed:e?!!Ws(e,s.objectName):!1})}),n},zs=e=>{var n;return{name:pn,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function Bp(e,t){var o;const n=Js(e,t),i=!!((o=t==null?void 0:t.content)!=null&&o.write)?zs(e):void 0;return i&&n.push(i),n}function Xs(e,t,n){const r=(e==null?void 0:e.filter(o=>!(t!=null&&t[o==null?void 0:o.mapToName])))||[],i=r.map(o=>o.mapToName);return n(Se.MAPPING,i),r!=null&&r.length&&console.error("required fields not met",r.map(o=>o.mapToDisplayName)),{errorList:i}}function Lo(e,t){return Lp(e,t)}const qp=(e,t,n)=>{var f,v,w,I,O,y;if(!e)return null;const r=$p(e,t),i=r&&Kp(r),o=r&&Hp(r),s=r&&Vp(r),a=(r==null?void 0:r.allFields)||[],c=n==null?void 0:n.content,l=((w=(v=(f=c==null?void 0:c.read)==null?void 0:f.objects)==null?void 0:v[t])==null?void 0:w.selectedFields)||{},d=((y=(O=(I=c==null?void 0:c.read)==null?void 0:I.objects)==null?void 0:O[t])==null?void 0:y.selectedFieldMappings)||{},p={...l},m={...d};return{allFields:a,requiredFields:i,optionalFields:o,requiredMapFields:s,selectedOptionalFields:l,selectedFieldMappings:d,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:p,requiredMapFields:m}}},Wp=(e,t)=>{var s,a;if(!e)return null;const n=(a=(s=t==null?void 0:t.content)==null?void 0:s.write)==null?void 0:a.objects,r=Object.keys(n||{}),i={};r.forEach(c=>{i[c]=!0});const o={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:o}}};function Gs(e,t,n){var o,s;const r=(o=e==null?void 0:e.content)==null?void 0:o.read,i=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:qp(r,t,n),write:Wp(i,n)}}const Ys=(e,t,n,r)=>{const i=Gs(e,n,t);r(n,i)},Jp=(e,t,n)=>{const r=Bp(t,e),i={};r.forEach(({name:o,completed:s})=>{s&&(i[o]=Gs(e,o,t))}),n(i)},Zs=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(o=>r.add(Up(o))),{...Array.from(r).reduce((o,s)=>({...o,[s]:!0}),{}),...n||{}}},Qs=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(r=>{t[r]!==void 0?n[r]=t[r]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${r}`)}),n};function ea(e,t){return t[e]||void 0}async function $o({createConfig:e,projectId:t,integrationId:n,groupRef:r,connectionId:i,apiKey:o,setError:s,setInstallation:a,onInstallSuccess:c}){const l={projectIdOrName:t,integrationId:n,installation:{groupRef:r,connectionId:i,config:e}};try{const d=await Te().installationApi.createInstallation(l,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}});a(d),c==null||c(d.id,d.config)}catch(d){Ye(d,s)}}function $r(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const zp=(e,t)=>{const n=e.content.read,r=n==null?void 0:n.objects;return r==null?void 0:r.find(i=>i.objectName===t)},Xp=(e,t,n,r)=>{const i=Zs(e),o=Qs(e),s=zp(n,t);if(!s)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const a={revisionId:n.id,createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:s.schedule,destination:s.destination,selectedFields:i,selectedFieldMappings:o,backfill:s.backfill}}}}};return $r(n)&&(a.content.proxy={enabled:!0}),a},Gp=(e,t,n,r,i,o,s,a,c,l,d,p)=>{const m=Xp(c,o,a,r);return m?$o({createConfig:m,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:s,setError:l,setInstallation:d,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ta=e=>{var o,s;const t={},n=(o=e.write)==null?void 0:o.writeObjects,r=(s=e.write)==null?void 0:s.selectedNonConfigurableWriteFields,i=r?Object.keys(r):[];return n&&n.forEach(a=>{const c=a.objectName;i.includes(c)&&(t[c]={objectName:c})}),t},Yp=e=>{const t=e.content.write;return t==null?void 0:t.objects},Zp=(e,t,n)=>{if(!Yp(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=ta(e),o={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return $r(t)&&(o.content.proxy={enabled:!0}),o},Qp=(e,t,n,r,i,o,s,a,c,l,d)=>{const p=Zp(a,s,r);return p?$o({createConfig:p,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:o,setError:c,setInstallation:l,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ef={backgroundColor:"var(--amp-colors-status-critical-muted)",borderColor:"var(--amp-colors-status-critical-muted)",color:"var(--amp-colors-status-critical-dark)",padding:".5rem 1rem"};function na({children:e,style:t}){return u.jsx(vn,{style:{...ef,...t},children:e})}var ra={exports:{}};/*!
|
|
@@ -46,4 +46,4 @@ Valid keys: `+JSON.stringify(Object.keys(S),null," "));var A=ae(G,B,D,R,X+"."+B
|
|
|
46
46
|
* @copyright ReactTooltip Team
|
|
47
47
|
* @license MIT
|
|
48
48
|
*/const Qm="react-tooltip-core-styles",eh="react-tooltip-base-styles",cs={core:!1,base:!1};function ls({css:e,id:t=eh,type:n="base",ref:r}){var i,o;if(!e||typeof document>"u"||cs[n]||n==="core"&&typeof process<"u"&&(!((i=process==null?void 0:process.env)===null||i===void 0)&&i.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((o=process==null?void 0:process.env)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Qm),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.id=t,c.type="text/css",s==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e)),cs[n]=!0}const us=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:i=10,strategy:o="absolute",middlewares:s=[Xm(Number(i)),Ym({fallbackAxisSideDirection:"start"}),Gm({padding:5})],border:a})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const c=s;return n?(c.push(Zm({element:n,padding:5})),as(e,t,{placement:r,strategy:o,middleware:c}).then(({x:l,y:d,placement:p,middlewareData:m})=>{var f,v;const w={left:`${l}px`,top:`${d}px`,border:a},{x:I,y:O}=(f=m.arrow)!==null&&f!==void 0?f:{x:0,y:0},y=(v={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&v!==void 0?v:"bottom",x=a&&{borderBottom:a,borderRight:a};let b=0;if(a){const _=`${a}`.match(/(\d+)px/);b=_!=null&&_[1]?Number(_[1]):1}return{tooltipStyles:w,tooltipArrowStyles:{left:I!=null?`${I}px`:"",top:O!=null?`${O}px`:"",right:"",bottom:"",...x,[y]:`-${4+b}px`},place:p}})):as(e,t,{placement:"bottom",strategy:o,middleware:c}).then(({x:l,y:d,placement:p})=>({tooltipStyles:{left:`${l}px`,top:`${d}px`},tooltipArrowStyles:{},place:p}))},ds=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),ps=(e,t,n)=>{let r=null;const i=function(...o){const s=()=>{r=null};!r&&(e.apply(this,o),r=setTimeout(s,t))};return i.cancel=()=>{r&&(clearTimeout(r),r=null)},i},fs=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",So=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((i,o)=>So(i,t[o]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!fs(e)||!fs(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(i=>So(e[i],t[i]))},th=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some(n=>{const r=t.getPropertyValue(n);return r==="auto"||r==="scroll"})},ms=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(th(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},nh=typeof window<"u"?g.useLayoutEffect:g.useEffect,mt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},rh="DEFAULT_TOOLTIP_ID",oh={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},ih=g.createContext({getTooltipData:()=>oh});function Za(e=rh){return g.useContext(ih).getTooltipData(e)}var In={tooltip:"core-styles-module_tooltip__3vRRp",fixed:"core-styles-module_fixed__pcSol",arrow:"core-styles-module_arrow__cvMwQ",noArrow:"core-styles-module_noArrow__xock6",clickable:"core-styles-module_clickable__ZuTTB",show:"core-styles-module_show__Nt9eE",closing:"core-styles-module_closing__sGnxF"},uo={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const sh=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:i="dark",anchorId:o,anchorSelect:s,place:a="top",offset:c=10,events:l=["hover"],openOnClick:d=!1,positionStrategy:p="absolute",middlewares:m,wrapper:f,delayShow:v=0,delayHide:w=0,float:I=!1,hidden:O=!1,noArrow:y=!1,clickable:x=!1,closeOnEsc:b=!1,closeOnScroll:_=!1,closeOnResize:E=!1,openEvents:$,closeEvents:T,globalCloseEvents:J,imperativeModeOnly:q,style:z,position:Y,afterShow:ee,afterHide:U,disableTooltip:se,content:ne,contentWrapperRef:Q,isOpen:de,defaultIsOpen:fe=!1,setIsOpen:S,activeAnchor:P,setActiveAnchor:M,border:F,opacity:D,arrowColor:R,role:X="tooltip"})=>{var G;const K=g.useRef(null),Z=g.useRef(null),B=g.useRef(null),ae=g.useRef(null),A=g.useRef(null),[pe,V]=g.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[we,Pe]=g.useState(!1),[He,Fe]=g.useState(!1),[me,gt]=g.useState(null),Ue=g.useRef(!1),nt=g.useRef(null),{anchorRefs:vt,setActiveAnchor:yt}=Za(t),Be=g.useRef(!1),[$e,je]=g.useState([]),Ce=g.useRef(!1),wt=d||l.includes("click"),ze=wt||($==null?void 0:$.click)||($==null?void 0:$.dblclick)||($==null?void 0:$.mousedown),Tt=$?{...$}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!$&&wt&&Object.assign(Tt,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const Kt=T?{...T}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!T&&wt&&Object.assign(Kt,{mouseleave:!1,blur:!1,mouseout:!1});const rt=J?{...J}:{escape:b||!1,scroll:_||!1,resize:E||!1,clickOutsideAnchor:ze||!1};q&&(Object.assign(Tt,{mouseenter:!1,focus:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(Kt,{mouseleave:!1,blur:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(rt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),nh(()=>(Ce.current=!0,()=>{Ce.current=!1}),[]);const Oe=H=>{Ce.current&&(H&&Fe(!0),setTimeout(()=>{Ce.current&&(S==null||S(H),de===void 0&&Pe(H))},10))};g.useEffect(()=>{if(de===void 0)return()=>null;de&&Fe(!0);const H=setTimeout(()=>{Pe(de)},10);return()=>{clearTimeout(H)}},[de]),g.useEffect(()=>{if(we!==Ue.current)if(mt(A),Ue.current=we,we)ee==null||ee();else{const H=(re=>{const ie=re.match(/^([\d.]+)(ms|s)$/);if(!ie)return 0;const[,Re,ke]=ie;return Number(Re)*(ke==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));A.current=setTimeout(()=>{Fe(!1),gt(null),U==null||U()},H+25)}},[we]);const Rt=H=>{V(re=>So(re,H)?re:H)},Vt=(H=v)=>{mt(B),He?Oe(!0):B.current=setTimeout(()=>{Oe(!0)},H)},At=(H=w)=>{mt(ae),ae.current=setTimeout(()=>{Be.current||Oe(!1)},H)},tn=H=>{var re;if(!H)return;const ie=(re=H.currentTarget)!==null&&re!==void 0?re:H.target;if(!(ie!=null&&ie.isConnected))return M(null),void yt({current:null});v?Vt():Oe(!0),M(ie),yt({current:ie}),mt(ae)},Ze=()=>{x?At(w||100):w?At():Oe(!1),mt(B)},Pt=({x:H,y:re})=>{var ie;const Re={getBoundingClientRect:()=>({x:H,y:re,width:0,height:0,top:re,left:H,right:H,bottom:re})};us({place:(ie=me==null?void 0:me.place)!==null&&ie!==void 0?ie:a,offset:c,elementReference:Re,tooltipReference:K.current,tooltipArrowReference:Z.current,strategy:p,middlewares:m,border:F}).then(ke=>{Rt(ke)})},Ht=H=>{if(!H)return;const re=H,ie={x:re.clientX,y:re.clientY};Pt(ie),nt.current=ie},nn=H=>{var re;if(!we)return;const ie=H.target;ie.isConnected&&(!((re=K.current)===null||re===void 0)&&re.contains(ie)||[document.querySelector(`[id='${o}']`),...$e].some(Re=>Re==null?void 0:Re.contains(ie))||(Oe(!1),mt(B)))},Ut=ps(tn,50),xe=ps(Ze,50),Xe=H=>{xe.cancel(),Ut(H)},te=()=>{Ut.cancel(),xe()},ue=g.useCallback(()=>{var H,re;const ie=(H=me==null?void 0:me.position)!==null&&H!==void 0?H:Y;ie?Pt(ie):I?nt.current&&Pt(nt.current):P!=null&&P.isConnected&&us({place:(re=me==null?void 0:me.place)!==null&&re!==void 0?re:a,offset:c,elementReference:P,tooltipReference:K.current,tooltipArrowReference:Z.current,strategy:p,middlewares:m,border:F}).then(Re=>{Ce.current&&Rt(Re)})},[we,P,ne,z,a,me==null?void 0:me.place,c,p,Y,me==null?void 0:me.position,I]);g.useEffect(()=>{var H,re;const ie=new Set(vt);$e.forEach(Ie=>{se!=null&&se(Ie)||ie.add({current:Ie})});const Re=document.querySelector(`[id='${o}']`);Re&&!(se!=null&&se(Re))&&ie.add({current:Re});const ke=()=>{Oe(!1)},Qe=ms(P),Ke=ms(K.current);rt.scroll&&(window.addEventListener("scroll",ke),Qe==null||Qe.addEventListener("scroll",ke),Ke==null||Ke.addEventListener("scroll",ke));let qe=null;rt.resize?window.addEventListener("resize",ke):P&&K.current&&(qe=zm(P,K.current,ue,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const et=Ie=>{Ie.key==="Escape"&&Oe(!1)};rt.escape&&window.addEventListener("keydown",et),rt.clickOutsideAnchor&&window.addEventListener("click",nn);const _e=[],rn=Ie=>{we&&(Ie==null?void 0:Ie.target)===P||tn(Ie)},Gr=Ie=>{we&&(Ie==null?void 0:Ie.target)===P&&Ze()},dt=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],nr=["click","dblclick","mousedown","mouseup"];Object.entries(Tt).forEach(([Ie,It])=>{It&&(dt.includes(Ie)?_e.push({event:Ie,listener:Xe}):nr.includes(Ie)&&_e.push({event:Ie,listener:rn}))}),Object.entries(Kt).forEach(([Ie,It])=>{It&&(dt.includes(Ie)?_e.push({event:Ie,listener:te}):nr.includes(Ie)&&_e.push({event:Ie,listener:Gr}))}),I&&_e.push({event:"pointermove",listener:Ht});const rr=()=>{Be.current=!0},or=()=>{Be.current=!1,Ze()};return x&&!ze&&((H=K.current)===null||H===void 0||H.addEventListener("mouseenter",rr),(re=K.current)===null||re===void 0||re.addEventListener("mouseleave",or)),_e.forEach(({event:Ie,listener:It})=>{ie.forEach(_t=>{var on;(on=_t.current)===null||on===void 0||on.addEventListener(Ie,It)})}),()=>{var Ie,It;rt.scroll&&(window.removeEventListener("scroll",ke),Qe==null||Qe.removeEventListener("scroll",ke),Ke==null||Ke.removeEventListener("scroll",ke)),rt.resize?window.removeEventListener("resize",ke):qe==null||qe(),rt.clickOutsideAnchor&&window.removeEventListener("click",nn),rt.escape&&window.removeEventListener("keydown",et),x&&!ze&&((Ie=K.current)===null||Ie===void 0||Ie.removeEventListener("mouseenter",rr),(It=K.current)===null||It===void 0||It.removeEventListener("mouseleave",or)),_e.forEach(({event:_t,listener:on})=>{ie.forEach(Yr=>{var jn;(jn=Yr.current)===null||jn===void 0||jn.removeEventListener(_t,on)})})}},[P,ue,He,vt,$e,$,T,J,wt,v,w]),g.useEffect(()=>{var H,re;let ie=(re=(H=me==null?void 0:me.anchorSelect)!==null&&H!==void 0?H:s)!==null&&re!==void 0?re:"";!ie&&t&&(ie=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Re=new MutationObserver(ke=>{const Qe=[],Ke=[];ke.forEach(qe=>{if(qe.type==="attributes"&&qe.attributeName==="data-tooltip-id"&&(qe.target.getAttribute("data-tooltip-id")===t?Qe.push(qe.target):qe.oldValue===t&&Ke.push(qe.target)),qe.type==="childList"){if(P){const et=[...qe.removedNodes].filter(_e=>_e.nodeType===1);if(ie)try{Ke.push(...et.filter(_e=>_e.matches(ie))),Ke.push(...et.flatMap(_e=>[..._e.querySelectorAll(ie)]))}catch{}et.some(_e=>{var rn;return!!(!((rn=_e==null?void 0:_e.contains)===null||rn===void 0)&&rn.call(_e,P))&&(Fe(!1),Oe(!1),M(null),mt(B),mt(ae),!0)})}if(ie)try{const et=[...qe.addedNodes].filter(_e=>_e.nodeType===1);Qe.push(...et.filter(_e=>_e.matches(ie))),Qe.push(...et.flatMap(_e=>[..._e.querySelectorAll(ie)]))}catch{}}}),(Qe.length||Ke.length)&&je(qe=>[...qe.filter(et=>!Ke.includes(et)),...Qe])});return Re.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Re.disconnect()}},[t,s,me==null?void 0:me.anchorSelect,P]),g.useEffect(()=>{ue()},[ue]),g.useEffect(()=>{if(!(Q!=null&&Q.current))return()=>null;const H=new ResizeObserver(()=>{setTimeout(()=>ue())});return H.observe(Q.current),()=>{H.disconnect()}},[ne,Q==null?void 0:Q.current]),g.useEffect(()=>{var H;const re=document.querySelector(`[id='${o}']`),ie=[...$e,re];P&&ie.includes(P)||M((H=$e[0])!==null&&H!==void 0?H:re)},[o,$e,P]),g.useEffect(()=>(fe&&Oe(!0),()=>{mt(B),mt(ae)}),[]),g.useEffect(()=>{var H;let re=(H=me==null?void 0:me.anchorSelect)!==null&&H!==void 0?H:s;if(!re&&t&&(re=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),re)try{const ie=Array.from(document.querySelectorAll(re));je(ie)}catch{je([])}},[t,s,me==null?void 0:me.anchorSelect]),g.useEffect(()=>{B.current&&(mt(B),Vt(v))},[v]);const Me=(G=me==null?void 0:me.content)!==null&&G!==void 0?G:ne,Dt=we&&Object.keys(pe.tooltipStyles).length>0;return g.useImperativeHandle(e,()=>({open:H=>{if(H!=null&&H.anchorSelect)try{document.querySelector(H.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${H.anchorSelect}" is not a valid CSS selector`)}gt(H??null),H!=null&&H.delay?Vt(H.delay):Oe(!0)},close:H=>{H!=null&&H.delay?At(H.delay):Oe(!1)},activeAnchor:P,place:pe.place,isOpen:!!(He&&!O&&Me&&Dt)})),He&&!O&&Me?g.createElement(f,{id:t,role:X,className:st("react-tooltip",In.tooltip,uo.tooltip,uo[i],n,`react-tooltip__place-${pe.place}`,In[Dt?"show":"closing"],Dt?"react-tooltip__show":"react-tooltip__closing",p==="fixed"&&In.fixed,x&&In.clickable),onTransitionEnd:H=>{mt(A),we||H.propertyName!=="opacity"||(Fe(!1),gt(null),U==null||U())},style:{...z,...pe.tooltipStyles,opacity:D!==void 0&&Dt?D:void 0},ref:K},Me,g.createElement(f,{className:st("react-tooltip-arrow",In.arrow,uo.arrow,r,y&&In.noArrow),style:{...pe.tooltipArrowStyles,background:R?`linear-gradient(to right bottom, transparent 50%, ${R} 50%)`:void 0},ref:Z})):null},ah=({content:e})=>g.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),ch=g.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:i,render:o,className:s,classNameArrow:a,variant:c="dark",place:l="top",offset:d=10,wrapper:p="div",children:m=null,events:f=["hover"],openOnClick:v=!1,positionStrategy:w="absolute",middlewares:I,delayShow:O=0,delayHide:y=0,float:x=!1,hidden:b=!1,noArrow:_=!1,clickable:E=!1,closeOnEsc:$=!1,closeOnScroll:T=!1,closeOnResize:J=!1,openEvents:q,closeEvents:z,globalCloseEvents:Y,imperativeModeOnly:ee=!1,style:U,position:se,isOpen:ne,defaultIsOpen:Q=!1,disableStyleInjection:de=!1,border:fe,opacity:S,arrowColor:P,setIsOpen:M,afterShow:F,afterHide:D,disableTooltip:R,role:X="tooltip"},G)=>{const[K,Z]=g.useState(r),[B,ae]=g.useState(i),[A,pe]=g.useState(l),[V,we]=g.useState(c),[Pe,He]=g.useState(d),[Fe,me]=g.useState(O),[gt,Ue]=g.useState(y),[nt,vt]=g.useState(x),[yt,Be]=g.useState(b),[$e,je]=g.useState(p),[Ce,wt]=g.useState(f),[ze,Tt]=g.useState(w),[Kt,rt]=g.useState(null),[Oe,Rt]=g.useState(null),Vt=g.useRef(de),{anchorRefs:At,activeAnchor:tn}=Za(e),Ze=xe=>xe==null?void 0:xe.getAttributeNames().reduce((Xe,te)=>{var ue;return te.startsWith("data-tooltip-")&&(Xe[te.replace(/^data-tooltip-/,"")]=(ue=xe==null?void 0:xe.getAttribute(te))!==null&&ue!==void 0?ue:null),Xe},{}),Pt=xe=>{const Xe={place:te=>{var ue;pe((ue=te)!==null&&ue!==void 0?ue:l)},content:te=>{Z(te??r)},html:te=>{ae(te??i)},variant:te=>{var ue;we((ue=te)!==null&&ue!==void 0?ue:c)},offset:te=>{He(te===null?d:Number(te))},wrapper:te=>{var ue;je((ue=te)!==null&&ue!==void 0?ue:p)},events:te=>{const ue=te==null?void 0:te.split(" ");wt(ue??f)},"position-strategy":te=>{var ue;Tt((ue=te)!==null&&ue!==void 0?ue:w)},"delay-show":te=>{me(te===null?O:Number(te))},"delay-hide":te=>{Ue(te===null?y:Number(te))},float:te=>{vt(te===null?x:te==="true")},hidden:te=>{Be(te===null?b:te==="true")},"class-name":te=>{rt(te)}};Object.values(Xe).forEach(te=>te(null)),Object.entries(xe).forEach(([te,ue])=>{var Me;(Me=Xe[te])===null||Me===void 0||Me.call(Xe,ue)})};g.useEffect(()=>{Z(r)},[r]),g.useEffect(()=>{ae(i)},[i]),g.useEffect(()=>{pe(l)},[l]),g.useEffect(()=>{we(c)},[c]),g.useEffect(()=>{He(d)},[d]),g.useEffect(()=>{me(O)},[O]),g.useEffect(()=>{Ue(y)},[y]),g.useEffect(()=>{vt(x)},[x]),g.useEffect(()=>{Be(b)},[b]),g.useEffect(()=>{Tt(w)},[w]),g.useEffect(()=>{Vt.current!==de&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[de]),g.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:de==="core",disableBase:de}}))},[]),g.useEffect(()=>{var xe;const Xe=new Set(At);let te=n;if(!te&&e&&(te=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),te)try{document.querySelectorAll(te).forEach(re=>{Xe.add({current:re})})}catch{console.warn(`[react-tooltip] "${te}" is not a valid CSS selector`)}const ue=document.querySelector(`[id='${t}']`);if(ue&&Xe.add({current:ue}),!Xe.size)return()=>null;const Me=(xe=Oe??ue)!==null&&xe!==void 0?xe:tn.current,Dt=new MutationObserver(re=>{re.forEach(ie=>{var Re;if(!Me||ie.type!=="attributes"||!(!((Re=ie.attributeName)===null||Re===void 0)&&Re.startsWith("data-tooltip-")))return;const ke=Ze(Me);Pt(ke)})}),H={attributes:!0,childList:!1,subtree:!1};if(Me){const re=Ze(Me);Pt(re),Dt.observe(Me,H)}return()=>{Dt.disconnect()}},[At,tn,Oe,t,n]),g.useEffect(()=>{U!=null&&U.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),fe&&!ds("border",`${fe}`)&&console.warn(`[react-tooltip] "${fe}" is not a valid \`border\`.`),U!=null&&U.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),S&&!ds("opacity",`${S}`)&&console.warn(`[react-tooltip] "${S}" is not a valid \`opacity\`.`)},[]);let Ht=m;const nn=g.useRef(null);if(o){const xe=o({content:(Oe==null?void 0:Oe.getAttribute("data-tooltip-content"))||K||null,activeAnchor:Oe});Ht=xe?g.createElement("div",{ref:nn,className:"react-tooltip-content-wrapper"},xe):null}else K&&(Ht=K);B&&(Ht=g.createElement(ah,{content:B}));const Ut={forwardRef:G,id:e,anchorId:t,anchorSelect:n,className:st(s,Kt),classNameArrow:a,content:Ht,contentWrapperRef:nn,place:A,variant:V,offset:Pe,wrapper:$e,events:Ce,openOnClick:v,positionStrategy:ze,middlewares:I,delayShow:Fe,delayHide:gt,float:nt,hidden:yt,noArrow:_,clickable:E,closeOnEsc:$,closeOnScroll:T,closeOnResize:J,openEvents:q,closeEvents:z,globalCloseEvents:Y,imperativeModeOnly:ee,style:U,position:se,isOpen:ne,defaultIsOpen:Q,border:fe,opacity:S,arrowColor:P,setIsOpen:M,afterShow:F,afterHide:D,disableTooltip:R,activeAnchor:Oe,setActiveAnchor:xe=>Rt(xe),role:X};return g.createElement(sh,{...Ut})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||ls({css:":root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9;--rt-transition-show-delay:0.15s;--rt-transition-closing-delay:0.15s}.core-styles-module_tooltip__3vRRp{position:absolute;top:0;left:0;pointer-events:none;opacity:0;will-change:opacity}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{opacity:var(--rt-opacity);transition:opacity var(--rt-transition-show-delay)ease-out}.core-styles-module_closing__sGnxF{opacity:0;transition:opacity var(--rt-transition-closing-delay)ease-in}",type:"core"}),e.detail.disableBase||ls({css:`
|
|
49
|
-
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})});function lh(){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[u.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[u.jsx("path",{d:"M8.00032 11.167L8.00032 7.83366M8.00032 1.83366C4.33366 1.83366 1.33366 4.83366 1.33366 8.50033C1.33366 12.167 4.33366 15.167 8.00033 15.167C11.667 15.167 14.667 12.167 14.667 8.50033C14.667 4.83366 11.667 1.83366 8.00032 1.83366Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("defs",{children:u.jsx("clipPath",{id:"clip0_2896_16290",children:u.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function uh({id:e,tooltipText:t}){return u.jsxs(u.Fragment,{children:[u.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:lh()}),u.jsx(ch,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const Qa=g.createContext(null);function ec(){const e=g.useContext(Qa);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const tc=g.createContext(()=>{});function dh(){const e=g.useContext(tc);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var nc=Symbol.for("immer-nothing"),hs=Symbol.for("immer-draftable"),ct=Symbol.for("immer-state"),ph=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 tt(e,...t){if(process.env.NODE_ENV!=="production"){const n=ph[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Tn=Object.getPrototypeOf;function Rn(e){return!!e&&!!e[ct]}function hn(e){var t;return e?rc(e)||Array.isArray(e)||!!e[hs]||!!((t=e.constructor)!=null&&t[hs])||qr(e)||Wr(e):!1}var fh=Object.prototype.constructor.toString();function rc(e){if(!e||typeof e!="object")return!1;const t=Tn(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)===fh}function Dr(e,t){Br(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Br(e){const t=e[ct];return t?t.type_:Array.isArray(e)?1:qr(e)?2:Wr(e)?3:0}function No(e,t){return Br(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function oc(e,t,n){const r=Br(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function mh(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qr(e){return e instanceof Map}function Wr(e){return e instanceof Set}function ln(e){return e.copy_||e.base_}function To(e,t){if(qr(e))return new Map(e);if(Wr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=rc(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[ct];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const s=i[o],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Tn(e),r)}else{const r=Tn(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function li(e,t=!1){return Jr(e)||Rn(e)||!hn(e)||(Br(e)>1&&(e.set=e.add=e.clear=e.delete=hh),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>li(r,!0))),e}function hh(){tt(2)}function Jr(e){return Object.isFrozen(e)}var gh={};function gn(e){const t=gh[e];return t||tt(0,e),t}var qn;function ic(){return qn}function vh(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function gs(e,t){t&&(gn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ro(e){Ao(e),e.drafts_.forEach(yh),e.drafts_=null}function Ao(e){e===qn&&(qn=e.parent_)}function vs(e){return qn=vh(qn,e)}function yh(e){const t=e[ct];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ys(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ct].modified_&&(Ro(t),tt(4)),hn(e)&&(e=Fr(t,e),t.parent_||jr(t,e)),t.patches_&&gn("Patches").generateReplacementPatches_(n[ct].base_,e,t.patches_,t.inversePatches_)):e=Fr(t,n,[]),Ro(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==nc?e:void 0}function Fr(e,t,n){if(Jr(t))return t;const r=t[ct];if(!r)return Dr(t,(i,o)=>ws(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return jr(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;r.type_===3&&(o=new Set(i),i.clear(),s=!0),Dr(o,(a,c)=>ws(e,r,i,a,c,n,s)),jr(e,i,!1),n&&e.patches_&&gn("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function ws(e,t,n,r,i,o,s){if(process.env.NODE_ENV!=="production"&&i===n&&tt(5),Rn(i)){const a=o&&t&&t.type_!==3&&!No(t.assigned_,r)?o.concat(r):void 0,c=Fr(e,i,a);if(oc(n,r,c),Rn(c))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(hn(i)&&!Jr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Fr(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&jr(e,i)}}function jr(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&li(t,n)}function wh(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ic(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=ui;n&&(i=[r],o=Wn);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}var ui={get(e,t){if(t===ct)return e;const n=ln(e);if(!No(n,t))return Ih(e,n,t);const r=n[t];return e.finalized_||!hn(r)?r:r===po(e.base_,t)?(fo(e),e.copy_[t]=Do(r,e)):r},has(e,t){return t in ln(e)},ownKeys(e){return Reflect.ownKeys(ln(e))},set(e,t,n){const r=sc(ln(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=po(ln(e),t),o=i==null?void 0:i[ct];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(mh(n,i)&&(n!==void 0||No(e.base_,t)))return!0;fo(e),Po(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 po(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,fo(e),Po(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ln(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){tt(11)},getPrototypeOf(e){return Tn(e.base_)},setPrototypeOf(){tt(12)}},Wn={};Dr(ui,(e,t)=>{Wn[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Wn.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&tt(13),Wn.set.call(this,e,t,void 0)};Wn.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&tt(14),ui.set.call(this,e[0],t,n,e[0])};function po(e,t){const n=e[ct];return(n?ln(n):e)[t]}function Ih(e,t,n){var i;const r=sc(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function sc(e,t){if(!(t in e))return;let n=Tn(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Tn(n)}}function Po(e){e.modified_||(e.modified_=!0,e.parent_&&Po(e.parent_))}function fo(e){e.copy_||(e.copy_=To(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var _h=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(c=o,...l){return s.produce(c,d=>n.call(this,d,...l))}}typeof n!="function"&&tt(6),r!==void 0&&typeof r!="function"&&tt(7);let i;if(hn(t)){const o=vs(this),s=Do(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?Ro(o):Ao(o)}return gs(o,r),ys(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===nc&&(i=void 0),this.autoFreeze_&&li(i,!0),r){const o=[],s=[];gn("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else tt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,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){hn(e)||tt(8),Rn(e)&&(e=bh(e));const t=vs(this),n=Do(e,void 0);return n[ct].isManual_=!0,Ao(t),n}finishDraft(e,t){const n=e&&e[ct];(!n||!n.isManual_)&&tt(9);const{scope_:r}=n;return gs(r,t),ys(void 0,r)}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 r=gn("Patches").applyPatches_;return Rn(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Do(e,t){const n=qr(e)?gn("MapSet").proxyMap_(e,t):Wr(e)?gn("MapSet").proxySet_(e,t):wh(e,t);return(t?t.scope_:ic()).drafts_.push(n),n}function bh(e){return Rn(e)||tt(10,e),ac(e)}function ac(e){if(!hn(e)||Jr(e))return e;const t=e[ct];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=To(e,t.scope_.immer_.useStrictShallowCopy_)}else n=To(e,!0);return Dr(n,(r,i)=>{oc(n,r,ac(i))}),t&&(t.finalized_=!1),n}var lt=new _h,$n=lt.produce;lt.produceWithPatches.bind(lt);lt.setAutoFreeze.bind(lt);lt.setUseStrictShallowCopy.bind(lt);lt.applyPatches.bind(lt);lt.createDraft.bind(lt);lt.finishDraft.bind(lt);const cc=g.createContext(void 0),xh={};function di(){const e=g.useContext(cc);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Ch({children:e}){const{installation:t}=ut(),{hydratedRevision:n,loading:r}=Dn(),[i,o]=g.useState(xh),s=t==null?void 0:t.config;g.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(i).length>0)&&Jp(n,s,o)},[n,r,s,i]);const a=g.useCallback((f,v)=>{o(w=>$n(w,I=>{I[f]=$n(I[f],v)}))},[o]),c=g.useCallback((f,v)=>{o(w=>$n(w,I=>{I[f]=v}))},[o]),l=g.useCallback(()=>{o($n(f=>{const v=f.other.write;v&&(v.isWriteModified=!1)}))},[o]),d=g.useCallback(f=>{o($n(v=>{var I;const w=(I=v[f])==null?void 0:I.read;w&&(w.isOptionalFieldsModified=!1,w.isRequiredMapFieldsModified=!1)}))},[o]),p=g.useCallback(f=>{f===pn?l():d(f)},[d,l]),m=g.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:o,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:p}),[i,c,p,a]);return u.jsx(cc.Provider,{value:m,children:e})}const yn=()=>{const{appName:e}=De(),{objectConfigurationsState:t,setConfigureState:n}=di(),{selectedObjectName:r}=ec(),i=ea(r||"",t);return{appName:e,configureState:i,setConfigureState:n,selectedObjectName:r}};function Oh(e,t,n){var i;const r=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(r[t]=n,e!=null&&e.read){const o=e.read.savedConfig.requiredMapFields,a=!Lo(o,r);e.read.isRequiredMapFieldsModified=a}}function lc(e,t,n,r){t(e,i=>Oh(i,n,r))}function uc({field:e,onSelectChange:t,allFields:n}){var m;const{configureState:r,selectedObjectName:i,setConfigureState:o}=yn(),[s,a]=g.useState(!0),c=(m=r==null?void 0:r.read)==null?void 0:m.selectedFieldMappings,l=c==null?void 0:c[e.mapToName];g.useEffect(()=>{e._default&&!l&&i&&r&&lc(i,o,e.mapToName,e._default),a(!1)},[e,o,i,l,r]);const d=g.useMemo(()=>n.map(f=>({id:f.fieldName,label:f.displayName,value:f.fieldName})),[n]),p=u.jsx(vm,{disabled:s,items:d,selectedValue:l||null,onSelectedItemChange:f=>{t({target:{name:e.mapToName,value:f==null?void 0:f.value}})},placeholder:"Please select one"});return u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[u.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName}),u.jsx("span",{children:(e==null?void 0:e.prompt)&&u.jsx(uh,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),p]},e.mapToName)}const Eh="_formControl_9qd8d_1",Sh="_formLabel_9qd8d_5",Nh="_formLabelRequired_9qd8d_11",Th="_formInput_9qd8d_16",Rh="_formInputInvalid_9qd8d_20",Ah="_formError_9qd8d_24",Ph="_disabled_9qd8d_30",cn={formControl:Eh,formLabel:Sh,formLabelRequired:Nh,formInput:Th,formInputInvalid:Rh,formError:Ah,disabled:Ph};function Dh({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:i=!1,errorMessage:o,children:s}){return u.jsxs("div",{className:st(cn.formControl,{[cn.disabled]:r}),children:[t&&u.jsx("label",{htmlFor:e,className:st(cn.formLabel,{[cn.formLabelRequired]:n}),children:t}),u.jsx("div",{id:e,className:st(cn.formInput,{[cn.formInputInvalid]:i}),children:s}),i&&o&&u.jsx("div",{className:cn.formError,role:"alert",children:o})]})}const Fh="_divider_1kmoj_1",Is={divider:Fh};function pi({className:e,style:t}){return u.jsx("hr",{className:e?`${Is.divider} ${e}`:Is.divider,style:t})}function zr({string:e}){return u.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[u.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),u.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:u.jsx(pi,{style:{width:"100%",marginLeft:"1rem"}})})]})}function jh(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=yn(),{fieldMapping:r}=ut(),{isError:i,removeError:o}=Zt(),s=c=>{const{value:l,name:d}=c.target;l&&(e&&lc(e,n,d,l),i(Se.MAPPING,d)&&o(Se.MAPPING,d))},a=g.useMemo(()=>{var p;const c=((p=t==null?void 0:t.read)==null?void 0:p.requiredMapFields)||[],l=e&&r?Object.values(r[e]||{}).flat():[];return c.concat(l).reduce((m,f)=>m.find(w=>w.mapToName===f.mapToName)?m.map(w=>w.mapToName===f.mapToName?f:w):m.concat(f),new Array).filter(Xt)},[t,r,e]);return a!=null&&a.length?u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:"Map the following fields"}),u.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:a.map(c=>{var l;return u.jsx(Dh,{id:c.mapToName,isInvalid:i(Se.MAPPING,c.mapToName),errorMessage:"* required",children:u.jsx(uc,{allFields:((l=t==null?void 0:t.read)==null?void 0:l.allFields)||[],field:c,onSelectChange:s})},c.mapToName)})})]}):null}const Mh={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function kh({children:e,style:t}){return u.jsx(vn,{style:{...Mh,...t},children:e})}function Lh(){var d,p,m;const{project:e}=De(),{hydratedRevision:t}=Dn(),{selectedObjectName:n}=yn(),{provider:r}=ut(),i=e==null?void 0:e.appName,o=Qt(r),s=(m=(p=(d=t==null?void 0:t.content)==null?void 0:d.read)==null?void 0:p.objects)==null?void 0:m.find(f=>f.objectName===n),a=(s==null?void 0:s.displayName)||n&&Un(n),c=s==null?void 0:s.mapToName,l=(s==null?void 0:s.mapToDisplayName)||c&&Un(c);return l&&i&&o?u.jsx(kh,{style:{marginTop:"1rem"},children:u.jsxs("p",{style:{margin:"1rem 0"},children:[u.jsx("b",{children:l})," in ",i," is mapped to ",u.jsx("b",{children:a})," in ",o,"."]})}):null}function $h(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function dc(...e){return t=>e.forEach(n=>$h(n,t))}function Jn(...e){return k.useCallback(dc(...e),e)}function Kh(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];const l=p=>{var O;const{scope:m,children:f,...v}=p,w=((O=m==null?void 0:m[e])==null?void 0:O[c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})};l.displayName=o+"Provider";function d(p,m){var w;const f=((w=m==null?void 0:m[e])==null?void 0:w[c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Vh(i,...t)]}function Vh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function xt(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 fi(e){const t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function mi({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=Hh({defaultProp:t,onChange:n}),o=e!==void 0,s=o?e:r,a=fi(n),c=k.useCallback(l=>{if(o){const p=typeof l=="function"?l(e):l;p!==e&&a(p)}else i(l)},[o,e,i,a]);return[s,c]}function Hh({defaultProp:e,onChange:t}){const n=k.useState(e),[r]=n,i=k.useRef(r),o=fi(t);return k.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}function Uh(e){const t=k.useRef({value:e,previous:e});return k.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Mr=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{};function Bh(e){const[t,n]=k.useState(void 0);return Mr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let s,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function qh(e,t){return k.useReducer((n,r)=>t[n][r]??n,e)}var hi=e=>{const{present:t,children:n}=e,r=Wh(t),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),o=Jn(r.ref,Jh(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:o}):null};hi.displayName="Presence";function Wh(e){const[t,n]=k.useState(),r=k.useRef({}),i=k.useRef(e),o=k.useRef("none"),s=e?"mounted":"unmounted",[a,c]=qh(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const l=yr(r.current);o.current=a==="mounted"?l:"none"},[a]),Mr(()=>{const l=r.current,d=i.current;if(d!==e){const m=o.current,f=yr(l);e?c("MOUNT"):f==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,c]),Mr(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,p=f=>{const w=yr(r.current).includes(f.animationName);if(f.target===t&&w&&(c("ANIMATION_END"),!i.current)){const I=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=I)})}},m=f=>{f.target===t&&(o.current=yr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:k.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function yr(e){return(e==null?void 0:e.animationName)||"none"}function Jh(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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 kr=k.forwardRef((e,t)=>{const{children:n,...r}=e,i=k.Children.toArray(n),o=i.find(Xh);if(o){const s=o.props.children,a=i.map(c=>c===o?k.Children.count(s)>1?k.Children.only(null):k.isValidElement(s)?s.props.children:null:c);return u.jsx(Fo,{...r,ref:t,children:k.isValidElement(s)?k.cloneElement(s,void 0,a):null})}return u.jsx(Fo,{...r,ref:t,children:n})});kr.displayName="Slot";var Fo=k.forwardRef((e,t)=>{const{children:n,...r}=e;if(k.isValidElement(n)){const i=Yh(n);return k.cloneElement(n,{...Gh(r,n.props),ref:t?dc(t,i):i})}return k.Children.count(n)>1?k.Children.only(null):null});Fo.displayName="SlotClone";var zh=({children:e})=>u.jsx(u.Fragment,{children:e});function Xh(e){return k.isValidElement(e)&&e.type===zh}function Gh(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{o(...a),i(...a)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function Yh(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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 Zh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],en=Zh.reduce((e,t)=>{const n=k.forwardRef((r,i)=>{const{asChild:o,...s}=r,a=o?kr:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(a,{...s,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),gi="Checkbox",[Qh,fy]=Kh(gi),[eg,tg]=Qh(gi),pc=k.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:c="on",onCheckedChange:l,form:d,...p}=e,[m,f]=k.useState(null),v=Jn(t,b=>f(b)),w=k.useRef(!1),I=m?d||!!m.closest("form"):!0,[O=!1,y]=mi({prop:i,defaultProp:o,onChange:l}),x=k.useRef(O);return k.useEffect(()=>{const b=m==null?void 0:m.form;if(b){const _=()=>y(x.current);return b.addEventListener("reset",_),()=>b.removeEventListener("reset",_)}},[m,y]),u.jsxs(eg,{scope:n,state:O,disabled:a,children:[u.jsx(en.button,{type:"button",role:"checkbox","aria-checked":zt(O)?"mixed":O,"aria-required":s,"data-state":hc(O),"data-disabled":a?"":void 0,disabled:a,value:c,...p,ref:v,onKeyDown:xt(e.onKeyDown,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:xt(e.onClick,b=>{y(_=>zt(_)?!0:!_),I&&(w.current=b.isPropagationStopped(),w.current||b.stopPropagation())})}),I&&u.jsx(ng,{control:m,bubbles:!w.current,name:r,value:c,checked:O,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:zt(o)?!1:o})]})});pc.displayName=gi;var fc="CheckboxIndicator",mc=k.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=tg(fc,n);return u.jsx(hi,{present:r||zt(o.state)||o.state===!0,children:u.jsx(en.span,{"data-state":hc(o.state),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});mc.displayName=fc;var ng=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:i,...o}=e,s=k.useRef(null),a=Uh(n),c=Bh(t);k.useEffect(()=>{const d=s.current,p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(a!==n&&f){const v=new Event("click",{bubbles:r});d.indeterminate=zt(n),f.call(d,zt(n)?!1:n),d.dispatchEvent(v)}},[a,n,r]);const l=k.useRef(zt(n)?!1:n);return u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??l.current,...o,tabIndex:-1,ref:s,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function zt(e){return e==="indeterminate"}function hc(e){return zt(e)?"indeterminate":e?"checked":"unchecked"}var gc=pc,vc=mc;function yc(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var rg=["color"],wc=g.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=yc(e,rg);return g.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}),g.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:r,fillRule:"evenodd",clipRule:"evenodd"}))}),og=["color"],ig=g.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=yc(e,og);return g.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}),g.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:r,fillRule:"evenodd",clipRule:"evenodd"}))});const sg="_checkboxGroupContainer_75zr7_1",ag="_stack_75zr7_6",cg="_selectAllContainer_75zr7_11",lg="_fieldContainer_75zr7_18",ug="_checkbox_75zr7_1",An={checkboxGroupContainer:sg,stack:ag,selectAllContainer:cg,fieldContainer:lg,checkbox:ug};function Ic({id:e,isChecked:t,label:n,onCheckedChange:r}){return u.jsxs("div",{className:An.fieldContainer,children:[u.jsx(gc,{className:An.checkbox,id:e,onCheckedChange:r,checked:t,children:u.jsx(vc,{children:u.jsx(wc,{})})}),u.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function _c({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:i}){return u.jsxs("div",{className:An.selectAllContainer,children:[u.jsx(gc,{className:An.checkbox,id:e,onCheckedChange:r,children:u.jsxs(vc,{children:[i&&u.jsx(ig,{}),t===!0&&u.jsx(wc,{})]})}),u.jsx("label",{htmlFor:e,children:n})]})}function bc({children:e}){return u.jsx("div",{className:An.checkboxGroupContainer,children:e})}function xc({children:e}){return u.jsx("div",{className:An.stack,children:e})}function dg(e,t,n){var i,o;const r=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(o=e.read)!=null&&o.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!Lo(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function _s(e,t,n,r){t(e,i=>dg(i,n,r))}function pg(){var p,m;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=yn(),i=(p=t==null?void 0:t.read)==null?void 0:p.selectedOptionalFields,o=(f,v)=>{f!=="indeterminate"&&r&&t&&_s(r,n,v,f)},s=(m=t==null?void 0:t.read)==null?void 0:m.optionalFields,a=f=>{r&&s&&s.forEach(v=>{Xt(v)||_s(r,n,v.fieldName,f)})},c=!!(s&&s.length>0),l=Object.keys(i||{}).length===(s==null?void 0:s.length),d=!l&&Object.keys(i||{}).length>0;return c&&u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`${e} reads the following optional fields`}),u.jsxs(bc,{children:[((s==null?void 0:s.length)||0)>=2&&u.jsx(_c,{id:"select-all-fields",isChecked:l,label:"Select all",onCheckedChange:a,isIndeterminate:d}),u.jsx(xc,{children:s.map(f=>Xt(f)?null:u.jsx(Ic,{id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),label:f.displayName,onCheckedChange:v=>o(v,f.fieldName)},f.fieldName))})]})]})}function fg(){return u.jsx(pg,{})}const mg={color:"var(--amp-colors-text-regular)",backgroundColor:"var(--amp-colors-bg-highlight)",borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function hg({children:e,style:t,...n}){return u.jsx("span",{style:{...mg,...t},...n,children:e})}function gg(){var r,i,o;const{configureState:e,selectedObjectName:t}=yn(),{appName:n}=De();return u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`${n} reads the following ${t} fields`}),u.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(i=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&i.length?(o=e.read)==null?void 0:o.requiredFields.map(s=>Xt(s)?null:u.jsx(hg,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function vg(){return u.jsxs(u.Fragment,{children:[u.jsx(Lh,{}),u.jsx(gg,{}),u.jsx(jh,{}),u.jsx(fg,{})]})}function yg(e,t,n){var r,i,o;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const s=e.write.selectedNonConfigurableWriteFields;if(s[t]=n,n||delete s[t],(o=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&o.selectedNonConfigurableWriteFields){const a=e.write.savedConfig.selectedNonConfigurableWriteFields,l=!Lo(a,s);e.write.isWriteModified=l}}}function bs(e,t,n,r){t(e,i=>{yg(i,n,r)})}function wg(){var p,m,f,v;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=yn(),i=(p=n==null?void 0:n.write)==null?void 0:p.selectedNonConfigurableWriteFields,o=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects,s=(w,I)=>{w!=="indeterminate"&&t&&n&&bs(t,r,I,w)},a=w=>{var I,O;t&&n&&((O=(I=n==null?void 0:n.write)==null?void 0:I.writeObjects)==null||O.forEach(y=>{bs(t,r,y.objectName,w)}))},c=!!o,l=Object.keys(i||{}).length===((v=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:v.length),d=!l&&Object.keys(i||{}).length>0;return c&&u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`Allow ${e} to write to these objects`}),u.jsxs(bc,{children:[((o==null?void 0:o.length)||0)>=2&&u.jsx(_c,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:l,label:"Select all"}),u.jsx(xc,{children:o.map(w=>u.jsx(Ic,{id:w.objectName,onCheckedChange:I=>s(I,w.objectName),isChecked:!!(i!=null&&i[w.objectName]),label:w.displayName},w.objectName))})]})]})}function Ig(){return u.jsx(wg,{})}function Cc({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const r=Je(),{projectId:i}=De(),{integrationId:o,installation:s,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:l}=ut(),[d,p]=g.useState(!1),m=!i||!o||!(s!=null&&s.id)||d,f=async()=>{if(!m){p(!0),console.warn("uninstalling installation",{projectId:i,integrationId:o,installationId:s.id});try{await Te().installationApi.deleteInstallation({projectIdOrName:i,integrationId:o,installationId:s.id},{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation:",s.id),l==null||l(s==null?void 0:s.id),a(),c()}catch(I){console.error("Error uninstalling installation."),Ye(I)}finally{p(!1)}}},v=d?"Uninstalling...":e,w=u.jsx(ht,{type:"button",onClick:f,disabled:m,variant:t,style:n,children:v});return s!=null&&s.id?w:null}function _g(){const{appName:e}=De(),{installation:t}=ut();return u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[t!=null&&t.id?u.jsxs("p",{children:["Once you uninstall this integration, all your configuration will be lost, and"," ",u.jsx("b",{children:e})," may stop working."]}):u.jsx("p",{children:"You've successfully uninstalled the integration."}),u.jsx(Cc,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})}function Oc({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:i}){var E,$,T;const{installation:o}=ut(),{hydratedRevision:s,loading:a}=Dn(),{configureState:c,selectedObjectName:l}=yn(),d=o==null?void 0:o.config,p=d&&l&&!!Ws(d,l)||!1,m=((E=c==null?void 0:c.read)==null?void 0:E.isOptionalFieldsModified)||(($=c==null?void 0:c.read)==null?void 0:$.isRequiredMapFieldsModified),f=(T=c==null?void 0:c.write)==null?void 0:T.isWriteModified,O=a||n||!c||!l||!(m||f||r||l!==pn&&!p),y=l===pn,x=l===Or,b=u.jsx(ht,{type:"submit",disabled:O,children:r?"Install":"Save"}),_=u.jsx(ht,{type:"button",onClick:t,disabled:O,variant:"ghost",children:"Reset"});return n?u.jsx($t,{}):u.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[u.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px"},children:[b,_]}),u.jsxs(vn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[i&&u.jsx(na,{children:typeof i=="string"?i:"Installation Failed."}),a&&u.jsx($t,{}),s&&!x&&!y&&u.jsx(vg,{}),s&&!x&&y&&u.jsx(Ig,{}),!a&&x&&u.jsx(_g,{})]})]})}const Ec=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:i,onUpdateSuccess:o}=ut(),{hydratedRevision:s,loading:a}=Dn(),{selectedObjectName:c}=ec(),{selectedConnection:l}=Pn(),d=Je(),{projectId:p}=De(),{resetBoundary:m,setErrors:f,setError:v,getError:w}=Zt(),{resetConfigureState:I,objectConfigurationsState:O,resetPendingConfigurationState:y}=di(),x=ea(c||"",O),{onNextIncompleteTab:b}=dh(),_=g.useCallback(()=>{m(Se.INSTALLATION_MUTATION)},[m]),E=g.useCallback(T=>T?J=>{v(Se.INSTALLATION_MUTATION,T,J)}:J=>{console.error("objectName is required to set installation error: ",J)},[v]),$=g.useCallback(T=>T?w(Se.INSTALLATION_MUTATION,T):"",[w]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:l,apiKey:d,projectId:p,resetBoundary:m,setErrors:f,setMutateInstallationError:E,getMutateInstallationError:$,resetMutateInstallationErrorState:_,resetConfigureState:I,objectConfigurationsState:O,resetPendingConfigurationState:y,configureState:x,onInstallSuccess:i,onUpdateSuccess:o,onNextIncompleteTab:b}},bg=void 0;function xg(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:i,loading:o,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:l,resetBoundary:d,setErrors:p,setMutateInstallationError:m,getMutateInstallationError:f,resetMutateInstallationErrorState:v,resetConfigureState:w,objectConfigurationsState:I,resetPendingConfigurationState:O,configureState:y,onInstallSuccess:x,onNextIncompleteTab:b}=Ec(),[_,E]=g.useState(!1),$=s===pn,T=f(s),J=g.useCallback(()=>{d(Se.MAPPING),i!=null&&i.content&&!o&&s&&Ys(i,bg,s,w)},[d,i,o,s,w]);g.useEffect(()=>{!y&&(i!=null&&i.content)&&!o&&J()},[y,I,i,o,J]);const q=()=>{v();const{requiredMapFields:ee,selectedFieldMappings:U}=(y==null?void 0:y.read)||{},{errorList:se}=Xs(ee,U,p);se.length>0||(s&&(a!=null&&a.id)&&c&&l&&e&&t&&n&&i?(E(!0),Gp(l,e,t,n,a.id,s,c,i,y,m(s),r,x).finally(()=>{E(!1),O(s),b()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},z=()=>{v(),s&&(a!=null&&a.id)&&c&&l&&e&&t&&n&&i?(E(!0),Qp(l,e,t,n,a.id,c,i,y,m(s),r,x).finally(()=>{E(!1),O(s),b()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},Y=ee=>{ee.preventDefault(),$?z():q()};return u.jsx(Oc,{errorMsg:T,isCreateMode:!0,isLoading:_,onSave:Y,onReset:J})}function Cg({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:i,selectedObjectName:o,setInstallation:s,onUpdateSuccess:a,setError:c}){const l={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${o}`],installation:{config:e}}};return Te().installationApi.updateInstallation(l,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{Ye(d,c)})}const Og=(e,t,n,r,i,o)=>{const s=Zs(e),a=Qs(e),c={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,backfill:o}}}}};return $r(i)&&(c.content||(c.content={}),c.content.proxy={enabled:!0}),c},Eg=(e,t,n,r,i,o,s,a,c,l,d)=>{const p=Og(o,r||"",a,a.schedule,c,a.backfill);return p?Cg({updateConfig:p,projectId:e,integrationId:t,installationId:n,apiKey:i,selectedObjectName:r,setError:l,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Sg=(e,t)=>{const r={content:{write:{objects:ta(e)}}};return $r(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Ng=(e,t,n,r,i,o,s,a,c)=>{const l=Sg(i,o);if(!l)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:l}}};return Te().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(p=>{a(p),c==null||c(p.id,p.config)}).catch(p=>{Ye(p,s)})};function Tg({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:i,selectedObjectName:o,apiKey:s,projectId:a,resetBoundary:c,setErrors:l,setMutateInstallationError:d,getMutateInstallationError:p,resetConfigureState:m,resetPendingConfigurationState:f,configureState:v,onUpdateSuccess:w,onNextIncompleteTab:I}=Ec(),[O,y]=g.useState(!1),x=o===pn,b=p(o),{config:_}=e,E=g.useCallback(()=>{c(Se.MAPPING),r!=null&&r.content&&!i&&o&&Ys(r,_,o,m)},[c,r,i,o,_,m]);g.useEffect(()=>{v||E()},[v,E]),g.useEffect(()=>{e&&E()},[e,E]);const $=g.useMemo(()=>{var Y,ee,U;return(U=(ee=(Y=r==null?void 0:r.content)==null?void 0:Y.read)==null?void 0:ee.objects)==null?void 0:U.find(se=>(se==null?void 0:se.objectName)===o)},[r,o]),T=()=>{const{requiredMapFields:z,selectedFieldMappings:Y}=(v==null?void 0:v.read)||{},{errorList:ee}=Xs(z,Y,l);ee.length>0||(r&&e&&o&&s&&a&&$?(y(!0),Eg(a,t.id,e.id,o,s,v,n,$,r,d(o),w).finally(()=>{y(!1),f(o),I()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},J=()=>{e&&o&&s&&a&&r?(y(!0),Ng(a,t.id,e.id,s,v,r,d(o),n,w).finally(()=>{y(!1),f(o),I()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},q=z=>{z.preventDefault(),x?J():T()};return u.jsx(Oc,{errorMsg:b,onSave:q,onReset:E,isLoading:O})}function Rg(){const{integrationObj:e,installation:t}=ut();return e?t&&e?u.jsx(Tg,{installation:t,integrationObj:e}):u.jsx(xg,{}):u.jsx(Lt,{message:"We can't load the integration"})}function Ag(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),u.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function vi({text:e,children:t}){return u.jsx(Xn,{children:u.jsxs(vn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[u.jsx(Ag,{}),u.jsx("p",{children:e}),t]})})}const Pg=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Dg({projectId:e,integrationId:t,groupRef:n,consumerRef:r,connectionId:i,apiKey:o,hydratedRevision:s,setError:a,setInstallation:c,onInstallSuccess:l}){const d=Pg(s,r);return d?$o({createConfig:d,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:o,setError:a,setInstallation:c,onInstallSuccess:l}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function Fg({provider:e}){const t=`You have successfully installed your ${Qt(e)} integration.`;return u.jsx(vi,{text:t,children:u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:u.jsx(Cc,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const jg=e=>{const{read:t,write:n,proxy:r}=(e==null?void 0:e.content)??{};return!t&&!n&&(r==null?void 0:r.enabled)||!1};function Mg({children:e,resetComponent:t}){var b;const{projectId:n}=De(),r=Je(),{hydratedRevision:i,loading:o}=Dn(),{integrationObj:s,installation:a,groupRef:c,consumerRef:l,setInstallation:d,onInstallSuccess:p,isIntegrationDeleted:m}=ut(),{selectedConnection:f}=Pn(),[v,w]=g.useState(!1),I=o||v,O=(b=i==null?void 0:i.content)==null?void 0:b.provider,y=jg(i),x=_=>{console.error("Error when creating proxy installation:",_)};return g.useEffect(()=>{!I&&i&&y&&!a&&f&&r&&(s!=null&&s.id)&&(w(!0),Dg({apiKey:r,projectId:n,integrationId:s==null?void 0:s.id,groupRef:c,consumerRef:l,connectionId:f==null?void 0:f.id,hydratedRevision:i,setError:x,setInstallation:d,onInstallSuccess:p}).then(()=>{w(!1)}).catch(_=>{w(!1),console.error("Error when creating proxy installation:",_)}))},[i,y,a,f,r,n,s==null?void 0:s.id,c,l,d,I,p]),m?u.jsx(vi,{text:"Integration successfully uninstalled.",children:u.jsx(ht,{type:"button",onClick:t,style:{width:"100%"},children:"Reinstall Integration"})}):s?I?u.jsx($t,{}):y&&O&&a?u.jsx(Fg,{provider:O}):u.jsx("div",{children:e}):u.jsx(Lt,{message:"We can't load the integration"})}function Sc(){return u.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:[u.jsx("p",{children:"Secured by"}),u.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:u.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}function Qn({children:e}){return u.jsx(Xn,{children:u.jsxs(vn,{children:[u.jsx("div",{style:{padding:"3rem 2rem"},children:e}),u.jsx(Sc,{})]})})}function er({children:e}){return u.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function tr({error:e}){return e?u.jsx(na,{style:{marginTop:"2em"},children:e}):null}function yi({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,children:i,title:o}){if(!o&&!r)throw new Error("Either title or providerName is required");return u.jsxs(Qn,{children:[u.jsx(er,{children:o||`Set up ${r} integration`}),u.jsx(tr,{error:t}),i,u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const kg="_link_oo2kv_1",Lg={link:kg};function Nc({href:e,className:t,style:n,label:r,children:i,newTab:o=!1}){return u.jsx("a",{className:st(Lg.link,t),style:n,href:e,"aria-label":r||void 0,target:o?"_blank":"_self",rel:o?"noopener noreferrer":void 0,children:i})}function Tc({url:e,providerDisplayName:t,credentialName:n}){return u.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[u.jsx(Nc,{href:e,newTab:!0,children:u.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const $g="_input_1g097_1",Kg="_inputError_1g097_17",Vg="_error_1g097_31",mo={input:$g,inputError:Kg,error:Vg};function Hg({id:e,type:t,className:n,isError:r=!1,...i}){const o=r?st(mo.inputError,mo.input):mo.input;return u.jsx("input",{id:e,type:t,className:st(o,n),...i})}const Ug="_textarea_1cwth_1",Bg="_textareaError_1cwth_14",qg="_error_1cwth_28",ho={textarea:Ug,textareaError:Bg,error:qg};function Wg({className:e,isError:t=!1,...n}){const r=t?st(ho.textareaError,ho.textarea):ho.textarea;return u.jsx("textarea",{className:st(e,r),...n})}const kt={Input:Hg,Textarea:Wg};function Jg({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:i}){var w;const[o,s]=g.useState(!1),a=()=>s(I=>!I),[c,l]=g.useState(""),d=I=>l(I.currentTarget.value),p=c.length>0,m=i||!p,f=Qt(e,t),v=(w=t.apiKeyOpts)==null?void 0:w.docsURL;return u.jsx(yi,{providerName:f,handleSubmit:()=>{n({apiKey:c})},error:r,isButtonDisabled:m,children:u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&u.jsx(Tc,{url:v,providerDisplayName:f,credentialName:"API key"}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"password",name:"password",type:o?"text":"password",placeholder:"Password",onChange:I=>d(I)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:o?"Hide":"Show"})]})]})})}function zg({...e}){return u.jsx(Jg,{...e})}function Xg({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,children:s,selectedConnection:a,setSelectedConnection:c}){const l=De(),[d,p]=g.useState(!1),[m,f]=g.useState(null),v=Je();g.useEffect(()=>{if(e&&Te&&d&&m!=null){const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,apiKey:m};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:I},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{c(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})}},[v,e,d,r,n,o,i,l,c,m]);const w=I=>{f(I.apiKey),p(!0)};return a===null?u.jsx(zg,{provider:e,providerInfo:t,handleSubmit:w,error:null}):s}function Gg({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:i}){var O;const[o,s]=g.useState(!1),a=()=>s(y=>!y),[c,l]=g.useState({username:"",password:""}),{username:d,password:p}=c,m=Qt(e,t),f=(O=t.basicOpts)==null?void 0:O.docsURL,v=d.length>0,w=i||!v,I=y=>{const{name:x,value:b}=y.currentTarget;l(_=>({..._,[x]:b}))};return u.jsx(yi,{providerName:m,handleSubmit:()=>{n({user:d,pass:p})},error:r,isButtonDisabled:w,children:u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[f&&u.jsx(Tc,{url:f,providerDisplayName:m,credentialName:"credentials"}),u.jsx(kt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:y=>I(y)}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"password",name:"password",type:o?"text":"password",placeholder:"Password",onChange:y=>I(y)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:o?"Hide":"Show"})]})]})})}function Yg({...e}){return u.jsx(Gg,{...e})}function Zg({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,children:s,selectedConnection:a,setSelectedConnection:c}){const l=De(),[d,p]=g.useState(!1),[m,f]=g.useState(null),v=Je();g.useEffect(()=>{if(e&&Te&&d&&m!=null){const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m.user,password:m.pass}};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:I},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{c(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})}},[v,e,d,r,n,o,i,l,m,c]);const w=I=>{const{user:O,pass:y}=I;f({user:O,pass:y}),p(!0)};return a===null?u.jsx(Yg,{provider:e,providerInfo:t,handleSubmit:w,error:null}):s}function Qg({...e}){return u.jsx(yi,{...e})}function ev({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:o,selectedConnection:s,setSelectedConnection:a,providerName:c}){const l=De(),d=Je(),[p,m]=g.useState(!1);g.useEffect(()=>{if(e&&Te&&p){const v={groupName:i,groupRef:r,consumerName:n,consumerRef:t,provider:e};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:v},{headers:{"X-Api-Key":d??"","Content-Type":"application/json"}}).then(w=>{a(w)}).catch(w=>{console.error("Error loading provider info."),Ye(w)})}},[d,e,p,n,t,i,r,a,l]);const f=()=>{m(!0)};return s===null?u.jsx(Qg,{handleSubmit:f,error:null,providerName:c}):o}const Rc=async(e,t,n,r,i,o,s,a)=>{var l,d;const c=await Te().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":r??""}});if(!c)throw new Error(`Provider ${i} not found`);if(c.authType==="oauth2"&&(((l=c.oauth2Opts)==null?void 0:l.grantType)==="authorizationCode"||((d=c.oauth2Opts)==null?void 0:d.grantType)==="authorizationCodePKCE")){const m=(await Te().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":r??""}})).find(I=>I.provider===i),f=Qt(i,c);if(!m)throw new Error(`You must first set up a ${f} Provider App using the Ampersand Console.`);const v={connectOAuthParams:{providerWorkspaceRef:o,projectId:e,groupRef:n,groupName:a,consumerRef:t,consumerName:s,providerAppId:m.id,provider:i,enableCSRFProtection:!0}};return await Te().oAuthApi.oauthConnect(v,{credentials:"include",headers:{"X-Api-Key":r??"","Content-Type":"application/json"}})}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},xs=600,Cs=600,tv="AUTHORIZATION_SUCCEEDED",nv="AUTHORIZATION_FAILED";function rv(e,t,n){return g.useCallback(async r=>{const i=await Te().connectionApi.getConnection({projectIdOrName:e,connectionId:r},{headers:{"X-Api-Key":t??""}});n(i)},[e,t,n])}function ov(e,t,n,r){return g.useCallback(()=>{if(!r)return;const i=window.screenX+(window.outerWidth-xs)/2,o=window.screenY+(window.outerHeight-Cs)/2.5,s=`width=${xs},height=${Cs},left=${i},top=${o}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function iv(e,t){return g.useCallback(n=>{var r,i;if(n.origin===yp){if(n.data.eventType===tv){const o=(r=n.data.data)==null?void 0:r.connection;o?e(o):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===nv&&(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 Ac({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:i}){const o=Je(),{projectId:s}=De(),[a,c]=g.useState(null),[l,d]=g.useState(null),{setSelectedConnection:p}=Pn(),m=iv(c,r),f=ov(n,d,m,t),v=rv(s,o,p);return g.useEffect(()=>{t&&!l&&f()},[t,l,f,m,n]),g.useEffect(()=>{a&&v(a).then(()=>{l==null||l.close()}).catch(w=>{console.error("Error refreshing connection: ",w),r==null||r(w.message??"Unexpected error: not able to refresh connection")})},[a,o,p,v,l,r]),g.useEffect(()=>{if(!l)return;const w=setInterval(()=>{l.closed&&(clearInterval(w),window.removeEventListener("message",m),d(null),!a&&!i?(console.error("OAuth failed. Please try again."),r==null||r("OAuth failed. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(w),window.removeEventListener("message",m)}},[l,a,i,m,r]),u.jsx("div",{children:e})}function sv({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return u.jsxs(Qn,{children:[u.jsx(er,{children:`Set up ${r} integration`}),u.jsx(tr,{error:t}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function av({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,providerName:o}){const{projectId:s}=De(),a=Je(),[c,l]=g.useState(null),[d,p]=g.useState(null),m=async()=>{p(null);try{const v=await Rc(s,t,r,a,e,void 0,n,i);l(v)}catch(v){console.error("Could not fetch OAuth popup URL."),Ye(v),p(v.message??"Unexpected error")}},f=g.useCallback(v=>{p(v),l(null)},[]);return u.jsx(Ac,{windowTitle:`Connect to ${o}`,oauthUrl:c,onError:f,children:u.jsx(sv,{handleSubmit:m,error:d,providerName:o})})}const cv="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function lv({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return u.jsxs(Qn,{children:[u.jsx(er,{children:"Enter your Salesforce subdomain"}),u.jsx(Nc,{href:cv,newTab:!0,children:"What is my Salesforce subdomain?"}),u.jsx(tr,{error:n}),u.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[u.jsx(kt.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:i=>t(i.currentTarget.value)}),u.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function uv({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:i}){return u.jsxs(Qn,{children:[u.jsxs(er,{children:["Enter your ",i," workspace"]}),u.jsx(tr,{error:n}),u.jsx("br",{}),u.jsx(kt.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:o=>t(o.currentTarget.value)}),u.jsx("br",{}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const dv="salesforce";function pv({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,providerName:o}){const{projectId:s}=De(),a=Je(),[c,l]=g.useState(""),[d,p]=g.useState(null),[m,f]=g.useState(null),v=async()=>{if(f(null),!c){f("Workspace is required");return}try{const O=await Rc(s,t,r,a,e,c,n,i);p(O)}catch(O){console.error(O),f((O==null?void 0:O.message)??"Unexpected error")}},w=g.useCallback(O=>{f(O),p(null)},[]),I=e===dv?u.jsx(lv,{handleSubmit:v,setWorkspace:l,error:m,isButtonDisabled:c.length===0}):u.jsx(uv,{handleSubmit:v,setWorkspace:l,error:m,isButtonDisabled:c.length===0,providerName:o});return u.jsx(Ac,{windowTitle:`Connect to ${o}`,oauthUrl:d,onError:w,children:I})}function fv({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:i,explicitWorkspaceRequired:o}){const[s,a]=g.useState(!1),[c,l]=g.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),d=()=>a(_=>!_),p=_=>{const{name:E,value:$}=_.currentTarget;l(T=>({...T,[E]:$}))},{clientSecret:m,clientId:f,workspace:v,scopes:w}=c,I=m.length>0,O=f.length>0,y=o?v.length>0:!0,x=n||!I||!O||!y,b=()=>{const _={clientId:f,clientSecret:m};o&&(_.workspace=v),i&&w.length>0&&(_.scopes=Pp(w)),e(_)};return u.jsxs(Qn,{children:[u.jsx(er,{children:`Set up ${r} integration`}),u.jsx(tr,{error:t}),u.jsx("br",{}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[o&&u.jsx(kt.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:_=>p(_)}),u.jsx(kt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:_=>p(_)}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:_=>p(_)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:d,children:s?"Hide":"Show"})]}),i&&u.jsx(kt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:_=>p(_)})]}),u.jsx("br",{}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:x,type:"submit",onClick:b,children:"Next"})]})}function mv({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:c,setSelectedConnection:l}){const{projectId:d}=De(),p=Je(),[m,f]=g.useState(null),v=async w=>{f(null);const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:w.workspace,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret,scopes:w.scopes}};Te().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:I},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(O=>{l(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O),f("Error loading provider info")})};return c===null?u.jsx(fv,{providerName:t,handleSubmit:v,error:m,explicitScopesRequired:s,explicitWorkspaceRequired:a}):u.jsx($t,{})}function hv({...e}){return u.jsx(mv,{...e})}const gv="authorizationCode",vv="authorizationCodePKCE",yv="clientCredentials";function wv({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,selectedConnection:s,setSelectedConnection:a}){if(t.oauth2Opts===void 0)return u.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:c,explicitScopesRequired:l,explicitWorkspaceRequired:d}=t.oauth2Opts,p=Qt(e,t),m={provider:e,consumerRef:n,consumerName:r,groupRef:i,groupName:o,providerName:p};return c===gv||c===vv?d?u.jsx(pv,{...m}):u.jsx(av,{...m}):c===yv?u.jsx(hv,{...m,explicitWorkspaceRequired:d,explicitScopesRequired:l,selectedConnection:s,setSelectedConnection:a}):c==="password"?u.jsx("em",{children:"Password flow not supported yet"}):u.jsxs("em",{children:["Unsupported grant type: ",c]})}function Iv(e){const{selectedConnection:t}=Pn();g.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function _v({onSuccess:e}){Iv(e)}const bv=async(e,t)=>{const n=await Te().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function Pc({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:o,onSuccess:s}){const a=Je(),[c,l]=g.useState(null),{provider:d}=ut(),{selectedConnection:p,setSelectedConnection:m,connections:f}=Pn();_v({onSuccess:s});const v=e||d,w=(c==null?void 0:c.displayName)??Un(v);if(g.useEffect(()=>{if(!p&&f&&f.length>0){const[O]=f;m(O)}bv(a,v).then(O=>{l(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})},[f,p,m,a,v]),!e&&!d)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return o;if(c==null)return u.jsx("strong",{children:"Provider not found"});const I={provider:v,consumerRef:t,consumerName:n,groupRef:r,groupName:i,selectedConnection:p,setSelectedConnection:m,providerName:w,providerInfo:c};return c.authType==="none"?u.jsx(ev,{...I,children:o}):c.authType==="basic"?u.jsx(Zg,{...I,children:o}):c.authType==="apiKey"?u.jsx(Xg,{...I,children:o}):u.jsx(wv,{...I})}function xv(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];const l=p=>{var O;const{scope:m,children:f,...v}=p,w=((O=m==null?void 0:m[e])==null?void 0:O[c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})};l.displayName=o+"Provider";function d(p,m){var w;const f=((w=m==null?void 0:m[e])==null?void 0:w[c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Cv(i,...t)]}function Cv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Dc(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];function l(p){const{scope:m,children:f,...v}=p,w=(m==null?void 0:m[e][c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})}function d(p,m){const f=(m==null?void 0:m[e][c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return l.displayName=o+"Provider",[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Ov(i,...t)]}function Ov(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Ev(e){const t=e+"CollectionProvider",[n,r]=Dc(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=f=>{const{scope:v,children:w}=f,I=g.useRef(null),O=g.useRef(new Map).current;return u.jsx(i,{scope:v,itemMap:O,collectionRef:I,children:w})};s.displayName=t;const a=e+"CollectionSlot",c=g.forwardRef((f,v)=>{const{scope:w,children:I}=f,O=o(a,w),y=Jn(v,O.collectionRef);return u.jsx(kr,{ref:y,children:I})});c.displayName=a;const l=e+"CollectionItemSlot",d="data-radix-collection-item",p=g.forwardRef((f,v)=>{const{scope:w,children:I,...O}=f,y=g.useRef(null),x=Jn(v,y),b=o(l,w);return g.useEffect(()=>(b.itemMap.set(y,{ref:y,...O}),()=>void b.itemMap.delete(y))),u.jsx(kr,{[d]:"",ref:x,children:I})});p.displayName=l;function m(f){const v=o(e+"CollectionConsumer",f);return g.useCallback(()=>{const I=v.collectionRef.current;if(!I)return[];const O=Array.from(I.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((b,_)=>O.indexOf(b.ref.current)-O.indexOf(_.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:c,ItemSlot:p},m,r]}var Sv=k.useId||(()=>{}),Nv=0;function Fc(e){const[t,n]=k.useState(Sv());return Mr(()=>{e||n(r=>r??String(Nv++))},[e]),e||(t?`radix-${t}`:"")}var Tv=k.createContext(void 0);function jc(e){const t=k.useContext(Tv);return e||t||"ltr"}var go="rovingFocusGroup.onEntryFocus",Rv={bubbles:!1,cancelable:!0},Xr="RovingFocusGroup",[jo,Mc,Av]=Ev(Xr),[Pv,kc]=Dc(Xr,[Av]),[Dv,Fv]=Pv(Xr),Lc=k.forwardRef((e,t)=>u.jsx(jo.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(jo.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(jv,{...e,ref:t})})}));Lc.displayName=Xr;var jv=k.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...p}=e,m=k.useRef(null),f=Jn(t,m),v=jc(o),[w=null,I]=mi({prop:s,defaultProp:a,onChange:c}),[O,y]=k.useState(!1),x=fi(l),b=Mc(n),_=k.useRef(!1),[E,$]=k.useState(0);return k.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(go,x),()=>T.removeEventListener(go,x)},[x]),u.jsx(Dv,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:w,onItemFocus:k.useCallback(T=>I(T),[I]),onItemShiftTab:k.useCallback(()=>y(!0),[]),onFocusableItemAdd:k.useCallback(()=>$(T=>T+1),[]),onFocusableItemRemove:k.useCallback(()=>$(T=>T-1),[]),children:u.jsx(en.div,{tabIndex:O||E===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:xt(e.onMouseDown,()=>{_.current=!0}),onFocus:xt(e.onFocus,T=>{const J=!_.current;if(T.target===T.currentTarget&&J&&!O){const q=new CustomEvent(go,Rv);if(T.currentTarget.dispatchEvent(q),!q.defaultPrevented){const z=b().filter(ne=>ne.focusable),Y=z.find(ne=>ne.active),ee=z.find(ne=>ne.id===w),se=[Y,ee,...z].filter(Boolean).map(ne=>ne.ref.current);Vc(se,d)}}_.current=!1}),onBlur:xt(e.onBlur,()=>y(!1))})})}),$c="RovingFocusGroupItem",Kc=k.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,...s}=e,a=Fc(),c=o||a,l=Fv($c,n),d=l.currentTabStopId===c,p=Mc(n),{onFocusableItemAdd:m,onFocusableItemRemove:f}=l;return k.useEffect(()=>{if(r)return m(),()=>f()},[r,m,f]),u.jsx(jo.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:u.jsx(en.span,{tabIndex:d?0:-1,"data-orientation":l.orientation,...s,ref:t,onMouseDown:xt(e.onMouseDown,v=>{r?l.onItemFocus(c):v.preventDefault()}),onFocus:xt(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:xt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){l.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=Lv(v,l.orientation,l.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let O=p().filter(y=>y.focusable).map(y=>y.ref.current);if(w==="last")O.reverse();else if(w==="prev"||w==="next"){w==="prev"&&O.reverse();const y=O.indexOf(v.currentTarget);O=l.loop?$v(O,y+1):O.slice(y+1)}setTimeout(()=>Vc(O))}})})})});Kc.displayName=$c;var Mv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function kv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Lv(e,t,n){const r=kv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Mv[r]}function Vc(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $v(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Kv=Lc,Vv=Kc,wi="Tabs",[Hv,my]=xv(wi,[kc]),Hc=kc(),[Uv,Ii]=Hv(wi),Uc=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:o,orientation:s="horizontal",dir:a,activationMode:c="automatic",...l}=e,d=jc(a),[p,m]=mi({prop:r,onChange:i,defaultProp:o});return u.jsx(Uv,{scope:n,baseId:Fc(),value:p,onValueChange:m,orientation:s,dir:d,activationMode:c,children:u.jsx(en.div,{dir:d,"data-orientation":s,...l,ref:t})})});Uc.displayName=wi;var Bc="TabsList",qc=k.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,o=Ii(Bc,n),s=Hc(n);return u.jsx(Kv,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:r,children:u.jsx(en.div,{role:"tablist","aria-orientation":o.orientation,...i,ref:t})})});qc.displayName=Bc;var Wc="TabsTrigger",Jc=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...o}=e,s=Ii(Wc,n),a=Hc(n),c=Xc(s.baseId,r),l=Gc(s.baseId,r),d=r===s.value;return u.jsx(Vv,{asChild:!0,...a,focusable:!i,active:d,children:u.jsx(en.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":l,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...o,ref:t,onMouseDown:xt(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?s.onValueChange(r):p.preventDefault()}),onKeyDown:xt(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&s.onValueChange(r)}),onFocus:xt(e.onFocus,()=>{const p=s.activationMode!=="manual";!d&&!i&&p&&s.onValueChange(r)})})})});Jc.displayName=Wc;var zc="TabsContent",Bv=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:o,...s}=e,a=Ii(zc,n),c=Xc(a.baseId,r),l=Gc(a.baseId,r),d=r===a.value,p=k.useRef(d);return k.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),u.jsx(hi,{present:i||d,children:({present:m})=>u.jsx(en.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:l,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&o})})});Bv.displayName=zc;function Xc(e,t){return`${e}-trigger-${t}`}function Gc(e,t){return`${e}-content-${t}`}var qv=Uc,Wv=qc,Yc=Jc;const Jv=u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[u.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),u.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function zv(e,t){return t?g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},g.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Jv:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:u.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function Xv(){return u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.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"}),u.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Gv="_tabsRoot_lqugd_1",Yv="_tabsList_lqugd_6",Zv="_tabTrigger_lqugd_12",Qv="_danger_lqugd_29",zn={tabsRoot:Gv,tabsList:Yv,tabTrigger:Zv,danger:Qv};function Zc({objectName:e,completed:t,pending:n,displayName:r}){return u.jsx(Yc,{value:e,className:zn.tabTrigger,children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[zv(t,n),u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsx("span",{children:r||e}),n&&u.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function ey({completed:e,pending:t,displayName:n}){return u.jsxs(u.Fragment,{children:[u.jsx(pi,{style:{margin:"1rem 0"}}),u.jsx(Zc,{objectName:pn,completed:e,pending:t,displayName:n},"other-write")]})}function ty(){return u.jsxs(u.Fragment,{children:[u.jsx(pi,{style:{margin:"3rem 0 1rem 0"}}),u.jsx(Yc,{value:Or,className:st(zn.tabTrigger,zn.danger),children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[Xv(),u.jsx("span",{children:"Uninstall"})]})})]})}function ny({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,otherNavObject:i,showUninstallButton:o}){var s,a;return u.jsx(qv,{value:e,className:zn.tabsRoot,onValueChange:n,children:u.jsxs(Wv,{className:zn.tabsList,children:[t.map(c=>{var l,d,p,m;return u.jsx(Zc,{objectName:c.name,displayName:c.displayName,completed:c.completed,pending:((d=(l=r==null?void 0:r[c.name])==null?void 0:l.read)==null?void 0:d.isOptionalFieldsModified)||((m=(p=r==null?void 0:r[c.name])==null?void 0:p.read)==null?void 0:m.isRequiredMapFieldsModified)||!1},c.name)}),i&&u.jsx(ey,{completed:i.completed,pending:((a=(s=r==null?void 0:r.other)==null?void 0:s.write)==null?void 0:a.isWriteModified)||!1,displayName:t.length?"Other":"Write"}),o&&u.jsx(ty,{})]})})}function ry(e,t){return t===Or?{name:Or,completed:!1}:e.find(n=>n.name===t)}function oy({children:e}){var O;const{project:t}=De(),{installation:n,provider:r}=ut(),{hydratedRevision:i}=Dn(),{objectConfigurationsState:o}=di(),[s,a]=g.useState(""),c=(t==null?void 0:t.appName)||"",l=n==null?void 0:n.config,d=i&&Js(l,i),p=d!==null,m=!!((O=i==null?void 0:i.content)!=null&&O.write),f=m?zs(l):void 0,v=g.useMemo(()=>{const y=[...d||[]];return f&&m&&y.push(f),y},[d,f,m]),w=ry(v,s),I=g.useCallback(()=>{const y=v.find(x=>w!==x&&!x.completed);y&&a(y.name)},[v,w]);return g.useEffect(()=>{!s&&v.length>0&&a(v[0].name)},[v,s,I]),u.jsx(tc.Provider,{value:I,children:u.jsx(Qa.Provider,{value:w==null?void 0:w.name,children:u.jsxs(Xn,{style:{maxWidth:"55rem"},children:[u.jsxs(vn,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[u.jsxs("div",{style:{width:"20rem"},children:[u.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[Qt(r)," integration"]}),u.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),p&&u.jsx(ny,{value:s,readNavObjects:d,onValueChange:y=>a(y),objectConfigurationsState:o,otherNavObject:f,showUninstallButton:!!n})]}),e]}),u.jsx(Sc,{})]})})})}function iy({...e}){return u.jsx(oy,{...e})}function sy(){const[e,t]=g.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}function ay({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onInstallSuccess:o,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var f;const{projectId:l}=De(),{errorState:d}=Zt(),{seed:p,reset:m}=sy();return(f=d[Se.INTEGRATION_LIST])!=null&&f.apiError?u.jsx(Lt,{message:"Something went wrong, couldn't find integration information"}):u.jsx("div",{className:qs.resetContainer,children:u.jsx(jp,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onInstallSuccess:o,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:u.jsx(Bs,{groupRef:r,children:u.jsx(Pc,{consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:u.jsx(af,{projectId:l,children:u.jsx(Mg,{resetComponent:m,children:u.jsx(Ch,{children:u.jsx(iy,{children:u.jsx(Rg,{})})})})})})})},p)})}function cy(){return u.jsxs(Xn,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[u.jsx($t,{}),u.jsx("p",{children:"Redirecting"})]})}function ly({redirectURL:e,children:t}){return g.useEffect(()=>{e&&window.location.replace(e)},[e]),e?u.jsx(cy,{}):t}function uy({provider:e}){const{appName:t}=De(),n=`You have successfully connected your ${Qt(e)} account to ${t}.`;return u.jsx(vi,{text:n})}function dy({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,redirectUrl:o,onSuccess:s}){return u.jsx("div",{className:qs.resetContainer,children:u.jsx(Bs,{provider:e,groupRef:r,children:u.jsx(Pc,{provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onSuccess:s,children:u.jsx(ly,{redirectURL:o,children:u.jsx(uy,{provider:e})})})})})}const py=(e,t)=>{const n=Je(),{projectId:r}=De(),{integrations:i}=$s(),[o,s]=g.useState(!1),[a,c]=g.useState(null);if(!n||!r)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 l=g.useMemo(()=>i==null?void 0:i.reduce((d,p)=>(p==null?void 0:p.name)===e?p:d,{}),[i,e]);return g.useEffect(()=>{l&&Te().installationApi.listInstallations({projectIdOrName:r,integrationId:l.id,groupRef:t},{headers:{"x-api-key":n}}).then(d=>{s(!0),c(d.length>0)}).catch(d=>{console.error("Error listing installations."),Ye(d),s(!0)})},[t,n,r,l]),{isLoaded:o,isIntegrationInstalled:a}};exports.AmpersandContext=Vs;exports.AmpersandProvider=Rp;exports.ConnectProvider=dy;exports.FieldMapping=uc;exports.InstallIntegration=ay;exports.useAmpersandProvider=Ap;exports.useIsIntegrationInstalled=py;
|
|
49
|
+
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})});function lh(){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[u.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[u.jsx("path",{d:"M8.00032 11.167L8.00032 7.83366M8.00032 1.83366C4.33366 1.83366 1.33366 4.83366 1.33366 8.50033C1.33366 12.167 4.33366 15.167 8.00033 15.167C11.667 15.167 14.667 12.167 14.667 8.50033C14.667 4.83366 11.667 1.83366 8.00032 1.83366Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("defs",{children:u.jsx("clipPath",{id:"clip0_2896_16290",children:u.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function uh({id:e,tooltipText:t}){return u.jsxs(u.Fragment,{children:[u.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:lh()}),u.jsx(ch,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const Qa=g.createContext(null);function ec(){const e=g.useContext(Qa);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const tc=g.createContext(()=>{});function dh(){const e=g.useContext(tc);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var nc=Symbol.for("immer-nothing"),hs=Symbol.for("immer-draftable"),ct=Symbol.for("immer-state"),ph=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 tt(e,...t){if(process.env.NODE_ENV!=="production"){const n=ph[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Tn=Object.getPrototypeOf;function Rn(e){return!!e&&!!e[ct]}function hn(e){var t;return e?rc(e)||Array.isArray(e)||!!e[hs]||!!((t=e.constructor)!=null&&t[hs])||qr(e)||Wr(e):!1}var fh=Object.prototype.constructor.toString();function rc(e){if(!e||typeof e!="object")return!1;const t=Tn(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)===fh}function Dr(e,t){Br(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Br(e){const t=e[ct];return t?t.type_:Array.isArray(e)?1:qr(e)?2:Wr(e)?3:0}function No(e,t){return Br(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function oc(e,t,n){const r=Br(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function mh(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qr(e){return e instanceof Map}function Wr(e){return e instanceof Set}function ln(e){return e.copy_||e.base_}function To(e,t){if(qr(e))return new Map(e);if(Wr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=rc(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[ct];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const s=i[o],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Tn(e),r)}else{const r=Tn(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function li(e,t=!1){return Jr(e)||Rn(e)||!hn(e)||(Br(e)>1&&(e.set=e.add=e.clear=e.delete=hh),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>li(r,!0))),e}function hh(){tt(2)}function Jr(e){return Object.isFrozen(e)}var gh={};function gn(e){const t=gh[e];return t||tt(0,e),t}var qn;function ic(){return qn}function vh(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function gs(e,t){t&&(gn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ro(e){Ao(e),e.drafts_.forEach(yh),e.drafts_=null}function Ao(e){e===qn&&(qn=e.parent_)}function vs(e){return qn=vh(qn,e)}function yh(e){const t=e[ct];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ys(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ct].modified_&&(Ro(t),tt(4)),hn(e)&&(e=Fr(t,e),t.parent_||jr(t,e)),t.patches_&&gn("Patches").generateReplacementPatches_(n[ct].base_,e,t.patches_,t.inversePatches_)):e=Fr(t,n,[]),Ro(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==nc?e:void 0}function Fr(e,t,n){if(Jr(t))return t;const r=t[ct];if(!r)return Dr(t,(i,o)=>ws(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return jr(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;r.type_===3&&(o=new Set(i),i.clear(),s=!0),Dr(o,(a,c)=>ws(e,r,i,a,c,n,s)),jr(e,i,!1),n&&e.patches_&&gn("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function ws(e,t,n,r,i,o,s){if(process.env.NODE_ENV!=="production"&&i===n&&tt(5),Rn(i)){const a=o&&t&&t.type_!==3&&!No(t.assigned_,r)?o.concat(r):void 0,c=Fr(e,i,a);if(oc(n,r,c),Rn(c))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(hn(i)&&!Jr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Fr(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&jr(e,i)}}function jr(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&li(t,n)}function wh(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ic(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=ui;n&&(i=[r],o=Wn);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}var ui={get(e,t){if(t===ct)return e;const n=ln(e);if(!No(n,t))return Ih(e,n,t);const r=n[t];return e.finalized_||!hn(r)?r:r===po(e.base_,t)?(fo(e),e.copy_[t]=Do(r,e)):r},has(e,t){return t in ln(e)},ownKeys(e){return Reflect.ownKeys(ln(e))},set(e,t,n){const r=sc(ln(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=po(ln(e),t),o=i==null?void 0:i[ct];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(mh(n,i)&&(n!==void 0||No(e.base_,t)))return!0;fo(e),Po(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 po(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,fo(e),Po(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ln(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){tt(11)},getPrototypeOf(e){return Tn(e.base_)},setPrototypeOf(){tt(12)}},Wn={};Dr(ui,(e,t)=>{Wn[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Wn.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&tt(13),Wn.set.call(this,e,t,void 0)};Wn.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&tt(14),ui.set.call(this,e[0],t,n,e[0])};function po(e,t){const n=e[ct];return(n?ln(n):e)[t]}function Ih(e,t,n){var i;const r=sc(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function sc(e,t){if(!(t in e))return;let n=Tn(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Tn(n)}}function Po(e){e.modified_||(e.modified_=!0,e.parent_&&Po(e.parent_))}function fo(e){e.copy_||(e.copy_=To(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var _h=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(c=o,...l){return s.produce(c,d=>n.call(this,d,...l))}}typeof n!="function"&&tt(6),r!==void 0&&typeof r!="function"&&tt(7);let i;if(hn(t)){const o=vs(this),s=Do(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?Ro(o):Ao(o)}return gs(o,r),ys(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===nc&&(i=void 0),this.autoFreeze_&&li(i,!0),r){const o=[],s=[];gn("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else tt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,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){hn(e)||tt(8),Rn(e)&&(e=bh(e));const t=vs(this),n=Do(e,void 0);return n[ct].isManual_=!0,Ao(t),n}finishDraft(e,t){const n=e&&e[ct];(!n||!n.isManual_)&&tt(9);const{scope_:r}=n;return gs(r,t),ys(void 0,r)}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 r=gn("Patches").applyPatches_;return Rn(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Do(e,t){const n=qr(e)?gn("MapSet").proxyMap_(e,t):Wr(e)?gn("MapSet").proxySet_(e,t):wh(e,t);return(t?t.scope_:ic()).drafts_.push(n),n}function bh(e){return Rn(e)||tt(10,e),ac(e)}function ac(e){if(!hn(e)||Jr(e))return e;const t=e[ct];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=To(e,t.scope_.immer_.useStrictShallowCopy_)}else n=To(e,!0);return Dr(n,(r,i)=>{oc(n,r,ac(i))}),t&&(t.finalized_=!1),n}var lt=new _h,$n=lt.produce;lt.produceWithPatches.bind(lt);lt.setAutoFreeze.bind(lt);lt.setUseStrictShallowCopy.bind(lt);lt.applyPatches.bind(lt);lt.createDraft.bind(lt);lt.finishDraft.bind(lt);const cc=g.createContext(void 0),xh={};function di(){const e=g.useContext(cc);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Ch({children:e}){const{installation:t}=ut(),{hydratedRevision:n,loading:r}=Dn(),[i,o]=g.useState(xh),s=t==null?void 0:t.config;g.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(i).length>0)&&Jp(n,s,o)},[n,r,s,i]);const a=g.useCallback((f,v)=>{o(w=>$n(w,I=>{I[f]=$n(I[f],v)}))},[o]),c=g.useCallback((f,v)=>{o(w=>$n(w,I=>{I[f]=v}))},[o]),l=g.useCallback(()=>{o($n(f=>{const v=f.other.write;v&&(v.isWriteModified=!1)}))},[o]),d=g.useCallback(f=>{o($n(v=>{var I;const w=(I=v[f])==null?void 0:I.read;w&&(w.isOptionalFieldsModified=!1,w.isRequiredMapFieldsModified=!1)}))},[o]),p=g.useCallback(f=>{f===pn?l():d(f)},[d,l]),m=g.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:o,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:p}),[i,c,p,a]);return u.jsx(cc.Provider,{value:m,children:e})}const yn=()=>{const{appName:e}=De(),{objectConfigurationsState:t,setConfigureState:n}=di(),{selectedObjectName:r}=ec(),i=ea(r||"",t);return{appName:e,configureState:i,setConfigureState:n,selectedObjectName:r}};function Oh(e,t,n){var i;const r=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(r[t]=n,e!=null&&e.read){const o=e.read.savedConfig.requiredMapFields,a=!Lo(o,r);e.read.isRequiredMapFieldsModified=a}}function lc(e,t,n,r){t(e,i=>Oh(i,n,r))}function uc({field:e,onSelectChange:t,allFields:n}){var m;const{configureState:r,selectedObjectName:i,setConfigureState:o}=yn(),[s,a]=g.useState(!0),c=(m=r==null?void 0:r.read)==null?void 0:m.selectedFieldMappings,l=c==null?void 0:c[e.mapToName];g.useEffect(()=>{e._default&&!l&&i&&r&&lc(i,o,e.mapToName,e._default),a(!1)},[e,o,i,l,r]);const d=g.useMemo(()=>n.map(f=>({id:f.fieldName,label:f.displayName,value:f.fieldName})),[n]),p=u.jsx(vm,{disabled:s,items:d,selectedValue:l||null,onSelectedItemChange:f=>{t({target:{name:e.mapToName,value:f==null?void 0:f.value}})},placeholder:"Please select one"});return u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[u.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName}),u.jsx("span",{children:(e==null?void 0:e.prompt)&&u.jsx(uh,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),p]},e.mapToName)}const Eh="_formControl_9qd8d_1",Sh="_formLabel_9qd8d_5",Nh="_formLabelRequired_9qd8d_11",Th="_formInput_9qd8d_16",Rh="_formInputInvalid_9qd8d_20",Ah="_formError_9qd8d_24",Ph="_disabled_9qd8d_30",cn={formControl:Eh,formLabel:Sh,formLabelRequired:Nh,formInput:Th,formInputInvalid:Rh,formError:Ah,disabled:Ph};function Dh({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:i=!1,errorMessage:o,children:s}){return u.jsxs("div",{className:st(cn.formControl,{[cn.disabled]:r}),children:[t&&u.jsx("label",{htmlFor:e,className:st(cn.formLabel,{[cn.formLabelRequired]:n}),children:t}),u.jsx("div",{id:e,className:st(cn.formInput,{[cn.formInputInvalid]:i}),children:s}),i&&o&&u.jsx("div",{className:cn.formError,role:"alert",children:o})]})}const Fh="_divider_1kmoj_1",Is={divider:Fh};function pi({className:e,style:t}){return u.jsx("hr",{className:e?`${Is.divider} ${e}`:Is.divider,style:t})}function zr({string:e}){return u.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[u.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),u.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:u.jsx(pi,{style:{width:"100%",marginLeft:"1rem"}})})]})}function jh(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=yn(),{fieldMapping:r}=ut(),{isError:i,removeError:o}=Zt(),s=c=>{const{value:l,name:d}=c.target;l&&(e&&lc(e,n,d,l),i(Se.MAPPING,d)&&o(Se.MAPPING,d))},a=g.useMemo(()=>{var p;const c=((p=t==null?void 0:t.read)==null?void 0:p.requiredMapFields)||[],l=e&&r?Object.values(r[e]||{}).flat():[];return c.concat(l).reduce((m,f)=>m.find(w=>w.mapToName===f.mapToName)?m.map(w=>w.mapToName===f.mapToName?f:w):m.concat(f),new Array).filter(Xt)},[t,r,e]);return a!=null&&a.length?u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:"Map the following fields"}),u.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:a.map(c=>{var l;return u.jsx(Dh,{id:c.mapToName,isInvalid:i(Se.MAPPING,c.mapToName),errorMessage:"* required",children:u.jsx(uc,{allFields:((l=t==null?void 0:t.read)==null?void 0:l.allFields)||[],field:c,onSelectChange:s})},c.mapToName)})})]}):null}const Mh={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function kh({children:e,style:t}){return u.jsx(vn,{style:{...Mh,...t},children:e})}function Lh(){var d,p,m;const{project:e}=De(),{hydratedRevision:t}=Dn(),{selectedObjectName:n}=yn(),{provider:r}=ut(),i=e==null?void 0:e.appName,o=Qt(r),s=(m=(p=(d=t==null?void 0:t.content)==null?void 0:d.read)==null?void 0:p.objects)==null?void 0:m.find(f=>f.objectName===n),a=(s==null?void 0:s.displayName)||n&&Un(n),c=s==null?void 0:s.mapToName,l=(s==null?void 0:s.mapToDisplayName)||c&&Un(c);return l&&i&&o?u.jsx(kh,{style:{marginTop:"1rem"},children:u.jsxs("p",{style:{margin:"1rem 0"},children:[u.jsx("b",{children:l})," in ",i," is mapped to ",u.jsx("b",{children:a})," in ",o,"."]})}):null}function $h(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function dc(...e){return t=>e.forEach(n=>$h(n,t))}function Jn(...e){return k.useCallback(dc(...e),e)}function Kh(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];const l=p=>{var O;const{scope:m,children:f,...v}=p,w=((O=m==null?void 0:m[e])==null?void 0:O[c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})};l.displayName=o+"Provider";function d(p,m){var w;const f=((w=m==null?void 0:m[e])==null?void 0:w[c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Vh(i,...t)]}function Vh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function xt(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 fi(e){const t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function mi({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=Hh({defaultProp:t,onChange:n}),o=e!==void 0,s=o?e:r,a=fi(n),c=k.useCallback(l=>{if(o){const p=typeof l=="function"?l(e):l;p!==e&&a(p)}else i(l)},[o,e,i,a]);return[s,c]}function Hh({defaultProp:e,onChange:t}){const n=k.useState(e),[r]=n,i=k.useRef(r),o=fi(t);return k.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}function Uh(e){const t=k.useRef({value:e,previous:e});return k.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Mr=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{};function Bh(e){const[t,n]=k.useState(void 0);return Mr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let s,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function qh(e,t){return k.useReducer((n,r)=>t[n][r]??n,e)}var hi=e=>{const{present:t,children:n}=e,r=Wh(t),i=typeof n=="function"?n({present:r.isPresent}):k.Children.only(n),o=Jn(r.ref,Jh(i));return typeof n=="function"||r.isPresent?k.cloneElement(i,{ref:o}):null};hi.displayName="Presence";function Wh(e){const[t,n]=k.useState(),r=k.useRef({}),i=k.useRef(e),o=k.useRef("none"),s=e?"mounted":"unmounted",[a,c]=qh(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const l=yr(r.current);o.current=a==="mounted"?l:"none"},[a]),Mr(()=>{const l=r.current,d=i.current;if(d!==e){const m=o.current,f=yr(l);e?c("MOUNT"):f==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,c]),Mr(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,p=f=>{const w=yr(r.current).includes(f.animationName);if(f.target===t&&w&&(c("ANIMATION_END"),!i.current)){const I=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=I)})}},m=f=>{f.target===t&&(o.current=yr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:k.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function yr(e){return(e==null?void 0:e.animationName)||"none"}function Jh(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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 kr=k.forwardRef((e,t)=>{const{children:n,...r}=e,i=k.Children.toArray(n),o=i.find(Xh);if(o){const s=o.props.children,a=i.map(c=>c===o?k.Children.count(s)>1?k.Children.only(null):k.isValidElement(s)?s.props.children:null:c);return u.jsx(Fo,{...r,ref:t,children:k.isValidElement(s)?k.cloneElement(s,void 0,a):null})}return u.jsx(Fo,{...r,ref:t,children:n})});kr.displayName="Slot";var Fo=k.forwardRef((e,t)=>{const{children:n,...r}=e;if(k.isValidElement(n)){const i=Yh(n);return k.cloneElement(n,{...Gh(r,n.props),ref:t?dc(t,i):i})}return k.Children.count(n)>1?k.Children.only(null):null});Fo.displayName="SlotClone";var zh=({children:e})=>u.jsx(u.Fragment,{children:e});function Xh(e){return k.isValidElement(e)&&e.type===zh}function Gh(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{o(...a),i(...a)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function Yh(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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 Zh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],en=Zh.reduce((e,t)=>{const n=k.forwardRef((r,i)=>{const{asChild:o,...s}=r,a=o?kr:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(a,{...s,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),gi="Checkbox",[Qh,fy]=Kh(gi),[eg,tg]=Qh(gi),pc=k.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:c="on",onCheckedChange:l,form:d,...p}=e,[m,f]=k.useState(null),v=Jn(t,b=>f(b)),w=k.useRef(!1),I=m?d||!!m.closest("form"):!0,[O=!1,y]=mi({prop:i,defaultProp:o,onChange:l}),x=k.useRef(O);return k.useEffect(()=>{const b=m==null?void 0:m.form;if(b){const _=()=>y(x.current);return b.addEventListener("reset",_),()=>b.removeEventListener("reset",_)}},[m,y]),u.jsxs(eg,{scope:n,state:O,disabled:a,children:[u.jsx(en.button,{type:"button",role:"checkbox","aria-checked":zt(O)?"mixed":O,"aria-required":s,"data-state":hc(O),"data-disabled":a?"":void 0,disabled:a,value:c,...p,ref:v,onKeyDown:xt(e.onKeyDown,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:xt(e.onClick,b=>{y(_=>zt(_)?!0:!_),I&&(w.current=b.isPropagationStopped(),w.current||b.stopPropagation())})}),I&&u.jsx(ng,{control:m,bubbles:!w.current,name:r,value:c,checked:O,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:zt(o)?!1:o})]})});pc.displayName=gi;var fc="CheckboxIndicator",mc=k.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=tg(fc,n);return u.jsx(hi,{present:r||zt(o.state)||o.state===!0,children:u.jsx(en.span,{"data-state":hc(o.state),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});mc.displayName=fc;var ng=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:i,...o}=e,s=k.useRef(null),a=Uh(n),c=Bh(t);k.useEffect(()=>{const d=s.current,p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(a!==n&&f){const v=new Event("click",{bubbles:r});d.indeterminate=zt(n),f.call(d,zt(n)?!1:n),d.dispatchEvent(v)}},[a,n,r]);const l=k.useRef(zt(n)?!1:n);return u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??l.current,...o,tabIndex:-1,ref:s,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function zt(e){return e==="indeterminate"}function hc(e){return zt(e)?"indeterminate":e?"checked":"unchecked"}var gc=pc,vc=mc;function yc(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var rg=["color"],wc=g.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=yc(e,rg);return g.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}),g.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:r,fillRule:"evenodd",clipRule:"evenodd"}))}),og=["color"],ig=g.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=yc(e,og);return g.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}),g.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:r,fillRule:"evenodd",clipRule:"evenodd"}))});const sg="_checkboxGroupContainer_75zr7_1",ag="_stack_75zr7_6",cg="_selectAllContainer_75zr7_11",lg="_fieldContainer_75zr7_18",ug="_checkbox_75zr7_1",An={checkboxGroupContainer:sg,stack:ag,selectAllContainer:cg,fieldContainer:lg,checkbox:ug};function Ic({id:e,isChecked:t,label:n,onCheckedChange:r}){return u.jsxs("div",{className:An.fieldContainer,children:[u.jsx(gc,{className:An.checkbox,id:e,onCheckedChange:r,checked:t,children:u.jsx(vc,{children:u.jsx(wc,{})})}),u.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function _c({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:i}){return u.jsxs("div",{className:An.selectAllContainer,children:[u.jsx(gc,{className:An.checkbox,id:e,onCheckedChange:r,children:u.jsxs(vc,{children:[i&&u.jsx(ig,{}),t===!0&&u.jsx(wc,{})]})}),u.jsx("label",{htmlFor:e,children:n})]})}function bc({children:e}){return u.jsx("div",{className:An.checkboxGroupContainer,children:e})}function xc({children:e}){return u.jsx("div",{className:An.stack,children:e})}function dg(e,t,n){var i,o;const r=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(o=e.read)!=null&&o.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!Lo(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function _s(e,t,n,r){t(e,i=>dg(i,n,r))}function pg(){var p,m;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=yn(),i=(p=t==null?void 0:t.read)==null?void 0:p.selectedOptionalFields,o=(f,v)=>{f!=="indeterminate"&&r&&t&&_s(r,n,v,f)},s=(m=t==null?void 0:t.read)==null?void 0:m.optionalFields,a=f=>{r&&s&&s.forEach(v=>{Xt(v)||_s(r,n,v.fieldName,f)})},c=!!(s&&s.length>0),l=Object.keys(i||{}).length===(s==null?void 0:s.length),d=!l&&Object.keys(i||{}).length>0;return c&&u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`${e} reads the following optional fields`}),u.jsxs(bc,{children:[((s==null?void 0:s.length)||0)>=2&&u.jsx(_c,{id:"select-all-fields",isChecked:l,label:"Select all",onCheckedChange:a,isIndeterminate:d}),u.jsx(xc,{children:s.map(f=>Xt(f)?null:u.jsx(Ic,{id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),label:f.displayName,onCheckedChange:v=>o(v,f.fieldName)},f.fieldName))})]})]})}function fg(){return u.jsx(pg,{})}const mg={color:"var(--amp-colors-text-regular)",backgroundColor:"var(--amp-colors-bg-highlight)",borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function hg({children:e,style:t,...n}){return u.jsx("span",{style:{...mg,...t},...n,children:e})}function gg(){var r,i,o;const{configureState:e,selectedObjectName:t}=yn(),{appName:n}=De();return u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`${n} reads the following ${t} fields`}),u.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(i=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&i.length?(o=e.read)==null?void 0:o.requiredFields.map(s=>Xt(s)?null:u.jsx(hg,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function vg(){return u.jsxs(u.Fragment,{children:[u.jsx(Lh,{}),u.jsx(gg,{}),u.jsx(jh,{}),u.jsx(fg,{})]})}function yg(e,t,n){var r,i,o;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const s=e.write.selectedNonConfigurableWriteFields;if(s[t]=n,n||delete s[t],(o=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&o.selectedNonConfigurableWriteFields){const a=e.write.savedConfig.selectedNonConfigurableWriteFields,l=!Lo(a,s);e.write.isWriteModified=l}}}function bs(e,t,n,r){t(e,i=>{yg(i,n,r)})}function wg(){var p,m,f,v;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=yn(),i=(p=n==null?void 0:n.write)==null?void 0:p.selectedNonConfigurableWriteFields,o=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects,s=(w,I)=>{w!=="indeterminate"&&t&&n&&bs(t,r,I,w)},a=w=>{var I,O;t&&n&&((O=(I=n==null?void 0:n.write)==null?void 0:I.writeObjects)==null||O.forEach(y=>{bs(t,r,y.objectName,w)}))},c=!!o,l=Object.keys(i||{}).length===((v=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:v.length),d=!l&&Object.keys(i||{}).length>0;return c&&u.jsxs(u.Fragment,{children:[u.jsx(zr,{string:`Allow ${e} to write to these objects`}),u.jsxs(bc,{children:[((o==null?void 0:o.length)||0)>=2&&u.jsx(_c,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:l,label:"Select all"}),u.jsx(xc,{children:o.map(w=>u.jsx(Ic,{id:w.objectName,onCheckedChange:I=>s(I,w.objectName),isChecked:!!(i!=null&&i[w.objectName]),label:w.displayName},w.objectName))})]})]})}function Ig(){return u.jsx(wg,{})}function Cc({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const r=Je(),{projectId:i}=De(),{integrationId:o,installation:s,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:l}=ut(),[d,p]=g.useState(!1),m=!i||!o||!(s!=null&&s.id)||d,f=async()=>{if(!m){p(!0),console.warn("uninstalling installation",{projectId:i,integrationId:o,installationId:s.id});try{await Te().installationApi.deleteInstallation({projectIdOrName:i,integrationId:o,installationId:s.id},{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation:",s.id),l==null||l(s==null?void 0:s.id),a(),c()}catch(I){console.error("Error uninstalling installation."),Ye(I)}finally{p(!1)}}},v=d?"Uninstalling...":e,w=u.jsx(ht,{type:"button",onClick:f,disabled:m,variant:t,style:n,children:v});return s!=null&&s.id?w:null}function _g(){const{appName:e}=De(),{installation:t}=ut();return u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[t!=null&&t.id?u.jsxs("p",{children:["Once you uninstall this integration, all your configuration will be lost, and"," ",u.jsx("b",{children:e})," may stop working."]}):u.jsx("p",{children:"You've successfully uninstalled the integration."}),u.jsx(Cc,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})}function Oc({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:i}){var E,$,T;const{installation:o}=ut(),{hydratedRevision:s,loading:a}=Dn(),{configureState:c,selectedObjectName:l}=yn(),d=o==null?void 0:o.config,p=d&&l&&!!Ws(d,l)||!1,m=((E=c==null?void 0:c.read)==null?void 0:E.isOptionalFieldsModified)||(($=c==null?void 0:c.read)==null?void 0:$.isRequiredMapFieldsModified),f=(T=c==null?void 0:c.write)==null?void 0:T.isWriteModified,O=a||n||!c||!l||!(m||f||r||l!==pn&&!p),y=l===pn,x=l===Or,b=u.jsx(ht,{type:"submit",disabled:O,children:r?"Install":"Save"}),_=u.jsx(ht,{type:"button",onClick:t,disabled:O,variant:"ghost",children:"Reset"});return n?u.jsx($t,{}):u.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[u.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px"},children:[b,_]}),u.jsxs(vn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[i&&u.jsx(na,{children:typeof i=="string"?i:"Installation Failed."}),a&&u.jsx($t,{}),s&&!x&&!y&&u.jsx(vg,{}),s&&!x&&y&&u.jsx(Ig,{}),!a&&x&&u.jsx(_g,{})]})]})}const Ec=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:i,onUpdateSuccess:o}=ut(),{hydratedRevision:s,loading:a}=Dn(),{selectedObjectName:c}=ec(),{selectedConnection:l}=Pn(),d=Je(),{projectId:p}=De(),{resetBoundary:m,setErrors:f,setError:v,getError:w}=Zt(),{resetConfigureState:I,objectConfigurationsState:O,resetPendingConfigurationState:y}=di(),x=ea(c||"",O),{onNextIncompleteTab:b}=dh(),_=g.useCallback(()=>{m(Se.INSTALLATION_MUTATION)},[m]),E=g.useCallback(T=>T?J=>{v(Se.INSTALLATION_MUTATION,T,J)}:J=>{console.error("objectName is required to set installation error: ",J)},[v]),$=g.useCallback(T=>T?w(Se.INSTALLATION_MUTATION,T):"",[w]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:l,apiKey:d,projectId:p,resetBoundary:m,setErrors:f,setMutateInstallationError:E,getMutateInstallationError:$,resetMutateInstallationErrorState:_,resetConfigureState:I,objectConfigurationsState:O,resetPendingConfigurationState:y,configureState:x,onInstallSuccess:i,onUpdateSuccess:o,onNextIncompleteTab:b}},bg=void 0;function xg(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:i,loading:o,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:l,resetBoundary:d,setErrors:p,setMutateInstallationError:m,getMutateInstallationError:f,resetMutateInstallationErrorState:v,resetConfigureState:w,objectConfigurationsState:I,resetPendingConfigurationState:O,configureState:y,onInstallSuccess:x,onNextIncompleteTab:b}=Ec(),[_,E]=g.useState(!1),$=s===pn,T=f(s),J=g.useCallback(()=>{d(Se.MAPPING),i!=null&&i.content&&!o&&s&&Ys(i,bg,s,w)},[d,i,o,s,w]);g.useEffect(()=>{!y&&(i!=null&&i.content)&&!o&&J()},[y,I,i,o,J]);const q=()=>{v();const{requiredMapFields:ee,selectedFieldMappings:U}=(y==null?void 0:y.read)||{},{errorList:se}=Xs(ee,U,p);se.length>0||(s&&(a!=null&&a.id)&&c&&l&&e&&t&&n&&i?(E(!0),Gp(l,e,t,n,a.id,s,c,i,y,m(s),r,x).finally(()=>{E(!1),O(s),b()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},z=()=>{v(),s&&(a!=null&&a.id)&&c&&l&&e&&t&&n&&i?(E(!0),Qp(l,e,t,n,a.id,c,i,y,m(s),r,x).finally(()=>{E(!1),O(s),b()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},Y=ee=>{ee.preventDefault(),$?z():q()};return u.jsx(Oc,{errorMsg:T,isCreateMode:!0,isLoading:_,onSave:Y,onReset:J})}function Cg({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:i,selectedObjectName:o,setInstallation:s,onUpdateSuccess:a,setError:c}){const l={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${o}`],installation:{config:e}}};return Te().installationApi.updateInstallation(l,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{Ye(d,c)})}const Og=(e,t,n,r,i,o)=>{const s=Zs(e),a=Qs(e),c={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,backfill:o}}}}};return $r(i)&&(c.content||(c.content={}),c.content.proxy={enabled:!0}),c},Eg=(e,t,n,r,i,o,s,a,c,l,d)=>{const p=Og(o,r||"",a,a.schedule,c,a.backfill);return p?Cg({updateConfig:p,projectId:e,integrationId:t,installationId:n,apiKey:i,selectedObjectName:r,setError:l,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Sg=(e,t)=>{const r={content:{write:{objects:ta(e)}}};return $r(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Ng=(e,t,n,r,i,o,s,a,c)=>{const l=Sg(i,o);if(!l)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:l}}};return Te().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(p=>{a(p),c==null||c(p.id,p.config)}).catch(p=>{Ye(p,s)})};function Tg({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:i,selectedObjectName:o,apiKey:s,projectId:a,resetBoundary:c,setErrors:l,setMutateInstallationError:d,getMutateInstallationError:p,resetConfigureState:m,resetPendingConfigurationState:f,configureState:v,onUpdateSuccess:w,onNextIncompleteTab:I}=Ec(),[O,y]=g.useState(!1),x=o===pn,b=p(o),{config:_}=e,E=g.useCallback(()=>{c(Se.MAPPING),r!=null&&r.content&&!i&&o&&Ys(r,_,o,m)},[c,r,i,o,_,m]);g.useEffect(()=>{v||E()},[v,E]),g.useEffect(()=>{e&&E()},[e,E]);const $=g.useMemo(()=>{var Y,ee,U;return(U=(ee=(Y=r==null?void 0:r.content)==null?void 0:Y.read)==null?void 0:ee.objects)==null?void 0:U.find(se=>(se==null?void 0:se.objectName)===o)},[r,o]),T=()=>{const{requiredMapFields:z,selectedFieldMappings:Y}=(v==null?void 0:v.read)||{},{errorList:ee}=Xs(z,Y,l);ee.length>0||(r&&e&&o&&s&&a&&$?(y(!0),Eg(a,t.id,e.id,o,s,v,n,$,r,d(o),w).finally(()=>{y(!1),f(o),I()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},J=()=>{e&&o&&s&&a&&r?(y(!0),Ng(a,t.id,e.id,s,v,r,d(o),n,w).finally(()=>{y(!1),f(o),I()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},q=z=>{z.preventDefault(),x?J():T()};return u.jsx(Oc,{errorMsg:b,onSave:q,onReset:E,isLoading:O})}function Rg(){const{integrationObj:e,installation:t}=ut();return e?t&&e?u.jsx(Tg,{installation:t,integrationObj:e}):u.jsx(xg,{}):u.jsx(Lt,{message:"We can't load the integration"})}function Ag(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),u.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function vi({text:e,children:t}){return u.jsx(Xn,{children:u.jsxs(vn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[u.jsx(Ag,{}),u.jsx("p",{children:e}),t]})})}const Pg=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Dg({projectId:e,integrationId:t,groupRef:n,consumerRef:r,connectionId:i,apiKey:o,hydratedRevision:s,setError:a,setInstallation:c,onInstallSuccess:l}){const d=Pg(s,r);return d?$o({createConfig:d,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:o,setError:a,setInstallation:c,onInstallSuccess:l}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function Fg({provider:e}){const t=`You have successfully installed your ${Qt(e)} integration.`;return u.jsx(vi,{text:t,children:u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:u.jsx(Cc,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const jg=e=>{const{read:t,write:n,proxy:r}=(e==null?void 0:e.content)??{};return!t&&!n&&(r==null?void 0:r.enabled)||!1};function Mg({children:e,resetComponent:t}){var b;const{projectId:n}=De(),r=Je(),{hydratedRevision:i,loading:o}=Dn(),{integrationObj:s,installation:a,groupRef:c,consumerRef:l,setInstallation:d,onInstallSuccess:p,isIntegrationDeleted:m}=ut(),{selectedConnection:f}=Pn(),[v,w]=g.useState(!1),I=o||v,O=(b=i==null?void 0:i.content)==null?void 0:b.provider,y=jg(i),x=_=>{console.error("Error when creating proxy installation:",_)};return g.useEffect(()=>{!I&&i&&y&&!a&&f&&r&&(s!=null&&s.id)&&(w(!0),Dg({apiKey:r,projectId:n,integrationId:s==null?void 0:s.id,groupRef:c,consumerRef:l,connectionId:f==null?void 0:f.id,hydratedRevision:i,setError:x,setInstallation:d,onInstallSuccess:p}).then(()=>{w(!1)}).catch(_=>{w(!1),console.error("Error when creating proxy installation:",_)}))},[i,y,a,f,r,n,s==null?void 0:s.id,c,l,d,I,p]),m?u.jsx(vi,{text:"Integration successfully uninstalled.",children:u.jsx(ht,{type:"button",onClick:t,style:{width:"100%"},children:"Reinstall Integration"})}):s?I?u.jsx($t,{}):y&&O&&a?u.jsx(Fg,{provider:O}):u.jsx("div",{children:e}):u.jsx(Lt,{message:"We can't load the integration"})}function Sc(){return u.jsxs("footer",{style:{backgroundColor:"light-dark(#EFEFEF, #646266)",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[u.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),u.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:u.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}function Qn({children:e}){return u.jsx(Xn,{children:u.jsxs(vn,{children:[u.jsx("div",{style:{padding:"3rem 2rem"},children:e}),u.jsx(Sc,{})]})})}function er({children:e}){return u.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function tr({error:e}){return e?u.jsx(na,{style:{marginTop:"2em"},children:e}):null}function yi({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,children:i,title:o}){if(!o&&!r)throw new Error("Either title or providerName is required");return u.jsxs(Qn,{children:[u.jsx(er,{children:o||`Set up ${r} integration`}),u.jsx(tr,{error:t}),i,u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const kg="_link_oo2kv_1",Lg={link:kg};function Nc({href:e,className:t,style:n,label:r,children:i,newTab:o=!1}){return u.jsx("a",{className:st(Lg.link,t),style:n,href:e,"aria-label":r||void 0,target:o?"_blank":"_self",rel:o?"noopener noreferrer":void 0,children:i})}function Tc({url:e,providerDisplayName:t,credentialName:n}){return u.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[u.jsx(Nc,{href:e,newTab:!0,children:u.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const $g="_input_1g097_1",Kg="_inputError_1g097_17",Vg="_error_1g097_31",mo={input:$g,inputError:Kg,error:Vg};function Hg({id:e,type:t,className:n,isError:r=!1,...i}){const o=r?st(mo.inputError,mo.input):mo.input;return u.jsx("input",{id:e,type:t,className:st(o,n),...i})}const Ug="_textarea_1cwth_1",Bg="_textareaError_1cwth_14",qg="_error_1cwth_28",ho={textarea:Ug,textareaError:Bg,error:qg};function Wg({className:e,isError:t=!1,...n}){const r=t?st(ho.textareaError,ho.textarea):ho.textarea;return u.jsx("textarea",{className:st(e,r),...n})}const kt={Input:Hg,Textarea:Wg};function Jg({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:i}){var w;const[o,s]=g.useState(!1),a=()=>s(I=>!I),[c,l]=g.useState(""),d=I=>l(I.currentTarget.value),p=c.length>0,m=i||!p,f=Qt(e,t),v=(w=t.apiKeyOpts)==null?void 0:w.docsURL;return u.jsx(yi,{providerName:f,handleSubmit:()=>{n({apiKey:c})},error:r,isButtonDisabled:m,children:u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&u.jsx(Tc,{url:v,providerDisplayName:f,credentialName:"API key"}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"password",name:"password",type:o?"text":"password",placeholder:"Password",onChange:I=>d(I)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:o?"Hide":"Show"})]})]})})}function zg({...e}){return u.jsx(Jg,{...e})}function Xg({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,children:s,selectedConnection:a,setSelectedConnection:c}){const l=De(),[d,p]=g.useState(!1),[m,f]=g.useState(null),v=Je();g.useEffect(()=>{if(e&&Te&&d&&m!=null){const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,apiKey:m};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:I},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{c(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})}},[v,e,d,r,n,o,i,l,c,m]);const w=I=>{f(I.apiKey),p(!0)};return a===null?u.jsx(zg,{provider:e,providerInfo:t,handleSubmit:w,error:null}):s}function Gg({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:i}){var O;const[o,s]=g.useState(!1),a=()=>s(y=>!y),[c,l]=g.useState({username:"",password:""}),{username:d,password:p}=c,m=Qt(e,t),f=(O=t.basicOpts)==null?void 0:O.docsURL,v=d.length>0,w=i||!v,I=y=>{const{name:x,value:b}=y.currentTarget;l(_=>({..._,[x]:b}))};return u.jsx(yi,{providerName:m,handleSubmit:()=>{n({user:d,pass:p})},error:r,isButtonDisabled:w,children:u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[f&&u.jsx(Tc,{url:f,providerDisplayName:m,credentialName:"credentials"}),u.jsx(kt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:y=>I(y)}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"password",name:"password",type:o?"text":"password",placeholder:"Password",onChange:y=>I(y)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:o?"Hide":"Show"})]})]})})}function Yg({...e}){return u.jsx(Gg,{...e})}function Zg({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,children:s,selectedConnection:a,setSelectedConnection:c}){const l=De(),[d,p]=g.useState(!1),[m,f]=g.useState(null),v=Je();g.useEffect(()=>{if(e&&Te&&d&&m!=null){const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m.user,password:m.pass}};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:I},{headers:{"X-Api-Key":v??"","Content-Type":"application/json"}}).then(O=>{c(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})}},[v,e,d,r,n,o,i,l,m,c]);const w=I=>{const{user:O,pass:y}=I;f({user:O,pass:y}),p(!0)};return a===null?u.jsx(Yg,{provider:e,providerInfo:t,handleSubmit:w,error:null}):s}function Qg({...e}){return u.jsx(yi,{...e})}function ev({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:o,selectedConnection:s,setSelectedConnection:a,providerName:c}){const l=De(),d=Je(),[p,m]=g.useState(!1);g.useEffect(()=>{if(e&&Te&&p){const v={groupName:i,groupRef:r,consumerName:n,consumerRef:t,provider:e};Te().connectionApi.generateConnection({projectIdOrName:l.projectId,generateConnectionParams:v},{headers:{"X-Api-Key":d??"","Content-Type":"application/json"}}).then(w=>{a(w)}).catch(w=>{console.error("Error loading provider info."),Ye(w)})}},[d,e,p,n,t,i,r,a,l]);const f=()=>{m(!0)};return s===null?u.jsx(Qg,{handleSubmit:f,error:null,providerName:c}):o}const Rc=async(e,t,n,r,i,o,s,a)=>{var l,d;const c=await Te().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":r??""}});if(!c)throw new Error(`Provider ${i} not found`);if(c.authType==="oauth2"&&(((l=c.oauth2Opts)==null?void 0:l.grantType)==="authorizationCode"||((d=c.oauth2Opts)==null?void 0:d.grantType)==="authorizationCodePKCE")){const m=(await Te().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":r??""}})).find(I=>I.provider===i),f=Qt(i,c);if(!m)throw new Error(`You must first set up a ${f} Provider App using the Ampersand Console.`);const v={connectOAuthParams:{providerWorkspaceRef:o,projectId:e,groupRef:n,groupName:a,consumerRef:t,consumerName:s,providerAppId:m.id,provider:i,enableCSRFProtection:!0}};return await Te().oAuthApi.oauthConnect(v,{credentials:"include",headers:{"X-Api-Key":r??"","Content-Type":"application/json"}})}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},xs=600,Cs=600,tv="AUTHORIZATION_SUCCEEDED",nv="AUTHORIZATION_FAILED";function rv(e,t,n){return g.useCallback(async r=>{const i=await Te().connectionApi.getConnection({projectIdOrName:e,connectionId:r},{headers:{"X-Api-Key":t??""}});n(i)},[e,t,n])}function ov(e,t,n,r){return g.useCallback(()=>{if(!r)return;const i=window.screenX+(window.outerWidth-xs)/2,o=window.screenY+(window.outerHeight-Cs)/2.5,s=`width=${xs},height=${Cs},left=${i},top=${o}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function iv(e,t){return g.useCallback(n=>{var r,i;if(n.origin===yp){if(n.data.eventType===tv){const o=(r=n.data.data)==null?void 0:r.connection;o?e(o):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===nv&&(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 Ac({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:i}){const o=Je(),{projectId:s}=De(),[a,c]=g.useState(null),[l,d]=g.useState(null),{setSelectedConnection:p}=Pn(),m=iv(c,r),f=ov(n,d,m,t),v=rv(s,o,p);return g.useEffect(()=>{t&&!l&&f()},[t,l,f,m,n]),g.useEffect(()=>{a&&v(a).then(()=>{l==null||l.close()}).catch(w=>{console.error("Error refreshing connection: ",w),r==null||r(w.message??"Unexpected error: not able to refresh connection")})},[a,o,p,v,l,r]),g.useEffect(()=>{if(!l)return;const w=setInterval(()=>{l.closed&&(clearInterval(w),window.removeEventListener("message",m),d(null),!a&&!i?(console.error("OAuth failed. Please try again."),r==null||r("OAuth failed. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(w),window.removeEventListener("message",m)}},[l,a,i,m,r]),u.jsx("div",{children:e})}function sv({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return u.jsxs(Qn,{children:[u.jsx(er,{children:`Set up ${r} integration`}),u.jsx(tr,{error:t}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function av({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,providerName:o}){const{projectId:s}=De(),a=Je(),[c,l]=g.useState(null),[d,p]=g.useState(null),m=async()=>{p(null);try{const v=await Rc(s,t,r,a,e,void 0,n,i);l(v)}catch(v){console.error("Could not fetch OAuth popup URL."),Ye(v),p(v.message??"Unexpected error")}},f=g.useCallback(v=>{p(v),l(null)},[]);return u.jsx(Ac,{windowTitle:`Connect to ${o}`,oauthUrl:c,onError:f,children:u.jsx(sv,{handleSubmit:m,error:d,providerName:o})})}const cv="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function lv({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return u.jsxs(Qn,{children:[u.jsx(er,{children:"Enter your Salesforce subdomain"}),u.jsx(Nc,{href:cv,newTab:!0,children:"What is my Salesforce subdomain?"}),u.jsx(tr,{error:n}),u.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[u.jsx(kt.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:i=>t(i.currentTarget.value)}),u.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function uv({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:i}){return u.jsxs(Qn,{children:[u.jsxs(er,{children:["Enter your ",i," workspace"]}),u.jsx(tr,{error:n}),u.jsx("br",{}),u.jsx(kt.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:o=>t(o.currentTarget.value)}),u.jsx("br",{}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const dv="salesforce";function pv({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,providerName:o}){const{projectId:s}=De(),a=Je(),[c,l]=g.useState(""),[d,p]=g.useState(null),[m,f]=g.useState(null),v=async()=>{if(f(null),!c){f("Workspace is required");return}try{const O=await Rc(s,t,r,a,e,c,n,i);p(O)}catch(O){console.error(O),f((O==null?void 0:O.message)??"Unexpected error")}},w=g.useCallback(O=>{f(O),p(null)},[]),I=e===dv?u.jsx(lv,{handleSubmit:v,setWorkspace:l,error:m,isButtonDisabled:c.length===0}):u.jsx(uv,{handleSubmit:v,setWorkspace:l,error:m,isButtonDisabled:c.length===0,providerName:o});return u.jsx(Ac,{windowTitle:`Connect to ${o}`,oauthUrl:d,onError:w,children:I})}function fv({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:i,explicitWorkspaceRequired:o}){const[s,a]=g.useState(!1),[c,l]=g.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),d=()=>a(_=>!_),p=_=>{const{name:E,value:$}=_.currentTarget;l(T=>({...T,[E]:$}))},{clientSecret:m,clientId:f,workspace:v,scopes:w}=c,I=m.length>0,O=f.length>0,y=o?v.length>0:!0,x=n||!I||!O||!y,b=()=>{const _={clientId:f,clientSecret:m};o&&(_.workspace=v),i&&w.length>0&&(_.scopes=Pp(w)),e(_)};return u.jsxs(Qn,{children:[u.jsx(er,{children:`Set up ${r} integration`}),u.jsx(tr,{error:t}),u.jsx("br",{}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[o&&u.jsx(kt.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:_=>p(_)}),u.jsx(kt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:_=>p(_)}),u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(kt.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:_=>p(_)}),u.jsx(ht,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:d,children:s?"Hide":"Show"})]}),i&&u.jsx(kt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:_=>p(_)})]}),u.jsx("br",{}),u.jsx(ht,{style:{marginTop:"1em",width:"100%"},disabled:x,type:"submit",onClick:b,children:"Next"})]})}function mv({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:c,setSelectedConnection:l}){const{projectId:d}=De(),p=Je(),[m,f]=g.useState(null),v=async w=>{f(null);const I={groupName:o,groupRef:i,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:w.workspace,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret,scopes:w.scopes}};Te().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:I},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(O=>{l(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O),f("Error loading provider info")})};return c===null?u.jsx(fv,{providerName:t,handleSubmit:v,error:m,explicitScopesRequired:s,explicitWorkspaceRequired:a}):u.jsx($t,{})}function hv({...e}){return u.jsx(mv,{...e})}const gv="authorizationCode",vv="authorizationCodePKCE",yv="clientCredentials";function wv({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:i,groupName:o,selectedConnection:s,setSelectedConnection:a}){if(t.oauth2Opts===void 0)return u.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:c,explicitScopesRequired:l,explicitWorkspaceRequired:d}=t.oauth2Opts,p=Qt(e,t),m={provider:e,consumerRef:n,consumerName:r,groupRef:i,groupName:o,providerName:p};return c===gv||c===vv?d?u.jsx(pv,{...m}):u.jsx(av,{...m}):c===yv?u.jsx(hv,{...m,explicitWorkspaceRequired:d,explicitScopesRequired:l,selectedConnection:s,setSelectedConnection:a}):c==="password"?u.jsx("em",{children:"Password flow not supported yet"}):u.jsxs("em",{children:["Unsupported grant type: ",c]})}function Iv(e){const{selectedConnection:t}=Pn();g.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function _v({onSuccess:e}){Iv(e)}const bv=async(e,t)=>{const n=await Te().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function Pc({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:o,onSuccess:s}){const a=Je(),[c,l]=g.useState(null),{provider:d}=ut(),{selectedConnection:p,setSelectedConnection:m,connections:f}=Pn();_v({onSuccess:s});const v=e||d,w=(c==null?void 0:c.displayName)??Un(v);if(g.useEffect(()=>{if(!p&&f&&f.length>0){const[O]=f;m(O)}bv(a,v).then(O=>{l(O)}).catch(O=>{console.error("Error loading provider info."),Ye(O)})},[f,p,m,a,v]),!e&&!d)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return o;if(c==null)return u.jsx("strong",{children:"Provider not found"});const I={provider:v,consumerRef:t,consumerName:n,groupRef:r,groupName:i,selectedConnection:p,setSelectedConnection:m,providerName:w,providerInfo:c};return c.authType==="none"?u.jsx(ev,{...I,children:o}):c.authType==="basic"?u.jsx(Zg,{...I,children:o}):c.authType==="apiKey"?u.jsx(Xg,{...I,children:o}):u.jsx(wv,{...I})}function xv(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];const l=p=>{var O;const{scope:m,children:f,...v}=p,w=((O=m==null?void 0:m[e])==null?void 0:O[c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})};l.displayName=o+"Provider";function d(p,m){var w;const f=((w=m==null?void 0:m[e])==null?void 0:w[c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Cv(i,...t)]}function Cv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Dc(e,t=[]){let n=[];function r(o,s){const a=k.createContext(s),c=n.length;n=[...n,s];function l(p){const{scope:m,children:f,...v}=p,w=(m==null?void 0:m[e][c])||a,I=k.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:I,children:f})}function d(p,m){const f=(m==null?void 0:m[e][c])||a,v=k.useContext(f);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${o}\``)}return l.displayName=o+"Provider",[l,d]}const i=()=>{const o=n.map(s=>k.createContext(s));return function(a){const c=(a==null?void 0:a[e])||o;return k.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return i.scopeName=e,[r,Ov(i,...t)]}function Ov(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(o)[`__scope${l}`];return{...a,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Ev(e){const t=e+"CollectionProvider",[n,r]=Dc(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=f=>{const{scope:v,children:w}=f,I=g.useRef(null),O=g.useRef(new Map).current;return u.jsx(i,{scope:v,itemMap:O,collectionRef:I,children:w})};s.displayName=t;const a=e+"CollectionSlot",c=g.forwardRef((f,v)=>{const{scope:w,children:I}=f,O=o(a,w),y=Jn(v,O.collectionRef);return u.jsx(kr,{ref:y,children:I})});c.displayName=a;const l=e+"CollectionItemSlot",d="data-radix-collection-item",p=g.forwardRef((f,v)=>{const{scope:w,children:I,...O}=f,y=g.useRef(null),x=Jn(v,y),b=o(l,w);return g.useEffect(()=>(b.itemMap.set(y,{ref:y,...O}),()=>void b.itemMap.delete(y))),u.jsx(kr,{[d]:"",ref:x,children:I})});p.displayName=l;function m(f){const v=o(e+"CollectionConsumer",f);return g.useCallback(()=>{const I=v.collectionRef.current;if(!I)return[];const O=Array.from(I.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((b,_)=>O.indexOf(b.ref.current)-O.indexOf(_.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:c,ItemSlot:p},m,r]}var Sv=k.useId||(()=>{}),Nv=0;function Fc(e){const[t,n]=k.useState(Sv());return Mr(()=>{e||n(r=>r??String(Nv++))},[e]),e||(t?`radix-${t}`:"")}var Tv=k.createContext(void 0);function jc(e){const t=k.useContext(Tv);return e||t||"ltr"}var go="rovingFocusGroup.onEntryFocus",Rv={bubbles:!1,cancelable:!0},Xr="RovingFocusGroup",[jo,Mc,Av]=Ev(Xr),[Pv,kc]=Dc(Xr,[Av]),[Dv,Fv]=Pv(Xr),Lc=k.forwardRef((e,t)=>u.jsx(jo.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(jo.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(jv,{...e,ref:t})})}));Lc.displayName=Xr;var jv=k.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...p}=e,m=k.useRef(null),f=Jn(t,m),v=jc(o),[w=null,I]=mi({prop:s,defaultProp:a,onChange:c}),[O,y]=k.useState(!1),x=fi(l),b=Mc(n),_=k.useRef(!1),[E,$]=k.useState(0);return k.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(go,x),()=>T.removeEventListener(go,x)},[x]),u.jsx(Dv,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:w,onItemFocus:k.useCallback(T=>I(T),[I]),onItemShiftTab:k.useCallback(()=>y(!0),[]),onFocusableItemAdd:k.useCallback(()=>$(T=>T+1),[]),onFocusableItemRemove:k.useCallback(()=>$(T=>T-1),[]),children:u.jsx(en.div,{tabIndex:O||E===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:xt(e.onMouseDown,()=>{_.current=!0}),onFocus:xt(e.onFocus,T=>{const J=!_.current;if(T.target===T.currentTarget&&J&&!O){const q=new CustomEvent(go,Rv);if(T.currentTarget.dispatchEvent(q),!q.defaultPrevented){const z=b().filter(ne=>ne.focusable),Y=z.find(ne=>ne.active),ee=z.find(ne=>ne.id===w),se=[Y,ee,...z].filter(Boolean).map(ne=>ne.ref.current);Vc(se,d)}}_.current=!1}),onBlur:xt(e.onBlur,()=>y(!1))})})}),$c="RovingFocusGroupItem",Kc=k.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,...s}=e,a=Fc(),c=o||a,l=Fv($c,n),d=l.currentTabStopId===c,p=Mc(n),{onFocusableItemAdd:m,onFocusableItemRemove:f}=l;return k.useEffect(()=>{if(r)return m(),()=>f()},[r,m,f]),u.jsx(jo.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:u.jsx(en.span,{tabIndex:d?0:-1,"data-orientation":l.orientation,...s,ref:t,onMouseDown:xt(e.onMouseDown,v=>{r?l.onItemFocus(c):v.preventDefault()}),onFocus:xt(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:xt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){l.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=Lv(v,l.orientation,l.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let O=p().filter(y=>y.focusable).map(y=>y.ref.current);if(w==="last")O.reverse();else if(w==="prev"||w==="next"){w==="prev"&&O.reverse();const y=O.indexOf(v.currentTarget);O=l.loop?$v(O,y+1):O.slice(y+1)}setTimeout(()=>Vc(O))}})})})});Kc.displayName=$c;var Mv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function kv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Lv(e,t,n){const r=kv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Mv[r]}function Vc(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $v(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Kv=Lc,Vv=Kc,wi="Tabs",[Hv,my]=xv(wi,[kc]),Hc=kc(),[Uv,Ii]=Hv(wi),Uc=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:o,orientation:s="horizontal",dir:a,activationMode:c="automatic",...l}=e,d=jc(a),[p,m]=mi({prop:r,onChange:i,defaultProp:o});return u.jsx(Uv,{scope:n,baseId:Fc(),value:p,onValueChange:m,orientation:s,dir:d,activationMode:c,children:u.jsx(en.div,{dir:d,"data-orientation":s,...l,ref:t})})});Uc.displayName=wi;var Bc="TabsList",qc=k.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,o=Ii(Bc,n),s=Hc(n);return u.jsx(Kv,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:r,children:u.jsx(en.div,{role:"tablist","aria-orientation":o.orientation,...i,ref:t})})});qc.displayName=Bc;var Wc="TabsTrigger",Jc=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...o}=e,s=Ii(Wc,n),a=Hc(n),c=Xc(s.baseId,r),l=Gc(s.baseId,r),d=r===s.value;return u.jsx(Vv,{asChild:!0,...a,focusable:!i,active:d,children:u.jsx(en.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":l,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...o,ref:t,onMouseDown:xt(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?s.onValueChange(r):p.preventDefault()}),onKeyDown:xt(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&s.onValueChange(r)}),onFocus:xt(e.onFocus,()=>{const p=s.activationMode!=="manual";!d&&!i&&p&&s.onValueChange(r)})})})});Jc.displayName=Wc;var zc="TabsContent",Bv=k.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:o,...s}=e,a=Ii(zc,n),c=Xc(a.baseId,r),l=Gc(a.baseId,r),d=r===a.value,p=k.useRef(d);return k.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),u.jsx(hi,{present:i||d,children:({present:m})=>u.jsx(en.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:l,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&o})})});Bv.displayName=zc;function Xc(e,t){return`${e}-trigger-${t}`}function Gc(e,t){return`${e}-content-${t}`}var qv=Uc,Wv=qc,Yc=Jc;const Jv=u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[u.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),u.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function zv(e,t){return t?g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},g.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Jv:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:u.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function Xv(){return u.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.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"}),u.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Gv="_tabsRoot_lqugd_1",Yv="_tabsList_lqugd_6",Zv="_tabTrigger_lqugd_12",Qv="_danger_lqugd_29",zn={tabsRoot:Gv,tabsList:Yv,tabTrigger:Zv,danger:Qv};function Zc({objectName:e,completed:t,pending:n,displayName:r}){return u.jsx(Yc,{value:e,className:zn.tabTrigger,children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[zv(t,n),u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsx("span",{children:r||e}),n&&u.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function ey({completed:e,pending:t,displayName:n}){return u.jsxs(u.Fragment,{children:[u.jsx(pi,{style:{margin:"1rem 0"}}),u.jsx(Zc,{objectName:pn,completed:e,pending:t,displayName:n},"other-write")]})}function ty(){return u.jsxs(u.Fragment,{children:[u.jsx(pi,{style:{margin:"3rem 0 1rem 0"}}),u.jsx(Yc,{value:Or,className:st(zn.tabTrigger,zn.danger),children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[Xv(),u.jsx("span",{children:"Uninstall"})]})})]})}function ny({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,otherNavObject:i,showUninstallButton:o}){var s,a;return u.jsx(qv,{value:e,className:zn.tabsRoot,onValueChange:n,children:u.jsxs(Wv,{className:zn.tabsList,children:[t.map(c=>{var l,d,p,m;return u.jsx(Zc,{objectName:c.name,displayName:c.displayName,completed:c.completed,pending:((d=(l=r==null?void 0:r[c.name])==null?void 0:l.read)==null?void 0:d.isOptionalFieldsModified)||((m=(p=r==null?void 0:r[c.name])==null?void 0:p.read)==null?void 0:m.isRequiredMapFieldsModified)||!1},c.name)}),i&&u.jsx(ey,{completed:i.completed,pending:((a=(s=r==null?void 0:r.other)==null?void 0:s.write)==null?void 0:a.isWriteModified)||!1,displayName:t.length?"Other":"Write"}),o&&u.jsx(ty,{})]})})}function ry(e,t){return t===Or?{name:Or,completed:!1}:e.find(n=>n.name===t)}function oy({children:e}){var O;const{project:t}=De(),{installation:n,provider:r}=ut(),{hydratedRevision:i}=Dn(),{objectConfigurationsState:o}=di(),[s,a]=g.useState(""),c=(t==null?void 0:t.appName)||"",l=n==null?void 0:n.config,d=i&&Js(l,i),p=d!==null,m=!!((O=i==null?void 0:i.content)!=null&&O.write),f=m?zs(l):void 0,v=g.useMemo(()=>{const y=[...d||[]];return f&&m&&y.push(f),y},[d,f,m]),w=ry(v,s),I=g.useCallback(()=>{const y=v.find(x=>w!==x&&!x.completed);y&&a(y.name)},[v,w]);return g.useEffect(()=>{!s&&v.length>0&&a(v[0].name)},[v,s,I]),u.jsx(tc.Provider,{value:I,children:u.jsx(Qa.Provider,{value:w==null?void 0:w.name,children:u.jsxs(Xn,{style:{maxWidth:"55rem"},children:[u.jsxs(vn,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[u.jsxs("div",{style:{width:"20rem"},children:[u.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[Qt(r)," integration"]}),u.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),p&&u.jsx(ny,{value:s,readNavObjects:d,onValueChange:y=>a(y),objectConfigurationsState:o,otherNavObject:f,showUninstallButton:!!n})]}),e]}),u.jsx(Sc,{})]})})})}function iy({...e}){return u.jsx(oy,{...e})}function sy(){const[e,t]=g.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}function ay({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onInstallSuccess:o,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var f;const{projectId:l}=De(),{errorState:d}=Zt(),{seed:p,reset:m}=sy();return(f=d[Se.INTEGRATION_LIST])!=null&&f.apiError?u.jsx(Lt,{message:"Something went wrong, couldn't find integration information"}):u.jsx("div",{className:qs.resetContainer,children:u.jsx(jp,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onInstallSuccess:o,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:u.jsx(Bs,{groupRef:r,children:u.jsx(Pc,{consumerRef:t,consumerName:n,groupRef:r,groupName:i,children:u.jsx(af,{projectId:l,children:u.jsx(Mg,{resetComponent:m,children:u.jsx(Ch,{children:u.jsx(iy,{children:u.jsx(Rg,{})})})})})})})},p)})}function cy(){return u.jsxs(Xn,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[u.jsx($t,{}),u.jsx("p",{children:"Redirecting"})]})}function ly({redirectURL:e,children:t}){return g.useEffect(()=>{e&&window.location.replace(e)},[e]),e?u.jsx(cy,{}):t}function uy({provider:e}){const{appName:t}=De(),n=`You have successfully connected your ${Qt(e)} account to ${t}.`;return u.jsx(vi,{text:n})}function dy({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,redirectUrl:o,onSuccess:s}){return u.jsx("div",{className:qs.resetContainer,children:u.jsx(Bs,{provider:e,groupRef:r,children:u.jsx(Pc,{provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:i,onSuccess:s,children:u.jsx(ly,{redirectURL:o,children:u.jsx(uy,{provider:e})})})})})}const py=(e,t)=>{const n=Je(),{projectId:r}=De(),{integrations:i}=$s(),[o,s]=g.useState(!1),[a,c]=g.useState(null);if(!n||!r)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 l=g.useMemo(()=>i==null?void 0:i.reduce((d,p)=>(p==null?void 0:p.name)===e?p:d,{}),[i,e]);return g.useEffect(()=>{l&&Te().installationApi.listInstallations({projectIdOrName:r,integrationId:l.id,groupRef:t},{headers:{"x-api-key":n}}).then(d=>{s(!0),c(d.length>0)}).catch(d=>{console.error("Error listing installations."),Ye(d),s(!0)})},[t,n,r,l]),{isLoaded:o,isIntegrationInstalled:a}};exports.AmpersandContext=Vs;exports.AmpersandProvider=Rp;exports.ConnectProvider=dy;exports.FieldMapping=uc;exports.InstallIntegration=ay;exports.useAmpersandProvider=Ap;exports.useIsIntegrationInstalled=py;
|
package/build/amp-react.es.js
CHANGED
|
@@ -1872,7 +1872,7 @@ class Ep {
|
|
|
1872
1872
|
this.connectionApi = new yp(t), this.installationApi = new wp(t), this.integrationApi = new Ip(t), this.oAuthApi = new _p(t), this.projectApi = new bp(t), this.providerApi = new Op(t), this.providerAppApi = new Cp(t), this.revisionApi = new Np(t);
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
|
-
const Sp = "2.0.
|
|
1875
|
+
const Sp = "2.0.3", xp = "v1", _r = "https://api.withampersand.com";
|
|
1876
1876
|
function Xs() {
|
|
1877
1877
|
try {
|
|
1878
1878
|
const e = process.env.REACT_APP_AMP_SERVER;
|
|
@@ -8975,7 +8975,7 @@ function Lc() {
|
|
|
8975
8975
|
"footer",
|
|
8976
8976
|
{
|
|
8977
8977
|
style: {
|
|
8978
|
-
backgroundColor: "#EFEFEF",
|
|
8978
|
+
backgroundColor: "light-dark(#EFEFEF, #646266)",
|
|
8979
8979
|
padding: "1em",
|
|
8980
8980
|
fontSize: "0.8em",
|
|
8981
8981
|
color: "gray",
|
|
@@ -8986,7 +8986,7 @@ function Lc() {
|
|
|
8986
8986
|
gap: "0.4em"
|
|
8987
8987
|
},
|
|
8988
8988
|
children: [
|
|
8989
|
-
/* @__PURE__ */ m("p", { children: "Secured by" }),
|
|
8989
|
+
/* @__PURE__ */ m("p", { style: { color: "light-dark(gray, #EFEFEF)" }, children: "Secured by" }),
|
|
8990
8990
|
/* @__PURE__ */ m(
|
|
8991
8991
|
"a",
|
|
8992
8992
|
{
|