// @bun
var{defineProperty:Z,getOwnPropertyNames:N,getOwnPropertyDescriptor:$}=Object,w=Object.prototype.hasOwnProperty;function V(j){return this[j]}var M=(j)=>{var q=(E??=new WeakMap).get(j),z;if(q)return q;if(q=Z({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var A of N(j))if(!w.call(q,A))Z(q,A,{get:V.bind(j,A),enumerable:!(z=$(j,A))||z.enumerable})}return E.set(j,q),q},E;var y=(j)=>j;function S(j,q){this[j]=y.bind(null,q)}var h=(j,q)=>{for(var z in q)Z(j,z,{get:q[z],enumerable:!0,configurable:!0,set:S.bind(q,z)})};var k=(j,q)=>()=>(j&&(q=j(j=0)),q);var x=import.meta.require;function U(){return typeof window<"u"&&"MutationObserver"in window}function O(j={}){let q=U(),z=new Set,{attributes:A=!0,attributeFilter:H,attributeOldValue:C=!1,characterData:K=!0,characterDataOldValue:Q=!1,childList:I=!0,subtree:L=!0,onMutate:R}=j,J={isSupported:q,isObserving:!1,mutations:[]},P=null,_=null;function X(){z.forEach((G)=>G(J))}function W(G){J={...J,mutations:G},X(),R?.(G)}function D(G){if(!q||!G)return;Y(),P=new MutationObserver(W);let B={attributes:A,attributeOldValue:C,characterData:K,characterDataOldValue:Q,childList:I,subtree:L};if(H)B.attributeFilter=H;P.observe(G,B),_=G,J={...J,isObserving:!0},X()}function Y(){if(P)P.disconnect(),P=null,_=null,J={...J,isObserving:!1,mutations:[]},X()}function F(){if(P)return P.takeRecords();return[]}return{get:()=>J,subscribe:(G)=>{return z.add(G),G(J),()=>{if(z.delete(G),z.size===0)Y()}},observe:D,disconnect:Y,takeRecords:F,isSupported:()=>q}}function f(j,q,z){if(!j||!U())return()=>{};let A=new MutationObserver((H)=>{for(let C of H)if(C.type==="attributes"&&C.attributeName){let K=C.target.getAttribute(C.attributeName);z(C.attributeName,C.oldValue,K)}});return A.observe(j,{attributes:!0,attributeFilter:q,attributeOldValue:!0}),()=>A.disconnect()}function p(j,q,z={}){if(!j||!U())return()=>{};let A=new MutationObserver((H)=>{let C=[],K=[];for(let Q of H)if(Q.type==="childList")C.push(...Array.from(Q.addedNodes)),K.push(...Array.from(Q.removedNodes));if(C.length>0||K.length>0)q(C,K)});return A.observe(j,{childList:!0,subtree:z.subtree??!1}),()=>A.disconnect()}function g(j,q){if(!j||!U())return()=>{};let z=new MutationObserver((A)=>{for(let H of A)if(H.type==="characterData")q(H.oldValue,H.target.textContent||"")});return z.observe(j,{characterData:!0,characterDataOldValue:!0,subtree:!0}),()=>z.disconnect()}export{g as useTextObserver,O as useMutationObserver,p as useChildListObserver,f as useAttributeObserver,U as isMutationObserverSupported};
