import{aa as E,ab as s}from"./_applist-tangy-colts-beg-36.js";import{_ as a}from"./main-tangy-colts-beg.js";import{s as p}from"./machine.-tangy-colts-beg-869.js";import{f as c,a as l,b as d}from"./machineh-tangy-colts-beg-716.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const _=E(({helpers:t})=>({states:{components:[{addConnectionHelpingText:a('You can find credentials from <a target="_blank" class="text-blue-600 underline" rel="noopener noreferrer nofollow" href="https://my.demio.com/manage/settings/api-details">Here</a>'),componentName:t.componentName.connection,connectionsTypes:[{encryptKeys:["value"],label:a("API Key"),type:"api_key",verifyConnection:{headers:{Accept:"application/json","api-key":"","api-secret":""},method:"GET",responseKeyMatch:["pong"],url:"https://my.demio.com/api/v1/ping"}}],fieldType:"config",id:"connection-id",label:a("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0},{componentName:t.componentName.select,fieldType:"config",id:"event-id",label:a("Event"),onChange:"SELECT_EVENT",onRefetch:"REFETCH_EVENT",optionFilterProp:"label",options:[],placeholder:a("Select an event"),render:"IF_CONNECTION_SELECTED",showSearch:!0,value:void 0},{componentName:t.componentName.select,fieldType:"config",id:"session-id",label:a("Session"),onChange:"SELECT_SESSION",onRefetch:"REFETCH_SESSION",optionFilterProp:"label",options:[],placeholder:a("Select a section"),render:"IF_EVENT_SELECTED",showSearch:!0,value:void 0},{addItemButtonLabel:"Add Column",componentName:t.componentName.repeaterField,fieldsMetaData:[{componentName:t.componentName.select,label:a("Field"),name:"demioField",options:[],required:!0,showSearch:!0,style:{width:200},value:""},{componentName:t.componentName.mixInput,label:a("Value"),name:"value",required:!0,value:[],wrapperClassName:"w-100"}],id:"row-data",label:a("Field Mapping"),onChange:"ON_CHANGE_ROW_DATA",path:"rowData",render:"IF_EVENT_SELECTED",value:[]}]},actions:{IF_CONNECTION_SELECTED:({$:e})=>{var o;return s((o=e.getComponent("connection-id"))==null?void 0:o.value)},IF_EVENT_SELECTED:({$:e})=>{var o;return s((o=e.getComponent("event-id"))==null?void 0:o.value)},IF_SESSION_SELECTED:({$:e})=>{var o;return s((o=e.getComponent("session-id"))==null?void 0:o.value)},ON_CHANGE_ROW_DATA:({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setDb(n=>{n.rowData=o})},ON_MACHINE_LOAD:async({$:e})=>{p(e,[{db:"connectionId",id:"connection-id"},{db:"eventId",id:"event-id"},{db:"sessionId",id:"session-id"},{db:"rowData",id:"row-data"}]),await Promise.all([c(e),d(e),l(e)])},REFETCH_SESSION:async({$:e})=>{await d(e)},REFETCH_EVENT:async({$:e})=>{await c(e)},SELECT_SESSION:async({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setComponent("section-title",n=>{n.value=void 0}),e.setDb(n=>{n.sessionId=o,n.sectionTitle=void 0})},SELECT_EVENT:async({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setComponent("project-title",n=>{n.value=void 0}),e.setDb(n=>{n.eventId=o,n.projectTitle=void 0}),await d(e),await l(e)},CONNECTION_ADD_CHANGE:({$:e,e:o})=>{e.setThisComponent(n=>{e.util.isConnectionComponent(n)&&n.connectionsTypes.forEach(i=>{var r;i.type==="api_key"&&((r=i.verifyConnection)!=null&&r.headers)&&(i.verifyConnection.headers["api-key"]=o.key,i.verifyConnection.headers["api-secret"]=o.value)})})},SET_CONNECTION:async({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setDb(n=>{n.connectionId=o}),await c(e),await l(e)}}}));export{_ as default};
