import{cs as s,ca as i}from"./index-7eqLqzhB.js";const c={account:{label:"account",path:"accounts"},contact:{label:"contact",path:"contacts"},opportunity:{label:"opportunity",path:"opportunities"},use_case:{label:"use case",path:"use-cases"},actor:{label:"actor",path:"actors"}};function a(e){return c[e].label}async function u(e,t,r){if(!t)return;const n=c[e];try{await s.get(`${n.path}/${t}`)}catch(o){throw o instanceof i&&o.status===404?new Error(`The selected ${r??n.label} no longer exists. Clear it or choose another record.`):o}}async function l(e,t){if(!(!e&&!t)){if(!e||!t)throw new Error("Choose both a linked record type and a record, or leave the link empty.");if(!(e in c)||e==="actor")throw new Error("Choose a supported linked record type.");await u(e,t,a(e))}}function h(e){const t=typeof e.subject_type=="string"?e.subject_type.trim():"",r=typeof e.subject_id=="string"?e.subject_id.trim():"";if(!t||!r){delete e.subject_type,delete e.subject_id;return}e.subject_type=t,e.subject_id=r}function b(e){for(const[t,r]of Object.entries(e)){if(typeof r!="string")continue;const n=r.trim();n?e[t]=n:delete e[t]}}export{l as a,u as b,h as n,b as t};
