import{j as m}from"./main.2.8.10.js";import{t as I}from"./lodash.DCvQBX3r.js";import{b as u}from"./react-router.DMwpH23k.js";function j({label:h,onChange:v,value:s,disabled:b,type:c,textarea:D,className:O,formFields:p}){const l=p?p.filter(t=>t.label!==void 0).map(t=>({name:t.label,value:t.name})):[],f=u.useRef(null),e=u.useRef(null);u.useEffect(()=>{const t=f.current;t.value=s,t.setAttribute("value",s),e.current&&e.current.destroy(),e.current=new I(t,y),e.current.DOM.originalInput.value=s,e.current.on("input",x),e.current.on("add",d),e.current.on("remove",T),e.current.on("change",d)},[]);const a=t=>{const i=t.match(/(\${{.*?"value":".*?)"}}/g);let r=t;i&&i.forEach(n=>{const g=n.slice(2,-1),o=JSON.parse(g);r=r.replace(n,`\${${o.value}}`)}),v(r)},x=t=>{const{prefix:i,textContent:r}=t.detail,n=r.slice(-1),o=n==="#"?n:i;o&&(o==="#"&&(e.current.whitelist=l),e.current.dropdown.show()),setTimeout(()=>{a(t.detail.tagify.DOM.originalInput.value)},100)},d=t=>{setTimeout(()=>{a(t.detail.tagify.DOM.originalInput.value)},100)},T=t=>{setTimeout(()=>{a(t.detail.tagify.DOM.originalInput.value)},100)},y={mixTagsInterpolator:["${","}"],mode:"mix",mixMode:{insertAfterTag:" "},pattern:/#/,placeholder:h,tagTextProp:"value",duplicates:!0,whitelist:l,enforceWhitelist:!0,trim:!0,editTags:!1,dropdown:{enabled:0,position:"text",mapValueTo:"value",highlightFirst:!0,searchKeys:["label","value"],closeOnSelect:!0,placeAbove:!1,maxItems:l.length},callbacks:{add:()=>{a(e.current.DOM.originalInput.value)},remove:()=>{a(e.current.DOM.originalInput.value)}}};return m.jsx("div",{children:m.jsx("input",{name:"tagify-inp",type:c===void 0?"text":c,ref:f})})}export{j as T};
