import{a3 as u,T as S,u as y,h as k,j as i,a4 as o,a5 as x,a6 as C,Y as E,q as b}from"./7RXv2Ffc.js";function A(e,c,a=c){var d=new WeakSet;u(e,"input",async r=>{var v=r?e.defaultValue:e.value;if(v=_(e)?t(v):v,a(v),o!==null&&d.add(o),await S(),v!==(v=c())){var f=e.selectionStart,n=e.selectionEnd;e.value=v??"",n!==null&&(e.selectionStart=f,e.selectionEnd=Math.min(n,e.value.length))}}),(i&&e.defaultValue!==e.value||y(c)==null&&e.value)&&(a(_(e)?t(e.value):e.value),o!==null&&d.add(o)),k(()=>{var r=c();if(e===document.activeElement){var v=x??o;if(d.has(v))return}_(e)&&r===t(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}const h=new Set;function V(e,c,a,d,r=d){var v=a.getAttribute("type")==="checkbox",f=e;let n=!1;if(c!==null)for(var g of c)f=f[g]??=[];f.push(a),u(a,"change",()=>{var l=a.__value;v&&(l=m(f,l,a.checked)),r(l)},()=>r(v?[]:null)),k(()=>{var l=d();if(i&&a.defaultChecked!==a.checked){n=!0;return}v?(l=l||[],a.checked=l.includes(a.__value)):a.checked=C(a.__value,l)}),E(()=>{var l=f.indexOf(a);l!==-1&&f.splice(l,1)}),h.has(f)||(h.add(f),b(()=>{f.sort((l,s)=>l.compareDocumentPosition(s)===4?-1:1),h.delete(f)})),b(()=>{if(n){var l;if(v)l=m(f,l,a.checked);else{var s=f.find(w=>w.checked);l=s?.__value}r(l)}})}function j(e,c,a=c){u(e,"change",d=>{var r=d?e.defaultChecked:e.checked;a(r)}),(i&&e.defaultChecked!==e.checked||y(c)==null)&&a(e.checked),k(()=>{var d=c();e.checked=!!d})}function m(e,c,a){for(var d=new Set,r=0;r<e.length;r+=1)e[r].checked&&d.add(e[r].__value);return a||d.delete(c),Array.from(d)}function _(e){var c=e.type;return c==="number"||c==="range"}function t(e){return e===""?null:+e}export{j as a,A as b,V as c};
