import{a as E,g as H,i as I,aH as C,u as L,k as V,r as K,H as M,j as t,_ as v,h as p,e7 as F,I as c,e8 as R,f as y,bG as $}from"./main-634.js";import{D as z,B as T}from"./bf-400-72.js";import{t as w}from"./bf-676-386.js";import{F as j}from"./bf-767-388.js";import{S as G}from"./bf-26-460.js";import{A as O}from"./bf-710-385.js";import{E as Z}from"./bf-178-233.js";import{S as q}from"./bf-982-242.js";import"./bf-25-81.js";import"./bf-438-114.js";import"./bf-638-271.js";import"./bf-247-269.js";import"./bf-692-111.js";import"./bf-486-243.js";import"./bf-497-246.js";import"./bf-723-244.js";import"./bf-299-245.js";import"./bf-534-247.js";import"./bf-962-248.js";import"./bf-343-249.js";import"./bf-791-250.js";import"./bf-641-107.js";import"./bf-570-251.js";import"./bf-838-80.js";import"./bf-297-103.js";import"./bf-284-252.js";import"./bf-17-106.js";import"./bf-671-253.js";import"./bf-334-254.js";import"./bf-423-273.js";import"./bf-457-387.js";import"./bf-577-275.js";import"./bf-288-389.js";import"./bf-939-390.js";var g=[{lbl:"Landline",val:"^$_bf_$s*$_bf_$+?$_bf_$s*(?:$_bf_$s*$_bf_$d){3,15}$_bf_$s*$",msg:"Format: +123-456-7890"}];function Se(){const{css:i}=E(),{fieldKey:s}=H(),[f,b]=I(C),A=L(V),x=K.useRef(null);if(!s)return null;const e=M(f[s]),h=e.adminLbl||"",l=A.err||{},_=e.valid.regexr||"",B=e.valid.flags||"",P=r=>{var n,m,o;if((m=(n=x==null?void 0:x.current)==null?void 0:n._tippy)==null||m.hide(),!c)return;if(r==="")delete e.valid.regexr;else{const d=R(r);e.valid.regexr=d,e.err||(e.err={}),e.err.regexr||(e.err.regexr={});const u=g.find(D=>D.val===d);e.err.regexr.dflt=u?`<p style="margin:0">${u.msg}</p>`:((o=l[e.typ])==null?void 0:o.regexr)||(l==null?void 0:l.regexr)||'<p style="margin:0">Pattern not matched</p>',e.err.regexr.show=!0,e.typ==="password"&&delete e.valid.validations}const a=y(f,d=>{d[s]=e});b(a),$({event:`Regex Pattern updated: ${e.lbl||h||s}`,type:"set_regexr",state:{fields:a,fldKey:s}})},N=r=>{var m;if(!c)return;const{value:a}=r.target;if(a==="")delete e.valid.regexr;else{const o=R(a);e.valid.regexr=o,e.err||(e.err={}),e.err.regexr||(e.err.regexr={});const d=g.find(u=>u.val===o);e.err.regexr.dflt=d?`<p style="margin:0">${d.msg}</p>`:((m=l[e.typ])==null?void 0:m.regexr)||(l==null?void 0:l.regexr)||'<p style="margin:0">Pattern not matched</p>',e.err.regexr.show=!0,e.typ==="password"&&delete e.valid.validations}const n=y(f,o=>{o[s]=e});b(n),$({event:`Regex Pattern updated: ${e.lbl||h||s}`,type:"set_regexr",state:{fields:n,fldKey:s}})},k=r=>{if(!c)return;r.target.value===""?delete e.valid.flags:e.valid.flags=r.target.value;const a=y(f,n=>{n[s]=e});b(a),$({event:`Regex Pattern Flag updated: ${e.lbl||h||s}`,type:"set_flags",state:{fields:a,fldKey:s}})};return t.jsx(q,{id:"ptrn-stng",title:v("Custom Validation (RegEx) Pattern"),className:i(j.fieldSection),isPro:!0,tip:w.pattern,proProperty:"regexPattern",children:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:i(p.mr2,p.mt3,p.pl1),children:[t.jsxs("div",{className:i(p.flxcb,p.ml1),children:[t.jsxs("h4",{className:i(p.m0,j.title),children:[v("Expression"),":"]}),t.jsxs(z,{instance:x,children:[t.jsx("button",{"data-testid":"ptrn-stng-exprsn-btn","data-close":!0,type:"button",className:i(S.dotBtn),unselectable:"on",draggable:"false",style:{cursor:"pointer"},title:v("Fields"),children:t.jsx(T,{size:"19"})}),t.jsx("div",{children:t.jsx("ul",{role:"menu",children:g==null?void 0:g.map((r,a)=>t.jsxs("li",{"data-testid":`ptrn-stng-expn-itm-${a}`,role:"menuitem",className:`${i(S.button)} btnHover`,onKeyDown:()=>P(r.val),onClick:()=>P(r.val),children:[t.jsx("span",{children:r.lbl}),t.jsx("br",{}),t.jsx("small",{children:F(r.val)})]},a))})})]})]}),t.jsx(O,{id:"ptrn-stng-expn",ariaLabel:"Pattern for input field",placeholder:"e.g. ([A-Z])\\w+",list:"patterns",disabled:!c,value:F(_),changeAction:N})]}),t.jsx("div",{className:i({mr:5},p.pl1),children:t.jsx(G,{id:"ptrn-stng-flg",inpType:"text",title:v("Flags:"),value:B,action:k,placeholder:"e.g. g",cls:i(j.input),disabled:!c})}),_&&t.jsx(Z,{id:"ptrn-stng-expn",type:"regexr",title:"Error Message",tipTitle:w.patternsErrMsg})]})})}const S={dotBtn:{b:0,brs:5,mr:15,curp:1},button:{dy:"block",w:"100%",ta:"left",b:0,bd:"none",p:3,curp:1,"&:hover":{bd:"var(--white-0-95)",cr:"var(--black-0)",brs:8},fs:11}};export{Se as default};
