var h=class{constructor(t={}){this.config=t,this.enabled=t.enabled!==!1,this.priority=t.priority||50}getName(){throw new Error("EventEnricher.getName() must be implemented")}canEnrich(t){return this.enabled}async enrich(t,i){throw new Error("EventEnricher.enrich() must be implemented")}handleError(t,i){return console.warn(`[${this.getName()}] Enrichment failed for event ${i.type}:`,t.message),null}};var b=class extends h{getName(){return"DOMEnricher"}getPriority(){return 85}canEnrich(t){return!this.enabled||!t.element||!t.event?!1:["click","fill","type","selectOption","hover"].includes(t.event.type)}async enrich(t,i){try{let{element:s}=i,r=await s.evaluate(n=>{let E=o=>{let c=[],e=o;for(;e&&e!==document.body;){let p=e.tagName.toLowerCase(),a=e.parentElement;if(a){let u=Array.from(a.children).filter(m=>m.tagName===e.tagName);if(u.length>1){let m=u.indexOf(e)+1;p+=`:nth-child(${m})`}}c.unshift(p),e=e.parentElement}return`body > ${c.join(" > ")}`},v=o=>{let c=[],e=o;for(;e&&e!==document.body;){let p=1,a=e.previousSibling;for(;a;)a.nodeType===1&&a.tagName===e.tagName&&p++,a=a.previousSibling;let u=e.tagName.toLowerCase();c.unshift(`${u}[${p}]`),e=e.parentElement}return`/html/body/${c.join("/")}`},f={};for(let o of n.attributes)f[o.name]=o.value;let l=window.getComputedStyle(n),w={display:l.display,visibility:l.visibility,opacity:l.opacity,pointerEvents:l.pointerEvents},g=0,d=n.parentElement;for(;d;)g++,d=d.parentElement;return{path:E(n),xpath:v(n),depth:g,parent:n.parentElement?n.parentElement.tagName.toLowerCase():null,tagName:n.tagName.toLowerCase(),attributes:f,state:{visible:l.display!=="none"&&l.visibility!=="hidden",enabled:!n.disabled,focused:document.activeElement===n,...w}}});return{dom:{path:r.path,xpath:r.xpath,depth:r.depth,parent:r.parent,selector:this.buildSmartSelector(r)},attributes:r.attributes,state:r.state}}catch(s){return this.handleError(s,t)}}buildSmartSelector(t){let i=t.tagName;if(t.attributes.id)return`#${t.attributes.id}`;if(t.attributes["data-test-id"])return`[data-test-id="${t.attributes["data-test-id"]}"]`;if(t.attributes.class){let s=t.attributes.class.split(" ").filter(r=>r&&!r.match(/^(active|focus|hover|disabled)/));s.length>0&&(i+=`.${s.slice(0,2).join(".")}`)}return t.parent&&(i=`${t.parent} > ${i}`),i}},x=b;export{b as DOMEnricher,x as default};
