import{aa as r,ab as p}from"./_applist-tangy-colts-beg-36.js";import{_ as i}from"./main-tangy-colts-beg.js";import{s as l}from"./machine.-tangy-colts-beg-869.js";import{a as c}from"./machineh-tangy-colts-beg-791.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 _=r(({helpers:t})=>({states:{components:[{addConnectionHelpingText:i('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:t.componentName.connection,connectionsTypes:[{encryptKeys:["value"],label:i("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:i("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0},{componentName:t.componentName.select,fieldType:"config",id:"prospect-id",label:i("Select Prospect to Delete"),onChange:"SET_PROSPECT_EMAIL",onRefetch:"REFETCH_CAMPAIGN_LIST",options:[],placeholder:i("Select a Prospect"),render:"IF_CONNECTION_SELECTED",required:!0,value:void 0}]},actions:{SET_CONNECTION:async({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setDb(n=>{n.connectionId=o}),await c(e)},IF_CONNECTION_SELECTED:({$:e})=>{var o;return p((o=e.getComponent("connection-id"))==null?void 0:o.value)},REFETCH_CAMPAIGN_LIST:async({$:e})=>{await c(e)},SET_PROSPECT_EMAIL:async({$:e,e:o})=>{e.setThisComponent(n=>{n.value=o}),e.setDb(n=>{n.prospectId=o})},CONNECTION_ADD_CHANGE:({$:e,e:o})=>{e.setThisComponent(n=>{e.util.isConnectionComponent(n)&&n.connectionsTypes.forEach(a=>{var s;a.type==="api_key"&&((s=a.verifyConnection)!=null&&s.headers)&&o.value&&(a.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"}]),(o=e.db)!=null&&o.connectionId&&await c(e)}}}));export{_ as default};
