import{aa as p,ab as r}from"./_applist-tangy-colts-beg-36.js";import{_ as n}from"./main-tangy-colts-beg.js";import{s as l}from"./machine.-tangy-colts-beg-869.js";import{a as s,b as d}from"./machineh-tangy-colts-beg-791.js";import{w as m}from"./woodpeck-tangy-colts-beg-773.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(a,e){return this.cache.has(a)?this.cache.get(a):(this.cache.set(a,e),e)}};const E=p(({helpers:a})=>({states:{components:[{addConnectionHelpingText:n('You can find your API key in <a target="_blank" class="text-blue-600 underline" rel="noopener noreferrer nofollow" href="https://app.woodpecker.co/settings/api">Woodpecker Settings</a>'),componentName:a.componentName.connection,connectionsTypes:[{encryptKeys:["value"],label:n("Api Key"),showKey:!1,type:"api_key",verifyConnection:{headers:{Authorization:"","Content-Type":"application/json"},method:"GET",responseKeyMatch:["0.id"],url:"https://api.woodpecker.co/rest/v1/campaign_list"}}],fieldType:"config",id:"connection-id",label:n("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0},{componentName:a.componentName.select,fieldType:"config",id:"prospect-id",label:n("Select Prospect"),onChange:"SET_PROSPECT_EMAIL",onRefetch:"REFETCH_CAMPAIGN_LIST",options:[],placeholder:n("Select a Prospect"),render:"IF_CONNECTION_SELECTED",required:!0,value:void 0},{componentName:a.componentName.select,fieldType:"config",id:"update-id",label:n("Update"),onChange:"IS_UPDATE",placeholder:n("Update"),render:!1,required:!0,style:{width:150},value:"true"},{addItemButtonLabel:n("Add Prospect Fields"),componentName:a.componentName.repeaterField,fieldsMetaData:[{componentName:a.componentName.select,id:"prospects-entry",label:n("Field"),name:"woodpeckerField",options:m,required:!0,style:{width:150},value:""},{componentName:a.componentName.mixInput,label:n("Value"),name:"value",required:!0,value:[],wrapperClassName:"w-100"}],id:"prospects-list",label:n("Field Mapping"),onChange:"ON_FIELD_MAP_CHANGE",render:"IF_CONNECTION_SELECTED",value:void 0},{componentName:a.componentName.select,fieldType:"config",id:"add-to",label:n("Add Prospects To"),onChange:"SET_ADD_TO",options:[{label:n("Campaign"),value:"campaign"},{label:n("Prospect List"),value:"prospect_list"}],placeholder:n("Select where to add prospects"),render:!1,required:!0,value:"prospect_list"}]},actions:{SET_CONNECTION:async({$:e,e:o})=>{e.setThisComponent(t=>{t.value=o}),e.setDb(t=>{t.connectionId=o}),await s(e)},IF_CONNECTION_SELECTED:({$:e})=>{var o;return r((o=e.getComponent("connection-id"))==null?void 0:o.value)},REFETCH_CAMPAIGN_LIST:async({$:e})=>{await s(e)},SET_PROSPECT_EMAIL:async({$:e,e:o})=>{e.setThisComponent(i=>{i.value=o}),e.setDb(i=>{i.prospectId=o});const t=await d(o,e);e.setComponent("prospects-list",i=>{i.value=t&&t.length>0?t:[]})},ON_FIELD_MAP_CHANGE:async({$:e,e:o})=>{e.setThisComponent(t=>{t.value=o}),e.setDb(t=>{t.prospects=o})},SET_ADD_TO:({$:e,e:o})=>{e.setThisComponent(t=>{t.value=o}),e.setDb(t=>{t.addTo=o})},IS_UPDATE:({$:e,e:o})=>{e.setThisComponent(t=>{t.value=o}),e.setDb(t=>{t.addTo=o})},CONNECTION_ADD_CHANGE:({$:e,e:o})=>{e.setThisComponent(t=>{e.util.isConnectionComponent(t)&&t.connectionsTypes.forEach(i=>{var c;i.type==="api_key"&&((c=i.verifyConnection)!=null&&c.headers)&&o.value&&(i.verifyConnection.headers.Authorization="Basic "+btoa(`${o.value}`))})})},ON_MACHINE_LOAD:async({$:e})=>{var o;l(e,[{db:"connectionId",id:"connection-id"},{db:"prospectId",id:"prospect-id"},{db:"prospects",id:"prospects-list"}]),(o=e.db)!=null&&o.connectionId&&await s(e)}}}));export{E as default};
