writetrack 0.7.0 → 0.9.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.
@@ -0,0 +1,77 @@
1
+ import { WriteTrack } from 'writetrack';
2
+
3
+ export interface WriteTrackLexicalOptions {
4
+ /** WriteTrack license key */
5
+ license?: string;
6
+ /** User identifier for metadata */
7
+ userId?: string;
8
+ /** Content identifier for metadata */
9
+ contentId?: string;
10
+ /** Additional metadata */
11
+ metadata?: Record<string, unknown>;
12
+ /** Auto-start tracking when editor root is available (default: true) */
13
+ autoStart?: boolean;
14
+ /** URL to the WASM binary for analysis. If omitted, uses default loader path. */
15
+ wasmUrl?: string;
16
+ /** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
17
+ persist?: boolean;
18
+ /** Callback fired every second with active session time. */
19
+ onTick?: (data: { activeTime: number; totalTime: number }) => void;
20
+ }
21
+
22
+ export interface WriteTrackLexicalHandle {
23
+ /** The underlying WriteTrack instance (null until root element is available) */
24
+ tracker: WriteTrack | null;
25
+ /** Whether tracking is currently active */
26
+ isTracking: boolean;
27
+ /** Stop tracking and clean up resources */
28
+ destroy(): void;
29
+ }
30
+
31
+ /**
32
+ * Attach WriteTrack to a Lexical editor.
33
+ *
34
+ * Uses `editor.registerRootListener()` to discover the contenteditable element.
35
+ * The tracker is created when the root becomes available and destroyed when
36
+ * the root is removed or `destroy()` is called.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { createEditor } from 'lexical';
41
+ * import { createWriteTrackLexical } from 'writetrack/lexical';
42
+ *
43
+ * import { createEditor, $getSelection } from 'lexical';
44
+ * import { createWriteTrackLexical } from 'writetrack/lexical';
45
+ *
46
+ * const editor = createEditor({ ... });
47
+ * const handle = createWriteTrackLexical(editor, $getSelection, {
48
+ * license: 'your-license-key',
49
+ * });
50
+ *
51
+ * // Access tracker
52
+ * const data = handle.tracker?.getData();
53
+ *
54
+ * // Clean up
55
+ * handle.destroy();
56
+ * ```
57
+ *
58
+ * @param editor - A Lexical `LexicalEditor` instance
59
+ * @param $getSelection - Lexical's `$getSelection` function for cursor position tracking
60
+ * @param options - WriteTrack configuration options
61
+ * @returns A handle with the tracker instance and a destroy method
62
+ */
63
+ export declare function createWriteTrackLexical(
64
+ editor: {
65
+ registerRootListener(
66
+ listener: (
67
+ rootElement: HTMLElement | null,
68
+ prevRootElement: HTMLElement | null
69
+ ) => void
70
+ ): () => void;
71
+ getEditorState(): {
72
+ read<T>(callback: () => T): T;
73
+ };
74
+ },
75
+ $getSelection: () => { anchor?: { offset: number } } | null,
76
+ options: WriteTrackLexicalOptions
77
+ ): WriteTrackLexicalHandle;
@@ -0,0 +1 @@
1
+ import{WriteTrack as d}from"writetrack";function f(n,s,r){let o=r.autoStart!==!1,a,l=n.registerUpdateListener(({tags:t})=>{t.has("paste")?a="paste":t.has("historic")?a="undo":a=void 0}),e={tracker:null,isTracking:!1,destroy(){e.tracker&&(e.tracker.stop(),e.tracker=null,e.isTracking=!1),l(),k()}};function u(t){e.tracker=new d({target:t,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>{try{return n.getEditorState().read(()=>{let i=s();return i&&typeof i.anchor?.offset=="number"?i.anchor.offset:0})}catch{return 0}},inputSourceProvider:()=>a}),r.onTick&&e.tracker.on("tick",r.onTick),o&&(r.persist?e.tracker.ready.then(()=>{e.tracker&&(e.tracker.start(),e.isTracking=!0)}):(e.tracker.start(),e.isTracking=!0))}function c(){e.tracker&&(e.tracker.stop(),e.tracker=null,e.isTracking=!1)}let k=n.registerRootListener(t=>{t?(c(),u(t)):c()});return e}export{f as createWriteTrackLexical};
@@ -1 +1 @@
1
- import{Plugin as s,PluginKey as c}from"prosemirror-state";import{WriteTrack as u}from"writetrack";var a=new c("writetrack");function o(r={}){let n=r.autoStart!==!1,t=null,e=!1;return new s({key:a,state:{init(){return{tracker:null,isTracking:!1}},apply(){return{tracker:t,isTracking:t!==null&&e}}},view(i){let l=i.dom;return t=new u({target:l,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>i.state.selection.from}),n&&(r.persist?t.ready.then(()=>{t&&(t.start(),e=!0)}):(t.start(),e=!0)),i.dispatch(i.state.tr),{destroy(){t&&(t.stop(),t=null,e=!1)}}}})}export{o as WriteTrackPlugin,a as WriteTrackPluginKey};
1
+ import{Plugin as u,PluginKey as c}from"prosemirror-state";import{WriteTrack as o}from"writetrack";var s=new c("writetrack");function g(e={}){let l=e.autoStart!==!1,t=null,a=!1,i;return new u({key:s,state:{init(){return{tracker:null,isTracking:!1}},apply(){return{tracker:t,isTracking:t!==null&&a}}},filterTransaction(r){let n=r.getMeta("uiEvent");return n==="paste"?i="paste":n==="drop"?i="drop":n==="cut"?i="cut":r.getMeta("composition")?i="composition":i=void 0,!0},view(r){let n=r.dom;return t=new o({target:n,license:e.license,userId:e.userId,contentId:e.contentId,metadata:e.metadata,wasmUrl:e.wasmUrl,persist:e.persist,cursorPositionProvider:()=>r.state.selection.from,inputSourceProvider:()=>i}),l&&(e.persist?t.ready.then(()=>{t&&(t.start(),a=!0)}):(t.start(),a=!0)),r.dispatch(r.state.tr),{destroy(){t&&(t.stop(),t=null,a=!1)}}}})}export{g as WriteTrackPlugin,s as WriteTrackPluginKey};
@@ -1 +1 @@
1
- import{WriteTrack as i}from"writetrack";var t=class{constructor(e,r){this._tracker=null;this._isTracking=!1;let a=r.autoStart!==!1;this._tracker=new i({target:e.root,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>e.getSelection()?.index??0}),a&&(r.persist?this._tracker.ready.then(()=>{this._tracker&&(this._tracker.start(),this._isTracking=!0)}):(this._tracker.start(),this._isTracking=!0))}get tracker(){return this._tracker}get isTracking(){return this._isTracking}destroy(){this._tracker&&(this._tracker.stop(),this._tracker=null,this._isTracking=!1)}};export{t as WriteTrackModule};
1
+ import{WriteTrack as a}from"writetrack";var e=class{constructor(t,r){this._tracker=null;this._isTracking=!1;let n=r.autoStart!==!1;t.on("text-change",(c,o,i)=>{this._currentSource=i==="api"?"api":void 0}),this._tracker=new a({target:t.root,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>t.getSelection()?.index??0,inputSourceProvider:()=>this._currentSource}),n&&(r.persist?this._tracker.ready.then(()=>{this._tracker&&(this._tracker.start(),this._isTracking=!0)}):(this._tracker.start(),this._isTracking=!0))}get tracker(){return this._tracker}get isTracking(){return this._isTracking}destroy(){this._tracker&&(this._tracker.stop(),this._tracker=null,this._isTracking=!1)}};export{e as WriteTrackModule};
@@ -0,0 +1,64 @@
1
+ import { WriteTrack } from 'writetrack';
2
+
3
+ export interface WriteTrackSlateOptions {
4
+ /** WriteTrack license key */
5
+ license?: string;
6
+ /** User identifier for metadata */
7
+ userId?: string;
8
+ /** Content identifier for metadata */
9
+ contentId?: string;
10
+ /** Additional metadata */
11
+ metadata?: Record<string, unknown>;
12
+ /** Auto-start tracking when created (default: true) */
13
+ autoStart?: boolean;
14
+ /** URL to the WASM binary for analysis. If omitted, uses default loader path. */
15
+ wasmUrl?: string;
16
+ /** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
17
+ persist?: boolean;
18
+ }
19
+
20
+ export interface WriteTrackSlateHandle {
21
+ /** The underlying WriteTrack instance */
22
+ tracker: WriteTrack | null;
23
+ /** Whether tracking is currently active */
24
+ isTracking: boolean;
25
+ /** Stop tracking and clean up resources */
26
+ destroy(): void;
27
+ }
28
+
29
+ /**
30
+ * Attach WriteTrack to a Slate editor.
31
+ *
32
+ * Slate is React-based and does not provide a built-in destroy lifecycle,
33
+ * so `destroy()` must be called manually (e.g. in a useEffect cleanup).
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createEditor } from 'slate';
38
+ * import { createWriteTrackSlate } from 'writetrack/slate';
39
+ *
40
+ * const editor = createEditor();
41
+ * const editableRef = document.querySelector('[data-slate-editor]');
42
+ * const handle = createWriteTrackSlate(editor, editableRef, {
43
+ * license: 'your-license-key',
44
+ * });
45
+ *
46
+ * // Access tracker
47
+ * const data = handle.tracker?.getData();
48
+ *
49
+ * // Clean up
50
+ * handle.destroy();
51
+ * ```
52
+ *
53
+ * @param editor - A Slate `Editor` instance
54
+ * @param element - The contenteditable DOM element (e.g. from a ref on `<Editable>`)
55
+ * @param options - WriteTrack configuration options
56
+ * @returns A handle with the tracker instance and a destroy method
57
+ */
58
+ export declare function createWriteTrackSlate(
59
+ editor: {
60
+ selection: { anchor: { offset: number }; focus: { offset: number } } | null;
61
+ },
62
+ element: HTMLElement,
63
+ options: WriteTrackSlateOptions
64
+ ): WriteTrackSlateHandle;
@@ -0,0 +1 @@
1
+ import{WriteTrack as o}from"writetrack";function k(t,c,r){let l=r.autoStart!==!1,a,s=t.insertText;t.insertText=n=>{a="keyboard",s.call(t,n)};let i=t.insertData;t.insertData=n=>{a="paste",i.call(t,n)};let e={tracker:null,isTracking:!1,destroy(){e.tracker&&(e.tracker.stop(),e.tracker=null,e.isTracking=!1),t.insertText=s,t.insertData=i}};return e.tracker=new o({target:c,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>t.selection?.anchor.offset??0,inputSourceProvider:()=>a}),l&&(r.persist?e.tracker.ready.then(()=>{e.tracker&&(e.tracker.start(),e.isTracking=!0)}):(e.tracker.start(),e.isTracking=!0)),e}export{k as createWriteTrackSlate};
@@ -0,0 +1,71 @@
1
+ import { WriteTrack } from 'writetrack';
2
+
3
+ export interface WriteTrackTinyMCEOptions {
4
+ /** WriteTrack license key */
5
+ license?: string;
6
+ /** User identifier for metadata */
7
+ userId?: string;
8
+ /** Content identifier for metadata */
9
+ contentId?: string;
10
+ /** Additional metadata */
11
+ metadata?: Record<string, unknown>;
12
+ /** Auto-start tracking when editor initializes (default: true) */
13
+ autoStart?: boolean;
14
+ /** URL to the WASM binary for analysis. If omitted, uses default loader path. */
15
+ wasmUrl?: string;
16
+ /** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
17
+ persist?: boolean;
18
+ /** Callback fired every second with active session time. */
19
+ onTick?: (data: { activeTime: number; totalTime: number }) => void;
20
+ }
21
+
22
+ export interface WriteTrackTinyMCEHandle {
23
+ /** The underlying WriteTrack instance (null until editor init fires) */
24
+ tracker: WriteTrack | null;
25
+ /** Whether tracking is currently active */
26
+ isTracking: boolean;
27
+ /** Stop tracking and clean up resources */
28
+ destroy(): void;
29
+ }
30
+
31
+ /**
32
+ * Attach WriteTrack to a TinyMCE editor.
33
+ *
34
+ * Hooks into TinyMCE's `init` and `remove` lifecycle events.
35
+ * Uses `editor.getBody()` as the target element.
36
+ *
37
+ * **Note:** Only inline mode (`inline: true`) is fully supported.
38
+ * In iframe mode (default), window/document-level listeners attach to the
39
+ * host page rather than the iframe, resulting in degraded tracking.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import tinymce from 'tinymce';
44
+ * import { createWriteTrackTinyMCE } from 'writetrack/tinymce';
45
+ *
46
+ * tinymce.init({
47
+ * selector: '#editor',
48
+ * inline: true,
49
+ * setup: (editor) => {
50
+ * const handle = createWriteTrackTinyMCE(editor, {
51
+ * license: 'your-license-key',
52
+ * });
53
+ * },
54
+ * });
55
+ * ```
56
+ *
57
+ * @param editor - A TinyMCE `Editor` instance
58
+ * @param options - WriteTrack configuration options
59
+ * @returns A handle with the tracker instance and a destroy method
60
+ */
61
+ export declare function createWriteTrackTinyMCE(
62
+ editor: {
63
+ getBody(): HTMLElement;
64
+ selection: {
65
+ getRng(): { startOffset: number };
66
+ };
67
+ on(event: string, handler: () => void): void;
68
+ off(event: string, handler: () => void): void;
69
+ },
70
+ options: WriteTrackTinyMCEOptions
71
+ ): WriteTrackTinyMCEHandle;
@@ -0,0 +1 @@
1
+ import{WriteTrack as k}from"writetrack";function m(t,r){let l=r.autoStart!==!1,n,a=!1,e={tracker:null,isTracking:!1,destroy(){e.tracker&&(e.tracker.stop(),e.tracker=null,e.isTracking=!1),t.off("init",s),t.off("remove",u),t.off("PastePreProcess",o),t.off("AutocompleterStart",c),t.off("AutocompleterEnd",i)}};function o(){n="paste"}function c(){a=!0}function i(){a&&(n="autocomplete"),a=!1}function s(){let f=t.getBody();e.tracker=new k({target:f,license:r.license,userId:r.userId,contentId:r.contentId,metadata:r.metadata,wasmUrl:r.wasmUrl,persist:r.persist,cursorPositionProvider:()=>{try{return t.selection.getRng().startOffset}catch{return 0}},inputSourceProvider:()=>n}),r.onTick&&e.tracker.on("tick",r.onTick),l&&(r.persist?e.tracker.ready.then(()=>{e.tracker&&(e.tracker.start(),e.isTracking=!0)}):(e.tracker.start(),e.isTracking=!0))}function u(){e.destroy()}return t.on("init",s),t.on("remove",u),t.on("PastePreProcess",o),t.on("AutocompleterStart",c),t.on("AutocompleterEnd",i),e}export{m as createWriteTrackTinyMCE};
@@ -16,6 +16,8 @@ export interface WriteTrackExtensionOptions {
16
16
  wasmUrl?: string;
17
17
  /** Enable IndexedDB session persistence and auto-resume. Requires contentId. */
18
18
  persist?: boolean;
19
+ /** Callback fired every second with active session time. Wired up inside onCreate to avoid lifecycle race conditions. */
20
+ onTick?: (data: { activeTime: number; totalTime: number }) => void;
19
21
  }
20
22
 
21
23
  export interface WriteTrackExtensionStorage {
@@ -1 +1 @@
1
- import{Extension as e}from"@tiptap/core";import{WriteTrack as r}from"writetrack";var i=e.create({name:"writetrack",addOptions(){return{license:void 0,userId:void 0,contentId:void 0,metadata:void 0,autoStart:!0,wasmUrl:void 0,persist:void 0}},addStorage(){return{tracker:null,isTracking:!1}},onCreate(){let t=this.editor.view.dom;this.storage.tracker=new r({target:t,license:this.options.license,userId:this.options.userId,contentId:this.options.contentId,metadata:this.options.metadata,wasmUrl:this.options.wasmUrl,persist:this.options.persist,cursorPositionProvider:()=>this.editor.view.state.selection.from}),this.options.autoStart&&(this.options.persist?this.storage.tracker.ready.then(()=>{this.storage.tracker&&(this.storage.tracker.start(),this.storage.isTracking=!0)}):(this.storage.tracker.start(),this.storage.isTracking=!0))},onDestroy(){this.storage.tracker&&(this.storage.tracker.stop(),this.storage.tracker=null,this.storage.isTracking=!1)}});export{i as WriteTrackExtension};
1
+ import{Extension as r}from"@tiptap/core";import{WriteTrack as i}from"writetrack";var n=r.create({name:"writetrack",addOptions(){return{license:void 0,userId:void 0,contentId:void 0,metadata:void 0,autoStart:!0,wasmUrl:void 0,persist:void 0,onTick:void 0}},addStorage(){return{tracker:null,isTracking:!1,currentSource:void 0}},onTransaction({transaction:t}){let e=t.getMeta("uiEvent");e==="paste"?this.storage.currentSource="paste":e==="drop"?this.storage.currentSource="drop":e==="cut"?this.storage.currentSource="cut":this.storage.currentSource=void 0},onCreate(){let t=this.editor.view.dom;this.storage.tracker=new i({target:t,license:this.options.license,userId:this.options.userId,contentId:this.options.contentId,metadata:this.options.metadata,wasmUrl:this.options.wasmUrl,persist:this.options.persist,cursorPositionProvider:()=>this.editor.view.state.selection.from,inputSourceProvider:()=>this.storage.currentSource}),this.options.onTick&&this.storage.tracker.on("tick",this.options.onTick),this.options.autoStart&&(this.options.persist?this.storage.tracker.ready.then(()=>{this.storage.tracker&&(this.storage.tracker.start(),this.storage.isTracking=!0)}):(this.storage.tracker.start(),this.storage.isTracking=!0))},onDestroy(){this.storage.tracker&&(this.storage.tracker.stop(),this.storage.tracker=null,this.storage.isTracking=!1)}});export{n as WriteTrackExtension};
package/dist/viz.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nt=Object.create;var st=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Ht=(n,e)=>{for(var r in e)st(n,r,{get:e[r],enumerable:!0})},kt=(n,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of Ft(e))!Gt.call(n,t)&&t!==r&&st(n,t,{get:()=>e[t],enumerable:!(a=It(e,t))||a.enumerable});return n};var P=(n,e,r)=>(r=n!=null?Nt(zt(n)):{},kt(e||!n||!n.__esModule?st(r,"default",{value:n,enumerable:!0}):r,n)),Vt=n=>kt(st({},"__esModule",{value:!0}),n);var ke={};Ht(ke,{BaseChart:()=>g,CATEGORY_NAMES:()=>L,CompositionTimeline:()=>z,CorrectionsBubble:()=>X,DocumentGrowth:()=>Y,DocumentRibbon:()=>K,EditWaterfall:()=>U,GLOSSARY:()=>vt,IntegrityFooter:()=>_,PauseDistribution:()=>j,RhythmHeatmap:()=>H,SEGMENT_COLORS:()=>lt,Sparkline:()=>it,SpeedTimeline:()=>I,TIER1_CATEGORIES:()=>ut,TIER2_CATEGORIES:()=>pt,WtScorecard:()=>ot,extractCorrectionBubbles:()=>J,extractGrowthData:()=>q,extractPasteMarkers:()=>gt,extractPauseHistogram:()=>yt,extractRhythmPairs:()=>V,extractRibbonData:()=>bt,extractSegments:()=>G,extractSeries:()=>ft,extractSpeedData:()=>F,extractWaterfallData:()=>Q,formatDuration:()=>at,generateCaption:()=>ht,generateSummary:()=>et,getMetrics:()=>rt,getStatus:()=>W,isPass:()=>Ot,wrapTerms:()=>nt});module.exports=Vt(ke);var St=`:host {
1
+ "use strict";var Nt=Object.create;var st=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Ft=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Ht=(n,e)=>{for(var r in e)st(n,r,{get:e[r],enumerable:!0})},kt=(n,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of zt(e))!Gt.call(n,t)&&t!==r&&st(n,t,{get:()=>e[t],enumerable:!(a=It(e,t))||a.enumerable});return n};var P=(n,e,r)=>(r=n!=null?Nt(Ft(n)):{},kt(e||!n||!n.__esModule?st(r,"default",{value:n,enumerable:!0}):r,n)),Vt=n=>kt(st({},"__esModule",{value:!0}),n);var Se={};Ht(Se,{BaseChart:()=>g,CATEGORY_NAMES:()=>L,CompositionTimeline:()=>F,CorrectionsBubble:()=>X,DocumentGrowth:()=>Y,DocumentRibbon:()=>K,EditWaterfall:()=>U,GLOSSARY:()=>vt,IntegrityFooter:()=>_,PauseDistribution:()=>j,RhythmHeatmap:()=>H,SEGMENT_COLORS:()=>lt,Sparkline:()=>it,SpeedTimeline:()=>I,TIER1_CATEGORIES:()=>ut,TIER2_CATEGORIES:()=>pt,WtScorecard:()=>ot,extractCorrectionBubbles:()=>J,extractGrowthData:()=>q,extractPasteMarkers:()=>gt,extractPauseHistogram:()=>yt,extractRhythmPairs:()=>V,extractRibbonData:()=>bt,extractSegments:()=>G,extractSeries:()=>ft,extractSpeedData:()=>z,extractWaterfallData:()=>Q,formatDuration:()=>at,generateCaption:()=>ht,generateSummary:()=>et,getMetrics:()=>rt,getStatus:()=>M,isPass:()=>Ot,wrapTerms:()=>nt});module.exports=Vt(Se);var St=`:host {
2
2
  --wt-color-primary: #fbbf24;
3
3
  --wt-color-secondary: #22d3ee;
4
4
  --wt-color-bg: #111113;
@@ -35,9 +35,9 @@
35
35
  }
36
36
 
37
37
  /* Force light text on dark tooltips regardless of chart theme */
38
- [aria-label="tip"] { color: #fafafa; }`,S={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.s=!0;this.a=!1;this.o=!1;this.shadow=this.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=this.getStylesheet(),this.shadow.appendChild(r),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return St}connectedCallback(){typeof ResizeObserver<"u"&&(this.s=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.s){this.s=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.i(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.i()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(r,a,t){if(r==="data"&&t)try{let s=JSON.parse(t);this.setData(s)}catch(s){console.warn("[WriteTrack] BaseChart: invalid JSON in data attribute:",s)}r==="theme"&&this._data&&this.a&&this.render()}setData(r){this._data=r,this.render()}getData(){return this._data}get hasRendered(){return this.a}replaceChart(...r){for(let a of r)if(a instanceof SVGElement){a.setAttribute("role","img");let t=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";a.setAttribute("aria-label",t)}this.container.replaceChildren(...r),this.a=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(r="No data"){let a=document.createElement("div");a.className="wt-empty",a.textContent=r,a.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(a),this.a=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.a=!1}onResize(){this.render()}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}i(){if(this.hasAttribute("theme")&&!this.o)return;let r=this.parentElement;for(;r;){let a=r.getAttribute("data-theme");if(a){this.shadow.host.setAttribute("theme",a),this.o=!0;return}r=r.parentElement}this.o&&(this.shadow.host.removeAttribute("theme"),this.o=!1)}};g.tagName="wt-base-chart";var D=P(require("@observablehq/plot"),1);var jt=5;function ft(n){var s;let e=(((s=n.session)==null?void 0:s.events)??[]).filter(o=>o.type==="keydown"&&o.flightTime!=null&&o.flightTime>0);if(e.length<2)return[[],[]];let r=n.session.sessionStartTime,a=[],t=[];for(let o=0;o<e.length;o++){let i=Math.max(0,o-jt+1),c=0,l=0;for(let u=i;u<=o;u++)c+=e[u].flightTime,l++;let d=c/l,m=Math.round(6e4/d);a.push(Math.round((e[o].timestamp-r)/1e3*100)/100),t.push(m)}return[a,t]}var N=class N extends g{connectedCallback(){super.connectedCallback();let e=getComputedStyle(this);!this.style.display&&e.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(e.width==="auto"||e.width==="0px")&&(this.style.width="200px"),!this.style.height&&(e.height==="auto"||e.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[e,r]=ft(this._data);if(e.length===0){this.showEmptyState("No data");return}let a=e.map((i,c)=>({time:i,speed:r[c]})),t=this.getBoundingClientRect(),s=Math.max(t.width||200,50),o=Math.max(t.height||40,20);try{let i=D.plot({width:s,height:o,axis:null,x:{axis:null},y:{axis:null},marks:[D.areaY(a,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),D.lineY(a,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(i)}catch(i){console.warn("[WriteTrack] Sparkline render failed:",i)}}static create(e,r){N.register();let a=document.createElement(N.tagName);return e.appendChild(a),a.setData(r),a}};N.tagName="wt-sparkline";var it=N;var C=P(require("@observablehq/plot"),1);function F(n){var t,s,o;let e=(s=(t=n.temporalPatterns)==null?void 0:t.metrics)==null?void 0:s.speedTimeline;if(!((o=e==null?void 0:e.timestamps)!=null&&o.length))return[];let r=Math.min(e.timestamps.length,e.values.length),a=[];for(let i=0;i<r;i++)a.push({time:e.timestamps[i]/1e3,speed:e.values[i]});return a}var I=class extends g{render(){if(!this._data)return;let e=F(this._data);if(e.length===0){this.showEmptyState("No speed data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=C.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(e,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"natural"}),C.lineY(e,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"natural"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(e,C.pointerX({x:"time",y:"speed",title:s=>`${s.time.toFixed(1)}s \u2014 ${Math.round(s.speed)} CPM`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] SpeedTimeline render failed:",t)}}};I.tagName="wt-speed-timeline";var A=P(require("@observablehq/plot"),1);var lt={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function G(n){let e=n.sessionTimeline;return e!=null&&e.length?e.map(r=>({start:r.startTime/1e3,end:r.endTime/1e3,type:r.type,color:lt[r.type]??"#666"})):[]}function gt(n){var r,a;return(((a=(r=n.contentOrigin)==null?void 0:r.metrics)==null?void 0:a.pasteEvents)??[]).map(t=>({time:t.timestamp/1e3,chars:t.characterCount,source:t.source}))}var z=class extends g{render(){if(!this._data)return;let e=G(this._data);if(e.length===0){this.showEmptyState("No session data");return}let r=gt(this._data),a=[A.barX(e,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),A.tip(e,A.pointer({x:o=>(o.start+o.end)/2,y:()=>"Activity",title:o=>`${o.type} \u2014 ${(o.end-o.start).toFixed(1)}s`,...S}))];r.length&&a.push(A.dot(r,{x:"time",y:()=>"Activity",r:"chars",fill:lt.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let t=this.clientWidth||640,s=this.clientHeight||80;try{let o=A.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:a,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(o)}catch(o){console.warn("[WriteTrack] CompositionTimeline render failed:",o)}}};z.tagName="wt-composition-timeline";var ct=P(require("@observablehq/plot"),1);var Yt=10;function V(n){var o,i,c,l,d;let e=(i=(o=n.timingAuthenticity)==null?void 0:o.metrics)==null?void 0:i.timingOverTime;if(!((c=e==null?void 0:e.timestamps)!=null&&c.length))return[];let r=((l=e.series)==null?void 0:l.meanDwell)??[],a=((d=e.series)==null?void 0:d.meanFlight)??[];if(!r.length||!a.length)return[];let t=[],s=Math.min(e.timestamps.length,r.length,a.length);for(let m=0;m<s;m++)r[m]!=null&&a[m]!=null&&t.push({dwell:r[m],flight:a[m]});return t}var H=class extends g{render(){if(!this._data)return;let e=V(this._data);if(e.length<Yt){this.showEmptyState("Insufficient timing data");return}let r=this.clientWidth||400,a=Math.min(r,this.clientHeight||400);try{let t=ct.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[ct.dot(e,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] RhythmHeatmap render failed:",t)}}};H.tagName="wt-rhythm-heatmap";var O=P(require("@observablehq/plot"),1);function yt(n){var r,a,t;let e=(a=(r=n.temporalPatterns)==null?void 0:r.metrics)==null?void 0:a.pauseDistribution;return(t=e==null?void 0:e.histogram)!=null&&t.length?e.histogram.map(s=>({start:s.binStart,end:s.binEnd,count:s.count})):[]}var j=class extends g{render(){if(!this._data)return;let e=yt(this._data);if(e.length===0){this.showEmptyState("No pause data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=O.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[O.rectY(e,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),O.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] PauseDistribution render failed:",t)}}};j.tagName="wt-pause-distribution";var E=P(require("@observablehq/plot"),1);var dt=/^.$/u;function v(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function q(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return[];let r=e.filter(l=>l.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let l of r)l.key==="Backspace"||l.key==="Delete"?t.push({timestamp:l.timestamp,type:"key",delta:-1}):dt.test(l.key)&&t.push({timestamp:l.timestamp,type:"key",delta:1});for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?t.push({timestamp:l.timestamp,type:"paste",delta:l.length,pasteLength:l.length}):l.type==="cut"&&t.push({timestamp:l.timestamp,type:"cut",delta:-l.length,cutLength:l.length});t.sort((l,d)=>l.timestamp-d.timestamp);let s=[],o=0;for(let l of t){let d=(l.timestamp-a)/1e3;l.type==="paste"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o+=l.delta,s.push({time:d+.001,chars:o,isPaste:!0,isCut:!1,pasteLength:l.pasteLength})):l.type==="cut"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o=Math.max(0,o+l.delta),s.push({time:d+.001,chars:o,isPaste:!1,isCut:!0,cutLength:l.cutLength})):(o=Math.max(0,o+l.delta),s.push({time:d,chars:o,isPaste:!1,isCut:!1}))}return s}var Y=class extends g{render(){if(!this._data)return;let e=q(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=e.filter(o=>o.isPaste),a=e.filter(o=>o.isCut),t=this.clientWidth||640,s=this.clientHeight||200;try{let o=[E.lineY(e,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];r.length>0&&o.push(E.text(r,{x:"time",y:"chars",text:c=>`+${c.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),a.length>0&&o.push(E.text(a,{x:"time",y:"chars",text:c=>`\u2212${c.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),o.push(E.tip(e,E.pointerX({x:"time",y:"chars",title:c=>{let l=`${c.time.toFixed(1)}s \u2014 ${c.chars} chars`;return c.isPaste?`${l}
38
+ [aria-label="tip"] { color: #fafafa; }`,S={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.s=!0;this.a=!1;this.o=!1;this.shadow=this.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=this.getStylesheet(),this.shadow.appendChild(r),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return St}connectedCallback(){typeof ResizeObserver<"u"&&(this.s=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.s){this.s=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.i(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.i()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(r,a,t){if(r==="data"&&t)try{let s=JSON.parse(t);this.setData(s)}catch(s){console.warn("[WriteTrack] BaseChart: invalid JSON in data attribute:",s)}r==="theme"&&this._data&&this.a&&this.render()}setData(r){this._data=r,this.render()}getData(){return this._data}get hasRendered(){return this.a}replaceChart(...r){for(let a of r)if(a instanceof SVGElement){a.setAttribute("role","img");let t=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";a.setAttribute("aria-label",t)}this.container.replaceChildren(...r),this.a=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(r="No data"){let a=document.createElement("div");a.className="wt-empty",a.textContent=r,a.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(a),this.a=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.a=!1}onResize(){this.render()}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}i(){if(this.hasAttribute("theme")&&!this.o)return;let r=this.parentElement;for(;r;){let a=r.getAttribute("data-theme");if(a){this.shadow.host.setAttribute("theme",a),this.o=!0;return}r=r.parentElement}this.o&&(this.shadow.host.removeAttribute("theme"),this.o=!1)}};g.tagName="wt-base-chart";var D=P(require("@observablehq/plot"),1);var jt=5;function ft(n){var s;let e=(((s=n.session)==null?void 0:s.events)??[]).filter(o=>o.type==="keydown"&&o.flightTime!=null&&o.flightTime>0);if(e.length<2)return[[],[]];let r=n.session.sessionStartTime,a=[],t=[];for(let o=0;o<e.length;o++){let i=Math.max(0,o-jt+1),c=0,l=0;for(let u=i;u<=o;u++)c+=e[u].flightTime,l++;let d=c/l,m=Math.round(6e4/d);a.push(Math.round((e[o].timestamp-r)/1e3*100)/100),t.push(m)}return[a,t]}var N=class N extends g{connectedCallback(){super.connectedCallback();let e=getComputedStyle(this);!this.style.display&&e.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(e.width==="auto"||e.width==="0px")&&(this.style.width="200px"),!this.style.height&&(e.height==="auto"||e.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[e,r]=ft(this._data);if(e.length===0){this.showEmptyState("No data");return}let a=e.map((i,c)=>({time:i,speed:r[c]})),t=this.getBoundingClientRect(),s=Math.max(t.width||200,50),o=Math.max(t.height||40,20);try{let i=D.plot({width:s,height:o,axis:null,x:{axis:null},y:{axis:null},marks:[D.areaY(a,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),D.lineY(a,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(i)}catch(i){console.warn("[WriteTrack] Sparkline render failed:",i)}}static create(e,r){N.register();let a=document.createElement(N.tagName);return e.appendChild(a),a.setData(r),a}};N.tagName="wt-sparkline";var it=N;var C=P(require("@observablehq/plot"),1);function z(n){var t,s,o;let e=(s=(t=n.temporalPatterns)==null?void 0:t.metrics)==null?void 0:s.speedTimeline;if(!((o=e==null?void 0:e.timestamps)!=null&&o.length))return[];let r=Math.min(e.timestamps.length,e.values.length),a=[];for(let i=0;i<r;i++)a.push({time:e.timestamps[i]/1e3,speed:e.values[i]});return a}var I=class extends g{render(){if(!this._data)return;let e=z(this._data);if(e.length===0){this.showEmptyState("No speed data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=C.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(e,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"natural"}),C.lineY(e,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"natural"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(e,C.pointerX({x:"time",y:"speed",title:s=>`${s.time.toFixed(1)}s \u2014 ${Math.round(s.speed)} CPM`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] SpeedTimeline render failed:",t)}}};I.tagName="wt-speed-timeline";var A=P(require("@observablehq/plot"),1);var lt={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function G(n){let e=n.sessionTimeline;return e!=null&&e.length?e.map(r=>({start:r.startTime/1e3,end:r.endTime/1e3,type:r.type,color:lt[r.type]??"#666"})):[]}function gt(n){var r,a;return(((a=(r=n.contentOrigin)==null?void 0:r.metrics)==null?void 0:a.pasteEvents)??[]).map(t=>({time:t.timestamp/1e3,chars:t.characterCount,source:t.source}))}var F=class extends g{render(){if(!this._data)return;let e=G(this._data);if(e.length===0){this.showEmptyState("No session data");return}let r=gt(this._data),a=[A.barX(e,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),A.tip(e,A.pointer({x:o=>(o.start+o.end)/2,y:()=>"Activity",title:o=>`${o.type} \u2014 ${(o.end-o.start).toFixed(1)}s`,...S}))];r.length&&a.push(A.dot(r,{x:"time",y:()=>"Activity",r:"chars",fill:lt.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let t=this.clientWidth||640,s=this.clientHeight||80;try{let o=A.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:a,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(o)}catch(o){console.warn("[WriteTrack] CompositionTimeline render failed:",o)}}};F.tagName="wt-composition-timeline";var ct=P(require("@observablehq/plot"),1);var Yt=10;function V(n){var o,i,c,l,d;let e=(i=(o=n.timingAuthenticity)==null?void 0:o.metrics)==null?void 0:i.timingOverTime;if(!((c=e==null?void 0:e.timestamps)!=null&&c.length))return[];let r=((l=e.series)==null?void 0:l.meanDwell)??[],a=((d=e.series)==null?void 0:d.meanFlight)??[];if(!r.length||!a.length)return[];let t=[],s=Math.min(e.timestamps.length,r.length,a.length);for(let m=0;m<s;m++)r[m]!=null&&a[m]!=null&&t.push({dwell:r[m],flight:a[m]});return t}var H=class extends g{render(){if(!this._data)return;let e=V(this._data);if(e.length<Yt){this.showEmptyState("Insufficient timing data");return}let r=this.clientWidth||400,a=Math.min(r,this.clientHeight||400);try{let t=ct.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[ct.dot(e,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] RhythmHeatmap render failed:",t)}}};H.tagName="wt-rhythm-heatmap";var O=P(require("@observablehq/plot"),1);function yt(n){var r,a,t;let e=(a=(r=n.temporalPatterns)==null?void 0:r.metrics)==null?void 0:a.pauseDistribution;return(t=e==null?void 0:e.histogram)!=null&&t.length?e.histogram.map(s=>({start:s.binStart,end:s.binEnd,count:s.count})):[]}var j=class extends g{render(){if(!this._data)return;let e=yt(this._data);if(e.length===0){this.showEmptyState("No pause data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=O.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[O.rectY(e,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),O.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] PauseDistribution render failed:",t)}}};j.tagName="wt-pause-distribution";var E=P(require("@observablehq/plot"),1);var dt=/^.$/u;function v(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function q(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return[];let r=e.filter(l=>l.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let l of r)l.key==="Backspace"||l.key==="Delete"?t.push({timestamp:l.timestamp,type:"key",delta:-1}):dt.test(l.key)&&t.push({timestamp:l.timestamp,type:"key",delta:1});for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?t.push({timestamp:l.timestamp,type:"paste",delta:l.length,pasteLength:l.length}):l.type==="cut"&&t.push({timestamp:l.timestamp,type:"cut",delta:-l.length,cutLength:l.length});t.sort((l,d)=>l.timestamp-d.timestamp);let s=[],o=0;for(let l of t){let d=(l.timestamp-a)/1e3;l.type==="paste"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o+=l.delta,s.push({time:d+.001,chars:o,isPaste:!0,isCut:!1,pasteLength:l.pasteLength})):l.type==="cut"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o=Math.max(0,o+l.delta),s.push({time:d+.001,chars:o,isPaste:!1,isCut:!0,cutLength:l.cutLength})):(o=Math.max(0,o+l.delta),s.push({time:d,chars:o,isPaste:!1,isCut:!1}))}return s}var Y=class extends g{render(){if(!this._data)return;let e=q(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=e.filter(o=>o.isPaste),a=e.filter(o=>o.isCut),t=this.clientWidth||640,s=this.clientHeight||200;try{let o=[E.lineY(e,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];r.length>0&&o.push(E.text(r,{x:"time",y:"chars",text:c=>`+${c.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),a.length>0&&o.push(E.text(a,{x:"time",y:"chars",text:c=>`\u2212${c.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),o.push(E.tip(e,E.pointerX({x:"time",y:"chars",title:c=>{let l=`${c.time.toFixed(1)}s \u2014 ${c.chars} chars`;return c.isPaste?`${l}
39
39
  +${c.pasteLength} pasted`:c.isCut?`${l}
40
- \u2212${c.cutLength} cut`:l},...S})));let i=E.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Characters",grid:!0},marks:o,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(i)}catch(o){console.warn("[WriteTrack] DocumentGrowth render failed:",o)}}};Y.tagName="wt-document-growth";var R=P(require("@observablehq/plot"),1);function bt(n){var s;let e=(s=n.session)==null?void 0:s.events;if(!(e!=null&&e.length))return[];let r=e.filter(o=>o.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let o=0;o<r.length;o++){let i=r[o],c=(i.timestamp-a)/1e3,l=o<r.length-1?(r[o+1].timestamp-a)/1e3:c+(i.dwellTime??50)/1e3,d=i.flightTime??0;t.push({start:c,end:l,flight:d})}return t}var K=class extends g{render(){if(!this._data)return;let e=bt(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=this.clientWidth||640,a=this.clientHeight||80;try{let t=R.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null},color:{type:"sequential",scheme:"YlOrRd",domain:[0,Math.max(1,e.reduce((s,o)=>o.flight>s?o.flight:s,0))],label:"Flight time (ms)"},marks:[R.rect(e,{x1:"start",x2:"end",y1:()=>0,y2:()=>1,fill:"flight",inset:.5}),R.tip(e,R.pointer({x:s=>(s.start+s.end)/2,y:()=>.5,title:s=>`${s.start.toFixed(1)}s \u2014 ${Math.round(s.flight)}ms flight time`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] DocumentRibbon render failed:",t)}}};K.tagName="wt-document-ribbon";var T=P(require("@observablehq/plot"),1);var qt=null;function Ct(){return qt}function Tt(n,e,r,a){let t=n.length;if(t<=e||e<3)return n;let s=Ct();if(!s)return n;let o=new Float64Array(t),i=new Float64Array(t);for(let d=0;d<t;d++)o[d]=r(n[d]),i[d]=a(n[d]);let c=s.lttb_downsample(o,i,e);if(c.length===0)return n;let l=new Array(c.length);for(let d=0;d<c.length;d++)l[d]=n[c[d]];return l}var Et=2e3;function Q(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return{keystrokes:[],pastes:[],cuts:[]};let r=e.filter(l=>l.type==="keydown"&&l.cursorPosition!=null);if(r.length===0)return{keystrokes:[],pastes:[],cuts:[]};let a=r[0].timestamp,t=r.map(l=>({time:(l.timestamp-a)/1e3,position:l.cursorPosition})),s=[],o=[];for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?s.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position}):l.type==="cut"&&o.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position});return{keystrokes:t,pastes:s,cuts:o}}var U=class extends g{render(){if(!this._data)return;let e=Q(this._data);if(e.keystrokes.length===0){this.showEmptyState("No cursor position data");return}let r=Tt(e.keystrokes,Et,i=>i.time,i=>i.position),{pastes:a,cuts:t}=e,s=this.clientWidth||640,o=this.clientHeight||200;try{let i=[T.line(r,{x:"time",y:"position",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1,strokeOpacity:.5}),T.dot(r,{x:"time",y:"position",fill:"var(--wt-color-primary, #fbbf24)",r:2})];a.length>0&&i.push(T.dot(a,{x:"time",y:"position",fill:"var(--wt-color-secondary, #22d3ee)",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),t.length>0&&i.push(T.dot(t,{x:"time",y:"position",fill:"#f97316",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),i.push(T.tip(r,T.pointerX({x:"time",y:"position",title:l=>`${l.time.toFixed(1)}s \u2014 position ${l.position}`,...S})));let c=T.plot({width:s,height:o,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Position",reverse:!0,grid:!0},marks:i,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(c)}catch(i){console.warn("[WriteTrack] EditWaterfall render failed:",i)}}};U.tagName="wt-edit-waterfall";var M=P(require("@observablehq/plot"),1);var Pt={insert:"#22c55e",delete:"#ef4444",paste:"var(--wt-color-secondary, #22d3ee)",cut:"#f97316"},At={insert:.6,delete:-.6,paste:0,cut:0};function J(n){var l,d;let e=(l=n.session)==null?void 0:l.events;if(!(e!=null&&e.length))return[];let r=e.filter(m=>m.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[],s=null,o=0,i=0;function c(){s&&o>0&&t.push({time:i,chars:o,type:s,size:Math.max(4,Math.sqrt(o)*3)}),s=null,o=0}for(let m of r){let u=(m.timestamp-a)/1e3,p=null;m.key==="Backspace"||m.key==="Delete"?p="delete":dt.test(m.key)&&(p="insert"),p!==null&&(p!==s&&(c(),s=p,i=u),o++)}c();for(let m of((d=n.session)==null?void 0:d.clipboardEvents)??[])if(m.type==="paste"||m.type==="cut"){let u=Math.max(0,(m.timestamp-a)/1e3),p=m.length;t.push({time:u,chars:p,type:m.type,size:Math.max(4,Math.sqrt(p)*3)})}return t.sort((m,u)=>m.time-u.time),t}var X=class extends g{render(){if(!this._data)return;let e=J(this._data);if(e.length===0){this.showEmptyState("No edit data");return}let r=this.clientWidth||640,a=this.clientHeight||140;try{let t=M.plot({width:r,height:a,marginLeft:50,marginBottom:35,marginTop:10,x:{label:"Time (s)"},y:{axis:null,domain:[-1.5,1.5]},marks:[M.dot(e,{x:"time",y:o=>At[o.type],r:"size",fill:o=>Pt[o.type],fillOpacity:.65,stroke:o=>Pt[o.type],strokeWidth:1}),M.tip(e,M.pointer({x:"time",y:o=>At[o.type],title:o=>`${o.time.toFixed(1)}s \u2014 ${o.type}, ${o.chars} chars`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t);let s=document.createElement("div");s.className="wt-legend",s.style.cssText="display:flex;gap:12px;padding:6px 0 0;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:10px;color:var(--wt-color-text-muted,#a1a1aa);";for(let[o,i]of[["Insert","#22c55e"],["Delete","#ef4444"],["Paste","#22d3ee"],["Cut","#f97316"]]){let c=document.createElement("span");c.style.cssText="display:flex;align-items:center;gap:4px;";let l=document.createElement("span");l.style.cssText=`width:8px;height:8px;border-radius:50%;background:${i};`,c.appendChild(l),c.appendChild(document.createTextNode(o)),s.appendChild(c)}this.container.appendChild(s)}catch(t){console.warn("[WriteTrack] CorrectionsBubble render failed:",t)}}};X.tagName="wt-corrections-bubble";var Z=`:host {
40
+ \u2212${c.cutLength} cut`:l},...S})));let i=E.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Characters",grid:!0},marks:o,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(i)}catch(o){console.warn("[WriteTrack] DocumentGrowth render failed:",o)}}};Y.tagName="wt-document-growth";var R=P(require("@observablehq/plot"),1);function bt(n){var s;let e=(s=n.session)==null?void 0:s.events;if(!(e!=null&&e.length))return[];let r=e.filter(o=>o.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let o=0;o<r.length;o++){let i=r[o],c=(i.timestamp-a)/1e3,l=o<r.length-1?(r[o+1].timestamp-a)/1e3:c+(i.dwellTime??50)/1e3,d=i.flightTime??0;t.push({start:c,end:l,flight:d})}return t}var K=class extends g{render(){if(!this._data)return;let e=bt(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=this.clientWidth||640,a=this.clientHeight||80;try{let t=R.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null},color:{type:"sequential",scheme:"YlOrRd",domain:[0,Math.max(1,e.reduce((s,o)=>o.flight>s?o.flight:s,0))],label:"Flight time (ms)"},marks:[R.rect(e,{x1:"start",x2:"end",y1:()=>0,y2:()=>1,fill:"flight",inset:.5}),R.tip(e,R.pointer({x:s=>(s.start+s.end)/2,y:()=>.5,title:s=>`${s.start.toFixed(1)}s \u2014 ${Math.round(s.flight)}ms flight time`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] DocumentRibbon render failed:",t)}}};K.tagName="wt-document-ribbon";var T=P(require("@observablehq/plot"),1);var qt=null;function Ct(){return qt}function Tt(n,e,r,a){let t=n.length;if(t<=e||e<3)return n;let s=Ct();if(!s)return n;let o=new Float64Array(t),i=new Float64Array(t);for(let d=0;d<t;d++)o[d]=r(n[d]),i[d]=a(n[d]);let c=s.lttb_downsample(o,i,e);if(c.length===0)return n;let l=new Array(c.length);for(let d=0;d<c.length;d++)l[d]=n[c[d]];return l}var Et=2e3;function Q(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return{keystrokes:[],pastes:[],cuts:[]};let r=e.filter(l=>l.type==="keydown"&&l.cursorPosition!=null);if(r.length===0)return{keystrokes:[],pastes:[],cuts:[]};let a=r[0].timestamp,t=r.map(l=>({time:(l.timestamp-a)/1e3,position:l.cursorPosition})),s=[],o=[];for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?s.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position}):l.type==="cut"&&o.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position});return{keystrokes:t,pastes:s,cuts:o}}var U=class extends g{render(){if(!this._data)return;let e=Q(this._data);if(e.keystrokes.length===0){this.showEmptyState("No cursor position data");return}let r=Tt(e.keystrokes,Et,i=>i.time,i=>i.position),{pastes:a,cuts:t}=e,s=this.clientWidth||640,o=this.clientHeight||200;try{let i=[T.line(r,{x:"time",y:"position",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1,strokeOpacity:.5}),T.dot(r,{x:"time",y:"position",fill:"var(--wt-color-primary, #fbbf24)",r:2})];a.length>0&&i.push(T.dot(a,{x:"time",y:"position",fill:"var(--wt-color-secondary, #22d3ee)",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),t.length>0&&i.push(T.dot(t,{x:"time",y:"position",fill:"#f97316",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),i.push(T.tip(r,T.pointerX({x:"time",y:"position",title:l=>`${l.time.toFixed(1)}s \u2014 position ${l.position}`,...S})));let c=T.plot({width:s,height:o,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Position",reverse:!0,grid:!0},marks:i,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(c)}catch(i){console.warn("[WriteTrack] EditWaterfall render failed:",i)}}};U.tagName="wt-edit-waterfall";var W=P(require("@observablehq/plot"),1);var Pt={insert:"#22c55e",delete:"#ef4444",paste:"var(--wt-color-secondary, #22d3ee)",cut:"#f97316"},At={insert:.6,delete:-.6,paste:0,cut:0};function J(n){var l,d;let e=(l=n.session)==null?void 0:l.events;if(!(e!=null&&e.length))return[];let r=e.filter(m=>m.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[],s=null,o=0,i=0;function c(){s&&o>0&&t.push({time:i,chars:o,type:s,size:Math.max(4,Math.sqrt(o)*3)}),s=null,o=0}for(let m of r){let u=(m.timestamp-a)/1e3,p=null;m.key==="Backspace"||m.key==="Delete"?p="delete":dt.test(m.key)&&(p="insert"),p!==null&&(p!==s&&(c(),s=p,i=u),o++)}c();for(let m of((d=n.session)==null?void 0:d.clipboardEvents)??[])if(m.type==="paste"||m.type==="cut"){let u=Math.max(0,(m.timestamp-a)/1e3),p=m.length;t.push({time:u,chars:p,type:m.type,size:Math.max(4,Math.sqrt(p)*3)})}return t.sort((m,u)=>m.time-u.time),t}var X=class extends g{render(){if(!this._data)return;let e=J(this._data);if(e.length===0){this.showEmptyState("No edit data");return}let r=this.clientWidth||640,a=this.clientHeight||140;try{let t=W.plot({width:r,height:a,marginLeft:50,marginBottom:35,marginTop:10,x:{label:"Time (s)"},y:{axis:null,domain:[-1.5,1.5]},marks:[W.dot(e,{x:"time",y:o=>At[o.type],r:"size",fill:o=>Pt[o.type],fillOpacity:.65,stroke:o=>Pt[o.type],strokeWidth:1}),W.tip(e,W.pointer({x:"time",y:o=>At[o.type],title:o=>`${o.time.toFixed(1)}s \u2014 ${o.type}, ${o.chars} chars`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t);let s=document.createElement("div");s.className="wt-legend",s.style.cssText="display:flex;gap:12px;padding:6px 0 0;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:10px;color:var(--wt-color-text-muted,#a1a1aa);";for(let[o,i]of[["Insert","#22c55e"],["Delete","#ef4444"],["Paste","#22d3ee"],["Cut","#f97316"]]){let c=document.createElement("span");c.style.cssText="display:flex;align-items:center;gap:4px;";let l=document.createElement("span");l.style.cssText=`width:8px;height:8px;border-radius:50%;background:${i};`,c.appendChild(l),c.appendChild(document.createTextNode(o)),s.appendChild(c)}this.container.appendChild(s)}catch(t){console.warn("[WriteTrack] CorrectionsBubble render failed:",t)}}};X.tagName="wt-corrections-bubble";var Z=`:host {
41
41
  /* \u2500\u2500 Surface colors (light default) \u2500\u2500 */
42
42
  --wt-scorecard-bg: #F7F6F2;
43
43
  --wt-scorecard-bg-card: #FFFFFF;
@@ -102,7 +102,7 @@
102
102
  .wt-term:hover {
103
103
  text-decoration-color: var(--wt-scorecard-text-secondary);
104
104
  }
105
- `,or=(()=>{try{let n=new CSSStyleSheet;return n.replaceSync(Z),n}catch{return null}})();var Kt={"--wt-color-bg":"var(--wt-scorecard-bg-card)","--wt-color-surface":"var(--wt-scorecard-bg-detail)","--wt-color-text":"var(--wt-scorecard-text)","--wt-color-text-muted":"var(--wt-scorecard-text-tertiary)","--wt-color-border":"var(--wt-scorecard-border)","--wt-color-primary":"var(--wt-scorecard-chart-accent)","--wt-color-secondary":"var(--wt-scorecard-chart-flagged)","--wt-font-data":"var(--wt-scorecard-font-data)","--wt-font-ui":"var(--wt-scorecard-font-body)"};function Rt(n){for(let[e,r]of Object.entries(Kt))n.style.setProperty(e,r)}var tt=new Uint8Array(256),wt=new Uint8Array(256);(function(){let n=1;for(let e=0;e<255;e++)tt[e]=n,wt[n]=e,n=n<<1^(n>=128?285:0);tt[255]=tt[0]})();function $t(n,e){return n===0||e===0?0:tt[(wt[n]+wt[e])%255]}function Ut(n){let e=[1];for(let r=0;r<n;r++){let a=new Array(e.length+1).fill(0);for(let t=0;t<e.length;t++)a[t]^=e[t],a[t+1]^=$t(e[t],tt[r]);e=a}return e}function Qt(n,e){let r=Ut(e),a=new Uint8Array(n.length+e);a.set(n);for(let t=0;t<n.length;t++){let s=a[t];if(s!==0)for(let o=0;o<r.length;o++)a[t+o]^=$t(r[o],s)}return a.slice(n.length)}var Xt=[{ver:1,size:21,dc:16,ec:10,blocks:1,cap:14},{ver:2,size:25,dc:28,ec:16,blocks:1,cap:26},{ver:3,size:29,dc:44,ec:26,blocks:1,cap:42},{ver:4,size:33,dc:64,ec:18,blocks:2,cap:62},{ver:5,size:37,dc:86,ec:24,blocks:2,cap:84},{ver:6,size:41,dc:108,ec:16,blocks:4,cap:106}],Jt=[[],[6,18],[6,22],[6,26],[6,30],[6,34]];function Zt(n){for(let e of Xt)if(n<=e.cap)return e;return null}function te(n,e){let r=[];function a(h,w){for(let b=w-1;b>=0;b--)r.push(h>>b&1)}a(4,4),a(n.length,8);for(let h of n)a(h,8);let t=e.dc*8;for(a(0,Math.min(4,t-r.length));r.length%8!==0;)r.push(0);let s=[236,17],o=0;for(;r.length<t;)a(s[o%2],8),o++;let i=[];for(let h=0;h<r.length;h+=8){let w=0;for(let b=0;b<8;b++)w=w<<1|r[h+b];i.push(w)}let c=Math.floor(e.dc/e.blocks),l=e.dc-c*e.blocks,d=[],m=[],u=0;for(let h=0;h<e.blocks;h++){let w=c+(h>=e.blocks-l?1:0),b=new Uint8Array(i.slice(u,u+w));d.push(b),m.push(Qt(b,e.ec)),u+=w}let p=[],y=0;for(let h of d)y=Math.max(y,h.length);for(let h=0;h<y;h++)for(let w of d)h<w.length&&p.push(w[h]);for(let h=0;h<e.ec;h++)for(let w of m)p.push(w[h]);return p}function ee(n){let e=n.size,r=[],a=[];for(let i=0;i<e;i++)r.push(new Int8Array(e)),a.push(new Uint8Array(e));function t(i,c,l){r[c][i]=l?1:-1,a[c][i]=1}function s(i,c){for(let d=-3;d<=3;d++)for(let m=-3;m<=3;m++){let u=i+m,p=c+d;u<0||u>=e||p<0||p>=e||t(u,p,Math.max(Math.abs(m),Math.abs(d))!==2)}let l=[[-4,0],[4,0],[0,-4],[0,4]];for(let d=-4;d<=4;d++)for(let m of l){let u=i+(m[0]!==0?m[0]:d),p=c+(m[1]!==0?m[1]:d);u>=0&&u<e&&p>=0&&p<e&&t(u,p,!1)}}s(3,3),s(e-4,3),s(3,e-4);for(let i=8;i<e-8;i++)t(i,6,i%2===0),t(6,i,i%2===0);let o=Jt[n.ver-1];if(o.length>0)for(let i=0;i<o.length;i++)for(let c=0;c<o.length;c++){let l=o[i],d=o[c];if(!a[l][d])for(let m=-2;m<=2;m++)for(let u=-2;u<=2;u++)t(d+u,l+m,Math.max(Math.abs(u),Math.abs(m))!==1)}t(8,4*n.ver+9,!0);for(let i=0;i<8;i++)a[8][i]||(a[8][i]=1),a[8][e-1-i]||(a[8][e-1-i]=1),a[i][8]||(a[i][8]=1),a[e-1-i][8]||(a[e-1-i][8]=1);return a[8][8]=1,{grid:r,reserved:a,n:e}}function re(n,e){let{grid:r,reserved:a,n:t}=n,s=[];for(let l of e)for(let d=7;d>=0;d--)s.push(l>>d&1);let o=0,i=t-1,c=!0;for(;i>=0;){if(i===6){i--;continue}let l=c?t-1:0,d=c?-1:t,m=c?-1:1;for(let u=l;u!==d;u+=m)for(let p=0;p<2;p++){let y=i-p;y<0||a[u][y]||(r[u][y]=o<s.length&&s[o]?1:-1,o++)}i-=2,c=!c}}var ae=[(n,e)=>(n+e)%2===0,(n,e)=>e%2===0,(n,e)=>n%3===0,(n,e)=>(n+e)%3===0,(n,e)=>(Math.floor(e/2)+Math.floor(n/3))%2===0,(n,e)=>n*e%2+n*e%3===0,(n,e)=>(n*e%2+n*e%3)%2===0,(n,e)=>((n+e)%2+n*e%3)%2===0];function Mt(n,e,r,a){let t=ae[a],s=n.map(o=>Int8Array.from(o));for(let o=0;o<r;o++)for(let i=0;i<r;i++)!e[o][i]&&t(i,o)&&(s[o][i]=s[o][i]===1?-1:1);return s}var ne=[21522,20773,24188,23371,17913,16590,20375,19104];function Wt(n,e,r){let a=ne[r],t=[];for(let i=14;i>=0;i--)t.push(a>>i&1);let s=[[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[7,8],[8,8],[8,7],[8,5],[8,4],[8,3],[8,2],[8,1],[8,0]],o=[[8,e-1],[8,e-2],[8,e-3],[8,e-4],[8,e-5],[8,e-6],[8,e-7],[e-8,8],[e-7,8],[e-6,8],[e-5,8],[e-4,8],[e-3,8],[e-2,8],[e-1,8]];for(let i=0;i<15;i++){let c=t[i]?1:-1;n[s[i][1]][s[i][0]]=c,n[o[i][1]][o[i][0]]=c}}function oe(n,e){let r=0;for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[a][s]>0==n[a][s-1]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[s][a]>0==n[s-1][a]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}return r}function se(n){let e=[];for(let c=0;c<n.length;c++){let l=n.charCodeAt(c);l<128?e.push(l):l<2048&&(e.push(192|l>>6),e.push(128|l&63))}let r=Zt(e.length);if(!r)return null;let a=te(e,r),t=ee(r);re(t,a);let s=0,o=1/0;for(let c=0;c<8;c++){let l=Mt(t.grid,t.reserved,t.n,c);Wt(l,t.n,c);let d=oe(l,t.n);d<o&&(o=d,s=c)}let i=Mt(t.grid,t.reserved,t.n,s);return Wt(i,t.n,s),{grid:i,size:t.n}}function ie(n,e,r){let a=n.size,t=Math.max(2,Math.floor(88/a)),s=a*t,o=t/2,i=o*.82,c=a/2,l=a*.18;function d(x,k){let B=Math.sin(x*31+k*17)*1e4;return .75+.25*(B-Math.floor(B))}let m="";for(let x=0;x<a;x++)for(let k=0;k<a;k++){if(n.grid[x][k]<=0)continue;let B=k-c,xt=x-c;if(Math.sqrt(B*B+xt*xt)<l)continue;if(k<7&&x<7||k>=a-7&&x<7||k<7&&x>=a-7)m+=`<rect x="${k*t}" y="${x*t}" width="${t}" height="${t}" rx="${t*.15}" fill="${e}"/>`;else{let Bt=i*d(k,x);m+=`<circle cx="${k*t+o}" cy="${x*t+o}" r="${Bt.toFixed(1)}" fill="${e}"/>`}}let u=c*t,p=c*t,y=l*t*.6,h=r||e,w=y*2/100,b=70*w,$=`<g transform="translate(${u-y},${p-b/2}) scale(${w.toFixed(4)})">`;return $+=`<path d="M86 2 L86 64" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,$+=`<path d="M7 12 L98 12" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,$+=`<path d="M7 18 C7 32, 16 64, 30 64 C44 64, 38 28, 52 28 C66 28, 62 64, 86 64" stroke="${e}" stroke-width="5" stroke-linecap="round" fill="none"/>`,$+=`<circle cx="7" cy="12" r="7" fill="${e}"/>`,$+=`<circle cx="86" cy="64" r="7" fill="${h}"/>`,$+="</g>",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${s}" width="${s}" height="${s}">${m}${$}</svg>`}var le=`.integrity-section {
105
+ `,sr=(()=>{try{let n=new CSSStyleSheet;return n.replaceSync(Z),n}catch{return null}})();var Kt={"--wt-color-bg":"var(--wt-scorecard-bg-card)","--wt-color-surface":"var(--wt-scorecard-bg-detail)","--wt-color-text":"var(--wt-scorecard-text)","--wt-color-text-muted":"var(--wt-scorecard-text-tertiary)","--wt-color-border":"var(--wt-scorecard-border)","--wt-color-primary":"var(--wt-scorecard-chart-accent)","--wt-color-secondary":"var(--wt-scorecard-chart-flagged)","--wt-font-data":"var(--wt-scorecard-font-data)","--wt-font-ui":"var(--wt-scorecard-font-body)"};function Rt(n){for(let[e,r]of Object.entries(Kt))n.style.setProperty(e,r)}var tt=new Uint8Array(256),wt=new Uint8Array(256);(function(){let n=1;for(let e=0;e<255;e++)tt[e]=n,wt[n]=e,n=n<<1^(n>=128?285:0);tt[255]=tt[0]})();function $t(n,e){return n===0||e===0?0:tt[(wt[n]+wt[e])%255]}function Ut(n){let e=[1];for(let r=0;r<n;r++){let a=new Array(e.length+1).fill(0);for(let t=0;t<e.length;t++)a[t]^=e[t],a[t+1]^=$t(e[t],tt[r]);e=a}return e}function Qt(n,e){let r=Ut(e),a=new Uint8Array(n.length+e);a.set(n);for(let t=0;t<n.length;t++){let s=a[t];if(s!==0)for(let o=0;o<r.length;o++)a[t+o]^=$t(r[o],s)}return a.slice(n.length)}var Xt=[{ver:1,size:21,dc:16,ec:10,blocks:1,cap:14},{ver:2,size:25,dc:28,ec:16,blocks:1,cap:26},{ver:3,size:29,dc:44,ec:26,blocks:1,cap:42},{ver:4,size:33,dc:64,ec:18,blocks:2,cap:62},{ver:5,size:37,dc:86,ec:24,blocks:2,cap:84},{ver:6,size:41,dc:108,ec:16,blocks:4,cap:106}],Jt=[[],[6,18],[6,22],[6,26],[6,30],[6,34]];function Zt(n){for(let e of Xt)if(n<=e.cap)return e;return null}function te(n,e){let r=[];function a(h,w){for(let b=w-1;b>=0;b--)r.push(h>>b&1)}a(4,4),a(n.length,8);for(let h of n)a(h,8);let t=e.dc*8;for(a(0,Math.min(4,t-r.length));r.length%8!==0;)r.push(0);let s=[236,17],o=0;for(;r.length<t;)a(s[o%2],8),o++;let i=[];for(let h=0;h<r.length;h+=8){let w=0;for(let b=0;b<8;b++)w=w<<1|r[h+b];i.push(w)}let c=Math.floor(e.dc/e.blocks),l=e.dc-c*e.blocks,d=[],m=[],u=0;for(let h=0;h<e.blocks;h++){let w=c+(h>=e.blocks-l?1:0),b=new Uint8Array(i.slice(u,u+w));d.push(b),m.push(Qt(b,e.ec)),u+=w}let p=[],y=0;for(let h of d)y=Math.max(y,h.length);for(let h=0;h<y;h++)for(let w of d)h<w.length&&p.push(w[h]);for(let h=0;h<e.ec;h++)for(let w of m)p.push(w[h]);return p}function ee(n){let e=n.size,r=[],a=[];for(let i=0;i<e;i++)r.push(new Int8Array(e)),a.push(new Uint8Array(e));function t(i,c,l){r[c][i]=l?1:-1,a[c][i]=1}function s(i,c){for(let d=-3;d<=3;d++)for(let m=-3;m<=3;m++){let u=i+m,p=c+d;u<0||u>=e||p<0||p>=e||t(u,p,Math.max(Math.abs(m),Math.abs(d))!==2)}let l=[[-4,0],[4,0],[0,-4],[0,4]];for(let d=-4;d<=4;d++)for(let m of l){let u=i+(m[0]!==0?m[0]:d),p=c+(m[1]!==0?m[1]:d);u>=0&&u<e&&p>=0&&p<e&&t(u,p,!1)}}s(3,3),s(e-4,3),s(3,e-4);for(let i=8;i<e-8;i++)t(i,6,i%2===0),t(6,i,i%2===0);let o=Jt[n.ver-1];if(o.length>0)for(let i=0;i<o.length;i++)for(let c=0;c<o.length;c++){let l=o[i],d=o[c];if(!a[l][d])for(let m=-2;m<=2;m++)for(let u=-2;u<=2;u++)t(d+u,l+m,Math.max(Math.abs(u),Math.abs(m))!==1)}t(8,4*n.ver+9,!0);for(let i=0;i<8;i++)a[8][i]||(a[8][i]=1),a[8][e-1-i]||(a[8][e-1-i]=1),a[i][8]||(a[i][8]=1),a[e-1-i][8]||(a[e-1-i][8]=1);return a[8][8]=1,{grid:r,reserved:a,n:e}}function re(n,e){let{grid:r,reserved:a,n:t}=n,s=[];for(let l of e)for(let d=7;d>=0;d--)s.push(l>>d&1);let o=0,i=t-1,c=!0;for(;i>=0;){if(i===6){i--;continue}let l=c?t-1:0,d=c?-1:t,m=c?-1:1;for(let u=l;u!==d;u+=m)for(let p=0;p<2;p++){let y=i-p;y<0||a[u][y]||(r[u][y]=o<s.length&&s[o]?1:-1,o++)}i-=2,c=!c}}var ae=[(n,e)=>(n+e)%2===0,(n,e)=>e%2===0,(n,e)=>n%3===0,(n,e)=>(n+e)%3===0,(n,e)=>(Math.floor(e/2)+Math.floor(n/3))%2===0,(n,e)=>n*e%2+n*e%3===0,(n,e)=>(n*e%2+n*e%3)%2===0,(n,e)=>((n+e)%2+n*e%3)%2===0];function Wt(n,e,r,a){let t=ae[a],s=n.map(o=>Int8Array.from(o));for(let o=0;o<r;o++)for(let i=0;i<r;i++)!e[o][i]&&t(i,o)&&(s[o][i]=s[o][i]===1?-1:1);return s}var ne=[21522,20773,24188,23371,17913,16590,20375,19104];function Mt(n,e,r){let a=ne[r],t=[];for(let i=14;i>=0;i--)t.push(a>>i&1);let s=[[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[7,8],[8,8],[8,7],[8,5],[8,4],[8,3],[8,2],[8,1],[8,0]],o=[[8,e-1],[8,e-2],[8,e-3],[8,e-4],[8,e-5],[8,e-6],[8,e-7],[e-8,8],[e-7,8],[e-6,8],[e-5,8],[e-4,8],[e-3,8],[e-2,8],[e-1,8]];for(let i=0;i<15;i++){let c=t[i]?1:-1;n[s[i][1]][s[i][0]]=c,n[o[i][1]][o[i][0]]=c}}function oe(n,e){let r=0;for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[a][s]>0==n[a][s-1]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[s][a]>0==n[s-1][a]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}return r}function se(n){let e=[];for(let c=0;c<n.length;c++){let l=n.charCodeAt(c);l<128?e.push(l):l<2048&&(e.push(192|l>>6),e.push(128|l&63))}let r=Zt(e.length);if(!r)return null;let a=te(e,r),t=ee(r);re(t,a);let s=0,o=1/0;for(let c=0;c<8;c++){let l=Wt(t.grid,t.reserved,t.n,c);Mt(l,t.n,c);let d=oe(l,t.n);d<o&&(o=d,s=c)}let i=Wt(t.grid,t.reserved,t.n,s);return Mt(i,t.n,s),{grid:i,size:t.n}}function ie(n,e,r){let a=n.size,t=Math.max(2,Math.floor(88/a)),s=a*t,o=t/2,i=o*.82,c=a/2,l=a*.18;function d(x,k){let B=Math.sin(x*31+k*17)*1e4;return .75+.25*(B-Math.floor(B))}let m="";for(let x=0;x<a;x++)for(let k=0;k<a;k++){if(n.grid[x][k]<=0)continue;let B=k-c,xt=x-c;if(Math.sqrt(B*B+xt*xt)<l)continue;if(k<7&&x<7||k>=a-7&&x<7||k<7&&x>=a-7)m+=`<rect x="${k*t}" y="${x*t}" width="${t}" height="${t}" rx="${t*.15}" fill="${e}"/>`;else{let Bt=i*d(k,x);m+=`<circle cx="${k*t+o}" cy="${x*t+o}" r="${Bt.toFixed(1)}" fill="${e}"/>`}}let u=c*t,p=c*t,y=l*t*.6,h=r||e,w=y*2/100,b=70*w,$=`<g transform="translate(${u-y},${p-b/2}) scale(${w.toFixed(4)})">`;return $+=`<path d="M86 2 L86 64" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,$+=`<path d="M7 12 L98 12" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,$+=`<path d="M7 18 C7 32, 16 64, 30 64 C44 64, 38 28, 52 28 C66 28, 62 64, 86 64" stroke="${e}" stroke-width="5" stroke-linecap="round" fill="none"/>`,$+=`<circle cx="7" cy="12" r="7" fill="${e}"/>`,$+=`<circle cx="86" cy="64" r="7" fill="${h}"/>`,$+="</g>",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${s}" width="${s}" height="${s}">${m}${$}</svg>`}var le=`.integrity-section {
106
106
  margin-top: 2rem;
107
107
  padding-top: 1.5rem;
108
108
  border-top: 1px solid var(--wt-scorecard-border);
@@ -168,7 +168,7 @@
168
168
  flex: 1;
169
169
  }
170
170
  `,_=class extends g{getStylesheet(){return Z+`
171
- `+le}render(){if(!this._data)return;let{integrity:e,outputSignature:r}=this._data,a=document.createElement("div");a.className="integrity-section";let t=document.createElement("div");t.className="integrity-title",t.textContent="Integrity & Verification",a.appendChild(t);let s=document.createElement("div");s.className="integrity-stats",s.textContent=`${e.eventCount} events \xB7 ${e.checkpoints.length} checkpoints`,a.appendChild(s);let o=document.createElement("div");o.className="integrity-hash-block";let i=document.createElement("span");i.className="integrity-hash-label",i.textContent="Digest (SHA-256)";let c=document.createElement("code");c.className="hash",c.textContent=e.finalDigest,o.append(i,c),a.appendChild(o);let l=document.createElement("div");l.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=r,l.append(d,m),a.appendChild(l);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),a.appendChild(u),this.replaceChart(a),requestAnimationFrame(()=>this.renderQr(e.finalDigest))}renderQr(e){let r=this.shadow.querySelector(".qr-container");if(!r)return;let a=se(e);if(!a)return;let t=getComputedStyle(this),s=t.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",o=t.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";r.innerHTML=ie(a,s,o)}};_.tagName="wt-integrity-footer";var Dt=new Set(["WT-104","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function Ot(n){return Dt.has(n)}function W(n){return n?Dt.has(n)?"pass":"flag":"unknown"}var L={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},mt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],ut=["contentOrigin","timingAuthenticity","revisionBehavior"],pt=["sessionContinuity","physicalPlausibility","temporalPatterns"],ce={"WT-100":()=>"No content was recorded during this session.","WT-101":n=>{let e=n.params.pct??0,r=100-e;return`Nearly all content (${e}%) was pasted from an external source. Only ${r}% of characters were typed directly.`},"WT-102":n=>`${n.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":n=>{let e=n.params.pct??0,r=100-e;return`${e}% of text was pasted from external sources. The remaining ${r}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected."},de={"WT-200":n=>{let e=(n.params.dwellMean??0).toFixed(1),r=(n.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${e}ms, flight ${r}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":n=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(n.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":n=>`A highly periodic keystroke pattern was detected (score ${(n.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":n=>`Flight times between keystrokes are suspiciously uniform (CV ${(n.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},me={"WT-500":(n,e)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${e.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":n=>`Very low correction rate (${(n.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":n=>`Normal correction rate (${(n.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":n=>`No corrections, navigation, or undo in a ${n.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":n=>`Authentic revision depth detected (product-process ratio ${(n.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":n=>{let e=n.params.count??0,r=n.params.keydowns??0;return`Linear transcription pattern: only ${e} insertions in a ${r}-keystroke session, with minimal revision or restructuring.`},"WT-508":n=>`Forward-edge concentration: ${Math.round((n.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":n=>`Multi-word restructuring detected (${Math.round((n.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},ue={"WT-300":n=>{let e=Math.round(n.params.timestamp??0),r=(n.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${e}s (magnitude ${r}), suggesting a possible switch in input method or author.`},"WT-301":n=>`${n.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},pe={"WT-400":n=>`${n.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":n=>{let e=n.params.count??0,r=n.params.pct??0;return`${e} keydown events had no matching keyup (${r}% of keydowns). Automation tools often omit keyup events.`},"WT-402":n=>`${n.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":n=>{let e=n.params.chars??0,r=n.params.pct??0;return`${e} characters (${r}%) were inserted programmatically, bypassing normal keystroke input. This is consistent with automated text injection.`}},he={"WT-600":n=>`No speed variation over a ${n.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":n=>`${n.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":n=>`Uniform typing pace across the session (fluency SD ${(n.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":n=>`Frequent revision interruptions detected (R-burst median ${(n.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":n=>`No linguistic pause structure detected (sentence/word pause ratio ${(n.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":n=>`Low cognitive pause rate (${(n.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},fe={contentOrigin:ce,timingAuthenticity:de,revisionBehavior:me,sessionContinuity:ue,physicalPlausibility:pe,temporalPatterns:he};function et(n,e){let r=e[n];if(!(r!=null&&r.indicator))return"Analysis data not available.";let a=fe[n];if(!a)return _t(r.indicator);let t=a[r.indicator.code];return t?t(r.indicator,e):_t(r.indicator)}function _t(n){return`Indicator ${n.code} detected.`}var ge={contentOrigin:"In a typical session, you'd see a continuous band of typed content with occasional small paste events. A single bulk insertion is characteristic of copy-paste submission.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function ht(n){return ge[n]??null}function rt(n,e){return({contentOrigin:a=>{let t=a.contentOrigin.metrics,s=Math.round(t.charactersByOrigin.pasted*100),o=Math.round(t.charactersByOrigin.typed*100),i=t.pasteEvents.length,c=t.pasteEvents.reduce((l,d)=>l+d.characterCount,0);return[{label:"pasted",value:`${s}%`,flagged:s>50},{label:"typed",value:`${o}%`,flagged:!1},{label:"paste events",value:String(i),flagged:!1},{label:"chars pasted",value:ye(c),flagged:!1}]},timingAuthenticity:a=>{let t=a.timingAuthenticity.metrics,s=t.flightTimeDistribution.cv,o=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:s.toFixed(2),flagged:s<.2},{label:"mean dwell",value:`${Math.round(o)}ms`,flagged:o<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]},revisionBehavior:a=>{let t=a.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]},sessionContinuity:a=>{let t=a.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]},physicalPlausibility:a=>{let t=a.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]},temporalPatterns:a=>{let t=a.temporalPatterns.metrics;return[{label:"duration",value:at(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}}[n]??(()=>[]))(e)}function ye(n){return n>=1e6?`${(n/1e6).toFixed(1)}m`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function at(n){let e=Math.round(n/1e3);if(e<60)return`${e}s`;let r=Math.floor(e/60),a=e%60;return a===0?`${r}m`:`${r}m ${a}s`}var vt={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function nt(n,e){let r=v(n);for(let[a,t]of Object.entries(vt)){let s=new RegExp(`\\b(${be(a)})\\b`,"gi");r=r.replace(s,o=>{let i=`title="${v(t.definition)}" class="wt-term"`,c=v(o);if(t.docsPath){let l=(e??"https://writetrack.dev")+t.docsPath;return`<a href="${v(l)}" target="_blank" rel="noopener"><abbr ${i}>${c}</abbr></a>`}return`<abbr ${i}>${c}</abbr>`})}return r}function be(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var f=P(require("@observablehq/plot"),1);var we={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},ve={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},Lt={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},xe=`:host { display: block; overflow: hidden; }
171
+ `+le}render(){if(!this._data)return;let{integrity:e,outputSignature:r}=this._data,a=document.createElement("div");a.className="integrity-section";let t=document.createElement("div");t.className="integrity-title",t.textContent="Integrity & Verification",a.appendChild(t);let s=document.createElement("div");s.className="integrity-stats",s.textContent=`${e.eventCount} events \xB7 ${e.checkpoints.length} checkpoints`,a.appendChild(s);let o=document.createElement("div");o.className="integrity-hash-block";let i=document.createElement("span");i.className="integrity-hash-label",i.textContent="Digest (SHA-256)";let c=document.createElement("code");c.className="hash",c.textContent=e.finalDigest,o.append(i,c),a.appendChild(o);let l=document.createElement("div");l.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=r,l.append(d,m),a.appendChild(l);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),a.appendChild(u),this.replaceChart(a),requestAnimationFrame(()=>this.renderQr(e.finalDigest))}renderQr(e){let r=this.shadow.querySelector(".qr-container");if(!r)return;let a=se(e);if(!a)return;let t=getComputedStyle(this),s=t.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",o=t.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";r.innerHTML=ie(a,s,o)}};_.tagName="wt-integrity-footer";var Dt=new Set(["WT-104","WT-106","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function Ot(n){return Dt.has(n)}function M(n){return n?Dt.has(n)?"pass":"flag":"unknown"}var L={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},mt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],ut=["contentOrigin","timingAuthenticity","revisionBehavior"],pt=["sessionContinuity","physicalPlausibility","temporalPatterns"],ce={"WT-100":()=>"No content was recorded during this session.","WT-101":n=>{let e=n.params.pct??0,r=100-e;return`Nearly all content (${e}%) was pasted from an external source. Only ${r}% of characters were typed directly.`},"WT-102":n=>`${n.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":n=>{let e=n.params.pct??0,r=100-e;return`${e}% of text was pasted from external sources. The remaining ${r}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected.","WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":n=>`${n.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":n=>{let e=n.params.pasteRatio??0,r=n.params.retentionPct??0;return`High paste volume (${e}% paste ratio) with ${r}% left unmodified \u2014 content was pasted in bulk without rework.`}},de={"WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":n=>`${n.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":n=>{let e=n.params.pasteRatio??0,r=n.params.retentionPct??0;return`High paste volume (${e}% paste ratio) with ${r}% left unmodified \u2014 content was pasted in bulk without rework.`}},me={"WT-200":n=>{let e=(n.params.dwellMean??0).toFixed(1),r=(n.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${e}ms, flight ${r}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":n=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(n.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":n=>`A highly periodic keystroke pattern was detected (score ${(n.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":n=>`Flight times between keystrokes are suspiciously uniform (CV ${(n.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},ue={"WT-500":(n,e)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${e.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":n=>`Very low correction rate (${(n.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":n=>`Normal correction rate (${(n.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":n=>`No corrections, navigation, or undo in a ${n.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":n=>`Authentic revision depth detected (product-process ratio ${(n.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":n=>{let e=n.params.count??0,r=n.params.keydowns??0;return`Linear transcription pattern: only ${e} insertions in a ${r}-keystroke session, with minimal revision or restructuring.`},"WT-508":n=>`Forward-edge concentration: ${Math.round((n.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":n=>`Multi-word restructuring detected (${Math.round((n.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},pe={"WT-300":n=>{let e=Math.round(n.params.timestamp??0),r=(n.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${e}s (magnitude ${r}), suggesting a possible switch in input method or author.`},"WT-301":n=>`${n.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},he={"WT-400":n=>`${n.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":n=>{let e=n.params.count??0,r=n.params.pct??0;return`${e} keydown events had no matching keyup (${r}% of keydowns). Automation tools often omit keyup events.`},"WT-402":n=>`${n.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":n=>{let e=n.params.chars??0,r=n.params.pct??0;return`${e} characters (${r}%) were inserted programmatically, bypassing normal keystroke input. This is consistent with automated text injection.`},"WT-405":n=>{let e=n.params.count??0,r=n.params.pct??0;return`${e} events (${r}% of keydowns) have sub-millisecond dwell time. Human key press/release always takes 30\u2013150ms; zero-latency events indicate programmatic injection.`}},fe={"WT-600":n=>`No speed variation over a ${n.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":n=>`${n.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":n=>`Uniform typing pace across the session (fluency SD ${(n.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":n=>`Frequent revision interruptions detected (R-burst median ${(n.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":n=>`No linguistic pause structure detected (sentence/word pause ratio ${(n.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":n=>`Low cognitive pause rate (${(n.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},ge={contentOrigin:ce,timingAuthenticity:me,revisionBehavior:ue,sessionContinuity:pe,physicalPlausibility:he,temporalPatterns:fe};function et(n,e){let r=e[n];if(!(r!=null&&r.indicator))return"Analysis data not available.";let a=ge[n];if(!a)return _t(r.indicator);if(n==="contentOrigin"&&r.pasteReworkIndicator){let s=r.pasteReworkIndicator.code,o=de[s];if(o)return o(r.pasteReworkIndicator,e)}let t=a[r.indicator.code];return t?t(r.indicator,e):_t(r.indicator)}function _t(n){return`Indicator ${n.code} detected.`}var ye={contentOrigin:"In a typical session, you'd see a continuous band of typed content with occasional small paste events. A single bulk insertion is characteristic of copy-paste submission.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function ht(n){return ye[n]??null}function rt(n,e){return({contentOrigin:a=>{let t=a.contentOrigin.metrics,s=Math.round(t.charactersByOrigin.pasted*100),o=Math.round(t.charactersByOrigin.typed*100),i=t.pasteEvents.length,c=t.pasteEvents.reduce((l,d)=>l+d.characterCount,0);return[{label:"pasted",value:`${s}%`,flagged:s>50},{label:"typed",value:`${o}%`,flagged:!1},{label:"paste events",value:String(i),flagged:!1},{label:"chars pasted",value:be(c),flagged:!1}]},timingAuthenticity:a=>{let t=a.timingAuthenticity.metrics,s=t.flightTimeDistribution.cv,o=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:s.toFixed(2),flagged:s<.2},{label:"mean dwell",value:`${Math.round(o)}ms`,flagged:o<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]},revisionBehavior:a=>{let t=a.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]},sessionContinuity:a=>{let t=a.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]},physicalPlausibility:a=>{let t=a.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]},temporalPatterns:a=>{let t=a.temporalPatterns.metrics;return[{label:"duration",value:at(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}}[n]??(()=>[]))(e)}function be(n){return n>=1e6?`${(n/1e6).toFixed(1)}m`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function at(n){let e=Math.round(n/1e3);if(e<60)return`${e}s`;let r=Math.floor(e/60),a=e%60;return a===0?`${r}m`:`${r}m ${a}s`}var vt={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function nt(n,e){let r=v(n);for(let[a,t]of Object.entries(vt)){let s=new RegExp(`\\b(${we(a)})\\b`,"gi");r=r.replace(s,o=>{let i=`title="${v(t.definition)}" class="wt-term"`,c=v(o);if(t.docsPath){let l=(e??"https://writetrack.dev")+t.docsPath;return`<a href="${v(l)}" target="_blank" rel="noopener"><abbr ${i}>${c}</abbr></a>`}return`<abbr ${i}>${c}</abbr>`})}return r}function we(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var f=P(require("@observablehq/plot"),1);var ve={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},xe={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},Lt={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},ke=`:host { display: block; overflow: hidden; }
172
172
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
173
173
  .page {
174
174
  max-width: 100%;
@@ -356,4 +356,4 @@
356
356
  .detail-inner { padding: 1rem; }
357
357
  }
358
358
  `,ot=class extends g{constructor(){super();this.t={1:null,2:null};_.register()}onResize(){this.rerenderAllCharts()}getStylesheet(){return Z+`
359
- `+xe}attributeChangedCallback(r,a,t){if(r==="theme"&&this._data&&this.hasRendered){let s=this.shadow.querySelector(".theme-toggle");s&&(s.textContent=t==="dark"?"Light":"Dark");let o=this.shadow.querySelector("wt-integrity-footer");o&&t&&o.setAttribute("theme",t),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(r,a,t)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:r,analysis:a}=this._data;this.t={1:null,2:null};let t=document.createElement("div");t.className="page",t.appendChild(this.buildHeader(a,r.metadata.sessionId??"")),t.appendChild(this.buildSummary(a)),t.appendChild(this.buildTierLabel("Primary Evidence"));let s=this.buildGrid(1,a);t.appendChild(s);let o=this.buildDetailPanel(1);t.appendChild(o),t.appendChild(this.buildTierLabel("Supporting Context"));let i=this.buildGrid(2,a);t.appendChild(i);let c=this.buildDetailPanel(2);t.appendChild(c);let l=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&l.setAttribute("theme",d),Rt(l),l.setData({integrity:a.integrity,outputSignature:a.outputSignature,sessionId:r.metadata.sessionId??""}),t.appendChild(l),this.replaceChart(t),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(r,a){let t=document.createElement("header");t.className="header";let s=document.createElement("div");s.className="header-meta";let o=document.createElement("span");o.textContent=`WriteTrack v${r.version}`;let i=document.createElement("span");i.className="sep",i.innerHTML="&middot;";let c=document.createElement("span"),l=new Date(r.analyzedAt);c.textContent=l.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="&middot;";let m=document.createElement("span");m.className="mono",m.textContent=a,s.append(o,i,c,d,m);let u=document.createElement("button");return u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),t.append(s,u),t}buildSummary(r){let a=document.createElement("section");a.className="summary";let t=document.createElement("div");t.className="summary-headline";let s=document.createElement("h1");s.textContent="Session Scorecard";let o=mt.filter(d=>W(this.getIndicatorCode(r,d))==="pass").length,i=document.createElement("span");i.className="tally",i.textContent=`${o} of ${mt.length} clear`,t.append(s,i),a.appendChild(t);let c=document.createElement("div");c.className="summary-stats";let l=at(r.temporalPatterns.metrics.sessionDurationMs);c.innerHTML=`<span>${v(l)} duration</span><span class="sep">&middot;</span><span>${r.keydownCount} keystrokes</span>`,a.appendChild(c);for(let d of mt)if(W(this.getIndicatorCode(r,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=et(d,r);m.innerHTML=`<strong>Flagged</strong> ${v(L[d]??d)}\u2009\u2014\u2009${v(u)}`,a.appendChild(m)}return a}buildTierLabel(r){let a=document.createElement("div");return a.className="tier-label",a.textContent=r,a}buildGrid(r,a){let t=document.createElement("div");t.className="indicator-grid",t.id=`grid-${r}`;let s=r===1?ut:pt;for(let o of s)t.appendChild(this.buildCell(o,a));return t}buildCell(r,a){let t=this.getIndicatorCode(a,r),o=W(t)==="flag",i=document.createElement("div");i.className="cell"+(o?" flagged":""),i.setAttribute("data-category",r),i.addEventListener("click",()=>this.selectCell(r));let c=document.createElement("div");c.className="cell-header";let l=document.createElement("div");l.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=L[r]??r,l.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${o?"flagged":"clear"}`,m.textContent=o?"flagged":"clear",c.append(l,m),i.appendChild(c);let u=document.createElement("div");u.className="cell-chart",i.appendChild(u);let p=rt(r,a),y=we[r];if(r==="physicalPlausibility"&&!o)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',i.appendChild(b)}else i.appendChild(this.buildCellMetrics(p,y));else i.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">&#x25B8;</span>',i.appendChild(h),i}buildCellMetrics(r,a){let t=document.createElement("div");t.className="cell-metrics";for(let s of a){let o=r[s];if(!o)continue;let i=document.createElement("div");i.className="cell-metric",i.innerHTML=`<span class="cell-metric-label">${v(o.label)}</span><span class="cell-metric-value">${v(o.value)}</span>`,t.appendChild(i)}return t}buildDetailPanel(r){let a=document.createElement("div");a.className="detail-panel",a.id=`detail-${r}`;let t=document.createElement("button");t.className="detail-close",t.setAttribute("aria-label","Close detail"),t.innerHTML="&times; Close",t.addEventListener("click",o=>{o.stopPropagation(),this.closeDetail(r)}),a.appendChild(t);let s=document.createElement("div");return s.className="detail-inner",s.id=`detail-${r}-inner`,a.appendChild(s),a}selectCell(r){var d;let a=(d=this._data)==null?void 0:d.analysis;if(!a)return;let t=Lt[r],s=this.shadow.getElementById(`detail-${t}`),o=this.shadow.getElementById(`detail-${t}-inner`);if(!s||!o)return;let i=this.shadow.getElementById(`grid-${t}`);if(i==null||i.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[t]===r){this.collapsePanel(s),this.t[t]=null;return}let c=this.t[t]!==null;this.t[t]=r;let l=i==null?void 0:i.querySelector(`[data-category="${r}"]`);l==null||l.classList.add("selected"),this.populateDetail(o,r,a),c?requestAnimationFrame(()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}}):this.expandPanel(s,()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}})}populateDetail(r,a,t){let s=this.getIndicatorCode(t,a),i=W(s)==="flag",c='<div class="detail-head">';c+=`<span class="detail-name">${v(L[a]??a)}</span>`,c+=`<span class="detail-code">${v(s??"")}</span>`,c+=`<span class="detail-status-label ${i?"flagged":"clear"}">${i?"flagged":"clear"}</span>`,c+="</div>";let l=et(a,t);c+=`<p class="detail-summary">${nt(l)}</p>`,c+='<div class="detail-chart-area"></div>';let d=ve[a];c+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=rt(a,t);c+='<div class="detail-metrics">';for(let p of m)c+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;c+="</div>";let u=ht(a);u&&(c+=`<p class="detail-explainer">${nt(u)}</p>`),r.innerHTML=c}closeDetail(r){let a=this.shadow.getElementById(`detail-${r}`);if(!a)return;let t=this.shadow.getElementById(`grid-${r}`);t==null||t.querySelectorAll(".cell").forEach(s=>s.classList.remove("selected")),this.collapsePanel(a),this.t[r]=null}expandPanel(r,a){let t=r.querySelector(".detail-inner");r.style.height="0px",r.style.display="block",r.offsetHeight,r.style.height=`${t.offsetHeight+40}px`;let s=()=>{r.style.height="auto",a==null||a()};r.addEventListener("transitionend",s,{once:!0})}collapsePanel(r){r.style.height=`${r.scrollHeight}px`,r.offsetHeight,r.style.height="0px";let a=()=>{r.style.display=""};r.addEventListener("transitionend",a,{once:!0})}getIndicatorCode(r,a){var s;let t=r[a];return(s=t==null?void 0:t.indicator)==null?void 0:s.code}getComputedColors(){let r=getComputedStyle(this);return{line:r.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:r.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:r.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:r.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:r.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(r,a){var s;let t=a?`[data-category="${r}"] .cell-chart`:`#detail-${Lt[r]}-inner .detail-chart-area`;return((s=this.shadow.querySelector(t))==null?void 0:s.getBoundingClientRect().width)??300}plotOpts(r,a,t,s,o){return{width:r,height:a?52:200,marginTop:a?4:36,marginRight:a?0:16,marginBottom:a?4:44,marginLeft:a?0:55,x:a?{axis:null,...s}:{...s},y:a?{axis:null,...o}:{...o},style:{background:"transparent",color:t.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(r,a){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:t,analysis:s}=this._data,o=this.getComputedColors(),i=this.getIndicatorCode(s,r),l=W(i)==="flag"?o.flagged:o.accent;switch(r){case"contentOrigin":return this.plotContentOrigin(s,a,o);case"timingAuthenticity":return this.plotTimingAuthenticity(s,a,o,l);case"revisionBehavior":return this.plotRevisionBehavior(t,a,o);case"sessionContinuity":return this.plotSessionContinuity(t,s,a,o,l);case"physicalPlausibility":return this.plotPhysicalPlausibility(t,a,o);case"temporalPatterns":return this.plotTemporalPatterns(s,a,o,l)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(r=>{let a=r.closest(".cell"),t=a==null?void 0:a.getAttribute("data-category");if(!t)return;let s=this.plotCategory(t,!0);s&&r.replaceChildren(s)})}rerenderAllCharts(){this.renderAllCharts();for(let r of[1,2]){let a=this.t[r];if(a){let t=this.shadow.querySelector(`#detail-${r}-inner .detail-chart-area`);if(t){let s=this.plotCategory(a,!1);s&&t.replaceChildren(s)}}}}plotContentOrigin(r,a,t){let s=G(r);if(s.length===0)return null;let o={typing:t.accent,paste:t.flagged,pause:t.border,tabAway:t.tertiary,autocomplete:t.flagged,navigating:t.line},i=s.map(d=>({...d,color:o[d.type]??t.line})),c=this.getChartWidth("contentOrigin",a),l=this.plotOpts(c,a,t,{label:"Time (s)"},{padding:.2});return f.plot({...l,marginLeft:a?0:8,y:{axis:null,padding:.2},marks:[f.barX(i,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(r,a,t,s){let o=V(r);if(o.length===0)return null;let i=this.getChartWidth("timingAuthenticity",a),c=[f.dot(o,{x:"dwell",y:"flight",fill:s,fillOpacity:a?.4:.5,r:a?2:3,stroke:"none"})];if(!a){let l=o.reduce((m,u)=>m+u.dwell,0)/o.length,d=o.reduce((m,u)=>m+u.flight,0)/o.length;c.push(f.ruleX([l],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(i,a,t,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:a?4:12,marks:c})}plotRevisionBehavior(r,a,t){let s=J(r);if(s.length===0)return null;let o={insert:t.accent,delete:t.flagged,paste:t.line,cut:t.tertiary},i=s.map(l=>({...l,color:o[l.type]??t.line})),c=this.getChartWidth("revisionBehavior",a);return a?f.plot({...this.plotOpts(c,a,t),marks:[f.dot(i,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,c/i.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(c,a,t,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(i,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(r,a,t,s,o){var m,u;let i=q(r);if(i.length===0)return null;let c=this.getChartWidth("sessionContinuity",t),l=[f.areaY(i,{x:"time",y:"chars",fill:o,fillOpacity:.1,curve:"step-after"}),f.lineY(i,{x:"time",y:"chars",stroke:o,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=a.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;l.push(f.ruleX([p],{stroke:s.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!t){let p=i.filter(h=>h.isPaste),y=i.filter(h=>h.isCut);p.length>0&&l.push(f.dot(p,{x:"time",y:"chars",fill:s.accent,r:4,stroke:"none"})),y.length>0&&l.push(f.dot(y,{x:"time",y:"chars",fill:s.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(c,t,s,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:l})}plotPhysicalPlausibility(r,a,t){let s=Q(r);if(s.keystrokes.length===0)return null;let o=this.getChartWidth("physicalPlausibility",a),i=[f.line(s.keystrokes,{x:"time",y:"position",stroke:t.line,strokeWidth:a?1:1.5,strokeOpacity:a?.6:.8})];return a||(s.pastes.length>0&&i.push(f.dot(s.pastes,{x:"time",y:"position",fill:t.accent,r:4,stroke:"none"})),s.cuts.length>0&&i.push(f.dot(s.cuts,{x:"time",y:"position",fill:t.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(o,a,t,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:i})}plotTemporalPatterns(r,a,t,s){let o=F(r);if(o.length===0)return null;let i=this.getChartWidth("temporalPatterns",a);return f.plot({...this.plotOpts(i,a,t,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(o,{x:"time",y:"speed",fill:s,fillOpacity:.12,curve:"natural"}),f.lineY(o,{x:"time",y:"speed",stroke:s,strokeWidth:1.5,curve:"natural"})]})}};ot.tagName="wt-scorecard";0&&(module.exports={BaseChart,CATEGORY_NAMES,CompositionTimeline,CorrectionsBubble,DocumentGrowth,DocumentRibbon,EditWaterfall,GLOSSARY,IntegrityFooter,PauseDistribution,RhythmHeatmap,SEGMENT_COLORS,Sparkline,SpeedTimeline,TIER1_CATEGORIES,TIER2_CATEGORIES,WtScorecard,extractCorrectionBubbles,extractGrowthData,extractPasteMarkers,extractPauseHistogram,extractRhythmPairs,extractRibbonData,extractSegments,extractSeries,extractSpeedData,extractWaterfallData,formatDuration,generateCaption,generateSummary,getMetrics,getStatus,isPass,wrapTerms});
359
+ `+ke}attributeChangedCallback(r,a,t){if(r==="theme"&&this._data&&this.hasRendered){let s=this.shadow.querySelector(".theme-toggle");s&&(s.textContent=t==="dark"?"Light":"Dark");let o=this.shadow.querySelector("wt-integrity-footer");o&&t&&o.setAttribute("theme",t),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(r,a,t)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:r,analysis:a}=this._data;this.t={1:null,2:null};let t=document.createElement("div");t.className="page",t.appendChild(this.buildHeader(a,r.metadata.sessionId??"")),t.appendChild(this.buildSummary(a)),t.appendChild(this.buildTierLabel("Primary Evidence"));let s=this.buildGrid(1,a);t.appendChild(s);let o=this.buildDetailPanel(1);t.appendChild(o),t.appendChild(this.buildTierLabel("Supporting Context"));let i=this.buildGrid(2,a);t.appendChild(i);let c=this.buildDetailPanel(2);t.appendChild(c);let l=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&l.setAttribute("theme",d),Rt(l),l.setData({integrity:a.integrity,outputSignature:a.outputSignature,sessionId:r.metadata.sessionId??""}),t.appendChild(l),this.replaceChart(t),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(r,a){let t=document.createElement("header");t.className="header";let s=document.createElement("div");s.className="header-meta";let o=document.createElement("span");o.textContent=`WriteTrack v${r.version}`;let i=document.createElement("span");i.className="sep",i.innerHTML="&middot;";let c=document.createElement("span"),l=new Date(r.analyzedAt);c.textContent=l.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="&middot;";let m=document.createElement("span");m.className="mono",m.textContent=a,s.append(o,i,c,d,m);let u=document.createElement("button");return u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),t.append(s,u),t}buildSummary(r){let a=document.createElement("section");a.className="summary";let t=document.createElement("div");t.className="summary-headline";let s=document.createElement("h1");s.textContent="Session Scorecard";let o=mt.filter(d=>M(this.getIndicatorCode(r,d))==="pass").length,i=document.createElement("span");i.className="tally",i.textContent=`${o} of ${mt.length} clear`,t.append(s,i),a.appendChild(t);let c=document.createElement("div");c.className="summary-stats";let l=at(r.temporalPatterns.metrics.sessionDurationMs);c.innerHTML=`<span>${v(l)} duration</span><span class="sep">&middot;</span><span>${r.keydownCount} keystrokes</span>`,a.appendChild(c);for(let d of mt)if(M(this.getIndicatorCode(r,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=et(d,r);m.innerHTML=`<strong>Flagged</strong> ${v(L[d]??d)}\u2009\u2014\u2009${v(u)}`,a.appendChild(m)}return a}buildTierLabel(r){let a=document.createElement("div");return a.className="tier-label",a.textContent=r,a}buildGrid(r,a){let t=document.createElement("div");t.className="indicator-grid",t.id=`grid-${r}`;let s=r===1?ut:pt;for(let o of s)t.appendChild(this.buildCell(o,a));return t}buildCell(r,a){let t=this.getIndicatorCode(a,r),o=M(t)==="flag",i=document.createElement("div");i.className="cell"+(o?" flagged":""),i.setAttribute("data-category",r),i.addEventListener("click",()=>this.selectCell(r));let c=document.createElement("div");c.className="cell-header";let l=document.createElement("div");l.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=L[r]??r,l.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${o?"flagged":"clear"}`,m.textContent=o?"flagged":"clear",c.append(l,m),i.appendChild(c);let u=document.createElement("div");u.className="cell-chart",i.appendChild(u);let p=rt(r,a),y=ve[r];if(r==="physicalPlausibility"&&!o)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',i.appendChild(b)}else i.appendChild(this.buildCellMetrics(p,y));else i.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">&#x25B8;</span>',i.appendChild(h),i}buildCellMetrics(r,a){let t=document.createElement("div");t.className="cell-metrics";for(let s of a){let o=r[s];if(!o)continue;let i=document.createElement("div");i.className="cell-metric",i.innerHTML=`<span class="cell-metric-label">${v(o.label)}</span><span class="cell-metric-value">${v(o.value)}</span>`,t.appendChild(i)}return t}buildDetailPanel(r){let a=document.createElement("div");a.className="detail-panel",a.id=`detail-${r}`;let t=document.createElement("button");t.className="detail-close",t.setAttribute("aria-label","Close detail"),t.innerHTML="&times; Close",t.addEventListener("click",o=>{o.stopPropagation(),this.closeDetail(r)}),a.appendChild(t);let s=document.createElement("div");return s.className="detail-inner",s.id=`detail-${r}-inner`,a.appendChild(s),a}selectCell(r){var d;let a=(d=this._data)==null?void 0:d.analysis;if(!a)return;let t=Lt[r],s=this.shadow.getElementById(`detail-${t}`),o=this.shadow.getElementById(`detail-${t}-inner`);if(!s||!o)return;let i=this.shadow.getElementById(`grid-${t}`);if(i==null||i.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[t]===r){this.collapsePanel(s),this.t[t]=null;return}let c=this.t[t]!==null;this.t[t]=r;let l=i==null?void 0:i.querySelector(`[data-category="${r}"]`);l==null||l.classList.add("selected"),this.populateDetail(o,r,a),c?requestAnimationFrame(()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}}):this.expandPanel(s,()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}})}populateDetail(r,a,t){let s=this.getIndicatorCode(t,a),i=M(s)==="flag",c='<div class="detail-head">';c+=`<span class="detail-name">${v(L[a]??a)}</span>`,c+=`<span class="detail-code">${v(s??"")}</span>`,c+=`<span class="detail-status-label ${i?"flagged":"clear"}">${i?"flagged":"clear"}</span>`,c+="</div>";let l=et(a,t);c+=`<p class="detail-summary">${nt(l)}</p>`,c+='<div class="detail-chart-area"></div>';let d=xe[a];c+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=rt(a,t);c+='<div class="detail-metrics">';for(let p of m)c+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;c+="</div>";let u=ht(a);u&&(c+=`<p class="detail-explainer">${nt(u)}</p>`),r.innerHTML=c}closeDetail(r){let a=this.shadow.getElementById(`detail-${r}`);if(!a)return;let t=this.shadow.getElementById(`grid-${r}`);t==null||t.querySelectorAll(".cell").forEach(s=>s.classList.remove("selected")),this.collapsePanel(a),this.t[r]=null}expandPanel(r,a){let t=r.querySelector(".detail-inner");r.style.height="0px",r.style.display="block",r.offsetHeight,r.style.height=`${t.offsetHeight+40}px`;let s=()=>{r.style.height="auto",a==null||a()};r.addEventListener("transitionend",s,{once:!0})}collapsePanel(r){r.style.height=`${r.scrollHeight}px`,r.offsetHeight,r.style.height="0px";let a=()=>{r.style.display=""};r.addEventListener("transitionend",a,{once:!0})}getIndicatorCode(r,a){var s;let t=r[a];return(s=t==null?void 0:t.indicator)==null?void 0:s.code}getComputedColors(){let r=getComputedStyle(this);return{line:r.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:r.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:r.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:r.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:r.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(r,a){var s;let t=a?`[data-category="${r}"] .cell-chart`:`#detail-${Lt[r]}-inner .detail-chart-area`;return((s=this.shadow.querySelector(t))==null?void 0:s.getBoundingClientRect().width)??300}plotOpts(r,a,t,s,o){return{width:r,height:a?52:200,marginTop:a?4:36,marginRight:a?0:16,marginBottom:a?4:44,marginLeft:a?0:55,x:a?{axis:null,...s}:{...s},y:a?{axis:null,...o}:{...o},style:{background:"transparent",color:t.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(r,a){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:t,analysis:s}=this._data,o=this.getComputedColors(),i=this.getIndicatorCode(s,r),l=M(i)==="flag"?o.flagged:o.accent;switch(r){case"contentOrigin":return this.plotContentOrigin(s,a,o);case"timingAuthenticity":return this.plotTimingAuthenticity(s,a,o,l);case"revisionBehavior":return this.plotRevisionBehavior(t,a,o);case"sessionContinuity":return this.plotSessionContinuity(t,s,a,o,l);case"physicalPlausibility":return this.plotPhysicalPlausibility(t,a,o);case"temporalPatterns":return this.plotTemporalPatterns(s,a,o,l)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(r=>{let a=r.closest(".cell"),t=a==null?void 0:a.getAttribute("data-category");if(!t)return;let s=this.plotCategory(t,!0);s&&r.replaceChildren(s)})}rerenderAllCharts(){this.renderAllCharts();for(let r of[1,2]){let a=this.t[r];if(a){let t=this.shadow.querySelector(`#detail-${r}-inner .detail-chart-area`);if(t){let s=this.plotCategory(a,!1);s&&t.replaceChildren(s)}}}}plotContentOrigin(r,a,t){let s=G(r);if(s.length===0)return null;let o={typing:t.accent,paste:t.flagged,pause:t.border,tabAway:t.tertiary,autocomplete:t.flagged,navigating:t.line},i=s.map(d=>({...d,color:o[d.type]??t.line})),c=this.getChartWidth("contentOrigin",a),l=this.plotOpts(c,a,t,{label:"Time (s)"},{padding:.2});return f.plot({...l,marginLeft:a?0:8,y:{axis:null,padding:.2},marks:[f.barX(i,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(r,a,t,s){let o=V(r);if(o.length===0)return null;let i=this.getChartWidth("timingAuthenticity",a),c=[f.dot(o,{x:"dwell",y:"flight",fill:s,fillOpacity:a?.4:.5,r:a?2:3,stroke:"none"})];if(!a){let l=o.reduce((m,u)=>m+u.dwell,0)/o.length,d=o.reduce((m,u)=>m+u.flight,0)/o.length;c.push(f.ruleX([l],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(i,a,t,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:a?4:12,marks:c})}plotRevisionBehavior(r,a,t){let s=J(r);if(s.length===0)return null;let o={insert:t.accent,delete:t.flagged,paste:t.line,cut:t.tertiary},i=s.map(l=>({...l,color:o[l.type]??t.line})),c=this.getChartWidth("revisionBehavior",a);return a?f.plot({...this.plotOpts(c,a,t),marks:[f.dot(i,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,c/i.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(c,a,t,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(i,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(r,a,t,s,o){var m,u;let i=q(r);if(i.length===0)return null;let c=this.getChartWidth("sessionContinuity",t),l=[f.areaY(i,{x:"time",y:"chars",fill:o,fillOpacity:.1,curve:"step-after"}),f.lineY(i,{x:"time",y:"chars",stroke:o,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=a.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;l.push(f.ruleX([p],{stroke:s.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!t){let p=i.filter(h=>h.isPaste),y=i.filter(h=>h.isCut);p.length>0&&l.push(f.dot(p,{x:"time",y:"chars",fill:s.accent,r:4,stroke:"none"})),y.length>0&&l.push(f.dot(y,{x:"time",y:"chars",fill:s.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(c,t,s,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:l})}plotPhysicalPlausibility(r,a,t){let s=Q(r);if(s.keystrokes.length===0)return null;let o=this.getChartWidth("physicalPlausibility",a),i=[f.line(s.keystrokes,{x:"time",y:"position",stroke:t.line,strokeWidth:a?1:1.5,strokeOpacity:a?.6:.8})];return a||(s.pastes.length>0&&i.push(f.dot(s.pastes,{x:"time",y:"position",fill:t.accent,r:4,stroke:"none"})),s.cuts.length>0&&i.push(f.dot(s.cuts,{x:"time",y:"position",fill:t.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(o,a,t,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:i})}plotTemporalPatterns(r,a,t,s){let o=z(r);if(o.length===0)return null;let i=this.getChartWidth("temporalPatterns",a);return f.plot({...this.plotOpts(i,a,t,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(o,{x:"time",y:"speed",fill:s,fillOpacity:.12,curve:"natural"}),f.lineY(o,{x:"time",y:"speed",stroke:s,strokeWidth:1.5,curve:"natural"})]})}};ot.tagName="wt-scorecard";0&&(module.exports={BaseChart,CATEGORY_NAMES,CompositionTimeline,CorrectionsBubble,DocumentGrowth,DocumentRibbon,EditWaterfall,GLOSSARY,IntegrityFooter,PauseDistribution,RhythmHeatmap,SEGMENT_COLORS,Sparkline,SpeedTimeline,TIER1_CATEGORIES,TIER2_CATEGORIES,WtScorecard,extractCorrectionBubbles,extractGrowthData,extractPasteMarkers,extractPauseHistogram,extractRhythmPairs,extractRibbonData,extractSegments,extractSeries,extractSpeedData,extractWaterfallData,formatDuration,generateCaption,generateSummary,getMetrics,getStatus,isPass,wrapTerms});
Binary file