import{g as b,i as S,aH as T,a as _,j as i,_ as a,h as m,f as F,bG as x,cV as N,cR as R}from"./main-634.js";import{F as n}from"./bf-767-388.js";import{S as C}from"./bf-982-242.js";import{C as y}from"./bf-297-103.js";import{S as $}from"./bf-26-460.js";import"./bf-25-81.js";import"./bf-497-246.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";function H(){var E;const{fieldKey:e}=b(),[d,v]=S(T),{css:t}=_();if(!e)return null;const c=d[e],p=(c==null?void 0:c.config)||{},f=p.receiverEmailType==="static",u=(E=c==null?void 0:c.lbl)!=null?E:e,j=()=>Object.entries(d).filter(([,s])=>s.typ==="email").map(([s,r])=>i.jsx("option",{value:s,children:r.adminLbl||r.lbl||s},s)),g=l=>{const{value:o}=l.target,s=F(d,r=>{r[e].config=r[e].config||{},r[e].config.receiverEmailType=o||"dynamic",delete r[e].config.receiverEmail,delete r[e].config.receiverEmailFld});v(s),x({event:`Receiver Email Type changed to "${o}": ${u}`,type:"otp_receiver_email_type_changed",state:{fields:s,fldKey:e}})},h=(l,o)=>{const s=F(d,r=>{r[e].config=r[e].config||{},r[e].config[l]=o});v(s),(l==="receiverEmailFld"||l==="receiverEmail")&&(o?N(e,"emailOtpReciverEmailMissing"):R({fieldKey:e,errorKey:"emailOtpReciverEmailMissing",errorMsg:a("Email OTP Receiver Email is missing"),errorUrl:`field-settings/${e}`})),x({event:`OTP ${l} changed: ${u}`,type:`otp_${l}_changed`,state:{fields:s,fldKey:e}})};return i.jsx(i.Fragment,{children:i.jsx(C,{id:"rcvr-eml-stng",title:a("Receiver Email"),className:t([n.fieldSection,n.hover_tip]),tip:a('The email address where the OTP will be sent. Choose "Dynamic" to use an Email field from your form, or "Static" to enter a fixed address.'),open:!0,children:i.jsxs("div",{className:t(n.placeholder),children:[i.jsxs("div",{className:t(n.flxCenter),children:[i.jsx(y,{id:"rcvr-eml-dynamic",onChange:g,radio:!0,checked:!f,title:a("Dynamic (Email Field)"),value:"dynamic",className:t({fs:"var(--bf-font-small)",pl:0})}),i.jsx(y,{id:"rcvr-eml-static",onChange:g,radio:!0,checked:f,title:a("Static (Fixed Email)"),value:"static",className:t({fs:"var(--bf-font-small)"})})]}),f?i.jsx($,{id:"rcvr-eml-inp",inpType:"email",title:a("Email Address"),className:t([m.mt1,{cr:"var(--bf-text-clr-dark)"}]),cls:t([n.input,m.mt1]),value:p.receiverEmail||"",action:l=>h("receiverEmail",l.target.value),placeholder:a("Enter a email here..")}):i.jsxs("label",{htmlFor:"rcvr-eml-fld",children:[i.jsx("span",{className:t([m.inputLabel,m.ml1]),children:a("Select Email Field")}),i.jsxs("select",{id:"rcvr-eml-fld",className:t([n.input,m.mt1]),value:p.receiverEmailFld||"",onChange:l=>h("receiverEmailFld",l.target.value),children:[i.jsx("option",{value:"",children:a("-- Select Email Field --")}),j()]})]})]})})})}export{H as default};
