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