import{_ as i}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,a){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,a),a)}};const s=e=>({addConnectionHelpingText:i("You can create an OAuth2 application and get credentials from ")+`<a target="_blank" class="text-blue-600 underline" rel="noopener noreferrer nofollow" href="https://www.flowlu.com/api/#section/OAuth-2.0">${i("Flowlu API Documentation")}</a>`,componentName:e.componentName.connection,connectionsTypes:[{authCodeEndpoint:{method:"GET",queryParams:{client_id:"",response_type:"code",scope:"read write"},url:""},encryptKeys:["access_token","refresh_token","client_secret"],label:i("OAuth 2"),refreshTokenUrl:"",tokenEndpoint:{bodyParams:{client_id:"",client_secret:"",grant_type:"authorization_code"},method:"POST",url:""},type:"oauth2",verifyConnection:{method:"GET",queryParams:{access_token:"$_access_token_$"},responseMatch:{responseCode:200},url:""}}],extraComponents:[{componentName:e.componentName.input,helperText:i('Enter only the subdomain part. If your URL is https://yourcompany.flowlu.com, enter "yourcompany"'),id:"domain",label:i("Domain"),onChange:"SET_DOMAIN",placeholder:i("Enter your company domain (e.g., yourcompany)"),render:!0,required:!0,value:void 0,wrapperClassName:"mb-2"}],extraData:{},fieldType:"config",id:"connection-id",label:i("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0}),l=({$:e,e:a})=>{e.setThisComponent(t=>{var o,r;if(!e.util.isConnectionComponent(t))return;const n=t.connectionsTypes[0];!n||n.type!=="oauth2"||((o=n.authCodeEndpoint)!=null&&o.queryParams&&(n.authCodeEndpoint.queryParams.client_id=a.clientId),(r=n.tokenEndpoint)!=null&&r.bodyParams&&(n.tokenEndpoint.bodyParams.client_id=a.clientId,n.tokenEndpoint.bodyParams.client_secret=a.clientSecret))})},u=({$:e,e:a})=>{e.setThisComponent(t=>{e.util.isInputComponent(t)&&(t.value=a.target.value,t.status=void 0)}),e.setComponent("connection-id",t=>{if(!e.util.isConnectionComponent(t))return;const n=a.target.value;t.extraData||(t.extraData={}),t.extraData.domain=n;const o=t.connectionsTypes[0];o&&o.type==="oauth2"&&(o.authCodeEndpoint&&(o.authCodeEndpoint.url=`https://${n}.flowlu.com/oauth2/authorize`),o.tokenEndpoint&&(o.tokenEndpoint.url=`https://${n}.flowlu.com/oauth2/access_token`,o.refreshTokenUrl=`https://${n}.flowlu.com/oauth2/refresh_token`),o.verifyConnection&&(o.verifyConnection.url=`https://${n}.flowlu.com/api/v1/module/crm/accounts/list`))})};export{l as a,s as c,u as h};
