import{aa as d,ab as h}from"./_applist-tangy-colts-beg-36.js";import{_ as a}from"./main-tangy-colts-beg.js";import{h as m,s as u}from"./machine.-tangy-colts-beg-869.js";import{h as l}from"./machineh-tangy-colts-beg-971.js";import{h as N,c as p}from"./twilioco-tangy-colts-beg-300.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,e){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,e),e)}};const f=d(({helpers:o})=>({states:{components:[{componentName:o.componentName.webhook,extraComponents:[p(o),{componentName:o.componentName.mixInput,helperText:a("Enter the Phone Number ID for the Twilio number you want to monitor incoming SMS messages."),id:"phone-number-id",label:a("Phone Number ID"),onChange:"SET_PHONE_NUMBER_ID",render:"IF_CONNECTION_SELECTED",required:!0,value:[]}],fieldType:"config",id:"webhook-id",label:a("Webhook"),onSave:"CLEAR_WEBHOOK_FORM_VALUES",onValidate:"HANDLE_VALIDATION",onWebhookChange:"SET_WEBHOOK",render:!0,value:void 0},{componentName:o.componentName.note,fieldType:"config",id:"note-id",label:a("Note"),note:[],render:!1}]},actions:{CONNECTION_ADD_CHANGE:N,IF_CONNECTION_SELECTED:({$:e})=>{var t;return h((t=e.getComponent("connection-id"))==null?void 0:t.value)},SET_CONNECTION:m("connectionId"),SET_PHONE_NUMBER_ID:m("phoneNumberId"),SET_WEBHOOK:({$:e,e:t})=>{m("webhookId")({$:e,e:t.id})},HANDLE_VALIDATION:({$:e})=>{var n,r,s,c;if(!((n=e.getComponent("connection-id"))!=null&&n.value))return e.setComponent("connection-id",i=>{e.util.isConnectionComponent(i)&&(i.status="error",i.invalidMessage="Please select a connection")}),!1;if(!((c=(s=(r=e.db)==null?void 0:r.phoneNumberId)==null?void 0:s[0])==null?void 0:c.value))return e.setComponent("phone-number-id",i=>{e.util.isMixInputComponent(i)&&(i.invalidMessage="Please enter Phone Number ID.")}),!1},CLEAR_WEBHOOK_FORM_VALUES:async({$:e,e:t})=>{await l(e,t.url),e.setComponent("connection-id",n=>{e.util.isConnectionComponent(n)&&(n.value=void 0)}),e.setComponent("phone-number-id",n=>{e.util.isMixInputComponent(n)&&(n.value=void 0)})},ON_MACHINE_LOAD:async({$:e})=>{u(e,[{db:"webhookId",id:"webhook-id"},{db:"phoneNumberId",id:"phone-number-id"}])}}}));export{f as default};
