@sentientui/core 0.41.2 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +32 -3
  2. package/dist/chunk-5VIREVXA.mjs +2 -0
  3. package/dist/chunk-5VIREVXA.mjs.map +1 -0
  4. package/dist/chunk-BGZLWZUG.mjs +2 -0
  5. package/dist/chunk-BGZLWZUG.mjs.map +1 -0
  6. package/dist/chunk-JNQY3XNF.mjs +2 -0
  7. package/dist/chunk-JNQY3XNF.mjs.map +1 -0
  8. package/dist/chunk-LCYGZNFI.mjs +2 -0
  9. package/dist/chunk-LCYGZNFI.mjs.map +1 -0
  10. package/dist/chunk-WUFFNQHQ.mjs +2 -0
  11. package/dist/{chunk-J5EL7HKC.mjs.map → chunk-WUFFNQHQ.mjs.map} +1 -1
  12. package/dist/{index-DlJDNOWu.d.cts → index-CWHTKETi.d.cts} +34 -5
  13. package/dist/index-consent.js +1 -1
  14. package/dist/index-consent.js.map +1 -1
  15. package/dist/index-consent.mjs +1 -1
  16. package/dist/index-consent.mjs.map +1 -1
  17. package/dist/{index-C--aVpoo.d.ts → index-cqfRT6LZ.d.ts} +34 -5
  18. package/dist/index-engagement.js +1 -1
  19. package/dist/index-engagement.js.map +1 -1
  20. package/dist/index-engagement.mjs +1 -1
  21. package/dist/index-engagement.mjs.map +1 -1
  22. package/dist/index-graph.d.cts +2 -2
  23. package/dist/index-graph.d.ts +2 -2
  24. package/dist/index-graph.js +1 -1
  25. package/dist/index-graph.js.map +1 -1
  26. package/dist/index-graph.mjs +1 -1
  27. package/dist/index-graph.mjs.map +1 -1
  28. package/dist/index-internal-traffic.d.cts +37 -0
  29. package/dist/index-internal-traffic.d.ts +37 -0
  30. package/dist/index-internal-traffic.js +2 -0
  31. package/dist/index-internal-traffic.js.map +1 -0
  32. package/dist/index-internal-traffic.mjs +2 -0
  33. package/dist/index-internal-traffic.mjs.map +1 -0
  34. package/dist/index-local.d.cts +1 -1
  35. package/dist/index-local.d.ts +1 -1
  36. package/dist/index-region.mjs +1 -1
  37. package/dist/index-server.d.cts +25 -1
  38. package/dist/index-server.d.ts +25 -1
  39. package/dist/index-server.js +1 -1
  40. package/dist/index-server.js.map +1 -1
  41. package/dist/index-server.mjs +1 -1
  42. package/dist/index-server.mjs.map +1 -1
  43. package/dist/index.d.cts +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +1 -1
  48. package/llms.txt +2 -1
  49. package/package.json +7 -2
  50. package/dist/chunk-FPOHOWJP.mjs +0 -2
  51. package/dist/chunk-FPOHOWJP.mjs.map +0 -1
  52. package/dist/chunk-J5EL7HKC.mjs +0 -2
  53. package/dist/chunk-KXA3X6T3.mjs +0 -2
  54. package/dist/chunk-KXA3X6T3.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{a as Z}from"./chunk-WKXD7KI3.mjs";import{a as j,d as J,e as H,f as q,g as se}from"./chunk-Z6ILOYBD.mjs";import{O as Q,Q as X}from"./chunk-KXA3X6T3.mjs";import"./chunk-FPOHOWJP.mjs";import"./chunk-EVF5PQ4U.mjs";import"./chunk-3HMJERH4.mjs";import"./chunk-J5EL7HKC.mjs";import{a as $,b as z}from"./chunk-TMCGHANO.mjs";import{fnv1a as ue}from"@sentientui/policy";var ee=[100,300,1e3,3e3,1e4],ie=250,ae=1e3,ce=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function te(t,o){t.n++;let e=o-t.mean;t.mean+=e/t.n,t.m2+=e*(o-t.mean)}var ne=t=>t.n>1?Math.sqrt(t.m2/t.n):0;function le(t){var o;try{let e=t.createElement("canvas"),u=e.getContext("webgl")||e.getContext("experimental-webgl");if(!u)return"unknown";let d=u.getExtension("WEBGL_debug_renderer_info"),p=d?String((o=u.getParameter(d.UNMASKED_RENDERER_WEBGL))!=null?o:""):"";return p?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(p)?"sw":"hw":"unknown"}catch(e){return"unknown"}}function re(t,o=Date.now){var a,c;let e=(a=t.defaultView)!=null?a:typeof window!="undefined"?window:void 0,u={n:0,mean:0,m2:0},d={n:0,mean:0,m2:0},p=[0,0,0,0,0,0],_=0,G=0,k=0,U=0,g=0,V=0,T=0,h=0,I=0,b=0,L=-1/0,C=-1/0,m=null,w=null,A=null,x=(c=e==null?void 0:e.scrollY)!=null?c:0,N=0,f=t.hidden?null:o(),E=()=>{let n=o();if(A!=null){let l=n-A,v=0;for(;v<ee.length&&l>=ee[v];)v++;p[v]++}A=n},O=()=>{_++,L=o()},R=()=>{G++,C=o()},M=()=>{m=o()},D=()=>{m!=null&&(te(u,o()-m),m=null)},P=()=>{let n=o();k++,n-L>ie&&n-C>ae&&U++,E()},S=()=>{g++},W=()=>{var l;let n=(l=e==null?void 0:e.scrollY)!=null?l:0;V+=Math.abs(n-x),x=n,E()},K=n=>{let l=o();T++,(n.key==="Backspace"||n.key==="Delete")&&I++,ce.has(n.key)&&b++,w!=null&&te(d,l-w),w=l,E()},F=n=>{let l=n.data;typeof l=="string"&&(h+=l.length),E()},B=()=>{let n=o();t.hidden?f!=null&&(N+=n-f,f=null):f==null&&(f=n)},i={passive:!0,capture:!0};t.addEventListener("mousemove",O,i),t.addEventListener("touchstart",R,i),t.addEventListener("touchmove",S,i),t.addEventListener("mousedown",M,i),t.addEventListener("mouseup",D,i),t.addEventListener("click",P,i),t.addEventListener("wheel",S,i),t.addEventListener("keydown",K,i),t.addEventListener("input",F,i),t.addEventListener("visibilitychange",B),e==null||e.addEventListener("scroll",W,i);let r=le(t),s=(()=>{var n;try{return((n=e==null?void 0:e.matchMedia)==null?void 0:n.call(e,"(prefers-reduced-motion: reduce)").matches)===!0}catch(l){return!1}})();return{snapshot(){var v,y;let n=o(),l=N+(f!=null?n-f:0);return{v:1,active_ms:Math.round(l),mm:_,mm_rate:l>0?Number((_*1e3/l).toFixed(2)):0,touches:G,clicks:k,hold_n:u.n,hold_mean:Math.round(u.mean),hold_std:Math.round(ne(u)),teleport:U,wheel:g,scroll_px:Math.round(V),keydowns:T,input_chars:h,ik_cv:d.mean>0?Number((ne(d)/d.mean).toFixed(2)):0,backspaces:I,gaps:[...p],reduced_motion:s,kb_nav:b,renderer:r,vp:[(v=e==null?void 0:e.innerWidth)!=null?v:0,(y=e==null?void 0:e.innerHeight)!=null?y:0],dpr:(e==null?void 0:e.devicePixelRatio)||1}},stop(){t.removeEventListener("mousemove",O,i),t.removeEventListener("touchstart",R,i),t.removeEventListener("touchmove",S,i),t.removeEventListener("mousedown",M,i),t.removeEventListener("mouseup",D,i),t.removeEventListener("click",P,i),t.removeEventListener("wheel",S,i),t.removeEventListener("keydown",K,i),t.removeEventListener("input",F,i),t.removeEventListener("visibilitychange",B),e==null||e.removeEventListener("scroll",W,i)}}}var de="section, header, footer, nav, main > div, [data-sentient-section]",me=2e4,oe="__session__";function pe(t){let o=Array.from(t.querySelectorAll(de)),e=o.filter(u=>o.filter(d=>d!==u&&u.contains(d)).length<2);return e.filter(u=>!e.some(d=>d!==u&&d.contains(u)))}function fe(t,o,e,u){try{fetch(`${o}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({pageUrl:e,sections:u})}).catch(()=>{})}catch(d){}}var Y=()=>{};function ve(t,o){var x,N,f,E,O,R,M,D,P,S,W,K,F,B,i;let e=(x=o.doc)!=null?x:typeof document!="undefined"?document:void 0;if(!e||typeof IntersectionObserver=="undefined"||X()||!o.apiKey||!o.apiKey.startsWith("pk_"))return Y;let u=((N=o.apiBase)!=null?N:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),d=pe(e);if(d.length===0)return Y;let p=new Map,_=[];for(let r of d){let s=(O=[(E=o.sectionTypes)==null?void 0:E[(f=r.getAttribute("data-sentient-id"))!=null?f:""],r.getAttribute("data-sentient-type")].find(y=>j.includes(y)))!=null?O:null,a=q(r),c=(M=s!=null?s:(R=o.typeOf)==null?void 0:R.call(o,r))!=null?M:H(a).type,n=Z(r,e),l=n?`nc-${c}-${ue(JSON.stringify({id:(D=n.id)!=null?D:null,dataAttr:(P=n.dataAttr)!=null?P:null,selector:(S=n.selector)!=null?S:null})).toString(36)}`:`nc-${c}`;p.set(r,l);let v=J.filter(([,y])=>y.test(a.bodyText)).map(([y])=>y);_.push(z($({componentId:l,semanticType:c,source:s?"markup":"auto"},n?{locator:n}:{}),{observation:$($({tag:a.tag,idClass:a.idClass.slice(0,200),headingText:a.headingText,textLength:a.textLength,actionCount:a.actionCount},a.ariaRole?{ariaRole:a.ariaRole}:{}),v.length>0?{patternFlags:v}:{})}))}let G=(B=(F=(K=(W=e.defaultView)!=null?W:typeof window!="undefined"?window:void 0)==null?void 0:K.location)==null?void 0:F.pathname)!=null?B:"/";fe(o.apiKey,u,G,_);let k=re(e),U=()=>{let r;try{r=k.snapshot()}catch(s){return}try{t.track({projectId:o.apiKey,componentId:oe,eventType:"interaction_stats",payload:r})}catch(s){}},g=new Map,V=r=>{let s=g.get(r);return s||(s={ms:0,scroll:0,enterAt:null,intersecting:!1},g.set(r,s)),s},T=new IntersectionObserver(r=>{for(let s of r){let a=p.get(s.target);if(!a)continue;let c=V(a);s.isIntersecting?(c.intersecting=!0,c.enterAt=Date.now(),s.intersectionRatio>c.scroll&&(c.scroll=s.intersectionRatio)):(c.intersecting=!1,c.enterAt!=null&&(c.ms+=Date.now()-c.enterAt,c.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let r of p.keys())T.observe(r);let h=(r=!1)=>{var a;let s=Date.now();for(let[c,n]of g)if(n.enterAt!=null&&(n.ms+=s-n.enterAt,n.enterAt=null),!(n.ms<=0)){try{t.track({projectId:o.apiKey,componentId:c,eventType:"dwell",payload:{dwell_time:Math.round(n.ms),scroll_depth:Number(n.scroll.toFixed(2))}})}catch(l){}n.ms=0}if(U(),r)try{(a=t.flush)==null||a.call(t)}catch(c){}},I=()=>{if(e.hidden)h(!0);else{let r=Date.now();for(let s of g.values())s.intersecting&&(s.enterAt=r)}},b=!1,L=r=>{if(h(!0),r!=null&&r.persisted){b=!0;return}try{T.disconnect()}catch(s){}},C=r=>{if(!(r!=null&&r.persisted)||!b)return;b=!1;let s=Date.now();for(let a of g.values())a.enterAt=a.intersecting&&!e.hidden?s:null};e.addEventListener("visibilitychange",I);let m=(i=e.defaultView)!=null?i:typeof window!="undefined"?window:void 0;m==null||m.addEventListener("pagehide",L),m==null||m.addEventListener("pageshow",C);let w=setInterval(()=>{if(e.hidden||b)return;h();let r=Date.now();for(let s of g.values())s.intersecting&&(s.enterAt=r)},me),A=[];return o.microSignals&&[...p.entries()].forEach(([r,s],a)=>{A.push(Q((c,n={})=>{try{t.track({projectId:o.apiKey,componentId:s,eventType:"micro_signal",payload:$({signalType:c},n)})}catch(l){}},r,void 0,{tabLoss:a===0}))}),()=>{h(!0),clearInterval(w),k.stop(),e.removeEventListener("visibilitychange",I),m==null||m.removeEventListener("pagehide",L),m==null||m.removeEventListener("pageshow",C);for(let r of A)r();try{T.disconnect()}catch(r){}}}export{oe as INTERACTION_STATS_COMPONENT,j as SEMANTIC_TYPES,H as classifyFeatures,se as classifySection,q as featuresFromElement,ve as startEngagementCapture};
1
+ import{a as Z}from"./chunk-WKXD7KI3.mjs";import{a as j,d as J,e as H,f as q,g as se}from"./chunk-Z6ILOYBD.mjs";import{O as Q,Q as X}from"./chunk-5VIREVXA.mjs";import"./chunk-JNQY3XNF.mjs";import"./chunk-LCYGZNFI.mjs";import"./chunk-BGZLWZUG.mjs";import"./chunk-EVF5PQ4U.mjs";import"./chunk-3HMJERH4.mjs";import"./chunk-WUFFNQHQ.mjs";import{a as $,b as z}from"./chunk-TMCGHANO.mjs";import{fnv1a as ue}from"@sentientui/policy";var ee=[100,300,1e3,3e3,1e4],ie=250,ae=1e3,ce=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function te(t,o){t.n++;let e=o-t.mean;t.mean+=e/t.n,t.m2+=e*(o-t.mean)}var ne=t=>t.n>1?Math.sqrt(t.m2/t.n):0;function le(t){var o;try{let e=t.createElement("canvas"),u=e.getContext("webgl")||e.getContext("experimental-webgl");if(!u)return"unknown";let d=u.getExtension("WEBGL_debug_renderer_info"),p=d?String((o=u.getParameter(d.UNMASKED_RENDERER_WEBGL))!=null?o:""):"";return p?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(p)?"sw":"hw":"unknown"}catch(e){return"unknown"}}function re(t,o=Date.now){var a,c;let e=(a=t.defaultView)!=null?a:typeof window!="undefined"?window:void 0,u={n:0,mean:0,m2:0},d={n:0,mean:0,m2:0},p=[0,0,0,0,0,0],_=0,G=0,k=0,U=0,g=0,V=0,T=0,h=0,I=0,b=0,L=-1/0,C=-1/0,m=null,w=null,A=null,x=(c=e==null?void 0:e.scrollY)!=null?c:0,N=0,f=t.hidden?null:o(),E=()=>{let n=o();if(A!=null){let l=n-A,v=0;for(;v<ee.length&&l>=ee[v];)v++;p[v]++}A=n},O=()=>{_++,L=o()},R=()=>{G++,C=o()},M=()=>{m=o()},D=()=>{m!=null&&(te(u,o()-m),m=null)},P=()=>{let n=o();k++,n-L>ie&&n-C>ae&&U++,E()},S=()=>{g++},W=()=>{var l;let n=(l=e==null?void 0:e.scrollY)!=null?l:0;V+=Math.abs(n-x),x=n,E()},K=n=>{let l=o();T++,(n.key==="Backspace"||n.key==="Delete")&&I++,ce.has(n.key)&&b++,w!=null&&te(d,l-w),w=l,E()},F=n=>{let l=n.data;typeof l=="string"&&(h+=l.length),E()},B=()=>{let n=o();t.hidden?f!=null&&(N+=n-f,f=null):f==null&&(f=n)},i={passive:!0,capture:!0};t.addEventListener("mousemove",O,i),t.addEventListener("touchstart",R,i),t.addEventListener("touchmove",S,i),t.addEventListener("mousedown",M,i),t.addEventListener("mouseup",D,i),t.addEventListener("click",P,i),t.addEventListener("wheel",S,i),t.addEventListener("keydown",K,i),t.addEventListener("input",F,i),t.addEventListener("visibilitychange",B),e==null||e.addEventListener("scroll",W,i);let r=le(t),s=(()=>{var n;try{return((n=e==null?void 0:e.matchMedia)==null?void 0:n.call(e,"(prefers-reduced-motion: reduce)").matches)===!0}catch(l){return!1}})();return{snapshot(){var v,y;let n=o(),l=N+(f!=null?n-f:0);return{v:1,active_ms:Math.round(l),mm:_,mm_rate:l>0?Number((_*1e3/l).toFixed(2)):0,touches:G,clicks:k,hold_n:u.n,hold_mean:Math.round(u.mean),hold_std:Math.round(ne(u)),teleport:U,wheel:g,scroll_px:Math.round(V),keydowns:T,input_chars:h,ik_cv:d.mean>0?Number((ne(d)/d.mean).toFixed(2)):0,backspaces:I,gaps:[...p],reduced_motion:s,kb_nav:b,renderer:r,vp:[(v=e==null?void 0:e.innerWidth)!=null?v:0,(y=e==null?void 0:e.innerHeight)!=null?y:0],dpr:(e==null?void 0:e.devicePixelRatio)||1}},stop(){t.removeEventListener("mousemove",O,i),t.removeEventListener("touchstart",R,i),t.removeEventListener("touchmove",S,i),t.removeEventListener("mousedown",M,i),t.removeEventListener("mouseup",D,i),t.removeEventListener("click",P,i),t.removeEventListener("wheel",S,i),t.removeEventListener("keydown",K,i),t.removeEventListener("input",F,i),t.removeEventListener("visibilitychange",B),e==null||e.removeEventListener("scroll",W,i)}}}var de="section, header, footer, nav, main > div, [data-sentient-section]",me=2e4,oe="__session__";function pe(t){let o=Array.from(t.querySelectorAll(de)),e=o.filter(u=>o.filter(d=>d!==u&&u.contains(d)).length<2);return e.filter(u=>!e.some(d=>d!==u&&d.contains(u)))}function fe(t,o,e,u){try{fetch(`${o}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({pageUrl:e,sections:u})}).catch(()=>{})}catch(d){}}var Y=()=>{};function ve(t,o){var x,N,f,E,O,R,M,D,P,S,W,K,F,B,i;let e=(x=o.doc)!=null?x:typeof document!="undefined"?document:void 0;if(!e||typeof IntersectionObserver=="undefined"||X()||!o.apiKey||!o.apiKey.startsWith("pk_"))return Y;let u=((N=o.apiBase)!=null?N:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),d=pe(e);if(d.length===0)return Y;let p=new Map,_=[];for(let r of d){let s=(O=[(E=o.sectionTypes)==null?void 0:E[(f=r.getAttribute("data-sentient-id"))!=null?f:""],r.getAttribute("data-sentient-type")].find(y=>j.includes(y)))!=null?O:null,a=q(r),c=(M=s!=null?s:(R=o.typeOf)==null?void 0:R.call(o,r))!=null?M:H(a).type,n=Z(r,e),l=n?`nc-${c}-${ue(JSON.stringify({id:(D=n.id)!=null?D:null,dataAttr:(P=n.dataAttr)!=null?P:null,selector:(S=n.selector)!=null?S:null})).toString(36)}`:`nc-${c}`;p.set(r,l);let v=J.filter(([,y])=>y.test(a.bodyText)).map(([y])=>y);_.push(z($({componentId:l,semanticType:c,source:s?"markup":"auto"},n?{locator:n}:{}),{observation:$($({tag:a.tag,idClass:a.idClass.slice(0,200),headingText:a.headingText,textLength:a.textLength,actionCount:a.actionCount},a.ariaRole?{ariaRole:a.ariaRole}:{}),v.length>0?{patternFlags:v}:{})}))}let G=(B=(F=(K=(W=e.defaultView)!=null?W:typeof window!="undefined"?window:void 0)==null?void 0:K.location)==null?void 0:F.pathname)!=null?B:"/";fe(o.apiKey,u,G,_);let k=re(e),U=()=>{let r;try{r=k.snapshot()}catch(s){return}try{t.track({projectId:o.apiKey,componentId:oe,eventType:"interaction_stats",payload:r})}catch(s){}},g=new Map,V=r=>{let s=g.get(r);return s||(s={ms:0,scroll:0,enterAt:null,intersecting:!1},g.set(r,s)),s},T=new IntersectionObserver(r=>{for(let s of r){let a=p.get(s.target);if(!a)continue;let c=V(a);s.isIntersecting?(c.intersecting=!0,c.enterAt=Date.now(),s.intersectionRatio>c.scroll&&(c.scroll=s.intersectionRatio)):(c.intersecting=!1,c.enterAt!=null&&(c.ms+=Date.now()-c.enterAt,c.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let r of p.keys())T.observe(r);let h=(r=!1)=>{var a;let s=Date.now();for(let[c,n]of g)if(n.enterAt!=null&&(n.ms+=s-n.enterAt,n.enterAt=null),!(n.ms<=0)){try{t.track({projectId:o.apiKey,componentId:c,eventType:"dwell",payload:{dwell_time:Math.round(n.ms),scroll_depth:Number(n.scroll.toFixed(2))}})}catch(l){}n.ms=0}if(U(),r)try{(a=t.flush)==null||a.call(t)}catch(c){}},I=()=>{if(e.hidden)h(!0);else{let r=Date.now();for(let s of g.values())s.intersecting&&(s.enterAt=r)}},b=!1,L=r=>{if(h(!0),r!=null&&r.persisted){b=!0;return}try{T.disconnect()}catch(s){}},C=r=>{if(!(r!=null&&r.persisted)||!b)return;b=!1;let s=Date.now();for(let a of g.values())a.enterAt=a.intersecting&&!e.hidden?s:null};e.addEventListener("visibilitychange",I);let m=(i=e.defaultView)!=null?i:typeof window!="undefined"?window:void 0;m==null||m.addEventListener("pagehide",L),m==null||m.addEventListener("pageshow",C);let w=setInterval(()=>{if(e.hidden||b)return;h();let r=Date.now();for(let s of g.values())s.intersecting&&(s.enterAt=r)},me),A=[];return o.microSignals&&[...p.entries()].forEach(([r,s],a)=>{A.push(Q((c,n={})=>{try{t.track({projectId:o.apiKey,componentId:s,eventType:"micro_signal",payload:$({signalType:c},n)})}catch(l){}},r,void 0,{tabLoss:a===0}))}),()=>{h(!0),clearInterval(w),k.stop(),e.removeEventListener("visibilitychange",I),m==null||m.removeEventListener("pagehide",L),m==null||m.removeEventListener("pageshow",C);for(let r of A)r();try{T.disconnect()}catch(r){}}}export{oe as INTERACTION_STATS_COMPONENT,j as SEMANTIC_TYPES,H as classifyFeatures,se as classifySection,q as featuresFromElement,ve as startEngagementCapture};
2
2
  //# sourceMappingURL=index-engagement.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/engagement/capture.ts","../src/engagement/interaction-stats.ts"],"sourcesContent":["import {\n classifyFeatures,\n featuresFromElement,\n CONTENT_PATTERNS,\n SEMANTIC_TYPES,\n type SemanticType,\n} from './classify';\nimport { fnv1a } from '@sentientui/policy';\nimport { isDoNotTrackEnabled } from '../index.js';\nimport { attachMicroSignalDetectors } from '../micro-signals.js';\nimport { locatorFromElement } from '../locator-from-dom.js';\nimport { startInteractionCollector, type InteractionStats } from './interaction-stats.js';\n\n// Shared engagement capture (spec 2026-07-22-persona-signal-capture). Detects\n// semantic sections, registers them via /v1/section-map, and records per-section\n// dwell/scroll via IntersectionObserver — emitting the same 'dwell' events the\n// persona pipeline consumes. Used by the React provider (default on) and the\n// no-code snippet. Defense-in-depth: checks DNT internally even though callers\n// gate on consent/DNT too; a missing IntersectionObserver → no-op.\n\ntype CaptureClient = {\n track(event: { projectId: string; componentId: string; eventType: string; payload: Record<string, unknown> }): void;\n /** Drain the event queue now. Optional so an embedder can pass a bare\n * tracker, but every first-party client has it — see the leave-path flush\n * in `emit`, which is what makes a short visit deliverable at all. */\n flush?(): void;\n};\n\nexport type EngagementCaptureOptions = {\n apiKey: string;\n /** API base, no trailing slash. Defaults to the hosted API. */\n apiBase?: string;\n doc?: Document;\n /**\n * Also attach per-section micro-signal detectors (rage click, text copy,\n * scroll hesitation, tab loss), attributed to the section's per-element `nc-*`\n * component. For the no-code snippet, whose pages have no `<Adaptive>`\n * components carrying their own detectors. Default false — the React SDK\n * keeps its per-component detectors and must not double-attach.\n */\n microSignals?: boolean;\n /**\n * Section types declared in code, keyed by `data-sentient-id`. The highest\n * precedence — the same map the graph scanner receives, so capture and the\n * graph never disagree on what a declared section is.\n */\n sectionTypes?: Readonly<Partial<Record<string, string>>>;\n /**\n * Server-served section-map lookup (persona-coverage auto-classification):\n * consulted after declared types and legacy `data-sentient-type` markup,\n * before the local heuristic. Return null when the element has no served label.\n */\n typeOf?: (el: Element) => SemanticType | null;\n};\n\nconst SECTION_SELECTOR = 'section, header, footer, nav, main > div, [data-sentient-section]';\n\n/** Bank cadence for visible dwell. Dwell used to leave the page only on\n * visibilitychange/pagehide, and in production that path delivered for ~5-8%\n * of sessions (Bodyshop audit 2026-08-30): a visitor who reads and closes the\n * tab races the unload pipeline, and mobile browsers can kill a page with no\n * lifecycle event at all. The heartbeat caps the loss at one interval. */\nconst HEARTBEAT_MS = 20_000;\n\n/** Sentinel component for the session-level interaction snapshot — same\n * pattern as pageview's `__page__`: not a component, never attributed to one.\n * Every report producer filters `raw_events` by event_type, so the sentinel\n * cannot leak into a component table. */\nexport const INTERACTION_STATS_COMPONENT = '__session__';\nexport type { InteractionStats };\n\n/**\n * Pick the elements to observe. Two rules, in order:\n * 1. A candidate that CONTAINS two or more other candidates is a layout\n * wrapper, not a section — drop it. Pages built from bare divs match\n * `main > div` with their page-wide content wrapper; keeping that outer\n * match swallowed every real <section> inside it, collapsing the whole page\n * into one nc-generic component whose intersectionRatio could never exceed\n * viewport-height / page-height (a constant ~0.05 scroll_depth on the\n * audited site). A candidate with exactly one nested candidate (header >\n * nav) is NOT a wrapper — rule 2 keeps the outer one, as before.\n * 2. Of what remains, skip a section nested inside another kept section\n * (avoid double count).\n */\nfunction selectSections(doc: Document): Element[] {\n const candidates = Array.from(doc.querySelectorAll(SECTION_SELECTOR));\n const kept = candidates.filter(\n (el) => candidates.filter((c) => c !== el && el.contains(c)).length < 2,\n );\n return kept.filter((el) => !kept.some((k) => k !== el && k.contains(el)));\n}\n\n/** Client-sensor observation riding each section-map entry (spec 2026-09-04\n * §2): structure, headings, and which CONTENT_PATTERNS matched — never body\n * text, so nothing beyond headings leaves the page. Lets the server's richer\n * topic classifier label pages the crawler cannot fetch (CSR, auth-walled). */\ntype SectionObservation = {\n tag: string;\n idClass: string;\n headingText: string;\n textLength: number;\n actionCount: number;\n ariaRole?: string;\n patternFlags?: SemanticType[];\n};\n\nfunction registerSections(\n apiKey: string,\n apiBase: string,\n pageUrl: string,\n sections: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }>,\n): void {\n try {\n void fetch(`${apiBase}/v1/section-map`, {\n method: 'POST',\n keepalive: true,\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({ pageUrl, sections }),\n }).catch(() => undefined);\n } catch {\n /* fail-safe */\n }\n}\n\nconst NOOP = (): void => undefined;\n\nexport function startEngagementCapture(\n client: CaptureClient,\n opts: EngagementCaptureOptions,\n): () => void {\n const doc = opts.doc ?? (typeof document !== 'undefined' ? document : undefined);\n if (!doc || typeof IntersectionObserver === 'undefined') return NOOP;\n if (isDoNotTrackEnabled()) return NOOP;\n // Keyless zero-network contract: capture exists to feed the hosted persona\n // pipeline — with no api key there is nothing to feed, and the section-map\n // registration fetch must never fire. Same validity rule as init() and the\n // graph entry: this used to check truthiness only, so an invalid non-`pk_`\n // (typo'd) key still fired /v1/section-map registration and dwell events\n // into a client that discards everything.\n if (!opts.apiKey || !opts.apiKey.startsWith('pk_')) return NOOP;\n // Normalize so both a ROOT base (`https://api.sentient-ui.com`) and a\n // `/v1`-suffixed base resolve to exactly one `/v1/section-map` — some callers\n // pass the versioned base, which would otherwise produce `/v1/v1/section-map`\n // (a silent 404). Strip trailing slashes, then a single trailing `/v1`.\n const apiBase = (opts.apiBase ?? 'https://api.sentient-ui.com')\n .replace(/\\/+$/, '')\n .replace(/\\/v1$/, '');\n\n const els = selectSections(doc);\n if (els.length === 0) return NOOP;\n\n // One component per ELEMENT (nc-* retirement, 2026-09-05): the id carries a\n // short locator hash — `nc-<type>-<hash>` — so two same-typed bands no longer\n // collapse into one row with summed dwell, which is what made \"which features\n // band holds attention?\" unanswerable. The hash is over the locator's\n // identity fields (the same subset section_key hashes server-side), so the id\n // is stable across visits. An element with no resolvable locator falls back\n // to the collapsed `nc-<type>` — no identity means no better name exists.\n // The type-level matrix is unaffected (it aggregates via graph_nodes\n // semantic_type); pre-change dwell history stays keyed to collapsed ids and\n // ages out of the reporting windows.\n // Per-element precedence: declared sectionTypes (by data-sentient-id) →\n // legacy data-sentient-type markup → served section map (opts.typeOf) →\n // local heuristic. Declared and markup types both report source 'markup':\n // they are author-asserted, not inferred.\n const componentOf = new Map<Element, string>();\n const entries: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }> = [];\n for (const el of els) {\n const markup = [\n opts.sectionTypes?.[el.getAttribute('data-sentient-id') ?? ''],\n el.getAttribute('data-sentient-type'),\n ].find((t): t is SemanticType => (SEMANTIC_TYPES as readonly unknown[]).includes(t)) ?? null;\n const f = featuresFromElement(el);\n const type = markup ?? opts.typeOf?.(el) ?? classifyFeatures(f).type;\n const locator = locatorFromElement(el, doc) as\n | { id?: string; dataAttr?: unknown; selector?: string }\n | null;\n const componentId = locator\n ? `nc-${type}-${fnv1a(\n JSON.stringify({ id: locator.id ?? null, dataAttr: locator.dataAttr ?? null, selector: locator.selector ?? null }),\n ).toString(36)}`\n : `nc-${type}`;\n componentOf.set(el, componentId);\n // Client-sensor observation: which shipped CONTENT_PATTERNS matched the\n // body text (booleans — the text itself never leaves the page), plus the\n // structural features the server classifier keys on.\n const patternFlags = CONTENT_PATTERNS.filter(([, re]) => re.test(f.bodyText)).map(([t]) => t);\n entries.push({\n componentId,\n semanticType: type,\n // `source` is per ELEMENT: with one row per section the server records\n // each section's real provenance, not the most-confident of its siblings'.\n source: markup ? 'markup' : 'auto',\n ...(locator ? { locator } : {}),\n observation: {\n tag: f.tag,\n idClass: f.idClass.slice(0, 200),\n headingText: f.headingText,\n textLength: f.textLength,\n actionCount: f.actionCount,\n ...(f.ariaRole ? { ariaRole: f.ariaRole } : {}),\n ...(patternFlags.length > 0 ? { patternFlags } : {}),\n },\n });\n }\n\n const pageUrl = (doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined))?.location?.pathname ?? '/';\n registerSections(opts.apiKey, apiBase, pageUrl, entries);\n\n // Browser-agent axis (spec 2026-09-22 §4.1): passive interaction aggregates,\n // emitted at the same bank points as dwell. Same DNT/key gate — we are past\n // both checks here — and the collector itself never touches the network.\n const interaction = startInteractionCollector(doc);\n // EVERY visit reports, however short. There used to be an 8 s floor here, on\n // the reasoning that a bounce has too few events for an aggregate to mean\n // anything. True of the aggregate, wrong as a place to act on it: a 2 s read\n // on a phone is a real visit, and suppressing it left the scorer unable to\n // tell that visitor from a JS-less crawler — the population that already\n // makes up 83% of the \"human\" sessions on the busiest prod project. Whether\n // a snapshot is thin enough to ignore is a SCORING question, and it now\n // lives with the scorer (a snapshot that fires no positive reason keeps\n // `client_js_present`), where the threshold can move without an SDK release.\n const emitInteraction = (): void => {\n let snap: InteractionStats;\n try { snap = interaction.snapshot(); } catch { return; }\n try {\n client.track({\n projectId: opts.apiKey,\n componentId: INTERACTION_STATS_COMPONENT,\n eventType: 'interaction_stats',\n payload: snap as unknown as Record<string, unknown>,\n });\n } catch {\n /* fail-safe */\n }\n };\n\n // Accumulate visible dwell (ms) + max scroll ratio per component. `intersecting`\n // tracks in-viewport state independently of `enterAt` (the running clock) so a\n // tab-hide can pause the clock and a tab-show can resume it for still-visible\n // sections — IntersectionObserver does not re-fire on visibilitychange.\n const state = new Map<string, { ms: number; scroll: number; enterAt: number | null; intersecting: boolean }>();\n const get = (id: string) => {\n let s = state.get(id);\n if (!s) { s = { ms: 0, scroll: 0, enterAt: null, intersecting: false }; state.set(id, s); }\n return s;\n };\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const id = componentOf.get(entry.target);\n if (!id) continue;\n const s = get(id);\n if (entry.isIntersecting) {\n s.intersecting = true;\n s.enterAt = Date.now();\n if (entry.intersectionRatio > s.scroll) s.scroll = entry.intersectionRatio;\n } else {\n s.intersecting = false;\n if (s.enterAt != null) { s.ms += Date.now() - s.enterAt; s.enterAt = null; }\n }\n }\n }, { threshold: [0, 0.25, 0.5, 0.75, 1] });\n for (const el of componentOf.keys()) observer.observe(el);\n\n // Bank accumulated dwell and RESET the accumulators (so a later emit can't\n // double-count) WITHOUT disconnecting — a visitor who hides/re-shows the tab\n // or tab-switches keeps being measured. Pauses the running clock; the tab-show\n // handler restarts it for still-visible sections so hidden time isn't counted.\n // `leaving` marks the paths where the page may not exist a tick from now.\n // The queue installed its OWN pagehide/visibilitychange flush when the\n // client was constructed — before this module was imported — so on those\n // events it drains first and everything banked below is enqueued after the\n // drain has already happened. With a 5 s queue timer and a 20 s heartbeat,\n // a visit shorter than either delivered nothing: measured at ~5-8% on the\n // leave path (Bodyshop audit 2026-08-30). Flushing here, after the bank,\n // is what closes that. Not on the heartbeat: the page is alive, the queue's\n // own timer covers it, and flushing every 20 s would double the requests.\n const emit = (leaving = false): void => {\n const now = Date.now();\n for (const [id, s] of state) {\n if (s.enterAt != null) { s.ms += now - s.enterAt; s.enterAt = null; }\n if (s.ms <= 0) continue;\n try {\n client.track({\n projectId: opts.apiKey, // SDK convention: server derives the real project from the key\n componentId: id,\n eventType: 'dwell',\n payload: { dwell_time: Math.round(s.ms), scroll_depth: Number(s.scroll.toFixed(2)) },\n });\n } catch {\n /* fail-safe */\n }\n s.ms = 0;\n }\n emitInteraction();\n if (leaving) {\n try { client.flush?.(); } catch { /* fail-safe */ }\n }\n };\n\n const onVisibility = (): void => {\n if (doc.hidden) {\n emit(true); // bank + pause + drain: on mobile this IS the leave path\n } else {\n const now = Date.now(); // resume the clock for sections still on screen\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }\n };\n // A page can be FROZEN into the bfcache rather than torn down. Timers keep\n // firing on restore, and `intersecting` still holds whatever it held at\n // pagehide — so without this the heartbeat kept banking dwell for sections the\n // visitor had scrolled far past, forever, while the observer that could have\n // corrected them had been disconnected. Freeze the clocks instead, and only\n // tear down for real when the page is genuinely going away.\n let frozen = false;\n const onPageHide = (event?: { persisted?: boolean }): void => {\n emit(true); // bank whatever is measured either way, then drain\n if (event?.persisted) {\n frozen = true; // bfcache: keep the observer, stop counting\n return;\n }\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n const onPageShow = (event?: { persisted?: boolean }): void => {\n if (!event?.persisted || !frozen) return;\n frozen = false;\n // The observer stayed connected, so it will correct `intersecting` for\n // anything that moved. Restart clocks only for what is on screen NOW.\n const now = Date.now();\n for (const s of state.values()) s.enterAt = s.intersecting && !doc.hidden ? now : null;\n };\n doc.addEventListener('visibilitychange', onVisibility);\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n win?.addEventListener('pagehide', onPageHide);\n win?.addEventListener('pageshow', onPageShow);\n\n // See HEARTBEAT_MS: bank visible dwell periodically so a hard close (or a\n // mobile page kill) loses at most one interval instead of the whole visit.\n // Hidden tabs skip the emit — their clock is already paused, and an empty\n // state map makes emit a no-op anyway.\n const heartbeat = setInterval(() => {\n if (doc.hidden || frozen) return;\n emit();\n // emit() pauses every running clock and only the tab-show handler restarts\n // them — here the page never went hidden, so restart the clock ourselves\n // or accumulation silently stops after the first heartbeat.\n const now = Date.now();\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }, HEARTBEAT_MS);\n\n // Per-section micro-signal detectors (opt-in; see EngagementCaptureOptions).\n // Attributed to the section's per-element nc-* id with no variant — they feed the\n // persona attention fallback and auto-discovery, never rewards.\n const detectorCleanups: Array<() => void> = [];\n if (opts.microSignals) {\n // tab_loss is a single document-level `visibilitychange` signal, so enabling\n // it on every section detector would emit one tab_loss per section\n // on a single tab-hide — attributing one page-level exit to every section\n // (audit M5). Enable it on only the first section so the exit is recorded\n // once, mirroring the per-option path in slot-signals.ts ({ tabLoss: index === 0 }).\n [...componentOf.entries()].forEach(([el, componentId], i) => {\n detectorCleanups.push(\n attachMicroSignalDetectors((signalType, extra = {}) => {\n try {\n client.track({\n projectId: opts.apiKey,\n componentId,\n eventType: 'micro_signal',\n payload: { signalType, ...extra },\n });\n } catch {\n /* fail-safe */\n }\n }, el, undefined, { tabLoss: i === 0 }),\n );\n });\n }\n\n // Cleanup: bank any remaining dwell, then detach everything (provider unmount\n // / consent re-init must not leak observers or listeners).\n return () => {\n emit(true);\n clearInterval(heartbeat);\n interaction.stop();\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('pagehide', onPageHide);\n win?.removeEventListener('pageshow', onPageShow);\n for (const c of detectorCleanups) c();\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n}\n","//\n// Session-scoped interaction AGGREGATES for the browser-agent axis (spec\n// 2026-09-22-agent-axis-human-verified-numbers-design.md §4.1). Counts, means\n// and variances only: no per-event timestamps, no coordinates, no text. A\n// raw trace is arguably a biometric; these statistics are not, and the whole\n// privacy posture of the feature rests on that line staying where it is.\n//\n// The collector knows nothing about the network. It exposes a snapshot; the\n// engagement capture decides when to emit it, under its own DNT/consent gate.\n\nexport type InteractionStats = {\n v: 1;\n active_ms: number;\n mm: number;\n /** Mousemoves per VISIBLE second, 2 dp. The count alone does not separate:\n * a driver dispatches one mousemove per click, so `mm === 0` is false for\n * the commonest automation stack (measured: Playwright emits 3 over a\n * 6-action script). The rate does — humans emit tens per second, drivers\n * around one. Carried alongside `mm` so a future threshold can use either. */\n mm_rate: number;\n touches: number;\n clicks: number;\n /** How many mousedown→mouseup pairs `hold_mean`/`hold_std` rest on. Without\n * it a zero-variance hold (a driver pressing and releasing in one tick) is\n * indistinguishable from never having measured one at all, and the scorer\n * would condemn the second case on the evidence of the first. */\n hold_n: number;\n hold_mean: number;\n hold_std: number;\n teleport: number;\n wheel: number;\n scroll_px: number;\n keydowns: number;\n input_chars: number;\n ik_cv: number;\n backspaces: number;\n gaps: [number, number, number, number, number, number];\n reduced_motion: boolean;\n kb_nav: number;\n renderer: 'sw' | 'hw' | 'unknown';\n vp: [number, number];\n dpr: number;\n};\n\nexport type InteractionCollector = { snapshot(): InteractionStats; stop(): void };\n\n/** Log-spaced action-gap edges (ms). Six buckets: <100, <300, <1000, <3000,\n * <10000, >=10000. LLM agents pile into the two ends (instant bursts after\n * model latency); humans sit in the middle. */\nexport const GAP_EDGES_MS: readonly number[] = [100, 300, 1000, 3000, 10000];\n\nconst TELEPORT_WINDOW_MS = 250;\nconst TOUCH_RECENT_MS = 1000;\nconst NAV_KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);\n\n/** Welford running mean/variance — one object per measured quantity, so the\n * std of click hold and the CV of inter-key intervals cost 3 numbers each. */\ntype Welford = { n: number; mean: number; m2: number };\nfunction push(w: Welford, x: number): void {\n w.n++;\n const d = x - w.mean;\n w.mean += d / w.n;\n w.m2 += d * (x - w.mean);\n}\nconst std = (w: Welford): number => (w.n > 1 ? Math.sqrt(w.m2 / w.n) : 0);\n\nfunction rendererClass(doc: Document): InteractionStats['renderer'] {\n try {\n const canvas = doc.createElement('canvas');\n const gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')) as\n | (WebGLRenderingContext & { getExtension(name: string): { UNMASKED_RENDERER_WEBGL: number } | null })\n | null;\n if (!gl) return 'unknown';\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n const name = ext ? String(gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) ?? '') : '';\n if (!name) return 'unknown';\n // Software rasterisers are what headless Chromium ships without a GPU.\n // Corroboration only — stealth tooling patches this string first — so the\n // scorer weights it low (spec §4.2).\n return /swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(name) ? 'sw' : 'hw';\n } catch {\n return 'unknown';\n }\n}\n\nexport function startInteractionCollector(doc: Document, now: () => number = Date.now): InteractionCollector {\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n const hold: Welford = { n: 0, mean: 0, m2: 0 };\n const interkey: Welford = { n: 0, mean: 0, m2: 0 };\n const gaps: InteractionStats['gaps'] = [0, 0, 0, 0, 0, 0];\n let mm = 0, touches = 0, clicks = 0, teleport = 0, wheel = 0, scrollPx = 0;\n let keydowns = 0, inputChars = 0, backspaces = 0, kbNav = 0;\n let lastMoveAt = -Infinity, lastTouchAt = -Infinity, downAt: number | null = null;\n let lastKeyAt: number | null = null, lastActionAt: number | null = null;\n let lastScrollY = win?.scrollY ?? 0;\n // Visible wall-clock: banked on hide, resumed on show. A hidden tab must not\n // accrue \"activity\", or a background tab left open all day reads as a\n // deeply engaged visitor with no mouse — the assistive-technology signature.\n let banked = 0;\n let visibleSince: number | null = doc.hidden ? null : now();\n\n const action = (): void => {\n const t = now();\n if (lastActionAt != null) {\n const g = t - lastActionAt;\n let i = 0;\n while (i < GAP_EDGES_MS.length && g >= GAP_EDGES_MS[i]!) i++;\n gaps[i as 0 | 1 | 2 | 3 | 4 | 5]++;\n }\n lastActionAt = t;\n };\n\n const onMove = (): void => { mm++; lastMoveAt = now(); };\n const onTouch = (): void => { touches++; lastTouchAt = now(); };\n const onDown = (): void => { downAt = now(); };\n const onUp = (): void => { if (downAt != null) { push(hold, now() - downAt); downAt = null; } };\n const onClick = (): void => {\n const t = now();\n clicks++;\n // A click with no pointer travel before it was placed at computed\n // coordinates — unless it was a tap, which never moves a mouse.\n if (t - lastMoveAt > TELEPORT_WINDOW_MS && t - lastTouchAt > TOUCH_RECENT_MS) teleport++;\n action();\n };\n const onWheel = (): void => { wheel++; };\n const onScroll = (): void => {\n const y = win?.scrollY ?? 0;\n scrollPx += Math.abs(y - lastScrollY);\n lastScrollY = y;\n // A scroll IS an action for gap purposes. Without this a session that\n // reads by scrolling contributes almost nothing to the gap histogram —\n // measured 3 gaps across a six-action script, far below what any shape\n // test can read.\n action();\n };\n const onKey = (e: KeyboardEvent): void => {\n const t = now();\n keydowns++;\n if (e.key === 'Backspace' || e.key === 'Delete') backspaces++;\n if (NAV_KEYS.has(e.key)) kbNav++;\n if (lastKeyAt != null) push(interkey, t - lastKeyAt);\n lastKeyAt = t;\n action();\n };\n const onInput = (e: Event): void => {\n const data = (e as InputEvent).data;\n if (typeof data === 'string') inputChars += data.length;\n action();\n };\n const onVisibility = (): void => {\n const t = now();\n if (doc.hidden) { if (visibleSince != null) { banked += t - visibleSince; visibleSince = null; } }\n else if (visibleSince == null) visibleSince = t;\n };\n\n const opts: AddEventListenerOptions = { passive: true, capture: true };\n doc.addEventListener('mousemove', onMove, opts);\n doc.addEventListener('touchstart', onTouch, opts);\n doc.addEventListener('touchmove', onWheel, opts);\n doc.addEventListener('mousedown', onDown, opts);\n doc.addEventListener('mouseup', onUp, opts);\n doc.addEventListener('click', onClick, opts);\n doc.addEventListener('wheel', onWheel, opts);\n doc.addEventListener('keydown', onKey as EventListener, opts);\n doc.addEventListener('input', onInput, opts);\n doc.addEventListener('visibilitychange', onVisibility);\n win?.addEventListener('scroll', onScroll, opts);\n\n const renderer = rendererClass(doc);\n const reducedMotion = ((): boolean => {\n try { return win?.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true; } catch { return false; }\n })();\n\n return {\n snapshot(): InteractionStats {\n const t = now();\n const active = banked + (visibleSince != null ? t - visibleSince : 0);\n return {\n v: 1,\n active_ms: Math.round(active),\n mm,\n mm_rate: active > 0 ? Number(((mm * 1000) / active).toFixed(2)) : 0,\n touches, clicks,\n hold_n: hold.n,\n hold_mean: Math.round(hold.mean),\n hold_std: Math.round(std(hold)),\n teleport, wheel,\n scroll_px: Math.round(scrollPx),\n keydowns,\n input_chars: inputChars,\n ik_cv: interkey.mean > 0 ? Number((std(interkey) / interkey.mean).toFixed(2)) : 0,\n backspaces,\n gaps: [...gaps] as InteractionStats['gaps'],\n reduced_motion: reducedMotion,\n kb_nav: kbNav,\n renderer,\n vp: [win?.innerWidth ?? 0, win?.innerHeight ?? 0],\n dpr: win?.devicePixelRatio || 1,\n };\n },\n stop(): void {\n doc.removeEventListener('mousemove', onMove, opts);\n doc.removeEventListener('touchstart', onTouch, opts);\n doc.removeEventListener('touchmove', onWheel, opts);\n doc.removeEventListener('mousedown', onDown, opts);\n doc.removeEventListener('mouseup', onUp, opts);\n doc.removeEventListener('click', onClick, opts);\n doc.removeEventListener('wheel', onWheel, opts);\n doc.removeEventListener('keydown', onKey as EventListener, opts);\n doc.removeEventListener('input', onInput, opts);\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('scroll', onScroll, opts);\n },\n };\n}\n"],"mappings":"mUAOA,OAAS,SAAAA,OAAa,qBC0Cf,IAAM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rendererClass","doc","_a","canvas","gl","ext","name","startInteractionCollector","now","_b","win","hold","interkey","gaps","mm","touches","clicks","teleport","wheel","scrollPx","keydowns","inputChars","backspaces","kbNav","lastMoveAt","lastTouchAt","downAt","lastKeyAt","lastActionAt","lastScrollY","banked","visibleSince","action","t","g","i","onMove","onTouch","onDown","onUp","onClick","onWheel","onScroll","y","onKey","e","onInput","data","onVisibility","opts","renderer","reducedMotion","active","SECTION_SELECTOR","HEARTBEAT_MS","INTERACTION_STATS_COMPONENT","selectSections","doc","candidates","kept","el","c","k","registerSections","apiKey","apiBase","pageUrl","sections","e","NOOP","startEngagementCapture","client","opts","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","isDoNotTrackEnabled","els","componentOf","entries","markup","t","SEMANTIC_TYPES","f","featuresFromElement","type","classifyFeatures","locator","locatorFromElement","componentId","fnv1a","patternFlags","CONTENT_PATTERNS","re","__spreadProps","__spreadValues","interaction","startInteractionCollector","emitInteraction","snap","state","get","id","observer","entry","s","emit","leaving","now","onVisibility","frozen","onPageHide","event","onPageShow","win","heartbeat","detectorCleanups","i","attachMicroSignalDetectors","signalType","extra"]}
1
+ {"version":3,"sources":["../src/engagement/capture.ts","../src/engagement/interaction-stats.ts"],"sourcesContent":["import {\n classifyFeatures,\n featuresFromElement,\n CONTENT_PATTERNS,\n SEMANTIC_TYPES,\n type SemanticType,\n} from './classify';\nimport { fnv1a } from '@sentientui/policy';\nimport { isDoNotTrackEnabled } from '../index.js';\nimport { attachMicroSignalDetectors } from '../micro-signals.js';\nimport { locatorFromElement } from '../locator-from-dom.js';\nimport { startInteractionCollector, type InteractionStats } from './interaction-stats.js';\n\n// Shared engagement capture (spec 2026-07-22-persona-signal-capture). Detects\n// semantic sections, registers them via /v1/section-map, and records per-section\n// dwell/scroll via IntersectionObserver — emitting the same 'dwell' events the\n// persona pipeline consumes. Used by the React provider (default on) and the\n// no-code snippet. Defense-in-depth: checks DNT internally even though callers\n// gate on consent/DNT too; a missing IntersectionObserver → no-op.\n\ntype CaptureClient = {\n track(event: { projectId: string; componentId: string; eventType: string; payload: Record<string, unknown> }): void;\n /** Drain the event queue now. Optional so an embedder can pass a bare\n * tracker, but every first-party client has it — see the leave-path flush\n * in `emit`, which is what makes a short visit deliverable at all. */\n flush?(): void;\n};\n\nexport type EngagementCaptureOptions = {\n apiKey: string;\n /** API base, no trailing slash. Defaults to the hosted API. */\n apiBase?: string;\n doc?: Document;\n /**\n * Also attach per-section micro-signal detectors (rage click, text copy,\n * scroll hesitation, tab loss), attributed to the section's per-element `nc-*`\n * component. For the no-code snippet, whose pages have no `<Adaptive>`\n * components carrying their own detectors. Default false — the React SDK\n * keeps its per-component detectors and must not double-attach.\n */\n microSignals?: boolean;\n /**\n * Section types declared in code, keyed by `data-sentient-id`. The highest\n * precedence — the same map the graph scanner receives, so capture and the\n * graph never disagree on what a declared section is.\n */\n sectionTypes?: Readonly<Partial<Record<string, string>>>;\n /**\n * Server-served section-map lookup (persona-coverage auto-classification):\n * consulted after declared types and legacy `data-sentient-type` markup,\n * before the local heuristic. Return null when the element has no served label.\n */\n typeOf?: (el: Element) => SemanticType | null;\n};\n\nconst SECTION_SELECTOR = 'section, header, footer, nav, main > div, [data-sentient-section]';\n\n/** Bank cadence for visible dwell. Dwell used to leave the page only on\n * visibilitychange/pagehide, and in production that path delivered for ~5-8%\n * of sessions (Bodyshop audit 2026-08-30): a visitor who reads and closes the\n * tab races the unload pipeline, and mobile browsers can kill a page with no\n * lifecycle event at all. The heartbeat caps the loss at one interval. */\nconst HEARTBEAT_MS = 20_000;\n\n/** Sentinel component for the session-level interaction snapshot — same\n * pattern as pageview's `__page__`: not a component, never attributed to one.\n * Every report producer filters `raw_events` by event_type, so the sentinel\n * cannot leak into a component table. */\nexport const INTERACTION_STATS_COMPONENT = '__session__';\nexport type { InteractionStats };\n\n/**\n * Pick the elements to observe. Two rules, in order:\n * 1. A candidate that CONTAINS two or more other candidates is a layout\n * wrapper, not a section — drop it. Pages built from bare divs match\n * `main > div` with their page-wide content wrapper; keeping that outer\n * match swallowed every real <section> inside it, collapsing the whole page\n * into one nc-generic component whose intersectionRatio could never exceed\n * viewport-height / page-height (a constant ~0.05 scroll_depth on the\n * audited site). A candidate with exactly one nested candidate (header >\n * nav) is NOT a wrapper — rule 2 keeps the outer one, as before.\n * 2. Of what remains, skip a section nested inside another kept section\n * (avoid double count).\n */\nfunction selectSections(doc: Document): Element[] {\n const candidates = Array.from(doc.querySelectorAll(SECTION_SELECTOR));\n const kept = candidates.filter(\n (el) => candidates.filter((c) => c !== el && el.contains(c)).length < 2,\n );\n return kept.filter((el) => !kept.some((k) => k !== el && k.contains(el)));\n}\n\n/** Client-sensor observation riding each section-map entry (spec 2026-09-04\n * §2): structure, headings, and which CONTENT_PATTERNS matched — never body\n * text, so nothing beyond headings leaves the page. Lets the server's richer\n * topic classifier label pages the crawler cannot fetch (CSR, auth-walled). */\ntype SectionObservation = {\n tag: string;\n idClass: string;\n headingText: string;\n textLength: number;\n actionCount: number;\n ariaRole?: string;\n patternFlags?: SemanticType[];\n};\n\nfunction registerSections(\n apiKey: string,\n apiBase: string,\n pageUrl: string,\n sections: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }>,\n): void {\n try {\n void fetch(`${apiBase}/v1/section-map`, {\n method: 'POST',\n keepalive: true,\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({ pageUrl, sections }),\n }).catch(() => undefined);\n } catch {\n /* fail-safe */\n }\n}\n\nconst NOOP = (): void => undefined;\n\nexport function startEngagementCapture(\n client: CaptureClient,\n opts: EngagementCaptureOptions,\n): () => void {\n const doc = opts.doc ?? (typeof document !== 'undefined' ? document : undefined);\n if (!doc || typeof IntersectionObserver === 'undefined') return NOOP;\n if (isDoNotTrackEnabled()) return NOOP;\n // Keyless zero-network contract: capture exists to feed the hosted persona\n // pipeline — with no api key there is nothing to feed, and the section-map\n // registration fetch must never fire. Same validity rule as init() and the\n // graph entry: this used to check truthiness only, so an invalid non-`pk_`\n // (typo'd) key still fired /v1/section-map registration and dwell events\n // into a client that discards everything.\n if (!opts.apiKey || !opts.apiKey.startsWith('pk_')) return NOOP;\n // Normalize so both a ROOT base (`https://api.sentient-ui.com`) and a\n // `/v1`-suffixed base resolve to exactly one `/v1/section-map` — some callers\n // pass the versioned base, which would otherwise produce `/v1/v1/section-map`\n // (a silent 404). Strip trailing slashes, then a single trailing `/v1`.\n const apiBase = (opts.apiBase ?? 'https://api.sentient-ui.com')\n .replace(/\\/+$/, '')\n .replace(/\\/v1$/, '');\n\n const els = selectSections(doc);\n if (els.length === 0) return NOOP;\n\n // One component per ELEMENT (nc-* retirement, 2026-09-05): the id carries a\n // short locator hash — `nc-<type>-<hash>` — so two same-typed bands no longer\n // collapse into one row with summed dwell, which is what made \"which features\n // band holds attention?\" unanswerable. The hash is over the locator's\n // identity fields (the same subset section_key hashes server-side), so the id\n // is stable across visits. An element with no resolvable locator falls back\n // to the collapsed `nc-<type>` — no identity means no better name exists.\n // The type-level matrix is unaffected (it aggregates via graph_nodes\n // semantic_type); pre-change dwell history stays keyed to collapsed ids and\n // ages out of the reporting windows.\n // Per-element precedence: declared sectionTypes (by data-sentient-id) →\n // legacy data-sentient-type markup → served section map (opts.typeOf) →\n // local heuristic. Declared and markup types both report source 'markup':\n // they are author-asserted, not inferred.\n const componentOf = new Map<Element, string>();\n const entries: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }> = [];\n for (const el of els) {\n const markup = [\n opts.sectionTypes?.[el.getAttribute('data-sentient-id') ?? ''],\n el.getAttribute('data-sentient-type'),\n ].find((t): t is SemanticType => (SEMANTIC_TYPES as readonly unknown[]).includes(t)) ?? null;\n const f = featuresFromElement(el);\n const type = markup ?? opts.typeOf?.(el) ?? classifyFeatures(f).type;\n const locator = locatorFromElement(el, doc) as\n | { id?: string; dataAttr?: unknown; selector?: string }\n | null;\n const componentId = locator\n ? `nc-${type}-${fnv1a(\n JSON.stringify({ id: locator.id ?? null, dataAttr: locator.dataAttr ?? null, selector: locator.selector ?? null }),\n ).toString(36)}`\n : `nc-${type}`;\n componentOf.set(el, componentId);\n // Client-sensor observation: which shipped CONTENT_PATTERNS matched the\n // body text (booleans — the text itself never leaves the page), plus the\n // structural features the server classifier keys on.\n const patternFlags = CONTENT_PATTERNS.filter(([, re]) => re.test(f.bodyText)).map(([t]) => t);\n entries.push({\n componentId,\n semanticType: type,\n // `source` is per ELEMENT: with one row per section the server records\n // each section's real provenance, not the most-confident of its siblings'.\n source: markup ? 'markup' : 'auto',\n ...(locator ? { locator } : {}),\n observation: {\n tag: f.tag,\n idClass: f.idClass.slice(0, 200),\n headingText: f.headingText,\n textLength: f.textLength,\n actionCount: f.actionCount,\n ...(f.ariaRole ? { ariaRole: f.ariaRole } : {}),\n ...(patternFlags.length > 0 ? { patternFlags } : {}),\n },\n });\n }\n\n const pageUrl = (doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined))?.location?.pathname ?? '/';\n registerSections(opts.apiKey, apiBase, pageUrl, entries);\n\n // Browser-agent axis (spec 2026-09-22 §4.1): passive interaction aggregates,\n // emitted at the same bank points as dwell. Same DNT/key gate — we are past\n // both checks here — and the collector itself never touches the network.\n const interaction = startInteractionCollector(doc);\n // EVERY visit reports, however short. There used to be an 8 s floor here, on\n // the reasoning that a bounce has too few events for an aggregate to mean\n // anything. True of the aggregate, wrong as a place to act on it: a 2 s read\n // on a phone is a real visit, and suppressing it left the scorer unable to\n // tell that visitor from a JS-less crawler — the population that already\n // makes up 83% of the \"human\" sessions on the busiest prod project. Whether\n // a snapshot is thin enough to ignore is a SCORING question, and it now\n // lives with the scorer (a snapshot that fires no positive reason keeps\n // `client_js_present`), where the threshold can move without an SDK release.\n const emitInteraction = (): void => {\n let snap: InteractionStats;\n try { snap = interaction.snapshot(); } catch { return; }\n try {\n client.track({\n projectId: opts.apiKey,\n componentId: INTERACTION_STATS_COMPONENT,\n eventType: 'interaction_stats',\n payload: snap as unknown as Record<string, unknown>,\n });\n } catch {\n /* fail-safe */\n }\n };\n\n // Accumulate visible dwell (ms) + max scroll ratio per component. `intersecting`\n // tracks in-viewport state independently of `enterAt` (the running clock) so a\n // tab-hide can pause the clock and a tab-show can resume it for still-visible\n // sections — IntersectionObserver does not re-fire on visibilitychange.\n const state = new Map<string, { ms: number; scroll: number; enterAt: number | null; intersecting: boolean }>();\n const get = (id: string) => {\n let s = state.get(id);\n if (!s) { s = { ms: 0, scroll: 0, enterAt: null, intersecting: false }; state.set(id, s); }\n return s;\n };\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const id = componentOf.get(entry.target);\n if (!id) continue;\n const s = get(id);\n if (entry.isIntersecting) {\n s.intersecting = true;\n s.enterAt = Date.now();\n if (entry.intersectionRatio > s.scroll) s.scroll = entry.intersectionRatio;\n } else {\n s.intersecting = false;\n if (s.enterAt != null) { s.ms += Date.now() - s.enterAt; s.enterAt = null; }\n }\n }\n }, { threshold: [0, 0.25, 0.5, 0.75, 1] });\n for (const el of componentOf.keys()) observer.observe(el);\n\n // Bank accumulated dwell and RESET the accumulators (so a later emit can't\n // double-count) WITHOUT disconnecting — a visitor who hides/re-shows the tab\n // or tab-switches keeps being measured. Pauses the running clock; the tab-show\n // handler restarts it for still-visible sections so hidden time isn't counted.\n // `leaving` marks the paths where the page may not exist a tick from now.\n // The queue installed its OWN pagehide/visibilitychange flush when the\n // client was constructed — before this module was imported — so on those\n // events it drains first and everything banked below is enqueued after the\n // drain has already happened. With a 5 s queue timer and a 20 s heartbeat,\n // a visit shorter than either delivered nothing: measured at ~5-8% on the\n // leave path (Bodyshop audit 2026-08-30). Flushing here, after the bank,\n // is what closes that. Not on the heartbeat: the page is alive, the queue's\n // own timer covers it, and flushing every 20 s would double the requests.\n const emit = (leaving = false): void => {\n const now = Date.now();\n for (const [id, s] of state) {\n if (s.enterAt != null) { s.ms += now - s.enterAt; s.enterAt = null; }\n if (s.ms <= 0) continue;\n try {\n client.track({\n projectId: opts.apiKey, // SDK convention: server derives the real project from the key\n componentId: id,\n eventType: 'dwell',\n payload: { dwell_time: Math.round(s.ms), scroll_depth: Number(s.scroll.toFixed(2)) },\n });\n } catch {\n /* fail-safe */\n }\n s.ms = 0;\n }\n emitInteraction();\n if (leaving) {\n try { client.flush?.(); } catch { /* fail-safe */ }\n }\n };\n\n const onVisibility = (): void => {\n if (doc.hidden) {\n emit(true); // bank + pause + drain: on mobile this IS the leave path\n } else {\n const now = Date.now(); // resume the clock for sections still on screen\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }\n };\n // A page can be FROZEN into the bfcache rather than torn down. Timers keep\n // firing on restore, and `intersecting` still holds whatever it held at\n // pagehide — so without this the heartbeat kept banking dwell for sections the\n // visitor had scrolled far past, forever, while the observer that could have\n // corrected them had been disconnected. Freeze the clocks instead, and only\n // tear down for real when the page is genuinely going away.\n let frozen = false;\n const onPageHide = (event?: { persisted?: boolean }): void => {\n emit(true); // bank whatever is measured either way, then drain\n if (event?.persisted) {\n frozen = true; // bfcache: keep the observer, stop counting\n return;\n }\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n const onPageShow = (event?: { persisted?: boolean }): void => {\n if (!event?.persisted || !frozen) return;\n frozen = false;\n // The observer stayed connected, so it will correct `intersecting` for\n // anything that moved. Restart clocks only for what is on screen NOW.\n const now = Date.now();\n for (const s of state.values()) s.enterAt = s.intersecting && !doc.hidden ? now : null;\n };\n doc.addEventListener('visibilitychange', onVisibility);\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n win?.addEventListener('pagehide', onPageHide);\n win?.addEventListener('pageshow', onPageShow);\n\n // See HEARTBEAT_MS: bank visible dwell periodically so a hard close (or a\n // mobile page kill) loses at most one interval instead of the whole visit.\n // Hidden tabs skip the emit — their clock is already paused, and an empty\n // state map makes emit a no-op anyway.\n const heartbeat = setInterval(() => {\n if (doc.hidden || frozen) return;\n emit();\n // emit() pauses every running clock and only the tab-show handler restarts\n // them — here the page never went hidden, so restart the clock ourselves\n // or accumulation silently stops after the first heartbeat.\n const now = Date.now();\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }, HEARTBEAT_MS);\n\n // Per-section micro-signal detectors (opt-in; see EngagementCaptureOptions).\n // Attributed to the section's per-element nc-* id with no variant — they feed the\n // persona attention fallback and auto-discovery, never rewards.\n const detectorCleanups: Array<() => void> = [];\n if (opts.microSignals) {\n // tab_loss is a single document-level `visibilitychange` signal, so enabling\n // it on every section detector would emit one tab_loss per section\n // on a single tab-hide — attributing one page-level exit to every section\n // (audit M5). Enable it on only the first section so the exit is recorded\n // once, mirroring the per-option path in slot-signals.ts ({ tabLoss: index === 0 }).\n [...componentOf.entries()].forEach(([el, componentId], i) => {\n detectorCleanups.push(\n attachMicroSignalDetectors((signalType, extra = {}) => {\n try {\n client.track({\n projectId: opts.apiKey,\n componentId,\n eventType: 'micro_signal',\n payload: { signalType, ...extra },\n });\n } catch {\n /* fail-safe */\n }\n }, el, undefined, { tabLoss: i === 0 }),\n );\n });\n }\n\n // Cleanup: bank any remaining dwell, then detach everything (provider unmount\n // / consent re-init must not leak observers or listeners).\n return () => {\n emit(true);\n clearInterval(heartbeat);\n interaction.stop();\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('pagehide', onPageHide);\n win?.removeEventListener('pageshow', onPageShow);\n for (const c of detectorCleanups) c();\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n}\n","//\n// Session-scoped interaction AGGREGATES for the browser-agent axis (spec\n// 2026-09-22-agent-axis-human-verified-numbers-design.md §4.1). Counts, means\n// and variances only: no per-event timestamps, no coordinates, no text. A\n// raw trace is arguably a biometric; these statistics are not, and the whole\n// privacy posture of the feature rests on that line staying where it is.\n//\n// The collector knows nothing about the network. It exposes a snapshot; the\n// engagement capture decides when to emit it, under its own DNT/consent gate.\n\nexport type InteractionStats = {\n v: 1;\n active_ms: number;\n mm: number;\n /** Mousemoves per VISIBLE second, 2 dp. The count alone does not separate:\n * a driver dispatches one mousemove per click, so `mm === 0` is false for\n * the commonest automation stack (measured: Playwright emits 3 over a\n * 6-action script). The rate does — humans emit tens per second, drivers\n * around one. Carried alongside `mm` so a future threshold can use either. */\n mm_rate: number;\n touches: number;\n clicks: number;\n /** How many mousedown→mouseup pairs `hold_mean`/`hold_std` rest on. Without\n * it a zero-variance hold (a driver pressing and releasing in one tick) is\n * indistinguishable from never having measured one at all, and the scorer\n * would condemn the second case on the evidence of the first. */\n hold_n: number;\n hold_mean: number;\n hold_std: number;\n teleport: number;\n wheel: number;\n scroll_px: number;\n keydowns: number;\n input_chars: number;\n ik_cv: number;\n backspaces: number;\n gaps: [number, number, number, number, number, number];\n reduced_motion: boolean;\n kb_nav: number;\n renderer: 'sw' | 'hw' | 'unknown';\n vp: [number, number];\n dpr: number;\n};\n\nexport type InteractionCollector = { snapshot(): InteractionStats; stop(): void };\n\n/** Log-spaced action-gap edges (ms). Six buckets: <100, <300, <1000, <3000,\n * <10000, >=10000. LLM agents pile into the two ends (instant bursts after\n * model latency); humans sit in the middle. */\nexport const GAP_EDGES_MS: readonly number[] = [100, 300, 1000, 3000, 10000];\n\nconst TELEPORT_WINDOW_MS = 250;\nconst TOUCH_RECENT_MS = 1000;\nconst NAV_KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);\n\n/** Welford running mean/variance — one object per measured quantity, so the\n * std of click hold and the CV of inter-key intervals cost 3 numbers each. */\ntype Welford = { n: number; mean: number; m2: number };\nfunction push(w: Welford, x: number): void {\n w.n++;\n const d = x - w.mean;\n w.mean += d / w.n;\n w.m2 += d * (x - w.mean);\n}\nconst std = (w: Welford): number => (w.n > 1 ? Math.sqrt(w.m2 / w.n) : 0);\n\nfunction rendererClass(doc: Document): InteractionStats['renderer'] {\n try {\n const canvas = doc.createElement('canvas');\n const gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')) as\n | (WebGLRenderingContext & { getExtension(name: string): { UNMASKED_RENDERER_WEBGL: number } | null })\n | null;\n if (!gl) return 'unknown';\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n const name = ext ? String(gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) ?? '') : '';\n if (!name) return 'unknown';\n // Software rasterisers are what headless Chromium ships without a GPU.\n // Corroboration only — stealth tooling patches this string first — so the\n // scorer weights it low (spec §4.2).\n return /swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(name) ? 'sw' : 'hw';\n } catch {\n return 'unknown';\n }\n}\n\nexport function startInteractionCollector(doc: Document, now: () => number = Date.now): InteractionCollector {\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n const hold: Welford = { n: 0, mean: 0, m2: 0 };\n const interkey: Welford = { n: 0, mean: 0, m2: 0 };\n const gaps: InteractionStats['gaps'] = [0, 0, 0, 0, 0, 0];\n let mm = 0, touches = 0, clicks = 0, teleport = 0, wheel = 0, scrollPx = 0;\n let keydowns = 0, inputChars = 0, backspaces = 0, kbNav = 0;\n let lastMoveAt = -Infinity, lastTouchAt = -Infinity, downAt: number | null = null;\n let lastKeyAt: number | null = null, lastActionAt: number | null = null;\n let lastScrollY = win?.scrollY ?? 0;\n // Visible wall-clock: banked on hide, resumed on show. A hidden tab must not\n // accrue \"activity\", or a background tab left open all day reads as a\n // deeply engaged visitor with no mouse — the assistive-technology signature.\n let banked = 0;\n let visibleSince: number | null = doc.hidden ? null : now();\n\n const action = (): void => {\n const t = now();\n if (lastActionAt != null) {\n const g = t - lastActionAt;\n let i = 0;\n while (i < GAP_EDGES_MS.length && g >= GAP_EDGES_MS[i]!) i++;\n gaps[i as 0 | 1 | 2 | 3 | 4 | 5]++;\n }\n lastActionAt = t;\n };\n\n const onMove = (): void => { mm++; lastMoveAt = now(); };\n const onTouch = (): void => { touches++; lastTouchAt = now(); };\n const onDown = (): void => { downAt = now(); };\n const onUp = (): void => { if (downAt != null) { push(hold, now() - downAt); downAt = null; } };\n const onClick = (): void => {\n const t = now();\n clicks++;\n // A click with no pointer travel before it was placed at computed\n // coordinates — unless it was a tap, which never moves a mouse.\n if (t - lastMoveAt > TELEPORT_WINDOW_MS && t - lastTouchAt > TOUCH_RECENT_MS) teleport++;\n action();\n };\n const onWheel = (): void => { wheel++; };\n const onScroll = (): void => {\n const y = win?.scrollY ?? 0;\n scrollPx += Math.abs(y - lastScrollY);\n lastScrollY = y;\n // A scroll IS an action for gap purposes. Without this a session that\n // reads by scrolling contributes almost nothing to the gap histogram —\n // measured 3 gaps across a six-action script, far below what any shape\n // test can read.\n action();\n };\n const onKey = (e: KeyboardEvent): void => {\n const t = now();\n keydowns++;\n if (e.key === 'Backspace' || e.key === 'Delete') backspaces++;\n if (NAV_KEYS.has(e.key)) kbNav++;\n if (lastKeyAt != null) push(interkey, t - lastKeyAt);\n lastKeyAt = t;\n action();\n };\n const onInput = (e: Event): void => {\n const data = (e as InputEvent).data;\n if (typeof data === 'string') inputChars += data.length;\n action();\n };\n const onVisibility = (): void => {\n const t = now();\n if (doc.hidden) { if (visibleSince != null) { banked += t - visibleSince; visibleSince = null; } }\n else if (visibleSince == null) visibleSince = t;\n };\n\n const opts: AddEventListenerOptions = { passive: true, capture: true };\n doc.addEventListener('mousemove', onMove, opts);\n doc.addEventListener('touchstart', onTouch, opts);\n doc.addEventListener('touchmove', onWheel, opts);\n doc.addEventListener('mousedown', onDown, opts);\n doc.addEventListener('mouseup', onUp, opts);\n doc.addEventListener('click', onClick, opts);\n doc.addEventListener('wheel', onWheel, opts);\n doc.addEventListener('keydown', onKey as EventListener, opts);\n doc.addEventListener('input', onInput, opts);\n doc.addEventListener('visibilitychange', onVisibility);\n win?.addEventListener('scroll', onScroll, opts);\n\n const renderer = rendererClass(doc);\n const reducedMotion = ((): boolean => {\n try { return win?.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true; } catch { return false; }\n })();\n\n return {\n snapshot(): InteractionStats {\n const t = now();\n const active = banked + (visibleSince != null ? t - visibleSince : 0);\n return {\n v: 1,\n active_ms: Math.round(active),\n mm,\n mm_rate: active > 0 ? Number(((mm * 1000) / active).toFixed(2)) : 0,\n touches, clicks,\n hold_n: hold.n,\n hold_mean: Math.round(hold.mean),\n hold_std: Math.round(std(hold)),\n teleport, wheel,\n scroll_px: Math.round(scrollPx),\n keydowns,\n input_chars: inputChars,\n ik_cv: interkey.mean > 0 ? Number((std(interkey) / interkey.mean).toFixed(2)) : 0,\n backspaces,\n gaps: [...gaps] as InteractionStats['gaps'],\n reduced_motion: reducedMotion,\n kb_nav: kbNav,\n renderer,\n vp: [win?.innerWidth ?? 0, win?.innerHeight ?? 0],\n dpr: win?.devicePixelRatio || 1,\n };\n },\n stop(): void {\n doc.removeEventListener('mousemove', onMove, opts);\n doc.removeEventListener('touchstart', onTouch, opts);\n doc.removeEventListener('touchmove', onWheel, opts);\n doc.removeEventListener('mousedown', onDown, opts);\n doc.removeEventListener('mouseup', onUp, opts);\n doc.removeEventListener('click', onClick, opts);\n doc.removeEventListener('wheel', onWheel, opts);\n doc.removeEventListener('keydown', onKey as EventListener, opts);\n doc.removeEventListener('input', onInput, opts);\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('scroll', onScroll, opts);\n },\n };\n}\n"],"mappings":"6XAOA,OAAS,SAAAA,OAAa,qBC0Cf,IAAMC,GAAkC,CAAC,IAAK,IAAK,IAAM,IAAM,GAAK,EAErEC,GAAqB,IACrBC,GAAkB,IAClBC,GAAW,IAAI,IAAI,CAAC,MAAO,UAAW,YAAa,YAAa,YAAY,CAAC,EAKnF,SAASC,GAAKC,EAAYC,EAAiB,CACzCD,EAAE,IACF,IAAME,EAAID,EAAID,EAAE,KAChBA,EAAE,MAAQE,EAAIF,EAAE,EAChBA,EAAE,IAAME,GAAKD,EAAID,EAAE,KACrB,CACA,IAAMG,GAAOH,GAAwBA,EAAE,EAAI,EAAI,KAAK,KAAKA,EAAE,GAAKA,EAA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O,EAAE,eAAc,EAAE,QAAUQ,EAClE,EAAGlE,EAAY,EAKT0E,EAAsC,CAAC,EAC7C,OAAIxD,EAAK,cAMP,CAAC,GAAGkB,EAAY,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC9B,EAAIyC,CAAW,EAAG4B,IAAM,CAC3DD,EAAiB,KACfE,EAA2B,CAACC,EAAYC,EAAQ,CAAC,IAAM,CACrD,GAAI,CACF7D,EAAO,MAAM,CACX,UAAWC,EAAK,OAChB,YAAA6B,EACA,UAAW,eACX,QAASM,EAAA,CAAE,WAAAwB,GAAeC,EAC5B,CAAC,CACH,OAAQhE,EAAA,CAER,CACF,EAAGR,EAAI,OAAW,CAAE,QAASqE,IAAM,CAAE,CAAC,CACxC,CACF,CAAC,EAKI,IAAM,CACXX,EAAK,EAAI,EACT,cAAcS,CAAS,EACvBnB,EAAY,KAAK,EACjBnD,EAAI,oBAAoB,mBAAoBgE,CAAY,EACxDK,GAAA,MAAAA,EAAK,oBAAoB,WAAYH,GACrCG,GAAA,MAAAA,EAAK,oBAAoB,WAAYD,GACrC,QAAWhE,KAAKmE,EAAkBnE,EAAE,EACpC,GAAI,CAAEsD,EAAS,WAAW,CAAG,OAAQ/C,EAAA,CAAe,CACtD,CACF","names":["fnv1a","GAP_EDGES_MS","TELEPORT_WINDOW_MS","TOUCH_RECENT_MS","NAV_KEYS","push","w","x","d","std","rendererClass","doc","_a","canvas","gl","ext","name","startInteractionCollector","now","_b","win","hold","interkey","gaps","mm","touches","clicks","teleport","wheel","scrollPx","keydowns","inputChars","backspaces","kbNav","lastMoveAt","lastTouchAt","downAt","lastKeyAt","lastActionAt","lastScrollY","banked","visibleSince","action","t","g","i","onMove","onTouch","onDown","onUp","onClick","onWheel","onScroll","y","onKey","e","onInput","data","onVisibility","opts","renderer","reducedMotion","active","SECTION_SELECTOR","HEARTBEAT_MS","INTERACTION_STATS_COMPONENT","selectSections","doc","candidates","kept","el","c","k","registerSections","apiKey","apiBase","pageUrl","sections","e","NOOP","startEngagementCapture","client","opts","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","isDoNotTrackEnabled","els","componentOf","entries","markup","t","SEMANTIC_TYPES","f","featuresFromElement","type","classifyFeatures","locator","locatorFromElement","componentId","fnv1a","patternFlags","CONTENT_PATTERNS","re","__spreadProps","__spreadValues","interaction","startInteractionCollector","emitInteraction","snap","state","get","id","observer","entry","s","emit","leaving","now","onVisibility","frozen","onPageHide","event","onPageShow","win","heartbeat","detectorCleanups","i","attachMicroSignalDetectors","signalType","extra"]}
@@ -1,5 +1,5 @@
1
- import { s as SentientConfig, r as SentientClient } from './index-DlJDNOWu.cjs';
2
- export { a as AssignResult, b as Assignment, c as AssignmentCache, E as EventQueue, g as EventType, i as GraphClient, j as GraphConfig, k as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, M as MicroSignalEmitter, m as MicroSignalType, o as PageNode, Q as QueueConfig, S as STAGE_ATTRIBUTE, t as SentientEvent, u as SessionConfig, v as SessionManager, x as StageAttributes, z as attachMicroSignalDetectors, F as exposedStage, I as grantConsent, K as isDoNotTrackEnabled, X as sanitizePageUrl, Y as sessionCookieName, $ as setStageAttribute } from './index-DlJDNOWu.cjs';
1
+ import { s as SentientConfig, r as SentientClient } from './index-CWHTKETi.cjs';
2
+ export { a as AssignResult, b as Assignment, c as AssignmentCache, E as EventQueue, g as EventType, i as GraphClient, j as GraphConfig, k as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, M as MicroSignalEmitter, m as MicroSignalType, o as PageNode, Q as QueueConfig, S as STAGE_ATTRIBUTE, t as SentientEvent, u as SessionConfig, v as SessionManager, x as StageAttributes, z as attachMicroSignalDetectors, F as exposedStage, J as grantConsent, N as isDoNotTrackEnabled, Y as sanitizePageUrl, Z as sessionCookieName, a0 as setStageAttribute } from './index-CWHTKETi.cjs';
3
3
  import { c as CompoundLocator } from './session-meta-BqBaLZag.cjs';
4
4
  export { D as DecisionSnapshot, S as SNAPSHOT_STORAGE_KEY_PREFIX, e as SlotConfigEntry, f as SlotDeclInput, g as SlotOps, j as armOfResult, k as baselineResultFor, l as baselineSlots, o as deriveSessionSegment, p as detectDeviceClass, q as detectTimeOfDay, r as detectTrafficSource, v as readSnapshot, w as referrerDomainFromReferer, x as renderPrePaintScript, y as toWireSlot, B as writeSnapshot } from './session-meta-BqBaLZag.cjs';
5
5
  export { B as BLOCK_ALIGNS, a as BLOCK_EMPHASES, b as BLOCK_FITS, c as BLOCK_GAPS, d as BLOCK_GRID_COLUMNS, e as BLOCK_HEADING_LEVELS, f as BLOCK_JUSTIFIES, g as BLOCK_MAX_WIDTHS, h as BLOCK_PADS, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_SURFACES, l as BLOCK_TEXT_ALIGNS, m as BLOCK_TONES, n as BLOCK_WEIGHTS, o as BadgeBlock, p as BlockAlign, q as BlockEmphasis, r as BlockFit, s as BlockGap, t as BlockJustify, u as BlockMaxWidth, v as BlockNode, w as BlockPad, x as BlockRatio, y as BlockSize, z as BlockSurface, A as BlockTextAlign, C as BlockTone, D as BlockWeight, E as ButtonBlock, G as DividerBlock, H as FORM_FIELD_KINDS, I as FORM_INPUT_TYPES, J as FormBlock, K as FormField, L as GridBlock, M as HeadingBlock, N as ImageBlock, P as LinkBlock, Q as MAX_BLOCK_ARMS, R as MAX_BLOCK_CHILDREN, S as MAX_BLOCK_DEPTH, T as MAX_BLOCK_NODES, U as MAX_BLOCK_TEXT_LEN, V as MAX_FORM_FIELDS, W as MAX_FORM_SELECT_OPTIONS, $ as SitePalette, a0 as SpacerBlock, a1 as StackBlock, a5 as TextBlock, a6 as containsFormBlock } from './style-vocabulary-Ba_g6_DD.cjs';
@@ -1,5 +1,5 @@
1
- import { s as SentientConfig, r as SentientClient } from './index-C--aVpoo.js';
2
- export { a as AssignResult, b as Assignment, c as AssignmentCache, E as EventQueue, g as EventType, i as GraphClient, j as GraphConfig, k as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, M as MicroSignalEmitter, m as MicroSignalType, o as PageNode, Q as QueueConfig, S as STAGE_ATTRIBUTE, t as SentientEvent, u as SessionConfig, v as SessionManager, x as StageAttributes, z as attachMicroSignalDetectors, F as exposedStage, I as grantConsent, K as isDoNotTrackEnabled, X as sanitizePageUrl, Y as sessionCookieName, $ as setStageAttribute } from './index-C--aVpoo.js';
1
+ import { s as SentientConfig, r as SentientClient } from './index-cqfRT6LZ.js';
2
+ export { a as AssignResult, b as Assignment, c as AssignmentCache, E as EventQueue, g as EventType, i as GraphClient, j as GraphConfig, k as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, M as MicroSignalEmitter, m as MicroSignalType, o as PageNode, Q as QueueConfig, S as STAGE_ATTRIBUTE, t as SentientEvent, u as SessionConfig, v as SessionManager, x as StageAttributes, z as attachMicroSignalDetectors, F as exposedStage, J as grantConsent, N as isDoNotTrackEnabled, Y as sanitizePageUrl, Z as sessionCookieName, a0 as setStageAttribute } from './index-cqfRT6LZ.js';
3
3
  import { c as CompoundLocator } from './session-meta-D_kdNsaU.js';
4
4
  export { D as DecisionSnapshot, S as SNAPSHOT_STORAGE_KEY_PREFIX, e as SlotConfigEntry, f as SlotDeclInput, g as SlotOps, j as armOfResult, k as baselineResultFor, l as baselineSlots, o as deriveSessionSegment, p as detectDeviceClass, q as detectTimeOfDay, r as detectTrafficSource, v as readSnapshot, w as referrerDomainFromReferer, x as renderPrePaintScript, y as toWireSlot, B as writeSnapshot } from './session-meta-D_kdNsaU.js';
5
5
  export { B as BLOCK_ALIGNS, a as BLOCK_EMPHASES, b as BLOCK_FITS, c as BLOCK_GAPS, d as BLOCK_GRID_COLUMNS, e as BLOCK_HEADING_LEVELS, f as BLOCK_JUSTIFIES, g as BLOCK_MAX_WIDTHS, h as BLOCK_PADS, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_SURFACES, l as BLOCK_TEXT_ALIGNS, m as BLOCK_TONES, n as BLOCK_WEIGHTS, o as BadgeBlock, p as BlockAlign, q as BlockEmphasis, r as BlockFit, s as BlockGap, t as BlockJustify, u as BlockMaxWidth, v as BlockNode, w as BlockPad, x as BlockRatio, y as BlockSize, z as BlockSurface, A as BlockTextAlign, C as BlockTone, D as BlockWeight, E as ButtonBlock, G as DividerBlock, H as FORM_FIELD_KINDS, I as FORM_INPUT_TYPES, J as FormBlock, K as FormField, L as GridBlock, M as HeadingBlock, N as ImageBlock, P as LinkBlock, Q as MAX_BLOCK_ARMS, R as MAX_BLOCK_CHILDREN, S as MAX_BLOCK_DEPTH, T as MAX_BLOCK_NODES, U as MAX_BLOCK_TEXT_LEN, V as MAX_FORM_FIELDS, W as MAX_FORM_SELECT_OPTIONS, $ as SitePalette, a0 as SpacerBlock, a1 as StackBlock, a5 as TextBlock, a6 as containsFormBlock } from './style-vocabulary-Ba_g6_DD.js';