rtl-analyzer 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +76 -52
  2. package/dist/cli.js +18 -1
  3. package/dist/codemod.js +50 -12
  4. package/dist/companion-security.js +2 -0
  5. package/dist/contextual-preview-bridge.js +113 -0
  6. package/dist/contextual-preview.js +74 -0
  7. package/dist/controlled-apply.js +222 -0
  8. package/dist/css-directional.js +60 -0
  9. package/dist/css-icons.js +51 -0
  10. package/dist/css-spacing.js +64 -0
  11. package/dist/dashboard-client.js +57 -40
  12. package/dist/dashboard-contextual-preview.js +119 -0
  13. package/dist/dashboard-data.js +1 -1
  14. package/dist/dashboard-embedded-preview.js +200 -0
  15. package/dist/dashboard-html.js +11 -10
  16. package/dist/dashboard-review-details.js +175 -0
  17. package/dist/dashboard-review-workflow.js +151 -0
  18. package/dist/directional-properties.js +53 -0
  19. package/dist/discovery.js +1 -2
  20. package/dist/eligibility.js +8 -8
  21. package/dist/evidence-store.js +110 -0
  22. package/dist/example-preview-mappings.js +98 -0
  23. package/dist/manual-change-store.js +27 -0
  24. package/dist/migration-lifecycle.js +19 -0
  25. package/dist/original-preview-runtime.js +68 -0
  26. package/dist/output-path.js +65 -0
  27. package/dist/policy-validation.js +1 -1
  28. package/dist/preview-cli.js +22 -0
  29. package/dist/preview-companion.js +621 -0
  30. package/dist/preview-configuration.js +144 -0
  31. package/dist/preview-runtime.js +98 -0
  32. package/dist/project-configuration.js +48 -0
  33. package/dist/project-root.js +12 -0
  34. package/dist/react-inline.js +65 -0
  35. package/dist/report-publisher.js +4 -7
  36. package/dist/review-approval.js +9 -0
  37. package/dist/review-session.js +199 -54
  38. package/dist/review-store.js +175 -0
  39. package/dist/review-workflow.js +554 -0
  40. package/dist/rules.js +14 -13
  41. package/dist/runtime-process.js +35 -0
  42. package/dist/scan-history.js +35 -0
  43. package/dist/scan-manifest-store.js +26 -0
  44. package/dist/scan.js +55 -4
  45. package/dist/serialization.js +1 -0
  46. package/dist/source-context.js +93 -0
  47. package/dist/source-snippets.js +3 -3
  48. package/dist/standalone-cli.js +14 -1
  49. package/dist/tailwind.js +3 -1
  50. package/dist/transformations.js +20 -0
  51. package/dist/validation.js +71 -0
  52. package/dist/workflow-validation.js +46 -0
  53. package/package.json +17 -8
@@ -0,0 +1,119 @@
1
+ /** Verifies real source/route targets and notifies the workflow-owned preparation coordinator. */
2
+ export const contextualPreviewClientSource = String.raw `
3
+ const targetSelectionKey=(record,item)=>'rtl-context-target:'+JSON.stringify([record.projectRoot,d.inputDigest,d.policyDigest,record.workflowId,record.finding.id,record.finding.path,item.role,item.role==='candidate'?record.session?.id:record.historical?'current-source':'original',record.routeId]);
4
+ function clearContextTargets(item){
5
+ item.targetSignature=null;item.contextReport=null;item.lastVerifiedReport=null;item.verifiedMapping=null;item.fingerprint=null;
6
+ item.state.dataset.targetCount='0';item.instanceSelect.replaceChildren(new Option('No target yet','0'));item.instanceSelect.disabled=true;
7
+ }
8
+ function reconcileContextTargets(item,record,report){
9
+ const previous=item.instance,key=targetSelectionKey(record,item);let saved=null;try{saved=JSON.parse(sessionStorage.getItem(key))}catch{}
10
+ const targets=report.targets;let selected=0,restoreFailed=false;
11
+ if(saved?.restoreRequired){selected=-2;restoreFailed=true}
12
+ else if((saved?.index===-1||saved?.value==='-1')&&targets.length)selected=-1;
13
+ else if(saved?.targetKey){
14
+ const matches=targets.filter(t=>t.key&&t.key===saved.targetKey);
15
+ if(matches.length===1&&matches[0].keyGuaranteed&&!matches[0].ambiguous)selected=matches[0].index;
16
+ else{try{sessionStorage.setItem(key,JSON.stringify({restoreRequired:true}))}catch{}selected=-2;restoreFailed=true}
17
+ }else if(saved?.label){
18
+ const labelMatches=targets.filter(t=>t.label===saved.label&&t.keyGuaranteed&&!t.ambiguous);
19
+ if(labelMatches.length===1)selected=labelMatches[0].index;
20
+ else{try{sessionStorage.setItem(key,JSON.stringify({restoreRequired:true}))}catch{}selected=-2;restoreFailed=true}
21
+ }else{
22
+ if(saved){try{sessionStorage.setItem(key,JSON.stringify({restoreRequired:true}))}catch{}selected=-2;restoreFailed=true}
23
+ else selected=0;
24
+ }
25
+ const cleanLabel=l=>{const s=(l||'Element').trim().split(/\s+[^\s@]+@[^\s@]+\.[^\s@]+/)[0].trim();return s||'Element'};
26
+ const options=targets.map(t=>({value:String(t.index),label:(t.index+1)+' · '+cleanLabel(t.label)}));
27
+ if(restoreFailed)options.unshift({value:'',label:'Previous target could not be restored. Select a target.'});
28
+ options.push(targets.length?{value:'-1',label:'All '+targets.length+' targets'}:{value:'0',label:'No target yet'});
29
+ // Check the actual options too: an unavailable descriptor may have cleared the DOM since the last report.
30
+ const signature=JSON.stringify([key,options]);
31
+ if(item.targetSignature!==signature||JSON.stringify([...item.instanceSelect.options].map(o=>({value:o.value,label:o.label})))!==JSON.stringify(options))item.instanceSelect.replaceChildren(...options.map(o=>new Option(o.label,o.value)));
32
+ item.targetSignature=signature;item.instance=selected;item.targetRestoreFailed=restoreFailed;item.instanceSelect.value=restoreFailed?'':String(selected);item.instanceSelect.disabled=!targets.length;
33
+ if(targets.length&&previous!==selected)contextProbe(item,record,record.finding,'highlight');
34
+ }
35
+ function contextControls(current){
36
+ if(current.contextControls)return;
37
+ const record=current.record,make=(toolbar,expanded)=>{
38
+ const group=el('div','','context-preview-controls'),route=document.createElement('select');route.setAttribute('aria-label',expanded?'Expanded contextual route':'Contextual route');route.onchange=()=>{record.routeId=route.value;current.items.forEach(item=>item.instance=0);contextRoutes(record,record.finding,current)};
39
+ const highlight=el('button','Highlight targets');highlight.onclick=()=>current.items.forEach(item=>contextProbe(item,record,record.finding,'highlight'));
40
+ const reveal=el('button','Reveal navigation');reveal.onclick=()=>current.items.forEach(item=>contextProbe(item,record,record.finding,'reveal-navigation'));
41
+ const start=el('button','Open candidate application');start.disabled=!record.session||!!record.historical;start.onclick=()=>{if(record.session&&!record.historical&&record.workflowId)window.dispatchEvent(new CustomEvent('rtl-context-runtime-request',{detail:{workflowId:record.workflowId,application:record.contextInfo?.route?.application}}))};
42
+ const retry=el('button','Retry context','context-retry');retry.onclick=()=>contextRoutes(record,record.finding,current);
43
+ const reset=el('button','Reset preview data');reset.title='Reset only the dedicated preview dataset on both origins; ordinary application storage is preserved.';reset.onclick=()=>{if(!record.defaultSeed)return;record.seedSnapshot=record.defaultSeed;current.items.forEach(item=>{item.ready=null;item.state.dataset.state='loading';item.state.dataset.contextStatus='loading-route';item.state.textContent='Resetting dedicated preview data…';contextProbe(item,record,record.finding,'reset-data')})};
44
+ group.append(route,highlight,reveal,reset,start,retry);if(expanded)toolbar.insertBefore(group,toolbar.querySelector('.preview-workspace-close'));else toolbar.append(group);return {group,route,reveal,start,reset};
45
+ };
46
+ current.contextControls=[make(current.component.querySelector('.component-toolbar'),false),make(current.workspace,true)];
47
+ const summary=el('span','Locating contextual target…','preview-context-summary');current.workspace.insertBefore(summary,current.workspace.querySelector('.preview-workspace-close'));current.contextSummary=summary;
48
+ for(const item of current.items){const instance=document.createElement('select');instance.setAttribute('aria-label',item.role==='original'?'Original target instance':'Candidate target instance');instance.className='context-instance';instance.onchange=()=>{if(instance.value==='')return;item.instance=Number(instance.value);const target=item.contextReport?.targets.find(t=>t.index===item.instance);item.targetRestoreFailed=false;if(item.instance===-1){sessionStorage.setItem(targetSelectionKey(record,item),JSON.stringify({index:-1,label:'All targets'}))}else if(target&&target.keyGuaranteed&&target.key&&!target.ambiguous){sessionStorage.setItem(targetSelectionKey(record,item),JSON.stringify({index:item.instance,targetKey:target.key,label:target.label}))}else{sessionStorage.removeItem(targetSelectionKey(record,item))};contextProbe(item,record,record.finding,'highlight')};item.instance=0;item.instanceSelect=instance;clearContextTargets(item);item.panel.querySelector('h3').append(instance)}
49
+ }
50
+ const candidateEligible=record=>!!record.contextInfo?.review?.hasAutomaticFix&&record.contextInfo.review.inScope!==false&&!record.historical&&!['Rejected','Deferred','Flagged'].includes(record.contextInfo.review.decision);
51
+ function activateVerifiedCandidate(current){
52
+ const record=current.record,item=current.items[1],descriptor=record.contextInfo?.candidate;
53
+ if(!candidateEligible(record)||!record.entryApplied||!descriptor?.available||!(capability(record.finding)?.verified||capability(record.finding)?.bindingVerified))return;
54
+ item.context=descriptor;item.application=record.contextInfo.route.application;load(item,descriptor.url,record,record.finding,descriptor.sourceHash);resize(item,record);
55
+ }
56
+ async function contextRoutes(record,f,current){
57
+ if(!current||!live(record,current.component))return;contextControls(current);
58
+ const token=(record.routeToken||0)+1;record.routeToken=token;record.contextResolving=true;for(const item of current.items){item.state.dataset.state='loading';item.state.dataset.contextStatus='loading-route';item.state.textContent='Resolving current route and contextual target…'}
59
+ try{
60
+ const query=new URLSearchParams({inputDigest:d.inputDigest,policyDigest:d.policyDigest,findingId:f.id,mode:record.mode,...(record.workflowId?{workflowId:record.workflowId}:{}),...(record.routeId?{routeId:record.routeId}:{})});
61
+ let info=await request('/contextual-preview?'+query);
62
+ // Original initialization never enters the candidate mutation/runtime path.
63
+ if(!live(record,current.component)||record.routeToken!==token)return;
64
+ if(info.route&&!info.original?.available){
65
+ try{info=await request('/contextual-preview/original?'+query,{method:'POST'});}catch(error){info.original={...info.original,reason:(info.original?.reason||'Original runtime unavailable.')+' Automatic original initialization failed: '+error.message+'. Retry context after runtime recovery.'};}
66
+ }if(!live(record,current.component)||record.routeToken!==token)return;
67
+ if(info.projectRoot!==record.projectRoot||info.findingId!==f.id||info.path!==f.path||info.inputDigest!==d.inputDigest||info.policyDigest!==d.policyDigest||info.sessionId!==(record.session?.id||null))throw Error('PREVIEW_SESSION_IDENTITY_MISMATCH');
68
+ record.contextResolving=false;record.contextInfo=info;record.routeId=info.route?.id;record.runtime=info.candidate?.available?{runtime:{origin:info.candidate.origin,status:'healthy'}}:null;if(info.original?.available){const u=new URL(info.original.origin);if(u.protocol==='http:'&&u.hostname==='127.0.0.1')originalOrigins.add(u.origin)}syncRoute(current);
69
+ if(!record.contextDefaults){record.contextDefaults=true;if(info.mapping.preferredViewport!==undefined){record.viewport=info.mapping.preferredViewport;const viewport=[...current.component.querySelector('.component-toolbar').querySelectorAll('button')].find(b=>['Desktop','Tablet','Mobile'].includes(b.textContent));if(viewport)viewport.textContent=['Desktop','Tablet','Mobile'][record.viewport]}if(info.mapping.preferredMode&&info.mapping.preferredMode!==record.mode){record.mode=info.mapping.preferredMode;syncControls(current);return contextRoutes(record,f,current)}}
70
+ syncControls(current);
71
+ for(const controls of current.contextControls){controls.route.replaceChildren(...info.mapping.routes.map(route=>new Option(route.label,route.id)));controls.route.value=record.routeId||'';controls.route.disabled=!info.mapping.routes.length;controls.reset.hidden=info.dataAdapter==='none'||!info.route;controls.reveal.hidden=!info.mapping.css?.media&&!info.mapping.routes.some(r=>r.prepare==='sidebar');controls.start.hidden=!!info.candidate?.available;controls.start.disabled=!info.route||!record.session||info.review?.workflowState!=='Reviewing'}
72
+ const summary=info.mapping.label+' · '+info.path+':'+info.line;current.contextSummary.textContent=summary;
73
+ const helper=current.component.querySelector('.component-helper');if(helper)helper.textContent=(info.mapping.configured?'Configured context · ':'Example-specific context · ')+summary+' · '+(info.mapping.limitation||'Live target checks are separate from validation and approval.')+(info.review?.inScope===false?' · Outside the selected review scope; original contextual review remains available.':info.review?.hasAutomaticFix?'':' · No automatic fix for this finding; original contextual review remains available.');
74
+ for(const item of current.items){const descriptor=info[item.role==='original'?'original':'candidate'];item.context=descriptor;item.application=info.route?.application;
75
+ if(item.role==='candidate'&&descriptor?.available&&candidateEligible(record)&&record.entryApplied){activateVerifiedCandidate(current);if(!item.frame)item.state.textContent='Waiting for verified Before before displaying this isolated candidate…';}
76
+ else if(descriptor?.available&&item.role==='original'){load(item,descriptor.url,record,f,descriptor.sourceHash);resize(item,record)}
77
+ else{clearTimeout(item.timeout);item.box.replaceChildren();item.frame=null;item.ready=null;clearContextTargets(item);item.state.dataset.state='unavailable';item.state.dataset.contextStatus=!info.route?'mapping-missing':'runtime-unavailable';item.state.textContent=item.role==='original'?(descriptor?.reason||info.reason||'Unresolved contextual mapping.'):(!record.session?'No candidate prepared · validation: Not run':descriptor?.reason||info.candidateReason||'No isolated candidate is available.');}
78
+ }
79
+ updateCandidateAction(current);syncRoute(current);
80
+ current.component.querySelectorAll('.route-actions button').forEach((button,index)=>{button.disabled=!info.candidate?.available;button.onclick=()=>{const url=new URL(info.candidate.urls?.[index?'rtl':'ltr']||info.candidate.url);if(!info.candidate.urls)url.searchParams.set('lang',index?'ar':'en');if(originAllowed(url.href,'candidate'))window.open(url.href,'_blank','noopener,noreferrer')}});
81
+ }catch(error){if(live(record,current.component)&&record.routeToken===token){record.contextResolving=false;for(const item of current.items){clearTimeout(item.timeout);item.box.replaceChildren();item.frame=null;item.ready=null;clearContextTargets(item);item.state.dataset.state='error';item.state.dataset.contextStatus='unavailable';item.state.textContent='Context unavailable: '+error.message+'. Retry connection or restart the scoped application runtime.'}current.contextSummary.textContent='Context unavailable · '+error.message;updateCandidateAction(current)}}
82
+ }
83
+ function updateCandidateAction(current){
84
+ const button=document.querySelector('.decision-card [data-candidate-action]');if(selected!==current.record.key)return;
85
+ if(current.record.workflowId){window.dispatchEvent(new CustomEvent('rtl-context-preview-updated',{detail:{workflowId:current.record.workflowId,findingId:current.record.finding.id}}));return;}
86
+ if(!button)return;const verified=capability(current.record.finding)?.verified;button.textContent=verified?'Apply & Preview':'Prepare candidate';
87
+ }
88
+
89
+ function contextProbe(item,record,f,command){
90
+ if(!item.frame||!item.nonce||!item.context?.available||!record.contextInfo?.route)return;
91
+ item.frame.contentWindow?.postMessage({type:'rtl-context-probe',version:2,nonce:item.nonce,role:item.role,application:item.application,sessionId:record.session?.id||'before-only',runtimeSessionId:item.context.runtimeSessionId,projectRoot:item.context.projectRoot,findingId:f.id,sourcePath:f.path,sourceSha256:item.expectedHash,routeId:record.routeId,mode:record.mode,instance:item.instance||0,seedData:command==='reset-data'?record.defaultSeed:item.role==='candidate'?record.seedSnapshot:undefined,...(command?{command}:{})},new URL(item.url).origin);
92
+ }
93
+ window.addEventListener('message',event=>{
94
+ if(!view?.record.contextual||selected!==view.record.key||view.record.contextResolving)return;const record=view.record,p=event.data;
95
+ if(!p||!['rtl-context-status','rtl-context-navigation'].includes(p.type)||p.version!==2)return;
96
+ if(p.type==='rtl-context-navigation'){
97
+ const item=view.items.find(item=>item.frame&&event.source===item.frame.contentWindow&&event.origin===new URL(item.url).origin&&p.nonce===item.nonce&&p.role===item.role&&p.application===item.application&&p.projectRoot===item.context?.projectRoot&&p.runtimeSessionId===item.context?.runtimeSessionId&&p.sessionId===(record.session?.id||'before-only')&&p.findingId===record.finding.id&&p.sourcePath===record.finding.path&&p.sourceSha256===item.expectedHash&&p.routeId===record.routeId);
98
+ if(!item)return;const route=record.contextInfo.mapping.routes.find(route=>route.application===p.nextApplication);
99
+ if(route){record.routeId=route.id;contextRoutes(record,record.finding,view)}else view.contextSummary.textContent='No verified consuming route in '+p.nextApplication+' for this finding. Choose a finding in that application.';return;
100
+ }
101
+ for(const item of view.items){
102
+ if(!item.frame||event.source!==item.frame.contentWindow||event.origin!==new URL(item.url).origin||p.nonce!==item.nonce||p.role!==item.role||p.application!==item.application||p.projectRoot!==item.context?.projectRoot||p.runtimeSessionId!==item.context?.runtimeSessionId||p.sessionId!==(record.session?.id||'before-only')||p.findingId!==record.finding.id||p.sourcePath!==record.finding.path||p.sourceSha256!==item.expectedHash||p.routeId!==record.routeId||!['ltr','rtl'].includes(p.dir)||typeof p.route!=='string'||p.route.length>200||!/^\/[a-zA-Z0-9/_-]*$/.test(p.route)||!Array.isArray(p.targets)||p.targets.length>500||p.targets.some(t=>!t||!Number.isInteger(t.index)||typeof t.label!=='string'||t.label.length>100||typeof t.rendered!=='boolean'||!t.rect||Object.values(t.rect).some(n=>typeof n!=='number'||!Number.isFinite(n))))continue;
103
+ item.currentRoute=p.route;syncRoute(view);
104
+ if(p.dir!==record.mode){item.contextReport=p;item.ready=null;clearTimeout(item.timeout);item.state.dataset.state='navigated';item.state.dataset.contextStatus='navigated';item.state.textContent='Live application · direction changed inside the app to '+p.dir.toUpperCase()+'. Re-select '+record.mode.toUpperCase()+' in the toolbar to restore the comparison direction.';continue}
105
+ if(item.role==='original'&&typeof p.seedData==='string'&&p.seedData.length<100000){record.seedSnapshot=p.seedData;record.defaultSeed=p.defaultSeedData}
106
+ item.fingerprint=p.dataFingerprint;
107
+ reconcileContextTargets(item,record,p);
108
+ const rendered=p.targets.filter(t=>t.rendered).length,offscreen=p.targets.filter(t=>t.rendered&&!t.inViewport).length;
109
+ const targetStatus=p.route!==record.contextInfo.route.path||p.targetStatus==='navigated'?'navigated':p.targetStatus==='document'&&rendered?'document':p.targetStatus==='verified'&&rendered&&p.routeReady&&(!record.contextInfo.mapping.configured||!record.contextInfo.mapping.sourceSelector||p.sourceStatus==='source-rule-matched')?'verified':p.targetStatus==='preparing'?'preparing':['source-not-loaded','target-mismatch','missing-target','route-not-ready'].includes(p.targetStatus)?p.targetStatus:p.targets.length?'hidden':'unresolved';
110
+ item.state.dataset.contextStatus=item.targetRestoreFailed?'target-selection-required':targetStatus;item.state.dataset.routeReady=String(!!p.routeReady);item.state.dataset.targetCount=String(p.targets.length);item.state.dataset.state=item.targetRestoreFailed?'unresolved':targetStatus==='navigated'?'navigated':['verified','document'].includes(targetStatus)?'ready':targetStatus==='preparing'?'loading':'unresolved';
111
+ const contextLabel=item.targetRestoreFailed?'Previous target could not be restored. Select a target.':targetStatus==='verified'?'Verified targets: '+p.targets.length+(offscreen?' · '+offscreen+' outside viewport':''):targetStatus==='document'?'Page/document-wide context':targetStatus==='navigated'?'Live application · navigated away from target':targetStatus==='route-not-ready'?'Application readiness target not observed on configured route':targetStatus==='source-not-loaded'?'Source stylesheet/rule not observed on this route · mapping unverified':targetStatus==='target-mismatch'?'Configured target does not match the source rule · mapping unverified':targetStatus==='missing-target'?'Source rule loaded; configured target is missing on this route':targetStatus==='hidden'?'Selector located · hidden at this viewport':targetStatus==='preparing'?'Preparing existing UI state…':'Route ready; target unresolved. Retry Highlight targets or restore the required UI state.';
112
+ const css=item.targetRestoreFailed?null:p.targets.find(t=>t.index===item.instance)?.css;const evidence=contextLabel+' · '+p.route+' · '+p.dir.toUpperCase()+(css?' · CSS '+css.sourceProperty+(css.resolvedProperty!==css.sourceProperty?' → '+css.resolvedProperty:'')+': '+css.contribution+' · computed '+css.computedValue:'')+(item.role==='candidate'?' · '+candidateStatus(record)+' · '+(record.contextInfo.review.applied?'selected preview patch present':'selected finding unchanged')+' · '+record.contextInfo.review.patchInventory.length+' actual candidate patches':'');if(item.diagnostic)setText(item.diagnostic,(item.role==='original'?'Before: ':'After: ')+evidence);setText(item.state,['verified','document'].includes(targetStatus)?contextLabel:evidence);
113
+ if(['verified','document','navigated','hidden'].includes(targetStatus)&&!item.targetRestoreFailed){item.ready=p;clearTimeout(item.timeout)}else if(item.targetRestoreFailed){item.ready=null;item.lastVerifiedReport=null;item.verifiedMapping=null;}
114
+ if(['verified','document'].includes(targetStatus)&&!item.targetRestoreFailed){item.lastVerifiedReport=p;item.verifiedMapping={sourceHash:item.expectedHash,routeId:record.routeId};}
115
+ item.contextReport=p;if(item.role==='original')activateVerifiedCandidate(view);updateCandidateAction(view);syncRoute(view);
116
+ }
117
+ const [before,after]=view.items;if(before.fingerprint&&after.fingerprint&&before.fingerprint!==after.fingerprint){setText(view.contextSummary,'Preview datasets differ after interaction · Reset preview data to compare equivalent data; this is not a patch effect.')}else if(record.contextInfo){setText(view.contextSummary,record.contextInfo.mapping.label+' · '+(record.contextInfo.dataAdapter==='none'?'Application data · dataset equivalence unverified':before.fingerprint&&after.fingerprint?'Equivalent preview data':'Dedicated preview data'))}
118
+ });
119
+ `;
@@ -5,7 +5,7 @@ const sort = (a, b) => a < b ? -1 : a > b ? 1 : 0;
5
5
  const breakdown = (values) => { const counts = new Map(); for (const value of values)
6
6
  counts.set(value, (counts.get(value) ?? 0) + 1); return [...counts].sort((a, b) => sort(a[0], b[0])).map(([name, count]) => ({ name, count })); };
7
7
  const findingSort = (a, b) => sort(a.path, b.path) || a.line - b.line || a.column - b.column || sort(a.id, b.id);
8
- function mapFinding(f, ref, sourceText) { const eligibility = classifyEligibility(f, !ref?.missingEvidenceIds.length, sourceText); const reviewClassification = eligibility.eligibility === 'AUTOMATED_ELIGIBLE' ? 'Automated / Codemod Eligible' : eligibility.eligibility === 'ASSISTED' ? 'Assisted' : 'Manual'; return { id: f.id, ruleId: f.ruleId, ruleVersion: f.ruleVersion, category: f.category, severity: f.severity, confidence: f.confidence, title: f.title, sourceMechanism: f.sourceMechanism, path: f.path, line: f.range.start.line, column: f.range.start.column, owner: f.ownership, applications: f.applications.slice().sort(sort), rationale: f.rationale, treatment: f.treatment, limitation: f.limitation, evidenceIds: f.evidenceIds.slice(), missingEvidenceIds: ref?.missingEvidenceIds.slice() ?? [], duplicateEvidenceIds: ref?.duplicateEvidenceIds.slice() ?? [], relatedLocations: f.relatedLocations.slice().sort((a, b) => sort(a.path, b.path) || a.range.start.offset - b.range.start.offset).map(x => `${x.path}:${x.range.start.line}:${x.range.start.column}`), issueIds: f.issueIds.slice().sort(sort), suggestion: f.suggestion ? { property: f.suggestion.property, value: f.suggestion.value } : null, previewMappingId: approvedPreviewForSource(f.path)?.id ?? null, reviewStatus: f.id === 'RTL.ICON.PROGRESSION:237172da962fe4d0605ddd83' ? 'Needs Manual Investigation' : 'Not Reviewed', reviewClassification, eligibility: eligibility.eligibility, eligibilityReason: eligibility.reason, eligibilityEvidence: eligibility.evidence, eligibilityTransformationId: eligibility.transformationId, eligibilityBlockers: eligibility.blockers, ...(f.exceptionReason ? { exceptionReason: f.exceptionReason } : {}), ...(f.originalCategory ? { originalCategory: f.originalCategory } : {}) }; }
8
+ function mapFinding(f, ref, sourceText) { const eligibility = classifyEligibility(f, !ref?.missingEvidenceIds.length, sourceText); const reviewClassification = eligibility.eligibility === 'AUTOMATED_ELIGIBLE' ? 'Automated / Codemod Eligible' : eligibility.eligibility === 'ASSISTED' ? 'Assisted' : 'Manual'; return { id: f.id, ruleId: f.ruleId, ruleVersion: f.ruleVersion, category: f.category, severity: f.severity, confidence: f.confidence, title: f.title, sourceMechanism: f.sourceMechanism, path: f.path, line: f.range.start.line, column: f.range.start.column, range: f.range, original: f.original, owner: f.ownership, applications: f.applications.slice().sort(sort), rationale: f.rationale, treatment: f.treatment, limitation: f.limitation, evidenceIds: f.evidenceIds.slice(), missingEvidenceIds: ref?.missingEvidenceIds.slice() ?? [], duplicateEvidenceIds: ref?.duplicateEvidenceIds.slice() ?? [], relatedLocations: f.relatedLocations.slice().sort((a, b) => sort(a.path, b.path) || a.range.start.offset - b.range.start.offset).map(x => `${x.path}:${x.range.start.line}:${x.range.start.column}`), issueIds: f.issueIds.slice().sort(sort), suggestion: f.suggestion ? { property: f.suggestion.property, value: f.suggestion.value } : null, previewMappingId: approvedPreviewForSource(f.path)?.id ?? null, reviewStatus: f.id === 'RTL.ICON.PROGRESSION:237172da962fe4d0605ddd83' ? 'Needs Manual Investigation' : 'Not Reviewed', reviewClassification, eligibility: eligibility.eligibility, eligibilityReason: eligibility.reason, eligibilityEvidence: eligibility.evidence, eligibilityTransformationId: eligibility.transformationId, eligibilityBlockers: eligibility.blockers, ...(f.exceptionReason ? { exceptionReason: f.exceptionReason } : {}), ...(f.originalCategory ? { originalCategory: f.originalCategory } : {}) }; }
9
9
  export function toDashboardData(report, snippets) { const refs = new Map(report.evidenceReferences.map(ref => [ref.findingId, ref])); const findings = report.findings.slice().sort((a, b) => sort(a.path, b.path) || a.range.start.offset - b.range.start.offset || sort(a.id, b.id)).map(f => mapFinding(f, refs.get(f.id), snippets?.sourceTextByPath?.[f.path])); const actionable = findings.filter(f => !['INFORMATIONAL', 'INTENTIONAL_LTR'].includes(f.category)); const queue = { critical: [], major: [], minor: [], runtimeConfig: [], informational: [], intentionalLtr: [] }; for (const f of findings) {
10
10
  const key = f.category === 'INFORMATIONAL' ? 'informational' : f.category === 'INTENTIONAL_LTR' ? 'intentionalLtr' : f.category === 'RUNTIME_CONFIG' ? 'runtimeConfig' : f.severity.toLowerCase();
11
11
  (queue[key] ??= []).push(f);
@@ -0,0 +1,200 @@
1
+ import { contextualPreviewClientSource } from './dashboard-contextual-preview.js';
2
+ /** Runs inside the existing dashboard closure, using its verified analysis and selection. */
3
+ export const embeddedPreviewClientSource = String.raw `
4
+ const embeddedReview=(()=>{
5
+ const records=new Map();let selected=null,view=null;
6
+ const key=f=>[d.inputDigest,d.policyDigest,f.id,f.path].join('|');
7
+ const request=async(path,options)=>{let response;try{response=await fetch(previewOrigin+path,options)}catch{throw Error('COMPANION_UNAVAILABLE')}const body=await response.json();if(!response.ok)throw Error(body.error||'PREVIEW_REQUEST_FAILED');return body};
8
+ const live=(record,node)=>selected===record.key&&node.isConnected;
9
+ const status=(record,text)=>{if(selected!==record.key)return;const n=document.querySelector('.analysis-status');if(n)n.textContent=text};
10
+ const workspaceLayout={position:'fixed',inset:'0',width:'100vw',height:'100vh','max-width':'none','max-height':'none','z-index':'10000',overflow:'hidden',display:'flex','flex-direction':'column','box-sizing':'border-box',margin:'0',padding:'8px','border-radius':'0',gap:'8px',background:'#0e1a2d',color:'#e9f0ff',font:'14px/1.4 Inter,ui-sans-serif,system-ui,sans-serif',transform:'none',animation:'none',transition:'none'};
11
+ const setText=(node,value)=>{if(node.textContent!==value)node.textContent=value};
12
+ const originalOrigins=new Set(['http://127.0.0.1:4200','http://127.0.0.1:4201']);
13
+ const originAllowed=(url,role)=>{const u=new URL(url);return u.protocol==='http:'&&u.hostname==='127.0.0.1'&&(role==='original'?originalOrigins.has(u.origin):Number(u.port)>=4202&&Number(u.port)<=4212)};
14
+ function closeWorkspace(current=view,restore=true){
15
+ if(!current?.expanded)return;const saved=current.expanded,surface=current.component;current.expanded=null;
16
+ if(saved.portal){
17
+ if(saved.host.isConnected){for(const child of [...surface.childNodes])saved.host.moveBefore(child,null);saved.host.className=saved.hostClass;saved.host.hidden=saved.hostHidden}
18
+ surface.remove();current.component=saved.host;
19
+ }else{
20
+ surface.classList.remove('embedded-expanded');surface.removeAttribute('role');surface.removeAttribute('aria-modal');surface.removeAttribute('aria-label');delete surface.dataset.previewView;
21
+ if(saved.style===null)surface.removeAttribute('style');else surface.setAttribute('style',saved.style);
22
+ }
23
+ delete current.component.dataset.previewView;saved.placeholder.remove();for(const [node,inert] of saved.background)node.inert=inert;
24
+ document.documentElement.style.overflow=saved.htmlOverflow;document.body.style.overflow=saved.bodyOverflow;
25
+ current.expand.textContent='Expand';current.items.forEach(item=>resize(item,current.record));syncRoute(current);
26
+ for(const [node,top,left] of saved.scroll)node.scrollTo(left,top);
27
+ if(restore&&saved.opener?.isConnected)saved.opener.focus({preventScroll:true});
28
+ }
29
+ function setView(current,mode){current.component.dataset.previewView=mode;current.workspace.querySelectorAll('[data-view]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.view===mode)));current.items.forEach(item=>resize(item,current.record));syncRoute(current)}
30
+ function openWorkspace(current,mode,opener){
31
+ if(!current.expanded){
32
+ const host=current.component,placeholder=el('div');placeholder.style.height=host.getBoundingClientRect().height+'px';placeholder.style.margin=getComputedStyle(host).margin;host.before(placeholder);
33
+ const background=[],scroll=[];for(let node=host;node.parentElement;node=node.parentElement){for(const sibling of node.parentElement.children)if(sibling!==node&&sibling!==placeholder&&sibling!==document.head){background.push([sibling,sibling.inert]);sibling.inert=true}scroll.push([node.parentElement,node.parentElement.scrollTop,node.parentElement.scrollLeft])}
34
+ const saved={opener,placeholder,background,scroll,host,hostClass:host.className,hostHidden:host.hidden,style:host.getAttribute('style'),portal:typeof host.moveBefore==='function',htmlOverflow:document.documentElement.style.overflow,bodyOverflow:document.body.style.overflow};current.expanded=saved;
35
+ if(saved.portal){
36
+ // moveBefore preserves live iframe browsing contexts; ordinary reparenting must not be used.
37
+ const portal=document.createElement('div');portal.className=host.className;for(const [property,value] of Object.entries(workspaceLayout))portal.style.setProperty(property,value,'important');portal.classList.add('embedded-expanded');document.body.append(portal);
38
+ host.classList.remove('component-review');host.hidden=true;
39
+ for(const child of [...host.childNodes])portal.moveBefore(child,null);
40
+ current.component=portal;
41
+ }
42
+ const surface=current.component;for(const [property,value] of Object.entries(workspaceLayout))surface.style.setProperty(property,value,'important');
43
+ document.documentElement.style.overflow='hidden';document.body.style.overflow='hidden';surface.classList.add('embedded-expanded');surface.setAttribute('role','dialog');surface.setAttribute('aria-modal','true');surface.setAttribute('aria-label','Live application preview');current.expand.textContent='Collapse';
44
+ }
45
+ setView(current,mode);current.workspace.querySelector('[data-view="'+mode+'"]').focus({preventScroll:true});
46
+ if(current.record.contextual)requestAnimationFrame(()=>{if(current.expanded&&live(current.record,current.component))current.items.forEach(item=>contextProbe(item,current.record,current.record.finding,'highlight'))});
47
+ }
48
+ function renderPreviewBadges(group,record,role){const values=role==='original'?[record.historical?'Current source':'Original']:record.historical?['No candidate']:candidateStatus(record).split(' · ').map(value=>value.replace('validation: Not run','Validation: Not run').replace(/^Not run$/,'Validation: Not run'));group.replaceChildren(...values.map(value=>{const badge=el('span',value,'preview-badge');badge.dataset.status=value;return badge}))}
49
+ function candidateStatus(record){if(record.preparation?.state==='failed')return 'Preview preparation failed · validation: '+(record.validation||'Not run');if(['waiting','preparing'].includes(record.preparation?.state))return 'Preparing isolated preview · '+(record.decision||'Pending')+' · validation: '+(record.validation||'Not run');if(record.preparation?.state==='unsupported')return 'Preview unavailable · validation: '+(record.validation||'Not run');if(!record.session)return 'No candidate prepared · validation: Not run';return 'Preview ready · '+(record.decision==='Accepted'?'Accepted':record.decision==='Pending'||!record.decision?'Pending approval':record.decision)+' · Validation: '+(record.validation||'Not run')}
50
+ function syncControls(current){
51
+ current.component.querySelectorAll('[data-direction]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.direction===current.record.mode)));
52
+ current.workspace.querySelector('[aria-label="Preview viewport"]').value=String(current.record.viewport);for(const [mode,label] of [['before','Current source'],['after','No candidate'],['split','Split']])current.workspace.querySelector('[data-view="'+mode+'"]').textContent=current.record.historical?label:mode[0].toUpperCase()+mode.slice(1);
53
+ current.items[0].panel.querySelector('.preview-identity').textContent='Before';current.items[1].panel.querySelector('.preview-identity').textContent='After';current.items.forEach(item=>renderPreviewBadges(item.panel.querySelector('.preview-status'),current.record,item.role));
54
+ }
55
+ function syncRoute(current){
56
+ if(current.record.contextual){const route=current.record.contextInfo?.route,verified=current.items.some(item=>['verified','document'].includes(item.state.dataset.contextStatus));const actual=current.items.find(item=>item.currentRoute)?.currentRoute;const label=route?'Route: '+(current.record.historical?'Current source ':'')+(actual||route.path)+' · '+(verified?'Verified target':'Configured · target unverified'):'Route: Unverified · no mapping';setText(current.workspace.querySelector('.preview-current-route'),label);const compact=current.component.querySelector('.component-toolbar > span');if(compact)setText(compact,label);return}
57
+ const route=current.items.find(item=>item.currentRoute)?.currentRoute;const label='Route: '+(route||'Unverified');setText(current.workspace.querySelector('.preview-current-route'),label);const compact=current.component.querySelector('.component-toolbar > span');if(compact)setText(compact,label);
58
+ }
59
+ function removeView(){if(view){closeWorkspace(view);clearInterval(view.poll);for(const item of view.items){clearTimeout(item.timeout);item.observer.disconnect()}view=null}}
60
+ function choose(id){selected=null;removeView();document.querySelectorAll('.component-review iframe').forEach(frame=>frame.remove())}
61
+ function makeView(record,f){
62
+ const component=document.querySelector('.component-review');if(!component)return null;
63
+ if(view?.component===component&&view.record===record){syncControls(view);return view}
64
+ removeView();component.querySelectorAll('.preview-diagnostic').forEach(node=>node.remove());component.querySelector('.preview-workspace-toolbar')?.remove();component.querySelectorAll('.context-preview-controls,.preview-context-summary').forEach(node=>node.remove());
65
+ const helper=component.querySelector('.component-helper');if(helper&&!helper.closest('.preview-diagnostics')){const diagnostics=el('details','','preview-diagnostics');diagnostics.append(el('summary','Preview diagnostics'));helper.before(diagnostics);diagnostics.append(helper);helper.textContent='Live owning-route preview · original / isolated candidate. Review and technical validation are separate.';}
66
+ const result={record,component,items:[],poll:null};
67
+ for(const [role,selector] of [['original','.component-before'],['candidate','.component-after']]){
68
+ const panel=component.querySelector(selector);panel.querySelectorAll('p,.embedded-viewport').forEach(n=>n.remove());
69
+ const heading=panel.querySelector('h3');heading.replaceChildren(el('span',role==='original'?'Before':'After','preview-identity'),el('span','','preview-status'));renderPreviewBadges(heading.querySelector('.preview-status'),record,role);
70
+ const expandFrame=el('button','⛶','preview-frame-expand');expandFrame.type='button';expandFrame.setAttribute('aria-label',role==='original'?'Expand original preview':'Expand candidate preview');expandFrame.title=expandFrame.getAttribute('aria-label');expandFrame.onclick=()=>openWorkspace(result,role==='original'?'before':'after',expandFrame);heading.append(expandFrame);
71
+ const state=el('p',role==='original'?'Checking original application…':'Apply & Preview to load the isolated candidate.','embedded-state');state.setAttribute('role','status');state.dataset.state='idle';
72
+ const box=el('div','','embedded-viewport');panel.append(state,box);
73
+ const diagnostic=el('p','','preview-diagnostic');diagnostic.setAttribute('aria-label',role==='original'?'Before preview evidence':'After preview evidence');component.querySelector('.preview-diagnostics')?.append(diagnostic);const item={role,panel,state,box,diagnostic,frame:null,nonce:null,url:null,timeout:null,ready:null};
74
+ item.observer=new ResizeObserver(()=>resize(item,record));item.observer.observe(box);result.items.push(item);
75
+ }
76
+ const toolbar=component.querySelector('.component-toolbar');
77
+ const direction=mode=>{if(record.mode===mode&&!result.items.some(item=>item.contextReport&&item.contextReport.dir!==mode))return;record.mode=mode;syncControls(result);routes(record,f,result)};
78
+ for(const mode of ['ltr','rtl']){const button=[...toolbar.querySelectorAll('button')].find(b=>b.textContent===mode.toUpperCase());if(button){button.disabled=false;button.dataset.direction=mode;button.onclick=()=>direction(mode)}}
79
+ const viewport=[...toolbar.querySelectorAll('button')].find(b=>['Desktop','Tablet','Mobile'].includes(b.textContent));
80
+ const setViewport=value=>{record.viewport=value;if(viewport)viewport.textContent=['Desktop','Tablet','Mobile'][value];syncControls(result);result.items.forEach(item=>resize(item,record))};
81
+ if(viewport){viewport.disabled=false;viewport.textContent=['Desktop','Tablet','Mobile'][record.viewport];viewport.onclick=()=>setViewport((record.viewport+1)%3)}
82
+ const expand=[...toolbar.querySelectorAll('button')].find(b=>['Expand','Collapse'].includes(b.textContent));result.expand=expand;if(expand){expand.disabled=false;expand.onclick=()=>result.expanded?closeWorkspace(result):openWorkspace(result,'split',expand)}
83
+ const workspace=el('div','','preview-workspace-toolbar');result.workspace=workspace;
84
+ const views=el('div','','preview-view-options');views.setAttribute('role','group');views.setAttribute('aria-label','Preview view');
85
+ for(const mode of ['before','after','split']){const b=el('button',mode[0].toUpperCase()+mode.slice(1));b.dataset.view=mode;b.onclick=()=>setView(result,mode);views.append(b)}
86
+ const route=el('span','Route: Unverified','preview-current-route');
87
+ const directions=el('div','','preview-direction-options');directions.setAttribute('role','group');directions.setAttribute('aria-label','Preview direction');
88
+ for(const mode of ['ltr','rtl']){const b=el('button',mode.toUpperCase());b.dataset.direction=mode;b.onclick=()=>direction(mode);directions.append(b)}
89
+ const device=document.createElement('select');device.setAttribute('aria-label','Preview viewport');['Desktop / Auto','Tablet · 768 × 850','Mobile · 390 × 850'].forEach((label,index)=>device.append(new Option(label,String(index))));device.onchange=()=>setViewport(Number(device.value));
90
+ const close=el('button','Close','preview-workspace-close');close.onclick=()=>closeWorkspace(result);workspace.append(views,route,directions,device,close);component.prepend(workspace);syncControls(result);
91
+ result.poll=setInterval(()=>{if(!live(record,component))return;for(const item of result.items)probe(item,record,f)},250);
92
+ view=result;return result;
93
+ }
94
+ function resize(item,record){if(!item.frame)return;const width=[1280,768,390][record.viewport],height=850,expanded=item.panel.closest('.embedded-expanded');if(expanded){Object.assign(item.frame.style,{width:record.viewport?width+'px':'100%',height:record.viewport?height+'px':'100%',transform:'none'});item.box.style.height='';item.box.dataset.viewport=record.viewport?String(width):'auto';return}const scale=Math.min(1,(item.box.clientWidth||300)/width);Object.assign(item.frame.style,{width:width+'px',height:height+'px',transform:'scale('+scale+')',transformOrigin:'top left'});item.box.style.height=Math.ceil(height*scale)+'px';item.box.dataset.viewport=String(width)}
95
+ function probe(item,record,f){if(record.contextual)return contextProbe(item,record,f);if(!item.frame||!item.nonce)return;item.frame.contentWindow?.postMessage({type:'rtl-preview-probe',version:1,nonce:item.nonce,role:item.role,sessionId:record.session?.id||'before-only',runtimeSessionId:item.role==='original'?'original':record.session.id,findingId:f.id,sourcePath:f.path,expectedSha256:item.expectedHash,...(record.workflowId?{projectRoot:item.role==='original'?record.projectRoot:record.session.candidateRoot}:{})},new URL(item.url).origin)}
96
+ function load(item,url,record,f,hash){
97
+ if(!originAllowed(url,item.role))throw Error('UNAPPROVED_PREVIEW_ORIGIN');
98
+ if(item.url===url&&item.expectedHash===hash&&item.frame&&(!record.contextual||item.loadedRuntimeSessionId===item.context?.runtimeSessionId)&&(!record.contextual||!item.contextReport||item.contextReport.dir===record.mode)&&(item.role==='original'||item.runtimeSessionId===record.session?.id)){item.frame.dataset.sessionId=record.session?.id||'before-only';return}
99
+ clearTimeout(item.timeout);item.ready=null;item.contextReport=null;item.lastVerifiedReport=null;item.url=url;item.currentRoute=new URL(url).pathname;item.expectedHash=hash;item.runtimeSessionId=record.session?.id;item.loadedRuntimeSessionId=item.context?.runtimeSessionId;item.nonce=crypto.randomUUID();
100
+ item.state.textContent='Loading live '+item.role+' route…';item.state.dataset.state='loading';
101
+ const pending=()=>{clearTimeout(item.timeout);item.ready=null;item.state.dataset.state='loading';if(record.contextual)item.state.dataset.contextStatus='loading-route';item.state.textContent='Checking the live application and current contextual target…';item.timeout=setTimeout(()=>{if(live(record,item.box)&&!item.ready){item.state.textContent=item.contextReport?item.state.textContent:'Embedding blocked or local preview bridge unavailable. Retry context or restart the scoped application runtime.';item.state.dataset.state='error';if(record.contextual){if(!item.contextReport)item.state.dataset.contextStatus='runtime-unavailable';updateCandidateAction(view)}}},12000)};
102
+ const frame=document.createElement('iframe');frame.title=item.role==='original'?(record.historical?'Current source: application route':'Before: original application route'):'After: isolated candidate application route';frame.dataset.findingId=f.id;frame.dataset.sessionId=record.session?.id||'before-only';frame.setAttribute('sandbox','allow-scripts allow-same-origin allow-forms');if(record.contextual)frame.name='rtl-preview:'+record.dataId;frame.src=url;item.frame=frame;item.box.replaceChildren(frame);resize(item,record);frame.onload=()=>{pending();probe(item,record,f)};
103
+ pending();
104
+ }
105
+ ${contextualPreviewClientSource}
106
+ async function routes(record,f,current){
107
+ if(record.contextual)return contextRoutes(record,f,current);
108
+ if(!current||!live(record,current.component))return;
109
+ const token=(record.routeToken||0)+1;record.routeToken=token;
110
+ try{
111
+ const query=new URLSearchParams({mode:record.mode,...(record.session&&record.patched?{session:record.session.id,findingId:f.id}:{})});
112
+ const info=await request(record.workflowId?'/review/workflows/'+record.workflowId+'/preview?'+new URLSearchParams({mode:record.mode,findingId:f.id}):'/mappings/'+encodeURIComponent(f.previewMappingId)+'/preview?'+query);
113
+ if(!live(record,current.component)||record.routeToken!==token)return;
114
+ const before=current.items[0],after=current.items[1];
115
+ if(info.originalAvailable)load(before,info.originalUrl,record,f,info.originalSourceSha256);else{before.box.replaceChildren();before.frame=null;before.state.textContent='Original application unavailable. Start the local original preview runtime.';before.state.dataset.state='error'}
116
+ if(record.runtime?.runtime?.status==='healthy'){
117
+ if(info.candidateSessionId!==record.session.id||info.findingId!==f.id||!info.candidateOrigin)throw Error('PREVIEW_SESSION_IDENTITY_MISMATCH');
118
+ load(after,info.url,record,f,info.candidateSourceSha256);
119
+ // Secondary external links always point to this exact candidate and direction.
120
+ const routeButtons=current.component.querySelectorAll('.route-actions button');routeButtons.forEach((b,index)=>{b.disabled=false;b.onclick=async()=>{try{const route=await request(record.workflowId?'/review/workflows/'+record.workflowId+'/preview?'+new URLSearchParams({mode:index===0?'ltr':'rtl',findingId:f.id}):'/mappings/'+encodeURIComponent(f.previewMappingId)+'/preview?'+new URLSearchParams({mode:index===0?'ltr':'rtl',session:record.session.id,findingId:f.id}));if(live(record,current.component)&&route.candidateSessionId===record.session.id&&originAllowed(route.url,'candidate'))window.open(route.url,'_blank','noopener,noreferrer')}catch(error){status(record,error.message)}}});
121
+ }
122
+ }catch(error){if(live(record,current.component)){for(const item of current.items){item.state.textContent=error.message==='COMPANION_UNAVAILABLE'?'Companion unavailable. Retry connection.':'Preview route unavailable: '+error.message;item.state.dataset.state='error'}}}
123
+ }
124
+ window.addEventListener('message',event=>{
125
+ if(!view||view.record.contextual||selected!==view.record.key)return;const record=view.record,p=event.data;
126
+ for(const item of view.items){
127
+ if(!item.frame||event.source!==item.frame.contentWindow||event.origin!==new URL(item.url).origin||!p||p.type!=='rtl-preview-status'||p.version!==1||p.nonce!==item.nonce||p.role!==item.role||p.sessionId!==(record.session?.id||'before-only')||p.runtimeSessionId!==(item.role==='original'?'original':record.session?.id)||p.findingId!==record.finding.id||p.sourcePath!==record.finding.path||p.sourceSha256!==item.expectedHash||(record.workflowId&&p.projectRoot!==(item.role==='original'?record.projectRoot:record.session.candidateRoot))||p.dir!==record.mode||!Array.isArray(p.invoiceIds)||p.invoiceIds.length>100||p.invoiceIds.some(id=>typeof id!=='string'||id.length>100)||!Number.isInteger(p.bdiCount)||p.fixtureData!=='atlas-seed-v1')continue;
128
+ if(typeof p.route!=='string'||p.route.length>200||!/^\/[a-zA-Z0-9/_-]*$/.test(p.route))continue;item.currentRoute=p.route;syncRoute(view);
129
+ if(p.route!=='/invoices'){item.ready=null;clearTimeout(item.timeout);item.state.textContent='Live application · '+p.route+' · '+p.dir.toUpperCase()+' · '+(item.role==='original'?'Original':candidateStatus(record));item.state.dataset.state='navigated';continue}
130
+ if(!p.rendered)continue;
131
+ item.ready=p;clearTimeout(item.timeout);item.state.textContent='Ready · live route · '+p.dir.toUpperCase()+' · '+p.invoiceIds.length+' invoice rows'+(item.role==='candidate'?' · '+candidateStatus(record):'');item.state.dataset.state='ready';
132
+ }
133
+ const [before,after]=view.items;if(before.ready&&after.ready&&JSON.stringify(before.ready.invoiceIds)!==JSON.stringify(after.ready.invoiceIds)){for(const item of view.items){item.state.dataset.state='error';item.state.textContent='Preview data mismatch. Reload the local seed fixtures.'}}
134
+ });
135
+ async function apply(record,f,payload,button,current){
136
+ if(record.busy)return;record.busy=true;button.disabled=true;
137
+ try{
138
+ if(!record.session){record.session=await request('/review/sessions',{method:'POST'});sessionStorage.setItem('rtl-preview:'+record.key,record.session.id)}
139
+ if(!record.patched){const saved=await request('/review/sessions/'+record.session.id);if(saved.candidateSha256){if(saved.findingId!==f.id||saved.originalSha256!==payload.sourceSha256)throw Error('PREVIEW_SESSION_IDENTITY_MISMATCH');record.patched={candidateSha256:saved.candidateSha256}}}
140
+ if(!record.patched){const patched=await request('/review/sessions/'+record.session.id+'/patch',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(payload.patch)});record.patched=patched;}
141
+ const diff=await request('/review/sessions/'+record.session.id+'/diff');if(diff.state!=='ready'||diff.candidateSessionId!==record.session.id||diff.path!==f.path||diff.after!==payload.patch.replacement)throw Error(diff.reason||'CANDIDATE_DIFF_UNAVAILABLE');record.diff=diff;
142
+ status(record,'Verified isolated candidate created. Starting preview…');
143
+ record.runtime=await request('/review/sessions/'+record.session.id+'/runtime/start',{method:'POST'});if(record.runtime.runtime?.status!=='healthy')throw Error(record.runtime.runtime?.error||'CANDIDATE_RUNTIME_FAILED');
144
+ reviewSession={...record.session,...record.patched,...record.runtime};
145
+ status(record,'Candidate preview is running. Original source remains unchanged.');
146
+ if(live(record,button)){button.textContent='Open candidate preview';button.title='Refresh the same embedded candidate preview';await routes(record,f,current)}
147
+ }catch(error){status(record,(error.message==='COMPANION_UNAVAILABLE'?'Companion unavailable: ':'Candidate startup failed: ')+error.message);if(live(record,button)){button.textContent='Retry candidate preview';const after=current.items[1];after.state.textContent='Candidate startup failed: '+error.message;after.state.dataset.state='error'}}
148
+ finally{record.busy=false;if(live(record,button))button.disabled=false}
149
+ }
150
+ function configure(f,payload){
151
+ const identity=key(f);selected=identity;let record=records.get(identity);if(!record){record={key:identity,mode:'ltr',viewport:0,session:null,patched:null,runtime:null,busy:false,finding:f};records.set(identity,record)}
152
+ if(payload.workflow){record.contextual=true;const dataKey='rtl-context-data:'+d.inputDigest;record.dataId=sessionStorage.getItem(dataKey)||crypto.randomUUID();sessionStorage.setItem(dataKey,record.dataId);const w=payload.workflow;if(record.workflowId!==w.id||(record.session?.id||null)!==(w.state==='Reviewing'?w.session?.id||null:null)){if(view?.record===record)removeView();record.preparation=null;}record.workflowId=w.id;record.projectRoot=w.root;record.historical=w.state!=='Reviewing';record.workflowState=w.state;record.session=record.historical?null:w.session||null;record.entryApplied=!record.historical&&!!w.entries.find(e=>e.finding.id===f.id)?.applied;record.decision=record.historical?'Pending':w.entries.find(e=>e.finding.id===f.id)?.decision||'Pending';record.manualPrepare=payload.onApply;record.validation=record.historical?'Not run':w.validationPresentation?.status||'Not run';record.patched=!record.historical&&w.session?{candidateSha256:w.session.candidateSha256}:null;record.runtime=!record.historical&&w.session?.runtime?.status==='healthy'?{runtime:w.session.runtime}:null}
153
+ const component=document.querySelector('.component-review'),card=document.querySelector('.decision-card');if(!component||!card)return;
154
+ let button=card.querySelector('[data-candidate-action]')||[...card.querySelectorAll('button')].find(b=>['Apply & Preview','Prepare candidate','Open candidate preview','Retry candidate preview'].includes(b.textContent));if(!button&&!payload.workflow){button=el('button','Apply & Preview');card.append(button)}
155
+ if(payload.onRetryPreview)record.retryPreview=payload.onRetryPreview;
156
+ const current=makeView(record,f);
157
+ if(!record.contextual&&!record.runtime&&current.items[1].frame){const item=current.items[1];clearTimeout(item.timeout);item.box.replaceChildren();item.frame=null;item.ready=null;item.state.textContent='Candidate runtime unavailable.';item.state.dataset.state='idle'}
158
+ if(button&&!button.dataset.automaticPreview){button.disabled=record.busy;button.title='Apply verified patch to an isolated candidate and embed its live route';button.onclick=payload.onApply||(()=>apply(record,f,payload,button,current));if(record.runtime?.runtime?.status==='healthy'&&(!payload.workflow||capability(f)?.verified)&&(!payload.workflow||payload.workflow.entries.some(e=>e.finding.id===f.id&&e.applied)))button.textContent='Open candidate preview';}
159
+ routes(record,f,current);
160
+ const restored=payload.workflow||!button?null:sessionStorage.getItem('rtl-preview:'+identity);
161
+ if(restored&&!record.session){button.disabled=true;request('/review/sessions/'+encodeURIComponent(restored)).then(info=>{if(info.source!==f.path||info.originalSha256!==payload.sourceSha256||info.findingId!==f.id||!info.candidateSha256)throw Error('STALE_PREVIEW_SESSION');record.session=info;record.patched={candidateSha256:info.candidateSha256};record.runtime=info.runtime?.status==='healthy'?{id:info.id,runtime:info.runtime,candidateOrigin:info.runtime.origin}:null;if(live(record,button)){button.textContent=record.runtime?'Open candidate preview':'Retry candidate preview';routes(record,f,current)}}).catch(()=>sessionStorage.removeItem('rtl-preview:'+identity)).finally(()=>{if(live(record,button))button.disabled=false})}
162
+ }
163
+ const style=el('style');style.textContent="\n.component-frame:has(.embedded-state:not([data-context-status=verified])){background:#18283e!important;border-color:#4a627f!important;color:#c8d5e7!important}.component-frame:has(.embedded-state[data-state=error]){border-color:#c15b70!important}.after-card{background:#18283e!important;border-color:#4a627f!important}.after-card pre{color:#d1deef!important}\n.embedded-viewport{position:relative;overflow:hidden;width:100%;min-height:0;background:#fff;border-radius:5px}\n.embedded-viewport iframe{display:block;border:0;max-width:none!important;background:white}\n.embedded-state{margin:5px 0!important;min-height:25px}\n.component-frame{overflow:hidden}.component-after{background:#18283e!important;border-color:#4a627f!important;color:#dce7fb!important}.component-frame h3{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.preview-identity{font-size:12px}.preview-status{display:flex;gap:4px;flex-wrap:wrap;color:#b8c9df;font-size:10px;letter-spacing:0;text-transform:none;font-weight:500;flex:1}.preview-badge{border:1px solid #4a627f;border-radius:99px;padding:2px 6px;background:#182b44}.preview-badge[data-status=Passed]{color:#6fe4b2;border-color:#398668}.preview-badge[data-status=Failed]{color:#ff99a8;border-color:#a64b5a}.preview-badge[data-status~=Limited]{color:#ffd166;border-color:#987524}.component-frame h3 .context-instance{order:3;margin-left:auto}.component-frame h3 .preview-frame-expand{order:4}.context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{background:#142944;color:#c5d0e0;border:1px solid #405775;border-radius:5px;padding:4px 6px;font-size:10px}.preview-diagnostics{margin:4px 0;color:#b9c9df;font-size:10px}.preview-diagnostics summary{cursor:pointer}.component-review .component-helper{display:block!important}\n.component-review .component-compare{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)!important}\n.preview-frame-expand{flex:none;min-width:28px;min-height:26px;border:1px solid currentColor;border-radius:5px;background:transparent;color:inherit;font-size:19px;cursor:pointer}\n.preview-workspace-toolbar{display:none}\n.component-review.embedded-expanded{position:fixed!important;inset:0!important;width:auto!important;height:auto!important;max-height:none!important;z-index:10000;overflow:hidden!important;background:#0e1a2d!important;padding:8px!important;margin:0!important;border-radius:0!important;display:flex!important;flex-direction:column!important;box-sizing:border-box;gap:8px}\n.embedded-expanded>:not(.preview-workspace-toolbar):not(.component-compare){display:none!important}\n.embedded-expanded .preview-workspace-toolbar{display:flex;flex:none;align-items:center;gap:12px;flex-wrap:wrap;min-height:36px;color:#dce7fb;font-size:12px}\n.preview-workspace-toolbar button,.preview-workspace-toolbar select{min-height:32px;padding:5px 11px;border:1px solid #547297;border-radius:6px;background:#142944;color:#e9f0ff;font:inherit;cursor:pointer}\n.preview-workspace-toolbar button[aria-pressed=true]{background:#6641ae;border-color:#c5a6ff;color:white}\n.preview-view-options,.preview-direction-options{display:flex;gap:4px}\n.preview-current-route{flex:1;min-width:110px;overflow-wrap:anywhere}\n.preview-workspace-close{margin-left:auto;background:#392640!important;border-color:#bc8da9!important}\n.embedded-expanded .component-compare{flex:1;min-height:0;gap:8px;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}\n.embedded-expanded .component-arrow{display:none!important}\n.embedded-expanded .component-frame{min-height:0;padding:7px;gap:3px}\n.embedded-expanded .component-frame h3{flex:none;align-items:center;margin:0!important;min-height:26px;font-size:12px!important}\n.embedded-expanded .preview-frame-expand{display:none}\n.embedded-expanded .embedded-state{flex:none;min-height:16px;font-size:10px!important;margin:0 0 3px!important}\n.embedded-expanded .embedded-viewport{flex:1;min-height:0;height:auto;overflow:auto;overscroll-behavior:contain;border-radius:3px}\n.embedded-expanded[data-preview-view=before] .component-after,.embedded-expanded[data-preview-view=after] .component-before{display:none!important}\n.embedded-expanded[data-preview-view=before] .component-compare,.embedded-expanded[data-preview-view=after] .component-compare{grid-template-columns:minmax(0,1fr)!important}\n.context-preview-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.context-preview-controls select,.context-instance{max-width:260px;min-width:90px;border:1px solid #547297;border-radius:5px;background:#142944;color:#e9f0ff;font-size:11px;padding:4px}.context-instance{max-width:40%;min-width:70px}.preview-context-summary{color:#c8d4eb;font-size:11px;flex:1;min-width:150px}.preview-workspace-toolbar .context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{padding:4px 7px;font-size:11px}.preview-workspace-toolbar :focus-visible,.preview-frame-expand:focus-visible{outline:2px solid #dcc4ff;outline-offset:2px}@media(max-width:760px){.component-review:not(.embedded-expanded) .component-compare{grid-template-columns:minmax(0,1fr)!important}.component-review:not(.embedded-expanded) .component-arrow{transform:rotate(90deg);justify-self:center}}\n";document.head.append(style);
164
+ document.addEventListener('keydown',event=>{
165
+ if(!view?.expanded)return;
166
+ if(event.key==='Escape'){event.preventDefault();closeWorkspace();return}
167
+ if(event.key==='Tab'){
168
+ const controls=[...view.component.querySelectorAll('button,select,iframe')].filter(n=>!n.disabled&&n.getClientRects().length);
169
+ const first=controls[0],last=controls[controls.length-1];
170
+ if(event.shiftKey&&document.activeElement===first){event.preventDefault();last?.focus()}
171
+ else if(!event.shiftKey&&document.activeElement===last){event.preventDefault();first?.focus()}
172
+ }
173
+ });
174
+ document.addEventListener('focusin',event=>{if(view?.expanded&&!view.component.contains(event.target))view.workspace.querySelector('button').focus({preventScroll:true})});
175
+ window.addEventListener('popstate',()=>{const id=new URLSearchParams(location.search).get('finding');if(view&&id&&by.has(id)&&id!==view.record.finding.id){closeWorkspace();select(id)}});
176
+ // Browser history can replace the detail card without invoking the finding buttons.
177
+ new MutationObserver(()=>{if(view&&(!view.component.isConnected||view.expanded?.portal&&!view.expanded.placeholder.isConnected))removeView()}).observe(document.body,{childList:true,subtree:true});
178
+ function capability(f){
179
+ const r=records.get(key(f));if(!r||view?.record!==r)return null;const [before,after]=view.items,info=r.contextInfo,status=before.state.dataset.contextStatus;
180
+ const panelHidden=item=>!item.panel.getClientRects().length;
181
+ // Before/After-only fullscreen hides a whole iframe, not its mapped target. Preserve its verified node/runtime.
182
+ const verified=item=>!!item.frame&&item.contextReport?.route===info?.route?.path&&item.contextReport?.dir===r.mode&&((['verified','document'].includes(item.state.dataset.contextStatus)||item.state.dataset.contextStatus==='target-selection-required'&&item.contextReport?.routeReady&&['verified','document'].includes(item.contextReport?.targetStatus)&&(!info?.mapping.configured||!info.mapping.sourceSelector||item.contextReport.sourceStatus==='source-rule-matched'))||panelHidden(item)&&item.lastVerifiedReport?.nonce===item.nonce&&item.lastVerifiedReport?.routeId===r.routeId&&item.lastVerifiedReport?.dir===r.mode);
183
+ const proof=before.verifiedMapping,p=before.contextReport,bindingVerified=!!before.frame&&panelHidden(before)&&proof?.sourceHash===before.expectedHash&&proof?.routeId===r.routeId&&p?.route===info?.route?.path&&p?.dir===r.mode&&p?.routeReady&&p?.targets?.length>0&&(!info?.mapping.configured||!info.mapping.sourceSelector||p.sourceStatus==='source-rule-matched');
184
+
185
+ return {resolving:!!r.contextResolving,application:info?.route?.application,routeId:r.routeId,bindingVerified:!!bindingVerified,verified:!r.contextResolving&&!!info?.route&&before.contextReport?.routeId===r.routeId&&before.contextReport?.dir===r.mode&&verified(before),blocked:['mapping-missing','source-not-loaded','target-mismatch','missing-target','unresolved'].includes(status)||status==='hidden'&&!panelHidden(before),failed:before.state.dataset.state==='error'||status==='runtime-unavailable',reason:before.state.textContent,candidateAvailable:!!info?.candidate?.available,candidateReady:verified(after),candidateFailed:after.state.dataset.state==='error',candidateReason:after.state.textContent};
186
+ }
187
+ function preparation(f,value){
188
+ const record=records.get(key(f));if(!record||selected!==record.key||view?.record!==record)return;record.preparation=value;const current=view,after=current.items[1];after.state.dataset.preparationState=value.state;
189
+ current.component.querySelector('[data-preview-retry]')?.remove();if(value.state==='unsupported'&&['Rejected','Deferred','Flagged'].includes(record.decision)&&record.manualPrepare&&!record.historical){const reconsider=el('button','Reconsider preview');reconsider.dataset.previewRetry='true';reconsider.disabled=!!value.busy;reconsider.onclick=record.manualPrepare;after.state.after(reconsider);}if(value.state==='failed'){const button=el('button','Retry preview');button.dataset.previewRetry='true';button.disabled=!!value.busy;button.onclick=record.retryPreview;after.state.after(button);}
190
+ if(value.state!=='ready'){
191
+ if(['failed','unsupported'].includes(value.state)){clearTimeout(after.timeout);after.box.replaceChildren();after.frame=null;after.ready=null;clearContextTargets(after);after.state.dataset.state=value.state==='failed'?'error':'unavailable';}
192
+ if(!after.targetRestoreFailed)setText(after.state,value.state==='failed'?'Preview preparation failed: '+value.reason+'. Retry preview.':value.state==='unsupported'?'Preview unavailable: '+value.reason:value.reason||'Preparing isolated preview…');
193
+ }
194
+ syncControls(current);
195
+ }
196
+ function refresh(f){const record=records.get(key(f));if(record&&selected===record.key&&view?.record===record){record.preparation=null;routes(record,f,view);}}
197
+
198
+ return{configure,select:choose,capability,preparation,refresh};
199
+ })();
200
+ `;
@@ -1,7 +1,7 @@
1
1
  import { dashboardClientSource } from './dashboard-client.js';
2
2
  import { severityDisplayLabel, toDashboardData } from './dashboard-data.js';
3
3
  const escapeJson = (v) => v.replace(/[<>&\u2028\u2029]/g, c => ({ '<': '\\u003c', '>': '\\u003e', '&': '\\u0026', '\u2028': '\\u2028', '\u2029': '\\u2029' }[c] ?? c));
4
- const css = `:root{
4
+ const css = `.stats-toggle{background:linear-gradient(180deg,#8447ed,#4e1da0)!important;border:1px solid #bf92ff!important;border-radius:10px;color:#fff;padding:10px 15px;font-weight:800;white-space:nowrap}.summary[hidden]{display:none}.workflow-dialog{width:min(920px,calc(100vw - 32px));border:1px solid #8f63ed;border-radius:18px;background:linear-gradient(145deg,#172441,#0d1428);color:#f4f7ff;padding:34px;box-shadow:0 0 70px #6f3fd977}.workflow-dialog::backdrop{background:#040817cc}.workflow-dialog h1{text-align:center;font-size:32px;margin:0 0 8px}.workflow-dialog>p{text-align:center;color:#9aaac1;font-size:16px;margin:0 0 28px}.workflow-options{display:grid;grid-template-columns:1fr 1fr;gap:18px}.workflow-card{min-height:190px;border:1px solid #4b5f86;border-radius:15px;background:#121e37;color:#f4f7ff;padding:28px;text-align:left;font-size:20px;font-weight:850}.workflow-card:hover{border-color:#b383ff;background:linear-gradient(145deg,#3e256c,#161c3a);box-shadow:0 0 28px #8b5cf655}.details{border-top:1px solid #263c5d;max-height:none}:root{
5
5
  color-scheme:dark;
6
6
  --bg:#060d1a;--nav:#0a1426;--surface:#0e1a2e;--surface-hi:#14243c;--surface-soft:#101f35;
7
7
  --line:#263c5d;--line-soft:#1c304e;--text:#f4f7ff;--muted:#9aaac1;--dim:#70819b;
@@ -11,17 +11,18 @@ const css = `:root{
11
11
  }
12
12
  :where(.app){width:100%;max-width:100vw;min-width:0}:where(.top),:where(.nav),:where(.tools),:where(.search-wrap){min-width:0}
13
13
  .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important}}
14
- :root{--space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-5:20px;--space-6:24px;--text-sm:12px;--text-md:14px;--text-lg:18px;--surface-raised:#14243a;--surface-panel:#0f1d31;--border-strong:#395477;--status-ok:#3fe0a0;--status-warn:#ffd166;--status-bad:#ff7188}.card,.scope,.project{background:var(--surface-raised);box-shadow:0 4px 14px #0003}.workspace{background:var(--border-strong);box-shadow:0 8px 24px #0004}.head{font-size:var(--text-sm);color:#c2cee0}.finding strong{font-size:var(--text-md);font-weight:750}.finding small,.file,.meta,.filter-control,.filter-summary{font-size:var(--text-sm)}.details{font-size:var(--text-md)}.details p,.review-panel p,.review-workspace p,.validation-panel p,.audit-history p{color:#c0ccdd}.details h3{font-size:var(--text-sm);color:#aebed3}.actions button,.finding-filters>button{font-size:var(--text-sm);min-height:38px}.actions button{background:#5f35b5;border-color:#a98ae8;box-shadow:none}.actions button:hover:not(:disabled){background:#7447cf}.actions button:disabled{opacity:.48}.review-state,.apply-ready,.validation-state{color:var(--status-ok);font-weight:750}.review-blocked,.apply-blocked,.preview-unavailable{color:var(--status-warn)}.review-diff{padding:var(--space-4);border:1px solid var(--border-strong);border-radius:var(--r-sm);background:#070e19;color:#e9eef8;line-height:1.55;white-space:pre-wrap;overflow:auto}.screenshot-preview{display:inline-flex;vertical-align:top;flex-direction:column;gap:var(--space-2);width:min(220px,100%);margin:var(--space-2)}.screenshot-preview img{border:1px solid var(--border-strong);border-radius:var(--r-sm);background:#080f1b}.screenshot-preview figcaption{font-size:var(--text-sm);color:#c0ccdd}.audit-history details,.archived-evidence details,.validation-panel details{border:1px solid var(--line);border-radius:var(--r-sm);margin:var(--space-2) 0;background:#132238}.audit-history summary,.archived-evidence summary,.validation-panel summary{padding:var(--space-3);font-size:var(--text-sm);font-weight:750}.audit-grid,.evidence-grid{gap:var(--space-2);font-size:var(--text-sm)}.line.hit{box-shadow:inset 3px 0 #ffd166}.mobile-back{background:#29466f!important;border-color:#6d8fbd!important}
15
- @media(max-width:800px){.app{grid-template-rows:auto auto auto auto 1fr}.top{flex-wrap:wrap;min-height:118px;padding:10px 14px}.brand{min-width:0;flex:1;font-size:17px}.nav{order:3;width:100%;overflow:auto}.nav button{min-height:42px}.tools{width:100%;margin-left:0}.tools input{flex:1;width:auto}.finding-filters{display:flex;padding:0 10px 10px;align-items:stretch}.filter-control{flex:1 1 calc(50% - 8px);min-width:140px}.filter-control select,.finding-filters>button{width:100%;min-height:44px}.finding-filters>button{flex:1 1 100%}.filter-summary{width:100%;margin:0}.summary{grid-template-columns:repeat(2,1fr);padding:10px}.scope-row{padding:0 10px 10px}.scope{align-items:stretch;flex-wrap:wrap}.scope select{min-width:100%;min-height:44px}.projects{display:none}.workspace{display:flex;flex-direction:column;margin:0 10px 10px;border-radius:12px}.workspace>.pane:nth-child(1),.workspace>.pane:nth-child(2){display:none}.workspace>.pane:nth-child(3){order:1;height:420px}.workspace>.pane:nth-child(5){order:2;height:auto;min-height:520px}.workspace>.pane:nth-child(4){order:3;height:420px}.pane{width:100%}}
14
+ :root{--space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-5:20px;--space-6:24px;--text-sm:12px;--text-md:14px;--text-lg:18px;--surface-raised:#14243a;--surface-panel:#0f1d31;--border-strong:#395477;--status-ok:#3fe0a0;--status-warn:#ffd166;--status-bad:#ff7188}.card,.scope,.project{background:var(--surface-raised);box-shadow:0 4px 14px #0003}.workspace{background:var(--border-strong);box-shadow:0 8px 24px #0004}.head{font-size:var(--text-sm);color:#c2cee0}.finding strong{font-size:var(--text-md);font-weight:750}.finding small,.file,.meta,.filter-control,.filter-summary{font-size:var(--text-sm)}.details{font-size:var(--text-md)}.details p,.review-panel p,.review-workspace p,.validation-panel p,.audit-history p{color:#c0ccdd}.details h3{font-size:var(--text-sm);color:#aebed3}.actions button,.finding-filters>button{font-size:var(--text-sm);min-height:38px}.actions button{background:#5f35b5;border-color:#a98ae8;box-shadow:none}.actions button:hover:not(:disabled){background:#7447cf}.actions button:disabled{opacity:.48}.review-state,.apply-ready,.validation-state{color:var(--status-ok);font-weight:750}.review-blocked,.apply-blocked,.preview-unavailable{color:var(--status-warn)}.review-diff{padding:var(--space-4);border:1px solid var(--border-strong);border-radius:var(--r-sm);background:#070e19;color:#e9eef8;line-height:1.55;white-space:pre-wrap;overflow:auto}.screenshot-preview{display:inline-flex;vertical-align:top;flex-direction:column;gap:var(--space-2);width:min(220px,100%);margin:var(--space-2)}.screenshot-preview img{border:1px solid var(--border-strong);border-radius:var(--r-sm);background:#080f1b}.screenshot-preview figcaption{font-size:var(--text-sm);color:#c0ccdd}.audit-history details,.archived-evidence details,.validation-panel details{border:1px solid var(--line);border-radius:var(--r-sm);margin:var(--space-2) 0;background:#132238}.audit-history summary,.archived-evidence summary,.validation-panel summary{padding:var(--space-3);font-size:var(--text-sm);font-weight:750}.audit-grid,.evidence-grid{gap:var(--space-2);font-size:var(--text-sm)}.mobile-back{background:#29466f!important;border-color:#6d8fbd!important}
15
+ @media(max-width:800px){.app{grid-template-rows:auto auto auto auto 1fr}.top{flex-wrap:wrap;min-height:118px;padding:10px 14px}.brand{min-width:0;flex:1;font-size:17px}.nav{order:3;width:100%;overflow:auto}.nav button{min-height:42px}.tools{width:100%;margin-left:0}.tools input{flex:1;width:auto}.finding-filters{display:flex;padding:0 10px 10px;align-items:stretch}.filter-control{flex:1 1 calc(50% - 8px);min-width:140px}.filter-control select,.finding-filters>button{width:100%;min-height:44px}.finding-filters>button{flex:1 1 100%}.filter-summary{width:100%;margin:0}.summary{grid-template-columns:repeat(2,1fr);padding:10px}.scope-row{padding:0 10px 10px}.scope{align-items:stretch;flex-wrap:wrap}.scope select{min-width:100%;min-height:44px}.projects{display:none}.workspace{display:flex;flex-direction:column;margin:0 10px 10px;border-radius:12px}.pane{width:100%}}
16
16
  *{box-sizing:border-box}html,body{min-width:0;overflow-x:hidden}body{margin:0;background:radial-gradient(900px 420px at 52% -12%,#1b3155 0%,var(--bg) 64%);color:var(--text);line-height:1.4}button,input,select{font:inherit;max-width:100%}button{cursor:pointer}button:disabled{cursor:not-allowed}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
17
- .app{min-height:100vh;display:grid;grid-template-rows:72px auto auto 1fr;gap:0}.top{display:flex;align-items:center;gap:22px;padding:10px 26px;border-bottom:1px solid var(--line-soft);background:linear-gradient(180deg,#0d192c,#091426);box-shadow:0 8px 26px #0005}.brand{position:relative;min-width:360px;padding-left:51px;font-size:20px;font-weight:850;letter-spacing:-.02em;white-space:nowrap}.brand:before{content:'RTL';position:absolute;left:0;top:-1px;display:grid;place-items:center;width:39px;height:39px;border-radius:10px;background:linear-gradient(145deg,#a855f7,#4c1d95);box-shadow:0 0 22px #8b5cf655;color:#fff;letter-spacing:0}.brand small{display:block;margin-top:2px;color:var(--muted);font-size:11px;font-weight:500;letter-spacing:0}.nav{display:flex;align-items:center;gap:7px}.nav button{border:1px solid transparent;border-radius:10px;background:transparent;color:#b0bdd0;padding:11px 15px;font-size:14px;font-weight:800;white-space:nowrap;transition:.15s ease}.nav button:not(:disabled):hover{background:#1b2b47;color:#fff;border-color:var(--line)}.nav .active{background:linear-gradient(180deg,#8447ed,#4e1da0);color:#fff;border-color:#bf92ff;box-shadow:0 0 24px #8b5cf677,inset 0 1px #e2cdff}.nav .disabled{opacity:.42}.tools{display:flex;align-items:center;gap:12px;margin-left:auto}.search-wrap{display:flex;align-items:center;border:1px solid #334b70;border-radius:10px;background:#07111f;padding:0 10px;box-shadow:inset 0 1px #ffffff08}.search-wrap span{color:var(--muted);font-size:19px}.tools input{width:190px;border:0;outline:0;background:transparent;color:var(--text);padding:10px 7px}.tools input::placeholder{color:#8090a7}.status{color:var(--green);font-size:11px;font-weight:900;letter-spacing:.04em;white-space:nowrap}.status.warn{color:var(--amber)}
17
+ .app{min-height:100vh;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:72px auto auto 1fr;gap:0}.top{display:flex;align-items:center;gap:22px;padding:10px 26px;border-bottom:1px solid var(--line-soft);background:linear-gradient(180deg,#0d192c,#091426);box-shadow:0 8px 26px #0005}.brand{position:relative;min-width:360px;padding-left:51px;font-size:20px;font-weight:850;letter-spacing:-.02em;white-space:nowrap}.brand:before{content:'RTL';position:absolute;left:0;top:-1px;display:grid;place-items:center;width:39px;height:39px;border-radius:10px;background:linear-gradient(145deg,#a855f7,#4c1d95);box-shadow:0 0 22px #8b5cf655;color:#fff;letter-spacing:0}.brand small{display:block;margin-top:2px;color:var(--muted);font-size:11px;font-weight:500;letter-spacing:0}.nav{display:flex;align-items:center;gap:7px}.nav button{border:1px solid transparent;border-radius:10px;background:transparent;color:#b0bdd0;padding:11px 15px;font-size:14px;font-weight:800;white-space:nowrap;transition:.15s ease}.nav button:not(:disabled):hover{background:#1b2b47;color:#fff;border-color:var(--line)}.nav .active{background:linear-gradient(180deg,#8447ed,#4e1da0);color:#fff;border-color:#bf92ff;box-shadow:0 0 24px #8b5cf677,inset 0 1px #e2cdff}.nav .disabled{opacity:.42}.tools{display:flex;align-items:center;gap:12px;margin-left:auto}.search-wrap{display:flex;align-items:center;border:1px solid #334b70;border-radius:10px;background:#07111f;padding:0 10px;box-shadow:inset 0 1px #ffffff08}.search-wrap span{color:var(--muted);font-size:19px}.tools input{width:190px;border:0;outline:0;background:transparent;color:var(--text);padding:10px 7px}.tools input::placeholder{color:#8090a7}.status{color:var(--green);font-size:11px;font-weight:900;letter-spacing:.04em;white-space:nowrap}.status.warn{color:var(--amber)}
18
18
  .summary{display:grid;grid-template-columns:1.35fr .85fr .9fr .9fr .9fr .95fr 1.75fr;gap:10px;padding:14px 18px 12px}.card{min-height:82px;border:1px solid var(--line);border-radius:var(--r-md);background:linear-gradient(145deg,#152640,#0d182b);padding:13px 15px;box-shadow:0 8px 26px #0003,inset 0 1px #ffffff08}.workspace-card{display:flex;align-items:center;gap:13px;position:relative}.workspace-icon{font-size:32px;color:#bd77ff;text-shadow:0 0 16px #9a63ff99}.workspace-card strong{font-size:18px}.workspace-card span{display:block}.workspace-secondary{display:block!important;margin-top:3px;color:var(--dim)!important;font-size:10px!important}.workspace-status{display:inline-block!important;margin-top:5px;border-radius:99px;padding:3px 9px;background:#0d6a4b;color:#d9fff0!important;font-size:10px!important;font-weight:800}.card strong{display:block;font-size:27px;line-height:1.05;letter-spacing:-.02em}.card span{color:var(--muted);font-size:11px}.card.green{border-color:#197c55;background:linear-gradient(145deg,#12372f,#0d1d2b)}.card.blue{border-color:#225f99}.card.red{border-color:#933047;background:linear-gradient(145deg,#341629,#111a2b)}.severity-card{min-height:82px}.severity-card strong{font-size:24px}.severity-card span{font-size:11px}.severity-card.red{border-color:#8b2945}.severity-card.amber{border-color:#836020;background:linear-gradient(145deg,#342a1b,#151e2c)}.severity-card.blue{border-color:#225d96;background:linear-gradient(145deg,#122d4c,#101d2f)}.severity-chart{display:flex;align-items:center;justify-content:center;gap:18px;padding:8px 14px}.donut{position:relative;width:82px;height:82px;flex:0 0 auto;border-radius:50%;background:conic-gradient(var(--red) 0 var(--major),var(--amber) var(--major) var(--minor),var(--blue) var(--minor) 100%);display:grid;place-items:center;box-shadow:0 0 20px #0006}.donut:after{content:'';position:absolute;width:53px;height:53px;border-radius:50%;background:#101d31;box-shadow:inset 0 0 0 1px #ffffff0b}.legend{font-size:11px;line-height:1.95;min-width:125px}.legend i{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:7px}.legend .r{background:var(--red);box-shadow:0 0 7px var(--red)}.legend .a{background:var(--amber);box-shadow:0 0 7px var(--amber)}.legend .b{background:var(--blue);box-shadow:0 0 7px var(--blue)}
19
19
  .scope-row{display:grid;grid-template-columns:1.1fr 2.2fr;gap:10px;padding:0 18px 13px}.scope,.project{border:1px solid var(--line);border-radius:var(--r-md);background:linear-gradient(145deg,#14243b,#0d182a);box-shadow:0 7px 22px #0003}.scope{display:flex;align-items:center;gap:14px;padding:12px 15px}.scope-icon{font-size:29px;color:#c07bff;text-shadow:0 0 12px #9a63ff88}.scope h2{margin:0;font-size:16px}.scope p{margin:2px 0;color:var(--muted);font-size:11px}.scope select{flex:1;min-width:190px;background:#07111f;color:var(--text);border:1px solid var(--purple);border-radius:9px;padding:10px;box-shadow:0 0 0 2px #8b5cf622}.projects{display:flex;gap:8px;overflow:auto}.project{min-width:145px;padding:10px 13px;border-color:transparent;color:var(--text);text-align:left}.project:not(:disabled):hover{border-color:#8558df}.project.active{background:linear-gradient(180deg,#7137c9,#421b8c);border-color:#b99cff;box-shadow:0 0 18px #8b5cf655}.project strong,.project span{display:block}.project strong{font-size:13px}.project span{color:var(--muted);font-size:10px}.project:disabled{opacity:.58}
20
- .workspace{min-height:0;display:grid;grid-template-columns:205px 235px 300px minmax(430px,1fr) 320px;gap:1px;background:var(--line);margin:0 18px 17px;border:1px solid var(--line);border-radius:var(--r-lg);overflow:hidden;box-shadow:0 12px 34px #0004}.pane{min-width:0;min-height:0;background:var(--surface)}.head{height:45px;padding:0 14px;display:flex;align-items:center;background:linear-gradient(180deg,#172840,#142239);border-bottom:1px solid var(--line);font-size:10px;font-weight:900;letter-spacing:.1em;color:#a7b5c9}.scroll{height:calc(100% - 45px);overflow:auto}.side{padding:10px;background:linear-gradient(180deg,#122139,#0e1b2e)}.side button{display:block;width:100%;margin-bottom:5px;padding:11px;border:1px solid transparent;border-radius:9px;background:transparent;color:#b6c2d4;text-align:left;font-size:13px;font-weight:750}.side button.active{background:linear-gradient(180deg,#7137c9,#421b8c);color:#fff;border-color:#bd91ff;box-shadow:0 0 15px #8b5cf655}.side button.disabled{opacity:.35}.tree{padding:9px}.folder>summary{cursor:pointer;padding:6px;color:#aebbd0;list-style:none;font-weight:800}.folder>summary::-webkit-details-marker{display:none}.folder>summary:before{content:'▸';display:inline-block;width:17px;color:#8799b3}.folder[open]>summary:before{content:'▾'}.file,.finding{display:flex;width:100%;gap:8px;align-items:center;text-align:left;background:transparent;color:var(--text);border:1px solid transparent;border-radius:8px;padding:8px}.file:hover,.file.selected,.finding:hover,.finding.selected{background:#29466f;border-color:#9562ed;box-shadow:inset 3px 0 #c098ff}.file{font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.count{margin-left:auto;color:#9fb0c8}.finding-list{padding:9px}.finding{display:block;margin-bottom:8px}.finding strong{display:block;font-size:13px;line-height:1.28}.finding small{display:block;margin-top:5px;color:var(--muted);font-size:10px}.code{height:calc(100% - 45px);display:flex;flex-direction:column}.meta{padding:10px 14px;border-bottom:1px solid var(--line);color:#aab8cc;background:#0c1829;font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.code-scroll{overflow:auto;flex:1;background:var(--code);padding:17px 0}.line{display:grid;grid-template-columns:58px 1fr;font:13px/1.8 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;color:#e6ebf5}.no{color:#657892;text-align:right;padding-right:15px;border-right:1px solid #1c2d45}.text{padding:0 17px}.line.hit{background:linear-gradient(90deg,#4c3716,#3d2d15 75%,transparent);box-shadow:inset 3px 0 #e5a82f}.details{padding:18px;background:linear-gradient(180deg,#101e32,#0d1829)}.details h2{margin:0 0 15px;font-size:19px;line-height:1.25}.details h3{margin:17px 0 4px;color:#91a2ba;font-size:10px;text-transform:uppercase;letter-spacing:.08em}.actions{display:flex;gap:7px;flex-wrap:wrap}.actions button{background:linear-gradient(180deg,#7440d1,#4f209c);border:1px solid #a477f5;border-radius:7px;color:#fff;padding:8px 10px;font-size:11px;font-weight:750;box-shadow:0 5px 12px #0003}.empty{padding:22px;color:var(--muted)}.rtl-value{unicode-bidi:isolate;direction:auto}
20
+ .workspace{min-width:0;min-height:0;display:grid;gap:1px;background:var(--line);margin:0 18px 17px;border:1px solid var(--line);border-radius:var(--r-lg);overflow:hidden;box-shadow:0 12px 34px #0004}.pane{min-width:0;min-height:0;background:var(--surface)}.head{height:45px;padding:0 14px;display:flex;align-items:center;background:linear-gradient(180deg,#172840,#142239);border-bottom:1px solid var(--line);font-size:10px;font-weight:900;letter-spacing:.1em;color:#a7b5c9}.scroll{height:calc(100% - 45px);overflow:auto}.tree{padding:9px}.folder>summary{cursor:pointer;padding:6px;color:#aebbd0;list-style:none;font-weight:800}.folder>summary::-webkit-details-marker{display:none}.folder>summary:before{content:'▸';display:inline-block;width:17px;color:#8799b3}.folder[open]>summary:before{content:'▾'}.file,.finding{display:flex;width:100%;gap:8px;align-items:center;text-align:left;background:transparent;color:var(--text);border:1px solid transparent;border-radius:8px;padding:8px}.file:hover,.file.selected,.finding:hover,.finding.selected{background:#29466f;border-color:#9562ed;box-shadow:inset 3px 0 #c098ff}.file{font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.count{margin-left:auto;color:#9fb0c8}.finding-list{padding:9px}.finding{display:block;margin-bottom:8px}.finding strong{display:block;font-size:13px;line-height:1.28}.finding small{display:block;margin-top:5px;color:var(--muted);font-size:10px}.code{height:calc(100% - 45px);display:flex;flex-direction:column}.meta{padding:10px 14px;border-bottom:1px solid var(--line);color:#aab8cc;background:#0c1829;font:12px ui-monospace,SFMono-Regular,Menlo,monospace}.code-scroll{overflow:auto;flex:1;background:var(--code);padding:17px 0}.line{display:grid;grid-template-columns:58px 1fr;font:13px/1.8 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;color:#e6ebf5}.no{color:#657892;text-align:right;padding-right:15px;border-right:1px solid #1c2d45}.text{padding:0 17px}.line.hit{background:linear-gradient(90deg,#483073,#352654 75%,transparent);box-shadow:inset 3px 0 #b189ef}.details{padding:18px;background:linear-gradient(180deg,#101e32,#0d1829)}.details h2{margin:0 0 15px;font-size:19px;line-height:1.25}.details h3{margin:17px 0 4px;color:#91a2ba;font-size:10px;text-transform:uppercase;letter-spacing:.08em}.actions{display:flex;gap:7px;flex-wrap:wrap}.actions button{background:linear-gradient(180deg,#7440d1,#4f209c);border:1px solid #a477f5;border-radius:7px;color:#fff;padding:8px 10px;font-size:11px;font-weight:750;box-shadow:0 5px 12px #0003}.empty{padding:22px;color:var(--muted)}.rtl-value{unicode-bidi:isolate;direction:auto}
21
21
  .finding-filters{display:flex;align-items:end;gap:8px;flex-wrap:wrap;min-width:0;padding:0 18px 12px}.finding-filters strong{width:100%;font-size:12px;color:#c5d2e6}.filter-control{display:flex;flex-direction:column;gap:4px;min-width:0;color:var(--muted);font-size:10px;font-weight:750}.filter-control select,.finding-filters>button{min-width:0;min-height:38px;background:#07111f;color:var(--text);border:1px solid var(--line);border-radius:8px;padding:7px 9px}.filter-control select{max-width:100%}.finding-filters>button{color:#fff;background:#253b5d}.filter-summary{align-self:center;color:var(--muted);font-size:10px;margin-left:auto;overflow-wrap:anywhere}.mobile-back{display:none}
22
- @media(max-width:1450px){.brand{min-width:300px}.nav button{padding:10px 10px}.summary{grid-template-columns:1.3fr .8fr .85fr .85fr .85fr .9fr 1.5fr}.workspace{grid-template-columns:185px 215px 270px minmax(360px,1fr) 290px}}
23
- @media(max-width:1350px){.workspace{grid-template-columns:185px 270px minmax(320px,1fr) 270px}.workspace>.pane:nth-child(2){display:none}.finding-filters{display:grid;grid-template-columns:repeat(5,minmax(0,1fr)) minmax(180px,1fr);align-items:end}.finding-filters strong{grid-column:1/-1}.filter-summary{margin-left:0}}
24
- @media(max-width:1100px){.summary{grid-template-columns:repeat(4,1fr)}.severity-chart{grid-column:span 2}.scope-row{grid-template-columns:1fr}.workspace{grid-template-columns:175px 205px minmax(300px,1fr) 270px}.workspace>.pane:nth-child(2){display:none}.tools input{width:130px}.finding-filters{padding-left:12px;padding-right:12px}}
25
- @media(max-width:760px){.app{grid-template-rows:auto auto auto auto 1fr}.top{flex-wrap:wrap;min-height:118px;padding:10px 14px}.brand{min-width:0;flex:1;font-size:17px}.nav{order:3;width:100%;overflow:auto}.nav button{min-height:42px}.tools{width:100%;margin-left:0}.tools input{flex:1;width:auto}.finding-filters{display:flex;padding:0 10px 10px;align-items:stretch}.filter-control{flex:1 1 calc(50% - 8px);min-width:140px}.filter-control select,.finding-filters>button{width:100%;min-height:44px}.finding-filters>button{flex:1 1 100%}.filter-summary{width:100%;margin:0}.summary{grid-template-columns:repeat(2,1fr);padding:10px}.summary .card{min-height:72px;padding:10px}.summary .card strong{font-size:21px}.severity-chart{grid-column:auto}.scope-row{padding:0 10px 10px}.scope{align-items:stretch;flex-wrap:wrap}.scope select{min-width:100%;min-height:44px}.projects{display:none}.workspace{display:flex;flex-direction:column;margin:0 10px 10px;border-radius:12px}.workspace>.pane:nth-child(1){display:none}.workspace>.pane:nth-child(2){display:none}.workspace>.pane:nth-child(3){order:1;height:420px}.workspace>.pane:nth-child(5){order:2;height:auto;min-height:520px}.workspace>.pane:nth-child(4){order:3;height:420px}.pane{width:100%}.head{min-height:45px}.scroll{height:calc(100% - 45px)}.details{padding:14px}.details h2{font-size:18px;overflow-wrap:anywhere}.details h3{margin-top:14px}.mobile-back{display:inline-flex!important;align-items:center;min-height:44px;margin-bottom:10px;background:#253b5d!important;border-color:#5778a9!important}.actions button,.actions a{min-height:44px}.review-diff,.code-scroll,.meta,.validation-results,.evidence-grid,.audit-grid{overflow-wrap:anywhere;word-break:break-word}.review-diff{white-space:pre-wrap;max-width:100%;overflow:auto}.screenshot-preview img{max-width:100%;height:auto}.details dialog{max-width:calc(100vw - 24px)}}
22
+ @media(max-width:1450px){.brand{min-width:300px}.nav button{padding:10px 10px}.summary{grid-template-columns:1.3fr .8fr .85fr .85fr .85fr .9fr 1.5fr}}
23
+ @media(max-width:1350px){.finding-filters{display:grid;grid-template-columns:repeat(5,minmax(0,1fr)) minmax(180px,1fr);align-items:end}.finding-filters strong{grid-column:1/-1}.filter-summary{margin-left:0}}
24
+ @media(max-width:1100px){.summary{grid-template-columns:repeat(4,1fr)}.severity-chart{grid-column:span 2}.scope-row{grid-template-columns:1fr}.tools input{width:130px}.finding-filters{padding-left:12px;padding-right:12px}}
25
+ @media(max-width:760px){.app{grid-template-rows:auto auto auto auto 1fr}.top{flex-wrap:wrap;min-height:118px;padding:10px 14px}.brand{min-width:0;flex:1;font-size:17px}.nav{order:3;width:100%;overflow:auto}.nav button{min-height:42px}.tools{width:100%;margin-left:0}.tools input{flex:1;width:auto}.finding-filters{display:flex;padding:0 10px 10px;align-items:stretch}.filter-control{flex:1 1 calc(50% - 8px);min-width:140px}.filter-control select,.finding-filters>button{width:100%;min-height:44px}.finding-filters>button{flex:1 1 100%}.filter-summary{width:100%;margin:0}.summary{grid-template-columns:repeat(2,1fr);padding:10px}.summary .card{min-height:72px;padding:10px}.summary .card strong{font-size:21px}.severity-chart{grid-column:auto}.scope-row{padding:0 10px 10px}.scope{align-items:stretch;flex-wrap:wrap}.scope select{min-width:100%;min-height:44px}.projects{display:none}.workspace{display:flex;flex-direction:column;margin:0 10px 10px;border-radius:12px}.pane{width:100%}.head{min-height:45px}.scroll{height:calc(100% - 45px)}.details{padding:14px}.details h2{font-size:18px;overflow-wrap:anywhere}.details h3{margin-top:14px}.mobile-back{display:inline-flex!important;align-items:center;min-height:44px;margin-bottom:10px;background:#253b5d!important;border-color:#5778a9!important}.actions button,.actions a{min-height:44px}.review-diff,.code-scroll,.meta,.validation-results,.evidence-grid,.audit-grid{overflow-wrap:anywhere;word-break:break-word}.review-diff{white-space:pre-wrap;max-width:100%;overflow:auto}.screenshot-preview img{max-width:100%;height:auto}.details dialog{max-width:calc(100vw - 24px)}}
26
26
  `;
27
- export function dashboardHtml(report, includeArtifactLinks = false, snippets) { const data = escapeJson(JSON.stringify(toDashboardData(report, snippets))), links = includeArtifactLinks ? '<nav aria-label="Report artifacts"><a href="rtl-report.json">JSON</a> <a href="rtl-report.md">Markdown</a> <a href="rtl-report-structured.md">Structured Markdown</a></nav>' : ''; return `<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>RTL Migration Analyzer v3 — Code Explorer</title><style>${css}.rtl-value{unicode-bidi:isolate;direction:auto}</style></head><body><div id="dashboard" aria-label="RTL code explorer"></div>${links}<script type="application/json" id="rtl-dashboard-data">${data}</script><script>${dashboardClientSource.replace('__SEVERITY_LABELS__', JSON.stringify({ Major: severityDisplayLabel('Major'), Minor: severityDisplayLabel('Minor'), Info: severityDisplayLabel('Info') }))}</script></body></html>\n`; }
27
+ const layoutOverrides = `.operations{margin:0 12px 8px;border:1px solid #8db6df;border-radius:7px;background:#0b1728}.operations>summary{cursor:pointer;padding:5px 12px;color:#e7f0ff;font-size:12px;font-weight:800;list-style:none}.operations>summary::-webkit-details-marker{display:none}.operations>summary:before{content:'▸';display:inline-block;margin-right:7px}.operations[open]>summary:before{content:'▾'}.operation-body{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:0 10px 10px}.operation-body>section{border:1px solid var(--line);border-radius:8px;background:#101e32;padding:10px}.operation-body h2{margin:0 0 5px;font-size:13px}.operation-body p{margin:4px 0;color:var(--muted);font-size:11px}.operation-body button{min-height:30px;border:1px solid #5878a5;border-radius:6px;background:#1a3152;color:#fff;padding:5px 9px;font-size:11px}.workspace{--explorer-width:210px;--findings-width:230px;grid-template-columns:var(--explorer-width) var(--findings-width) minmax(0,1fr);margin:0 12px 12px}.explorer-pane,.findings-pane{overflow:hidden}.review-pane{min-width:0}@media(max-width:1100px){.workspace{--explorer-width:170px;--findings-width:190px}}@media(max-width:800px){.workspace>.explorer-pane,.workspace>.findings-pane{height:210px}.workspace>.review-pane{height:auto;min-height:0}.workspace.panel-tree-collapsed>.explorer-pane,.workspace.panel-findings-collapsed>.findings-pane{height:40px}.workspace.panel-tree-collapsed>.explorer-pane .head,.workspace.panel-findings-collapsed>.findings-pane .head{font-size:10px;padding:0 14px}}.head{height:40px}.scroll{height:calc(100% - 40px)}.tree,.finding-list{padding:8px}.file,.finding{padding:7px}.finding strong{font-size:12px}.finding small{font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.code{height:auto}.meta{padding:8px 12px;font-size:11px}.code-scroll{flex:0 0 120px;padding:10px 0}.line{grid-template-columns:48px minmax(0,1fr);font-size:12px;line-height:1.65}.text{padding:0 13px;overflow:hidden;text-overflow:ellipsis}.details{height:auto;overflow:visible;padding:10px}.details h2{font-size:16px;margin-bottom:10px}`;
28
+ export function dashboardHtml(report, includeArtifactLinks = false, snippets) { const data = escapeJson(JSON.stringify(toDashboardData(report, snippets))), links = includeArtifactLinks ? `<nav class="artifact-links" aria-label="Report artifacts"><a href="rtl-report.json">JSON report</a><a href="rtl-report.md">Markdown report</a><a href="rtl-report-structured.md">Structured report</a></nav>` : ''; return `<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>RTL Migration Analyzer v3 — Code Explorer</title><style>${css}${layoutOverrides}.artifact-links{display:flex;gap:10px;padding:8px 18px}.artifact-links a{color:#c9a9ff}.rtl-value{unicode-bidi:isolate;direction:auto}</style></head><body><div id="dashboard" aria-label="RTL code explorer"></div>${links}<script type="application/json" id="rtl-dashboard-data">${data}</script><script>${dashboardClientSource.replace('__SEVERITY_LABELS__', JSON.stringify({ Major: severityDisplayLabel('Major'), Minor: severityDisplayLabel('Minor'), Info: severityDisplayLabel('Info') }))}</script><script>document.addEventListener('click',event=>{const target=event.target.closest('.stats-toggle');if(!target)return;const summary=document.querySelector('.summary');if(summary){summary.hidden=!summary.hidden;target.textContent=summary.hidden?'Show all statistics':'Close statistics'}})</script></body></html>\n`; }