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