import{Q as s,w as o,x as v,k as c,R as b,T as m,U as h}from"./CiQWViEs.js";function d(e,r,f=!1){if(e.multiple){if(r==null)return;if(!b(r))return m();for(var a of e.options)a.selected=r.includes(t(a));return}for(a of e.options){var i=t(a);if(h(i,r)){a.selected=!0;return}}(!f||r!==void 0)&&(e.selectedIndex=-1)}function y(e){var r=new MutationObserver(()=>{d(e,e.__value)});r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),s(()=>{r.disconnect()})}function S(e,r,f=r){var a=new WeakSet,i=!0;o(e,"change",u=>{var l=u?"[selected]":":checked",n;if(e.multiple)n=[].map.call(e.querySelectorAll(l),t);else{var _=e.querySelector(l)??e.querySelector("option:not([disabled])");n=_&&t(_)}f(n),e.__value=n,v!==null&&a.add(v)}),c(()=>{var u=r();if(e===document.activeElement){var l=v;if(a.has(l))return}if(d(e,u,i),i&&u===void 0){var n=e.querySelector(":checked");n!==null&&(u=t(n),f(u))}e.__value=u,i=!1}),y(e)}function t(e){return"__value"in e?e.__value:e.value}export{S as b,y as i,d as s};
