PageSourceSearch

https://cdn.abacus.ai/chatllm/assets/AppConnector-7HnuctQP.js

js abacus.ai collected 2026-10-01 10:16:29 UTC 27,817 bytes, 1 lines download raw bytes

1import{s as e}from"./rolldown-runtime-Bkc_ZF-M.js";import{Fn as t,Rn as n}from"./vendor-react-BZt4xn4K.js";import{f as r}from"./useBaseQuery-DsS9t1wH.js";import{Is as i,Ws as a,ac as o,k_ as s,yo as c}from"./CHQueries-DPMJK1YS.js";import{t as l}from"./v1-BEhZsOzv.js";import{ct as u,dt as d,et as f,tt as p}from"./vendor-lodash-BTY8rCei.js";import{o as m,x as h}from"./i18n-D7MhJc4e.js";import{t as g}from"./useLanguage-CYk3zbdt.js";import{n as _}from"./dist-BItEYCHf.js";import{xt as ee}from"./CHUses-Dx2_Y76_.js";import{t as v}from"./LoadingExt-CUr-der0.js";import{t as y}from"./ButtonExt-BzYH6nl_.js";import{t as b}from"./DialogExt-cldpL-AP.js";import{t as x}from"./InputExt-BZv8sWkF.js";import{t as te}from"./query-string-7xCgi5Eb.js";var S=e(u()),C=e(p()),w=e(f());const T=`https://abacus.ai/oauth/callback`;var E=new Set([`offline_access`,`openid`,`profile`,`email`]),D=e=>{let t=(e||``).trim().toLowerCase();return t===`.default`||t.endsWith(`/.default`)},ne=e=>E.has((e||``).trim().toLowerCase());const O=e=>!Array.isArray(e)||e.length===0?e??[]:e.some(e=>!D(e)&&!ne(e))?e.filter(e=>!D(e)):e;var k=class{windowOpen;randomS;onMessage;authQueryParam;forwardSignedCallbackParams;broadcastChannel;doCloseWindow=()=>{this.windowOpen&&(this.windowOpen.closed||(this.windowOpen.close(),this.windowOpen=null)),this.broadcastChannel!=null&&(this.broadcastChannel.close(),this.broadcastChannel=null)};handleCallback=(e,t)=>{if(e){let n=e.error;if(!s.isNullOrEmpty(n)){n=e.error_description?e.error_description:n,_.error(n||s.errorDefault),t(null);return}let r=e.code,i=e.state;if(!s.isNullOrEmpty(r)&&!s.isNullOrEmpty(i))return i===this.randomS?t(r,(0,C.default)(e,this.forwardSignedCallbackParams?[`error`,`error_description`]:[`code`,`state`,`error`,`error_description`])):void 0}t(null)};redirectOauth=(e,t,n,r,i,a)=>{let o=window.location.protocol+`//`+window.location.hostname,c=window.location.port;s.isNullOrEmpty(c)||(o+=`:`+c);let u=Array.from(new TextEncoder().encode(i),e=>e.toString(16).padStart(2,`0`)).join(``),d=l()+`__`+o+`__chatweb__r=`+u,f=O(n),p=f?.length?`&`+(a||`scope`)+`=`+f.join(`%20`):``,m=`client_id=`+s.encodeQueryParam(t)+`&redirect_uri=`+s.encodeQueryParam(T)+p+`&state=`+s.encodeQueryParam(d)+(r?`&`+r.join(`&`):``);return window.location.assign(e+(e.includes(`?`)?`&`:`?`)+m),d};openOauth=(e,t,n,r,i,a,o,c,u,d,f)=>{this.doCloseWindow(),this.forwardSignedCallbackParams=!!d;let p=c||window.location.protocol+`//`+window.location.hostname,h=window.location.port;s.isNullOrEmpty(h)||(p+=`:`+h),this.randomS=l()+`__`+p+`__chatweb`;let g=O(n),ee=g?.length?`&`+(o||`scope`)+`=`+g.join(`%20`):``,v=`client_id=`+s.encodeQueryParam(t)+`&redirect_uri=`+s.encodeQueryParam(`https://abacus.ai/oauth/callback`)+ee+`&state=`+s.encodeQueryParam(this.randomS)+(r?`&`+r.join(`&`):``),y=e+(e.includes(`?`)?`&`:`?`)+v;if(u)try{let t=new URL(e);y=t.origin+`/?redirect=`+encodeURIComponent(t.pathname+t.search+(t.search?`&`:`?`)+v)+`&no_redirect=true`}catch(e){console.warn(`Could not build the account-picker URL; falling back to the direct authorize URL`,e)}if(f)try{let e=new URL(y),t=new URL(f);t.origin===e.origin?(t.searchParams.set(`redirect`,e.pathname+e.search),y=t.toString()):console.warn(`Ignoring the SSO sign-in URL: it is not on the authorize endpoint origin`)}catch(e){console.warn(`Could not build the SSO sign-in URL; falling back to the direct authorize URL`,e)}let b=a||y;this.onMessage!=null&&window.removeEventListener(`message`,this.onMessage),this.broadcastChannel!=null&&this.broadcastChannel.close(),this.broadcastChannel=new BroadcastChannel(`abacusai_channel`),this.broadcastChannel.onmessage=e=>{(0,S.default)(e.data?.query)&&window.__oauthCallbackPost(e.data?.query)},this.onMessage=e=>{(0,S.default)(e.data?.query)&&window.__oauthCallbackPost(e.data?.query)},window.addEventListener(`message`,this.onMessage),window.__oauthCallbackPost=e=>{if(this.authQueryParam===e)return;(0,w.default)(e,`?`)&&(e=e.substring(1));let t=te.parse(e);this.handleCallback(t,i),this.doCloseWindow(),this.authQueryParam=e};let x=window.screenLeft==null?window.screenX:window.screenLeft,C=window.screenTop==null?window.screenY:window.screenTop,T=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,E=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,D=T/window.screen.availWi
1dth,ne=(T-600)/2/D+x,k=(E-600)/2/D+C;return this.windowOpen=window.open(b,`_blank`,`toolbar=0,location=0,menubar=0,height=600,width=600,top=`+k+`,left=`+ne),this.windowOpen||_.error(m.t(`oauth.yourBrowserBlockedThe`,`Your browser blocked the sign-in popup. Please allow popups and try again.`)),this?.windowOpen?.focus?.(),this.windowOpen};generateCodeVerifierS256=()=>{let e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode.apply(null,Array.from(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)};generateCodeChallengeS256=async e=>{let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(n)))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}},A=`https://connect.facebook.net/en_US/sdk.js`,j=`v26.0`,M=1500,re=new Set([`FINISH`,`FINISH_ONLY_WABA`,`FINISH_WHATSAPP_BUSINESS_APP_ONBOARDING`]),N=null,P=null,F=()=>window.FB,I=()=>{let e=F();return e?Promise.resolve(e):(N||=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=A,n.async=!0,n.crossOrigin=`anonymous`,n.onload=()=>{let n=F();n?e(n):(N=null,t(Error(`Meta SDK loaded without defining FB`)))},n.onerror=()=>{N=null,t(Error(`Failed to load the Meta SDK`))},document.head.appendChild(n)}),N)};const ie=()=>{I().catch(()=>{})},ae=(e,t)=>{let n=t+`=`,r=(e||[]).find(e=>typeof e==`string`&&e.startsWith(n));if(!r)return null;try{return decodeURIComponent(r.substring(n.length))||null}catch{return r.substring(n.length)||null}},oe=e=>{let t=/\/(v\d+\.\d+)\//.exec(e||``);return t?t[1]:j};var L=e=>{try{let t=new URL(e).hostname;return t===`facebook.com`||t.endsWith(`.facebook.com`)}catch{return!1}},se=e=>
1{if(typeof e.data!=`string`||!L(e.origin))return null;try{let t=JSON.parse(e.data);return t?.type===`WA_EMBEDDED_SIGNUP`?t:null}catch{return null}};const ce=async({appId:e,configId:t,graphApiVersion:n})=>{let r=await I();return P!==e&&(r.init({appId:e,version:n,cookie:!1,xfbml:!1,autoLogAppEvents:!1,fedCM:!1}),P=e),new Promise(e=>{let n=null,i=!1,a=null,o,s=t=>{i||(i=!0,window.clearTimeout(o),window.removeEventListener(`message`,c),e(t))},c=e=>{let t=se(e);!t?.event||!re.has(t.event)||(n={wabaId:t.data?.waba_id,phoneNumberId:t.data?.phone_number_id},a&&s({code:a,...n}))};window.addEventListener(`message`,c),r.login(e=>{let t=e?.authResponse?.code;if(!t){s(null);return}if(n){s({code:t,...n});return}a=t,o=window.setTimeout(()=>s({code:t}),M)},{config_id:t,response_type:`code`,override_default_response_type:!0,extras:{setup:{}}})})},le=async(e,t)=>{let n=e?.oauthConfig;if(!n?.url)return _.error(m.t(`mcpOauth.missingOauthConfig`,`This connection is missing its sign-in configuration. Delete it and add the server again.`)),t(null,null),null;let r=n?.extras;Array.isArray(r)&&(r=r.map(e=>typeof e==`string`&&/^code_challenge_method=s256$/i.test(e.trim())?`code_challenge_method=S256`:e));let i=n?.scopes||[],a=new k,o=null;if(r?.includes(`code_challenge_method=S256`)){o=a.generateCodeVerifierS256();let e=await a.generateCodeChallengeS256(o);r.some(e=>typeof e==`string`&&e.startsWith(`code_challenge=`))||(r=[...r,`code_challenge=${e}`])}return a.openOauth(n.url,n.clientId,i,r,e=>t(e,o))},ue=(e,t,n)=>({applicationConnectorId:e.applicationConnectorId,mcpServerName:e.serverName||e.name,oauthToken:t,scopes:e?.oauthConfig?.scopes||[],...n?{codeVerifier:n}:{}}),R=`abacus_oauth_redirect_pending`,de=e=>{sessionStorage.setItem(R,JSON.stringify(e))};var fe=()=>{try{let e=sessionStorage.getItem(R);return e?JSON.parse(e):null}catch{return null}},z=[`code`,`state`,`error`,`error_description`],B=[`error`,`error_description`],V=(e,t)=>{if(Object.keys(t).length===0)return e;if(typeof e.metadata==`string`){let n={};try{n=JSON.parse(e.metadata)||{}}catch{n={}}return{...e,metadata:JSON.stringify({...n,...t})}}return{...e,metadata:{...e.metadata||{},...t}}};const H=async e=>{let t=fe(),n=new URLSearchParams(e),r=n.get(`state`);if(!t||!r||r!==t.state)return null;sessionStorage.removeItem(R);let a=n.get(`error`);if(a)return{error:n.get(`error_description`)||a};let o=n.get(`code`);if(!o)return{error:s.errorDefault};let c=t.forwardSignedCallbackParams?B:z,l={};n.forEach((e,t)=>{c.includes(t)||(l[t]=e)});let u=await i({endpoint:t.endpoint,obj:{...V(t.values,l),[t.tokenField]:o}});return!u?.success||u?.error?{error:(typeof u?.error==`string`?u.error:typeof u?.error==`object`?u?.error?.message:null)||s.errorDefault}:{result:u?.result}},U=e=>{let t=new URLSearchParams(e),n=(t.get(`state`)||``).split(`__`),r=n.slice(3).join(`__`);if(n.length<4||n[2]!==`chatweb`||!r.startsWith(`r=`)||!/^[0-9a-f]*$/i.test(r.substring(2)))return null;let i;try{i=new URL(decodeURIComponent(n[1])).origin}catch{return null}let a=r.substring(2).match(/[0-9a-f]{2}/gi)||[],o=new TextDecoder().decode(new Uint8Array(a.map(e=>parseInt(e,16)))),s=o.startsWith(`/chatllm/`)&&!o.includes(`//`)&&!o.includes(`\\`);return i!==window.location.origin||!s?null:(t.delete(`appId`),window.location.origin+o+(o.includes(`?`)?`&`:`?`)+`oauthReturn=1&providerQuery=`+encodeURIComponent(t.toString()))};var pe=e(d()),W=e(n()),G=e(t()),K=(e,t=!1)=>(e?.isOAuthConnector||e?.isGenericOauth)&&(t?e?.serviceName?.toLowerCase():null)||e?.service?.toUpperCase(),q=(e,t,n,r={})=>{let i=K(e,!0)||(typeof e?.service==`string`?e.service:``).toLowerCase(),a=e?.base_connector??e?.baseConnector,o={...a?{baseConnector:a,genericOauthService:i||(e?.generic_oauth_service??e?.genericOauthService)?.toLowerCase?.()}:e?.metadata||{},...r};return{service:`GENERIC_OAUTH`,genericOauthService:i,oauthToken:t,scopes:Array.isArray(n)?JSON.stringify(n):n,...Object.keys(o).length>0&&{metadata:typeof o==`string`?o:JSON.stringify(o)}}},me=async(e,t,n)=>{if(!Array.isArray(t))return{extras:t,pkceData:n||null};let r=t.map(e=>typeof e==`string`&&/^code_challenge_method=s256$/i.test(e.trim())?`co
1de_challenge_method=S256`:e);if(!r.includes(`code_challenge_method=S256`))return{extras:r,pkceData:null};let i=n||null;if(!i?.codeChallenge){let t=e.generateCodeVerifierS256();i={codeVerifier:t,codeChallenge:await e.generateCodeChallengeS256(t)}}return{extras:r.some(e=>typeof e==`string`&&e.startsWith(`code_challenge=`))?r:[...r,`code_challenge=${i.codeChallenge}`],pkceData:i}},J=({disabled:e,itemClassName:t,className:n,appConnector:l,closePopover:u,refreshAppConectors:d,handleOpenGoogleDrivePicker:f,handleOpenOneDrivePicker:p,handleOpenBoxPicker:m,handleOpenSharePointPicker:te,isAgentConnector:S,handleAgentConnectorSuccess:C,buttonComponent:w,agentInfo:T,onConnectionSuccess:E,onConnectionError:D,onConnectionValidate:ne,allowOauth:O=!0,isDatabaseConnector:A=!1,isMcpConnector:j=!1,isReconnect:M=!1,mergeWithGrantedScopes:re=!1,oauthMode:N=`popup`,oauthExtras:P,autoStart:F=!1,redirectReturnPath:I})=>{let{t:L}=g(),[se,R]=(0,W.useState)(!1),[fe,z]=(0,W.useState)(!1),[B,V]=(0,W.useState)(`form`),[H,U]=(0,W.useState)({ssoStartUrl:``,ssoRegion:``,registrationScopes:`sso:account:access`,ssoAccountId:``,ssoRoleName:``}),[J,Y]=(0,W.useState)(null),[he,X]=(0,W.useState)(!1),[ge,_e]=(0,W.useState)({}),[ve,ye]=(0,W.useState)(null),be=r(),Z=l?.requiresConfigConnector===!0||l?.requires_config_connector===!0,{data:xe,isLoading:Se,isError:Ce}=ee(Z),we=(0,W.useMemo)(()=>{if(!Z||Ce)return!0;let e=(l?.service||``).toString().toLowerCase();return(xe?.result||[]).some(t=>(t?.service||``).toString().toLowerCase()===e)},[Z,Ce,xe,l?.service]),Te=(0,W.useCallback)(async()=>{if(!H.ssoStartUrl||!H.ssoRegion||!H.ssoAccountId||!H.ssoRoleName){_.error(L(`appConnector.sSOStartURLRegion`,`SSO Start URL, Region, Account ID, and Role Name are required.`));return}V(`verify`);try{let e=await i({endpoint:`_connectAwsssoInitiate`,obj:{ssoStartUrl:H.ssoStartUrl,ssoRegion:H.ssoRegion,registrationScopes:H.registrationScopes,ssoAccountId:H.ssoAccountId,ssoRoleName:H.ssoRoleName}});if(!e?.success||e?.error){_.error(h(e?.error,L)||L(`appConnector.failedToInitiateAWS`,`Failed to initiate AWS SSO.`)),V(`form`);return}Y(e?.result)}catch(e){_.error(h(e?.message,L)||L(`appConnector.failedToInitiateAWS2`,`Failed to initiate AWS SSO.`)),V(`form`)}},[H]),Ee=(0,W.useCallback)(async()=>{if(!J)return;V(`polling`);let e=J.interval?Math.max(J.interval,5)*1e3:5e3;for(let t=0;t<60;t++)try{let t=await i({endpoint:`_connectAwsssoExchangeToken`,obj:{deviceCode:J.deviceCode,clientId:J.clientId,clientSecret:J.clientSecret,ssoRegion:H.ssoRegion}}),n=t?.result?.status;if(n===`success`){let e=t.result;Q(`_createUserConnector`,{service:`AWSSSO`,oauthToken:JSON.stringify({access_token:e.accessToken,refresh_token:e.refreshToken||``,token_type:e.tokenType||`Bearer`,expires_in:e.expiresIn||0,client_id:J.clientId,client_secret:J.clientSecret,client_secret_expires_at:J.clientSecretExpiresAt||0,sso_start_url:H.ssoStartUrl,sso_region:H.ssoRegion,registration_scopes:H.registrationScopes,sso_account_id:H.ssoAccountId,sso_role_name:H.ssoRoleName})}),z(!1),V(`form`),Y(null);return}if(n===`authorization_pending`||n===`slow_down`){await new Promise(t=>setTimeout(t,n===`slow_down`?e+5e3:e));continue}_.error(h(t?.error,L)||L(`appConnector.aWSSSOAuthorizationFailed`,`AWS SSO authorization failed. Please try again.`)),V(`verify`);return}catch(e){_.error(h(e?.message,L)||L(`appConnector.authorizationFailedOrExpired`,`Authorization failed or expired.`)),V(`verify`);return}_.error(L(`appConnector.authorizationTimedOutPlease`,`Authorization timed out. Please try again.`)),V(`verify`)},[J,H]),Q=(e,t)=>{t!=null&&(ne?.(),i({endpoint:e,obj:t}).then(e=>{if(!e?.success||e?.error){let t=typeof e?.error==`string`?e?.error:typeof e?.error==`object`?e?.error?.message:null;_.error(h(t,L)||s.errorDefault),D?.(t||s.errorDefault)}else if(be.invalidateQueries({queryKey:[`listUserLevelConnectors`]}),u?.(),d?.(),E?.(e?.result),S)if(e?.result?.error){let t=typeof e?.result?.error==`string`?e?.result?.error:typeof e?.result?.error==`object`?e?.result?.error?.message:null;_.error(h(t,L)||s.errorDefault)}else C?.(t);else !j&&e?.result?.service?.toUpperCase()===`GOOGLEDRIVEUSER`?f?.():!j&&e?.result?.service?.toUpperCase()===`ONEDRIVE`?p?.():!j&&e?.result?.service?.toUpperCase()===`BOX`?m?.():!j&&e?.result?.service?.toUpperCase()===`SHAREPOINT`&&te?.()}).catch(e=>{let t=typeof e?.error==`string`?e?.error:typeof e?.error==`object`?e?.error?.message:null;_.error(h(t,L)||s.errorDefault),D?.(t||s.errorDefault)}).finally(()=>{}))},De=()=>{let e=l?.credentialFormFields||[],t={};for(let n of e){let e=ge[n.name]?.trim()||n.default||``;if(n.required&&!e){_.error(L(`appConnector.pleaseFillInAll`,`Please fill in all required fields.`));return}e&&(t[n.name]=e)}X(!1),Q(l.userLevelConfigurationEndpoint||`_createUserConnector`,{service:l.service?.toUpperCase?.()||l.service,oauthToken:JSON.stringify(t)})},Oe=async()=>
1{if(!O)return;let e=l.oauthConfig.userLevel?.scopes||l.oauthConfig.scopes,t=l.oauthConfig.userLevel?.extras||l.oauthConfig.extras,n=new k,r=null;({extras:t,pkceData:r}=await me(n,t,r)),R(!0),o({service:l.service?.toUpperCase()}).then(i=>{if(!i?.success||i?.error)_.error(h(i?.error,L)||s.errorDefault);else{let a=i?.result?.find(e=>e.type===`oAuthButton`);if(a){let i=(t,n={})=>{if(!t)return;let i=l?.metadata?.baseConnector??l?.metadata?.base_connector??l?.base_connector??l?.baseConnector,o={...l.metadata,...i&&{baseConnector:i},...n};if(l?.isOAuthConnector){let i={...q(l,t,e,n),...r?.codeVerifier&&{codeVerifier:r.codeVerifier}};Q(l.configurationEndpoint,i)}else if(l?.userLevelConfigurationEndpoint){let n={service:l.service?.toUpperCase(),oauthToken:t,scopes:e,metadata:o,...r?.codeVerifier&&{codeVerifier:r.codeVerifier}};Q(l.userLevelConfigurationEndpoint,n)}else{let n={[a.value]:t,scopes:e,isUserLevel:!0,metadata:o};Q(l.configurationEndpoint,n)}},o;o=l.oauthConfig.userLevel?window.location.hostname?.toLowerCase().includes(`preprod`)&&l.oauthConfig.userLevel.preprodClientId||l.oauthConfig.userLevel.clientId:window.location.hostname?.toLowerCase().includes(`preprod`)&&l.oauthConfig.preprodClientId||l.oauthConfig.clientId;let s=a?.overrides,c=l.metadata?.oauth_config||l.metadata?.oauthConfig,u=c?.userLevel?.clientId||c?.clientId;o=s?.clientId||u||o;let d=s?.url||l.oauthConfig.url||c?.url,f=c?.scopes;e=s?.scopes||f||e,n.openOauth(d,o,e,t,i,null,l.oauthConfig.userScopesParam,void 0,void 0,void 0,s?.ssoSignInUrl)}}}).catch(e=>{let t=e&&typeof e==`object`&&`message`in e?e.message:typeof e==`string`?e:String(e)||s.errorDefault;_.error(h(t,L))}).finally(()=>{R(!1)})},ke=async()=>{if(!O)return;let e=l?.oauthConfig?.loginFlow===`meta_embedded_signup`;e&&ie();let t=T?.agentConfig?.AGENT_CONNECTORS;(t?.hasOwnProperty(`USER_LEVEL_CONNECTORS`)||t?.hasOwnProperty(`ORG_LEVEL_CONNECTORS`))&&(t=t?.USER_LEVEL_CONNECTORS);let n=K(l),r=t?.[n||``],i=null;if(!M)try{i=await c({service:K(l)})}catch{i={result:[]}}let o=(0,pe.default)(r)&&r?.length>0;r||=null;let u=l?.oauthConfig?.scopes;r||=u,!M&&(re||!o)&&(r=(r||[]).concat(i?.result||[])),r=r.filter((e,t)=>r.indexOf(e)===t);let d=l.oauthConfig.userLevel?.extras||l.oauthConfig.extras,f=null;R(!0);let p=K(l),m=l?.is_generic_oauth===!0||l?.isGenericOauth===!0,g=l?.base_connector??l?.baseConnector;a({service:m&&g?`GENERIC_OAUTH`:p,metadata:m&&g?{baseConnector:g,genericOauthService:(typeof l?.service==`string`?l.service:``).toLowerCase()||(l?.generic_oauth_service??l?.genericOauthService)?.toLowerCase?.()}:l?.metadata}).then(async t=>{if(!t?.success||t?.error)_.error(h(t?.error,L)||s.errorDefault);else{let n=t?.result?.find(e=>e.type===`oAuthButton`),i=new k;if(n){let t;t=l.oauthConfig.userLevel?window.location.hostname?.toLowerCase().includes(`preprod`)&&l.oauthConfig.userLevel?.preprodClientId||l.oauthConfig.userLevel?.clientId:window.location.hostname?.toLowerCase().includes(`preprod`)&&l.oauthConfig.preprodClientId||l.oauthConfig.clientId;let a=n?.overrides;t=a?.clientId||t,d=a?.extras||d,P?.length&&(d=[...d||[],...P]);let s=a?.url||l.oauthConfig.url;({extras:d,pkceData:f}=await me(i,d,f));let c=o?r:a?.scopes||((0,pe.default)(r)&&r.length>0?r:[]),u=(e,t={})=>{if(!e)return;let r={...l.metadata,...t};if(l?.isOAuthConnector||n?.isGenericOauth){let r={...q(l,e,c,t),...f?.codeVerifier&&{codeVerifier:f.codeVerifier}};Q(l.configurationEndpoint||n?.endpoint||n?.overrides?.configurationEndpoint,r)}else if(l?.userLevelConfigurationEndpoint){let t={service:l.service?.toUpperCase(),oauthToken:e,scopes:c,metadata:r,...f?.codeVerifier&&{codeVerifier:f.codeVerifier}};Q(l.userLevelConfigurationEndpoint,t)}else{let t={[n.value]:e,scopes:c,isUserLevel:!0,metadata:r};Q(l.configurationEndpoint,t)}},p=()=>{if(N===`redirect`&&I){let e={...l.metadata},r=f?.codeVerifier?{codeVerifier:f.codeVerifier}:{},o=l?.isOAuthConnector||n?.isGenericOauth?{endpoint:l.configurationEndpoint||n?.endpoint||n?.overrides?.configurationEndpoint,values:{...q(l,``,c),...r},tokenField:`oauthToken`}:l?.userLevelConfigurationEndpoint?{endpoint:l.userLevelConfigurationEndpoint,values:{service:l.service?.toUpperCase(),scopes:c,metadata:e,...r},tokenField:`oauthToken`}:{endpoint:l.configurationEndpoint,values:{scopes:c,isUserLevel:!0,metadata:e},tokenField:n.value},u=i.redirectOauth(s,t,c,d,I,l.oauthConfig.userScopesParam);de({...o,state:u,forwardSignedCallbackParams:!!a?.verifySignedCallback});return}i.openOauth(s,t,c,d,u,null,l.oauthConfig.userScopesParam,void 0,!!a?.accountPicker,!!a?.verifySignedCallback,a?.ssoSignInUrl)},m=e?ae(d,`config_id`):null,h=()=>
1{if(!m){p();return}ce({appId:t,configId:m,graphApiVersion:oe(s)}).then(e=>{e?u(e.code,{login_flow:`embedded_signup`,waba_id:e.wabaId??null,phone_number_id:e.phoneNumberId??null}):_.error(L(`appConnector.whatsappSignInNotCompleted`,`WhatsApp sign-in was not completed. If your browser blocked the popup, allow popups and try again.`))}).catch(e=>{console.warn(`Meta SDK unavailable, falling back to the redirect sign-in`,e),p()})};$?ye({launch:h,installUrl:`${s}?client_id=${encodeURIComponent(t)}&${($.installExtras||[]).join(`&`)}`}):h()}}}).catch(e=>{let t=e&&typeof e==`object`&&`message`in e?e.message:typeof e==`string`?e:String(e)||s.errorDefault;_.error(h(t,L))}).finally(()=>{R(!1)})},Ae=async()=>{if(O)try{R(!0),await le(l,(e,t)=>{e&&Q(l.mcpConfigurationEndpoint,ue(l,e,t))})}catch(e){let t=e&&typeof e==`object`&&`message`in e?e.message:typeof e==`string`?e:String(e)||s.errorDefault;_.error(h(t,L)),D?.(t)}finally{R(!1)}},$=!A&&!j?l?.installPrompt:null,je=()=>{window.open(ve?.installUrl,`_blank`,`noopener,noreferrer`)},Me=async()=>(ve?.launch(),ye(null),!0),Ne=e=>{e||ye(null)},Pe=()=>{if(!(A&&l.status===`ACTIVE`||e)){if(Z&&!we){if(Se){_.info(L(`appConnector.checkingConnectorConfiguration`,`Checking your organization’s connector configuration…`));return}let e=l?.name||l?.service||``;_.error(L(`appConnector.configConnectorRequired`,`{{name}} requires an organization-level connector configuration. Set one up under User Connectors → Connector Configurations → Add Config, or ask an organization admin to add it.`,{name:e}));return}if(l?.isAwsAuthConnector){z(!0),V(`form`);return}if(l?.isCredentialFormConnector){_e({}),X(!0);return}if(l?.isZeroInteractionConnector){Q(l.userLevelConfigurationEndpoint||`_createUserConnector`,{service:l.service?.toUpperCase?.()||l.service});return}A?Oe():j?Ae():ke()}},Fe=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{!F||Fe.current||(Fe.current=!0,Pe())},[F,Pe]),(0,G.jsxs)(`div`,{"data-id":`connectorContainer`,className:`${n} ${!w&&`p-[4px]`}`,children:[(0,G.jsxs)(`div`,{"data-id":`connectorEach`,className:`${t} ${e?`cursor-not-allowed!`:``} flex justify-between items-center option gap-[12px] ${w?``:`px-[8px] rounded-md hover:bg-bwleftblue/20`} text-darkcolor ${S?`cursor-pointer bg-darkcolor/10 hover:bg-darkcolor/20 px-[15px]!`:``}
1 ${A&&l.status===`ACTIVE`?`cursor-default`:`cursor-pointer`}`,onClick:Pe,children:[w||(0,G.jsxs)(`div`,{"data-id":`logo`,className:`flex items-center gap-[5px]`,children:[l.logo&&(0,G.jsx)(`img`,{alt:l.name,className:`h-[20px] w-[20px] object-contain`,src:`https://abacus.ai/static/imgs/${l.logo||`connectors/`+l.service.toLowerCase()+`.webp`||`connectors/`+l.service.toLowerCase()+`.png`}`}),(0,G.jsxs)(`span`,{"data-id":`name`,className:`text-sm`,children:[l.name,` `,A&&l.status===`ACTIVE`?L(`appConnector.connected`,`Connected`):``]})]}),se&&(0,G.jsx)(v,{bare:!0,size:`sm`})]}),l?.isAwsAuthConnector&&(0,G.jsx)(b,{open:fe,onOpenChange:e=>{z(e),e||(V(`form`),Y(null))},className:`max-w-[520px] w-full! rounded-2xl focus:outline-hidden`,title:B===`form`?L(`appConnector.connectAWSSSO`,`Connect AWS SSO`):B===`verify`?L(`appConnector.authorizeAccess`,`Authorize Access`):L(`appConnector.completing`,`Completing...`),content:(0,G.jsxs)(G.Fragment,{children:[B===`form`&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(x,{placeholder:L(`appConnector.sSOStartURLEG`,`SSO Start URL (e.g., https://mycompany.awsapps.com/start)`),value:H.ssoStartUrl,onChange:e=>U({...H,ssoStartUrl:e.target.value})}),(0,G.jsx)(x,{placeholder:L(`appConnector.sSORegionEGUsEast1`,`SSO Region (e.g., us-east-1)`),value:H.ssoRegion,onChange:e=>U({...H,ssoRegion:e.target.value})}),(0,G.jsx)(x,{placeholder:L(`appConnector.registrationScopesCommaSeparated`,`Registration Scopes (comma-separated)`),value:H.registrationScopes,onChange:e=>U({...H,registrationScopes:e.target.value})}),(0,G.jsx)(x,{placeholder:L(`appConnector.aWSAccountID`,`AWS Account ID`),value:H.ssoAccountId,onChange:e=>U({...H,ssoAccountId:e.target.value})}),(0,G.jsx)(x,{placeholder:L(`appConnector.sSORoleName`,`SSO Role Name`),value:H.ssoRoleName,onChange:e=>U({...H,ssoRoleName:e.target.value})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,G.jsx)(y,{variant:`ghost`,className:`text-primary`,noScale:!0,onClick:()=>z(!1),children:L(`appConnector.cancel`,`Cancel`)}),(0,G.jsx)(y,{shape:`pill`,variant:`default`,noScale:!0,onClick:Te,children:L(`appConnector.continue`,`Continue`)})]})]}),B===`verify`&&J&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-darkcolor/70`,children:L(`appConnector.openTheLinkBelow`,`Open the link below in your browser and enter the code to authorize access:`)}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg`,children:[J.userCode&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:L(`appConnector.code`,`Code:`)}),(0,G.jsx)(`span`,{className:`font-mono text-lg font-bold tracking-wider`,children:J.userCode})]}),(0,G.jsx)(`a`,{href:J.verificationUriComplete||J.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-bwleftblue underline text-sm break-all`,children:J.verificationUriComplete||J.verificationUri})]}),(0,G.jsx)(`p`,{className:`text-xs text-darkcolor/50`,children:L(`appConnector.afterAuthorizingInYour`,`After authorizing in your browser, click the button below.`)}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(y,{variant:`ghost`,className:`text-primary`,noScale:!0,onClick:()=>{V(`form`),Y(null)},children:L(`appConnector.back`,`Back`)}),(0,G.jsx)(y,{shape:`pill`,variant:`default`,noScale:!0,onClick:Ee,children:L(`appConnector.iVeAuthorized`,`I've Authorized`)})]})]}),B===`polling`&&(0,G.jsx)(v,{size:`lg`,className:`flex flex-col items-center gap-3 py-4`,captionClassName:`mt-0 text-sm text-darkcolor/70`,children:L(`appConnector.completingAuthorization`,`Completing authorization...`)})]}),hideOkButton:!0,hideCancelButton:!0}),l?.isCredentialFormConnector&&(0,G.jsx)(b,{open:he,onOpenChange:X,className:`max-w-[520px] w-full! rounded-2xl focus:outline-hidden`,title:L(`appConnector.connectService`,`Connect {{name}}`,{name:l?.name}),content:(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(l?.credentialFormFields||[]).map(e=>e.type===`password`?(0,G.jsx)(x,{type:`password`,placeholder:e.placeholder||e.label,value:ge[e.name]||``,onChange:t=>_e(n=>({...n,[e.name]:t.target.value}))},e.name):(0,G.jsx)(x,{placeholder:e.placeholder||e.label,value:ge[e.name]||``,onChange:t=>_e(n=>({...n,[e.name]:t.target.value}))},e.name)),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,G.jsx)(y,{className:`bg-transparent! text-primary`,noScale:!0,onClick:()=>X(!1),children:L(`appConnector.cancel`,`Cancel`)}),(0,G.jsx)(y,{variant:`default`,shape:`pill`,noScale:!0,onClick:De,children:L(`appConnector.connect`,`Connect`)})]})]})}),hideOkButton:!0,hideCancelButton:!0}),$&&(0,G.jsx)(b,{open:ve!==null,onOpenChange:Ne,size:`default`,title:L(`appConnector.connectService`,`Connect {{name}}`,{name:l?.name}),description:L(`appConnector.installPromptDescription`,`The Abacus.AI a
1pp must be installed in your {{name}} account before you can connect. If it is not installed yet, install it first (an account admin may need to do this), then continue. Without it, {{name}} rejects the connection with an "Invalid scope param" error.`,{name:l?.name}),content:$.documentation?(0,G.jsx)(`a`,{href:s.baseHelpPagesUrl()+`/`+$.documentation,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-primary underline`,children:L(`appConnector.viewTheSetupGuide`,`View the setup guide`)}):null,tertiaryText:$.installExtras?L(`appConnector.installApp`,`Install app`):void 0,onClickTertiary:je,okText:L(`appConnector.continue`,`Continue`),onClickOk:Me})]})};export{ue as a,k as c,de as i,H as n,le as o,U as r,T as s,J as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.