@wafertools/wafermap 0.40.0 → 0.41.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 (220) hide show
  1. package/AGENTS.md +20 -21
  2. package/CHANGELOG.md +154 -0
  3. package/README.md +6 -6
  4. package/dist/packages/canvas-adapter/canvasTheme.d.ts +12 -0
  5. package/dist/packages/canvas-adapter/canvasTheme.js +1 -1
  6. package/dist/packages/canvas-adapter/cellShade.d.ts +2 -2
  7. package/dist/packages/canvas-adapter/cellShade.js +1 -1
  8. package/dist/packages/canvas-adapter/chartPopulation.d.ts +3 -0
  9. package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
  10. package/dist/packages/canvas-adapter/charts/capability.d.ts +3 -0
  11. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +2 -1
  13. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +47 -27
  15. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  16. package/dist/packages/canvas-adapter/charts/commonality.js +4 -4
  17. package/dist/packages/canvas-adapter/charts/correlation.d.ts +6 -12
  18. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  19. package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +45 -15
  20. package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -1
  21. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/palette.d.ts +16 -30
  23. package/dist/packages/canvas-adapter/charts/palette.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/patCard.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +29 -3
  26. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  27. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +3 -0
  28. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  29. package/dist/packages/canvas-adapter/charts/sweep.d.ts +3 -0
  30. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  31. package/dist/packages/canvas-adapter/chromeRow.d.ts +68 -0
  32. package/dist/packages/canvas-adapter/chromeRow.js +1 -0
  33. package/dist/packages/canvas-adapter/chunked.d.ts +6 -0
  34. package/dist/packages/canvas-adapter/chunked.js +1 -1
  35. package/dist/packages/canvas-adapter/columnFilterPopup.d.ts +25 -0
  36. package/dist/packages/canvas-adapter/columnFilterPopup.js +1 -0
  37. package/dist/packages/canvas-adapter/composePng.d.ts +37 -0
  38. package/dist/packages/canvas-adapter/composePng.js +1 -0
  39. package/dist/packages/canvas-adapter/dataTab.d.ts +39 -6
  40. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  41. package/dist/packages/canvas-adapter/dieList.js +1 -1
  42. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +3 -1
  43. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
  44. package/dist/packages/canvas-adapter/drilldown.d.ts +20 -1
  45. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  46. package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
  47. package/dist/packages/canvas-adapter/filterButton.js +1 -1
  48. package/dist/packages/canvas-adapter/filterEditor.d.ts +5 -0
  49. package/dist/packages/canvas-adapter/filterEditor.js +1 -1
  50. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  51. package/dist/packages/canvas-adapter/icons.js +1 -1
  52. package/dist/packages/canvas-adapter/identityHeader.d.ts +5 -0
  53. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  54. package/dist/packages/canvas-adapter/index.d.ts +7 -0
  55. package/dist/packages/canvas-adapter/index.js +1 -1
  56. package/dist/packages/canvas-adapter/insightsTab.d.ts +32 -9
  57. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  58. package/dist/packages/canvas-adapter/maplessSummary.d.ts +4 -2
  59. package/dist/packages/canvas-adapter/maplessSummary.js +1 -1
  60. package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
  61. package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
  62. package/dist/packages/canvas-adapter/panelChart.d.ts +7 -0
  63. package/dist/packages/canvas-adapter/panelChart.js +1 -0
  64. package/dist/packages/canvas-adapter/panelTable.d.ts +50 -0
  65. package/dist/packages/canvas-adapter/panelTable.js +1 -0
  66. package/dist/packages/canvas-adapter/plotCard.js +1 -1
  67. package/dist/packages/canvas-adapter/plotEditor.d.ts +12 -0
  68. package/dist/packages/canvas-adapter/plotEditor.js +10 -10
  69. package/dist/packages/canvas-adapter/plotItems.d.ts +9 -4
  70. package/dist/packages/canvas-adapter/plotItems.js +1 -1
  71. package/dist/packages/canvas-adapter/plotJsonComplete.js +1 -1
  72. package/dist/packages/canvas-adapter/plotModal.d.ts +7 -0
  73. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  74. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  75. package/dist/packages/canvas-adapter/plotTab.d.ts +60 -2
  76. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  77. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +7 -0
  78. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  79. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +41 -9
  80. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  81. package/dist/packages/canvas-adapter/reportCharts.d.ts +41 -0
  82. package/dist/packages/canvas-adapter/reportCharts.js +1 -0
  83. package/dist/packages/canvas-adapter/reportExport.d.ts +91 -0
  84. package/dist/packages/canvas-adapter/reportExport.js +1 -0
  85. package/dist/packages/canvas-adapter/reportFigures.d.ts +29 -0
  86. package/dist/packages/canvas-adapter/reportFigures.js +1 -0
  87. package/dist/packages/canvas-adapter/reportRun.d.ts +9 -0
  88. package/dist/packages/canvas-adapter/reportRun.js +1 -0
  89. package/dist/packages/canvas-adapter/selectionOverlay.d.ts +12 -0
  90. package/dist/packages/canvas-adapter/selectionOverlay.js +1 -0
  91. package/dist/packages/canvas-adapter/summaryPanel.d.ts +152 -111
  92. package/dist/packages/canvas-adapter/summaryPanel.js +7 -4
  93. package/dist/packages/canvas-adapter/summaryToggle.js +1 -1
  94. package/dist/packages/canvas-adapter/tableDrilldown.d.ts +48 -0
  95. package/dist/packages/canvas-adapter/tableDrilldown.js +1 -0
  96. package/dist/packages/canvas-adapter/tableFilter.d.ts +42 -0
  97. package/dist/packages/canvas-adapter/tableFilter.js +1 -0
  98. package/dist/packages/canvas-adapter/tablePlots.d.ts +85 -0
  99. package/dist/packages/canvas-adapter/tablePlots.js +1 -0
  100. package/dist/packages/canvas-adapter/themeWatch.d.ts +7 -0
  101. package/dist/packages/canvas-adapter/themeWatch.js +1 -0
  102. package/dist/packages/canvas-adapter/toCanvas.d.ts +3 -0
  103. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  104. package/dist/packages/canvas-adapter/toolbar.d.ts +125 -36
  105. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  106. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  107. package/dist/packages/canvas-adapter/userGuideHtml.js +530 -414
  108. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  109. package/dist/packages/canvas-adapter/version.js +1 -1
  110. package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
  111. package/dist/packages/canvas-adapter/virtualTable.d.ts +37 -7
  112. package/dist/packages/canvas-adapter/virtualTable.js +1 -1
  113. package/dist/packages/core/aggregates.d.ts +14 -0
  114. package/dist/packages/core/aggregates.js +1 -1
  115. package/dist/packages/core/dies.d.ts +7 -0
  116. package/dist/packages/core/dies.js +1 -1
  117. package/dist/packages/core/utils.d.ts +2 -0
  118. package/dist/packages/core/utils.js +1 -1
  119. package/dist/packages/experimental/charts.d.ts +4 -0
  120. package/dist/packages/experimental/charts.js +1 -0
  121. package/dist/packages/renderer/binColors.d.ts +6 -2
  122. package/dist/packages/renderer/binColors.js +1 -1
  123. package/dist/packages/renderer/buildView.d.ts +36 -14
  124. package/dist/packages/renderer/buildView.js +1 -1
  125. package/dist/packages/renderer/buildWaferMap.d.ts +8 -0
  126. package/dist/packages/renderer/buildWaferMap.js +1 -1
  127. package/dist/packages/renderer/categoryColors.d.ts +3 -0
  128. package/dist/packages/renderer/categoryColors.js +1 -0
  129. package/dist/packages/renderer/colorMap.d.ts +15 -16
  130. package/dist/packages/renderer/colorMap.js +1 -1
  131. package/dist/packages/renderer/colorSchemes.d.ts +34 -30
  132. package/dist/packages/renderer/colorSchemes.js +1 -1
  133. package/dist/packages/renderer/dataColors.d.ts +126 -0
  134. package/dist/packages/renderer/dataColors.js +1 -0
  135. package/dist/packages/renderer/deprecate.js +1 -1
  136. package/dist/packages/renderer/fmt.d.ts +16 -0
  137. package/dist/packages/renderer/fmt.js +1 -1
  138. package/dist/packages/renderer/index.d.ts +2 -0
  139. package/dist/packages/renderer/index.js +1 -1
  140. package/dist/packages/renderer/spec.d.ts +5 -0
  141. package/dist/packages/renderer/spec.js +1 -1
  142. package/dist/packages/renderer/stacks.d.ts +21 -0
  143. package/dist/packages/renderer/stacks.js +1 -0
  144. package/dist/packages/renderer/timeAxis.d.ts +19 -0
  145. package/dist/packages/renderer/timeAxis.js +1 -0
  146. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  147. package/dist/packages/stats/analyzeWaferMap.d.ts +2 -4
  148. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  149. package/dist/packages/stats/binRows.js +1 -1
  150. package/dist/packages/stats/binShifts.d.ts +59 -0
  151. package/dist/packages/stats/binShifts.js +1 -0
  152. package/dist/packages/stats/capability.d.ts +6 -1
  153. package/dist/packages/stats/capability.js +1 -1
  154. package/dist/packages/stats/chartCatalogue.d.ts +3 -0
  155. package/dist/packages/stats/chartCatalogue.js +1 -1
  156. package/dist/packages/stats/clusterDetection.js +1 -1
  157. package/dist/packages/stats/columnPlot.d.ts +38 -0
  158. package/dist/packages/stats/columnPlot.js +1 -0
  159. package/dist/packages/stats/commonality.d.ts +8 -1
  160. package/dist/packages/stats/commonality.js +1 -1
  161. package/dist/packages/stats/correlation.d.ts +7 -2
  162. package/dist/packages/stats/correlation.js +1 -1
  163. package/dist/packages/stats/dataTable.d.ts +44 -0
  164. package/dist/packages/stats/dataTable.js +1 -0
  165. package/dist/packages/stats/dieRegions.js +1 -1
  166. package/dist/packages/stats/examplePicks.js +1 -1
  167. package/dist/packages/stats/facets.d.ts +11 -0
  168. package/dist/packages/stats/facets.js +1 -1
  169. package/dist/packages/stats/filterFindings.d.ts +21 -0
  170. package/dist/packages/stats/filterFindings.js +1 -1
  171. package/dist/packages/stats/groupEffects.d.ts +8 -0
  172. package/dist/packages/stats/groupEffects.js +1 -1
  173. package/dist/packages/stats/math.d.ts +2 -0
  174. package/dist/packages/stats/math.js +1 -1
  175. package/dist/packages/stats/overview.d.ts +114 -0
  176. package/dist/packages/stats/overview.js +1 -0
  177. package/dist/packages/stats/pat.d.ts +0 -2
  178. package/dist/packages/stats/pat.js +1 -1
  179. package/dist/packages/stats/patternClassification.d.ts +20 -3
  180. package/dist/packages/stats/patternClassification.js +1 -1
  181. package/dist/packages/stats/permutationNull.d.ts +16 -0
  182. package/dist/packages/stats/permutationNull.js +1 -0
  183. package/dist/packages/stats/plotData.d.ts +138 -12
  184. package/dist/packages/stats/plotData.js +1 -1
  185. package/dist/packages/stats/plotSpec.d.ts +10 -1
  186. package/dist/packages/stats/plotSpec.js +3 -3
  187. package/dist/packages/stats/plotTable.js +1 -1
  188. package/dist/packages/stats/plotWords.d.ts +52 -0
  189. package/dist/packages/stats/plotWords.js +1 -0
  190. package/dist/packages/stats/presentation.d.ts +63 -14
  191. package/dist/packages/stats/presentation.js +1 -1
  192. package/dist/packages/stats/presentationPresets.d.ts +35 -0
  193. package/dist/packages/stats/presentationPresets.js +1 -0
  194. package/dist/packages/stats/presentationSections.d.ts +83 -0
  195. package/dist/packages/stats/presentationSections.js +1 -0
  196. package/dist/packages/stats/renderSummaryReport.d.ts +80 -2
  197. package/dist/packages/stats/renderSummaryReport.js +1 -67
  198. package/dist/packages/stats/reportBlocks.d.ts +249 -0
  199. package/dist/packages/stats/reportBlocks.js +1 -0
  200. package/dist/packages/stats/reportContents.d.ts +22 -0
  201. package/dist/packages/stats/reportContents.js +1 -0
  202. package/dist/packages/stats/reportDeck.d.ts +245 -0
  203. package/dist/packages/stats/reportDeck.js +212 -0
  204. package/dist/packages/stats/reportHtml.d.ts +44 -43
  205. package/dist/packages/stats/reportHtml.js +82 -46
  206. package/dist/packages/stats/reportMaps.d.ts +67 -0
  207. package/dist/packages/stats/reportMaps.js +1 -0
  208. package/dist/packages/stats/reportSections.d.ts +55 -0
  209. package/dist/packages/stats/reportSections.js +1 -0
  210. package/dist/packages/stats/sweep.d.ts +14 -6
  211. package/dist/packages/stats/sweep.js +1 -1
  212. package/dist/packages/stats/synthesis.d.ts +87 -10
  213. package/dist/packages/stats/synthesis.js +1 -1
  214. package/dist/packages/stats/types.d.ts +22 -0
  215. package/dist/packages/stats/worthItems.d.ts +15 -0
  216. package/dist/packages/stats/worthItems.js +1 -0
  217. package/dist/packages/stats/yield.d.ts +13 -0
  218. package/dist/packages/stats/yield.js +1 -1
  219. package/llms.txt +1 -1
  220. package/package.json +6 -1
@@ -1 +1 @@
1
- import{fontPx as Xt}from"./toolbar.js";import{findTestDef as Xe,buildMapTitle as Ye}from"../renderer/buildView.js";import{niceStep as Yt,compactTickIndices as uo}from"../renderer/axisTicks.js";import{sortBinsForDisplay as po}from"../stats/binPareto.js";import{affineInvert as xo,affineVector as $e}from"../core/transforms.js";import{asList as Mo,compareNatural as bo,maxOf as se,minOf as we}from"../core/utils.js";import{resolveValueColorFn as yo}from"../renderer/colorSchemes.js";import{NO_DATA_FILL as To}from"../renderer/colorMap.js";import{SPEC_PASS_FILL as Ve,SPEC_FAIL_LOW as So,SPEC_FAIL_HIGH as Ke,contrastTextColor as ze}from"../renderer/colorMap.js";import{fmt as qe,fmtColorbarAxis as Ue}from"../renderer/fmt.js";import{resolveCanvasTheme as ko}from"./canvasTheme.js";import{hitGridDims as Lo}from"./hitGrid.js";const Ao=5,Je=4;function je(f,e,q,m,s){f.moveTo(e,q+s*m),f.lineTo(e-m*.9,q-s*m*.6),f.lineTo(e+m*.9,q-s*m*.6),f.closePath()}const _o=new Set(["value","stackedValues","stackedBins","stackedSoftBins"]),Co=new Set(["hardBin","softBin","metadata"]),ct=()=>`${Xt(-2)}px system-ui, sans-serif`,Ze=3,le=2,Ro=6,Po=20,Bo=()=>`600 ${Xt()}px system-ui, sans-serif`,Qe=36,Ae=()=>`${Xt(-1)}px system-ui, sans-serif`,ve=()=>`600 ${Xt(-1)}px system-ui, sans-serif`,ie=128,Do=()=>`${Xt(-2)}px system-ui, sans-serif`,to=4,z=17,Z=11;export const BIN_LEGEND_W=110,BIN_LEGEND_W_COMPACT=64,BIN_LEGEND_MAP_GAP=12;const eo=8;export const BIN_LEGEND_ADAPT_COMPACT=280,BIN_LEGEND_ADAPT_FLOATING=180,BIN_LEGEND_MIN_CANVAS_W=150,BIN_LEGEND_MIN_CANVAS_H=120;const ae=28,Tt=5,pt=8,oo=15,no=12,so=6;export function toCanvas(f,e,q={}){return drawMapCanvas(f,e,q)}export function drawMapCanvas(f,e,q={}){const m=ko(f.parentElement??f),{padding:s=16,showColorbar:D=!0,markFailingDies:rt=!1,colorbarWidth:d=16,background:Y=m.background,legendPosition:_="default",legendOffset:U,showAxes:H=!1,diePitchMm:W,viewport:et,activeBin:$,hoverBin:J,afterDies:Pt,fallbackFormat:dt,minRightReserve:Bt,hbinDefs:Dt,sbinDefs:It,metadataFields:St,showTitle:st=!0}=q,Nt=Mo($),R=Math.floor(f.clientWidth||f.width),G=Math.floor(f.clientHeight||f.height),Wt=R>=BIN_LEGEND_MIN_CANVAS_W&&G>=BIN_LEGEND_MIN_CANVAS_H,Et=D&&Wt&&_o.has(e.plotMode)&&e.passFailDisplay==="off",kt=D&&Wt&&Co.has(e.plotMode),xt=D&&Wt&&e.plotMode==="value"&&(e.passFailDisplay==="spec"&&e.specCounts!==void 0||e.passFailDisplay==="test"&&e.passFailCounts!==void 0),Mt=kt||xt,Lt=kt&&e.plotMode!=="metadata"&&e.binCounts?po(e.binCounts.entries(),e.plotMode==="softBin"?e.binColors.pass.soft:e.binColors.pass.hard):[],At=kt&&e.plotMode==="metadata"&&e.metadataCounts?[...e.metadataColorMap?.keys()??[...e.metadataCounts.keys()].sort(bo)].map(o=>[o,e.metadataCounts.get(o)??0]):[],ht=[];if(xt&&e.passFailDisplay==="test"){const o=e.passFailCounts;ht.push({key:-1,color:Ve,label:"Pass",compactLabel:"Pass",count:o.pass,tooltip:`Pass \xB7 ${o.pass} dies`}),ht.push({key:-2,color:Ke,label:"Fail",compactLabel:"Fail",count:o.fail,tooltip:`Fail \xB7 ${o.fail} dies`})}else if(xt){const o=e.specCounts,c=Xe(e.testDefs,e.activeTest);ht.push({key:-1,color:Ve,label:"Pass",compactLabel:"Pass",count:o.pass,tooltip:`Pass \xB7 ${o.pass} dies`}),c?.limitHigh!==void 0&&ht.push({key:-2,color:Ke,label:"Fail high",compactLabel:"Fail hi",count:o.failHigh,tooltip:`Fail high \xB7 ${o.failHigh} dies`}),c?.limitLow!==void 0&&ht.push({key:-3,color:So,label:"Fail low",compactLabel:"Fail lo",count:o.failLow,tooltip:`Fail low \xB7 ${o.failLow} dies`})}const $t=xt?ht.length:e.plotMode==="metadata"?At.length:Lt.length,v=(f.ownerDocument.defaultView??window).devicePixelRatio??1;if(R<=0||G<=0)return{hitTarget:{getDieAtPoint:()=>null},viewport:{originX:0,originY:0,ppm:1,snapDist:1},binLegendRows:[]};const nt=_!=="default"?_:R<BIN_LEGEND_ADAPT_FLOATING?"floating":R<BIN_LEGEND_ADAPT_COMPACT?"compact":"default",wt=nt==="default"||nt==="compact",Vt=nt==="left",b=nt==="bottom",ot=nt==="top",w=nt==="floating",_t=nt==="compact"||nt==="floating"?BIN_LEGEND_W_COMPACT:BIN_LEGEND_W,Kt=Math.floor((G-2*s)/z),Ft=$t>Kt?Kt-1:$t,ce=Mt&&b?Ft*z+eo:0,zt=Mt&&ot?Ft*z+eo:0,re=e.plotMode==="stackedBins"||e.plotMode==="stackedSoftBins",fe=Xe(e.testDefs,e.activeTest),_e=re?"Count":fe?.name??(e.activeTest!=null?`Test ${e.activeTest}`:void 0),Ce=re?void 0:fe?.unit,[Ot,Ht]=e.valueRange,he=o=>String(Math.round(o)),ao=e.logScale||e.allIntegerValues?void 0:Yt(Math.max(0,Ht-Ot)*Qe/Math.max(1,G))||void 0,de=e.allIntegerValues?he:Ue(Ht,_e,Ce,dt,ao).edgeFmt;let ge=0;if(Et){const o=f.getContext("2d");o.font=ct();const c=[de(Ot),de(Ht)];Ot<0&&c.push(de(-Math.max(Math.abs(Ot),Math.abs(Ht))));for(const x of c)ge=Math.max(ge,o.measureText(x).width)}const Re=Math.max(Po,Math.ceil(ge)+Ze+le+Ro-s),me=Et?d+Re+8:Mt&&wt?_t+BIN_LEGEND_MAP_GAP:0,qt=Mt&&Vt?_t+BIN_LEGEND_MAP_GAP:0,ue=H?32:0,Ut=H?36:0,Pe=Bt!=null?Math.max(me,Bt):me,co=R-2*s-Pe-Ut-qt,Be=G-2*s-ue-ce-zt;f.width=Math.round(R*v),f.height=Math.round(G*v);const t=f.getContext("2d");t.scale(v,v),t.fillStyle=Y,t.fillRect(0,0,R,G);const tt=e.hoverPoints;if(!tt.length)return{hitTarget:{getDieAtPoint:()=>null},viewport:{originX:0,originY:0,ppm:1,snapDist:1},binLegendRows:[]};const Jt=e.rectangles[0],pe=Jt?Jt.width/2:0,xe=Jt?Jt.height/2:0,jt=e.dieBounds,Me=(jt?.minX??0)-pe,De=(jt?.maxX??0)+pe,Ie=(jt?.minY??0)-xe,be=(jt?.maxY??0)+xe,Ne=De-Me,We=be-Ie;let lt,it,P;if(et)({originX:lt,originY:it,ppm:P}=et);else{const c=e.notchDir,x=c&&c.y>.1?13:0,u=c&&c.y<-.1?13:0,k=c&&c.x<-.1?13:0,p=c&&c.x>.1?13:0,h=co-k-p,i=Be-x-u;P=Math.min(h/Ne,i/We),lt=s+Ut+qt+k+(h-Ne*P)/2-Me*P,it=s+zt+x+(i-We*P)/2+be*P}const Zt=et?.snapDist??Math.max(pe,xe,1)*1.5,Qt=lt+e.waferCenter.x*P,ro=it-e.waferCenter.y*P,ye=e.waferRadius*P,gt=o=>{const c=Math.abs(o-ro);return c>=ye?0:Math.sqrt(ye*ye-c*c)},bt=(o,c,x,u,k,p,h=Bo(),i=m.text)=>{if(!o)return;t.save(),t.fillStyle=i,t.font=h,t.textAlign=u,t.textBaseline=k;const a=u==="right"?c-p:p-c;let n=o;if(a>8&&t.measureText(n).width>a){for(;n.length>1&&t.measureText(n+"\u2026").width>a;)n=n.slice(0,-1);n=n+"\u2026"}a>8&&t.fillText(n,c,x),t.restore()};t.save(),t.setTransform(P*v,0,0,-P*v,lt*v,it*v);const mt=1/P;let vt=!1;const fo=1/(P*v),te=e.rectangles.length>0&&e.dieGap*P*v<1;if(e.rectangles.length>0){const o=new Map;for(const h of e.rectangles){const i=String(h.fill);let a=o.get(i);a||(a=[],o.set(i,a)),a.push(h)}const c=P*v,x=lt*v,u=it*v,k=e.dieGap/2;te&&(t.save(),t.setTransform(1,0,0,1,0,0));for(const[h,i]of o){t.fillStyle=h;for(let a=0;a<i.length;a+=PATH_SHAPES){t.beginPath();const n=Math.min(i.length,a+PATH_SHAPES);for(let l=a;l<n;l++){const g=i[l];if(te){const L=g.width/2+k,y=g.height/2+k,I=2*L*c>=Je?1:0,j=2*y*c>=Je?1:0,Q=Math.round(x+(g.x-L)*c),N=Math.max(Q+1,Math.round(x+(g.x+L)*c)-I),B=Math.round(u-(g.y+y)*c),yt=Math.max(B+1,Math.round(u-(g.y-y)*c)-j);t.rect(Q,B,N-Q,yt-B)}else t.rect(g.x-g.width/2,g.y-g.height/2,g.width,g.height)}t.fill()}}if(te&&t.restore(),!te){t.strokeStyle="rgba(0,0,0,0.18)",t.lineWidth=.5*fo,t.lineCap="square";const h=io.get(e.rectangles)??outlineSegments(e.rectangles);io.set(e.rectangles,h);const i=PATH_SHAPES*4;for(let a=0;a<h.length;a+=i){t.beginPath();const n=Math.min(h.length,a+i);for(let l=a;l<n;l+=4)t.moveTo(h[l],h[l+1]),t.lineTo(h[l+2],h[l+3]);t.stroke()}t.lineCap="butt"}if(rt){const h=e.rectangles.filter(i=>i.binFail);if(h.length>0){const i=new Map;for(const a of h){const n=ze(String(a.fill));let l=i.get(n);l||(l=[],i.set(n,l)),l.push(a)}t.save(),t.lineCap="butt";for(const[a,n]of i){t.strokeStyle=a,t.globalAlpha=.55,t.lineWidth=Math.max(.6*mt,Math.min(n[0].width,n[0].height)*.1);for(const l of n){const g=l.width/2,L=l.height/2,y=Math.max(1.6*mt,Math.min(l.width,l.height)/3);t.save(),t.beginPath(),t.rect(l.x-g,l.y-L,l.width,l.height),t.clip(),t.beginPath();for(let I=-(g+L);I<=g+L;I+=y)t.moveTo(l.x-g+I,l.y-L),t.lineTo(l.x-g+I+l.height,l.y+L);t.stroke(),t.restore()}}t.restore()}}const p=e.rectangles.filter(h=>h.specMark);if(vt=p.length>0&&Math.min(p[0].width,p[0].height)<Ao*mt,p.length>0&&!vt){const h=new Map;for(const a of p){const n=ze(String(a.fill)),l=`${a.specMark}|${n}`;let g=h.get(l);g||(g=[],h.set(l,g)),g.push(a)}const i=2.5*mt;t.lineJoin="round";for(const[a,n]of h){const[l,g]=a.split("|"),L=g==="#000000"?"#ffffff":"#000000",y=l==="failHigh"?1:-1,I=Math.min(n[0].width,n[0].height),j=Math.max(2.5*mt,I*.3);t.beginPath();for(const Q of n)je(t,Q.x,Q.y,j,y);t.strokeStyle=L,t.lineWidth=i,t.stroke(),t.fillStyle=g,t.fill()}}}for(const o of e.overlays){t.beginPath();for(const c of o.points){for(let x=0;x<c.length;x++)x===0?t.moveTo(c[x].x,c[x].y):t.lineTo(c[x].x,c[x].y);o.closed&&t.closePath()}o.fill&&!o.fill.startsWith("rgba(0,0,0,0)")&&(t.fillStyle=o.fill,t.fill()),o.kind==="ring-boundary"||o.kind==="quadrant-boundary"||o.kind==="reticle"?(t.strokeStyle="rgba(0,0,0,0.45)",t.lineWidth=3*mt,t.stroke(),t.strokeStyle="rgba(255,255,255,0.8)",t.lineWidth=1*mt,t.stroke()):(t.strokeStyle=o.lineColor,t.lineWidth=o.lineWidth*mt,t.stroke())}if(t.restore(),e.notchDir){const o=lt+e.waferCenter.x*P,c=it-e.waferCenter.y*P,x=e.notchDir.x,u=-e.notchDir.y,k=e.waferRadius*P,p=4,h=9,i=5,a=o+x*(k+p),n=c+u*(k+p),l=a+x*h,g=n+u*h,L={x:-u,y:x},y=s+Ut+qt,I=R-s-me,j=s+zt,Q=G-s-ce-ue;t.save(),t.beginPath(),t.rect(y,j,I-y,Q-j),t.clip(),t.beginPath(),t.moveTo(a,n),t.lineTo(l+L.x*i,g+L.y*i),t.lineTo(l-L.x*i,g-L.y*i),t.closePath(),t.fillStyle=m.text,t.fill(),t.restore()}t.save(),t.textAlign="center",t.textBaseline="middle";let Ee=0;if(e.rectangles.length>0){let o=1;for(const p of e.texts)p.role!=="indicator"&&p.text.length>o&&(o=p.text.length);const c=e.rectangles[0].width*P,x=e.rectangles[0].height*P,u=Math.min(c,x),k=c/o;Ee=Math.max(8,Math.min(64,Math.round(Math.min(u*.55,k*1.8))))}for(const o of e.texts){const c=lt+o.x*P,x=it-o.y*P;t.font=`${o.role==="indicator"?o.fontSize:Ee}px system-ui, sans-serif`,t.fillStyle=o.color,t.fillText(o.text,c,x)}if(t.restore(),Pt?.(t,{originX:lt,originY:it,ppm:P},{background:Y,text:m.text}),H&&Io(t,R,G,lt,it,P,s,ue,Ut,{left:s+qt,right:R-s-Pe,top:s+zt,bottom:G-s-ce},{minX:Me,maxX:De,minY:Ie,maxY:be},W,e.gridToScreen,e.rotation,m,e.compact),Et){const o=yo(e.valueColorScheme,e.reverseValueScheme),c=Re,x=Be,u=Math.round(x*.75),k=s+Math.round((x-u)/2),p=R-s-d-c,h=Ot,i=Ht,a=i-h,n=e.plotMode==="stackedSoftBins"?It:Dt,{primary:l,secondary:g,note:L}=st?Ye(e,dt,n):{primary:"",secondary:"",note:void 0};if(st){const r=Math.max(k-6,s+11),O=Qt+Math.max(gt(r),gt(r-12))+8;bt(l,R-s,r,"right","bottom",O)}let y=k+u+4;const I=r=>Qt+Math.max(gt(r),gt(r+12))+8,j=e.logScale&&h>0?Math.log10(h):0,Q=e.logScale&&i>0?Math.log10(i)-j:1,N=r=>e.logScale?(1-(Math.log10(r)-j)/Q)*u:(1-(r-h)/a)*u;for(let r=0;r<ie;r++){const O=1-r/(ie-1),X=k+r/ie*u,M=u/ie+1;t.fillStyle=o(O),t.fillRect(p,X,d,M)}t.strokeStyle="rgba(0,0,0,0.25)",t.lineWidth=.5,t.strokeRect(p,k,d,u),t.fillStyle=m.text,t.font=ct(),t.textAlign="left",t.strokeStyle="rgba(0,0,0,0.35)",t.lineWidth=.5;const B=Ze,yt=Qe,ft=14;let V;const F=e.logScale&&Q>0?No(h,i,u,yt,ft,j,Q):e.allIntegerValues?(()=>{const r=Math.max(1,Yt(a*yt/u)),O=[],X=Math.ceil(h/r)*r;for(let M=X;M<=i+r*1e-6;M+=r){const E=(1-(M-h)/a)*u;E>ft&&E<u-ft&&O.push(Math.round(M))}return O})():(()=>{const r=a>0?Yt(a*yt/u):0,O=[];if(r>0){V=r;const X=Math.ceil(h/r)*r;for(let M=X;M<=i+r*1e-6;M+=r){const E=(1-(M-h)/a)*u;E>ft&&E<u-ft&&O.push(M)}}return O})(),T=fe,C=re,S=Ue(i,_e,Ce,dt,V),K=e.allIntegerValues?he:S.tickFmt,A=e.allIntegerValues?he:S.edgeFmt;t.textBaseline="middle";for(const r of F){const O=k+N(r);t.beginPath(),t.moveTo(p+d,O),t.lineTo(p+d+B,O),t.stroke(),t.fillText(K(r),p+d+B+le,O)}if(t.beginPath(),t.moveTo(p+d,k),t.lineTo(p+d+B,k),t.stroke(),t.textBaseline="top",t.fillText(A(i),p+d+B+le,k),t.beginPath(),t.moveTo(p+d,k+u),t.lineTo(p+d+B,k+u),t.stroke(),t.textBaseline="bottom",t.fillText(A(h),p+d+B+le,k+u),!C&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0)){const r=[],O=e.colorbarRangeMode==="spec";for(const[X,M]of[[T.limitLow,"Lo limit"],[T.limitHigh,"Hi limit"]]){if(X===void 0||e.logScale&&X<=0)continue;const E=N(X);!O&&(E<-ft||E>u+ft)||r.push({value:X,label:M,py:Math.max(0,Math.min(u,E))})}if(r.length>0){t.save(),t.font=ct(),t.textAlign="right",t.textBaseline="middle";for(const{py:X,label:M}of r){const E=k+X;if(O||(t.strokeStyle="rgba(255,255,255,0.85)",t.lineWidth=3,t.beginPath(),t.moveTo(p,E),t.lineTo(p+d,E),t.stroke(),t.strokeStyle="rgba(0,0,0,0.7)",t.lineWidth=1,t.beginPath(),t.moveTo(p,E),t.lineTo(p+d,E),t.stroke()),t.fillStyle=m.text,t.fillText(M,p-3,E),vt)continue;const Ct=M==="Hi limit"?-1:1,Rt=4,ne=p-3-t.measureText(M).width-Rt-4;t.beginPath(),je(t,ne,E,Rt,Ct),t.strokeStyle="#fff",t.lineWidth=2,t.lineJoin="round",t.stroke(),t.fillStyle=m.text,t.fill()}t.restore()}}if(!C){const r=e.logScale?"log\u2081\u2080":e.logScaleRequested?"linear \u2014 log n/a":null;r&&(t.save(),t.fillStyle=m.text,t.font=ve(),t.textAlign="right",t.textBaseline="top",t.fillText(r,R-s,y),t.restore(),y+=15)}vt&&(t.save(),t.fillStyle=m.text,t.font=ve(),t.textAlign="right",t.textBaseline="top",t.fillText("\u25BD\u25B3 limit marks: zoom in",R-s,y),t.restore(),y+=15),st&&g&&(bt(g,R-s,y,"right","top",I(y),Ae(),m.text),y+=15),st&&L&&bt(L,R-s,y,"right","top",I(y),Ae(),m.text)}const Te=[];let at;if(Mt){const o=nt==="compact",c=e.plotMode==="softBin"?It:Dt,x=c?new Map(c.map(n=>[n.bin,n])):null,u=e.plotMode==="softBin"?e.binColors.soft:e.binColors.hard,k=n=>u.get(n)??To,p=(n,l)=>{const g=t.measureText(n).width,L=o?0:t.measureText(String(l)).width,y=Z+Tt+g+(L?ae:0);return{labelWidth:g,countWidth:L,totalWidth:y}},h=St?.find(n=>n.key===e.activeMetadataKey),i=xt?ht.map(n=>{const l=o?n.compactLabel:n.label;return{key:n.key,color:n.color,count:n.count,label:l,tooltipLabel:n.tooltip,...p(l,n.count)}}):e.plotMode==="metadata"?At.map(([n,l])=>{const L=h?.values?.find(j=>j.value===n)?.label??n,y=o?n:L,I=e.metadataColorMap?.get(n)??"#d6d9dd";return{key:n,color:I,count:l,label:y,tooltipLabel:`${L} \xB7 ${l} dies`,...p(y,l)}}):Lt.map(([n,l])=>{const g=x?.get(n),L=g?.name?`${n} \xB7 ${g.name}`:`Bin ${n}`,y=o?String(n):L;return{key:n,color:k(n),count:l,label:y,tooltipLabel:`${L} \xB7 ${l} dies`,...p(y,l)}}),a=R-s*2;if(i.length>0){const n=w?pt*2+(st?oo:0):st&&!ot?no+so:0,l=Math.max(1,Math.floor((G-2*s-n)/z));let g=i.length,L=1,y=g*z,I=[],j=0;const Q=b||ot;if(Q){const V=se(i.map(T=>T.totalWidth)),F=Math.max(1,Math.min(i.length,Math.floor((a+8)/(V+8))));for(let T=F;T>=1;T--){const C=Math.ceil(i.length/T);if(C>l)continue;const S=new Array(T).fill(0);for(let A=0;A<i.length;A++){const r=A%T;S[r]=Math.max(S[r],i[A].totalWidth)}if(S.reduce((A,r)=>A+r,0)+(T-1)*8<=a||T===1){L=T,I=S,g=C,y=C*z;break}}}else g=Math.min(i.length,l),y=g*z,i.length>l&&(j=i.length-(l-1)),I=[_t];let N,B;if(w){const V=se(i.map(r=>Z+Tt+t.measureText(r.label).width+ae)),F=Math.ceil(V);I=[F];const T=st?oo:0,C=F+pt*2,S=y+T+pt*2,K=U?.x??0,A=U?.y??0;N=Math.min(Math.max(R-s-C+K,s),R-s-C),B=Math.min(Math.max(G-s-S+A,s),G-s-S),at={x:N,y:B,w:C,h:S},t.save(),t.globalAlpha=.92,t.fillStyle=m.surface,t.fillRect(N,B,C,S),t.globalAlpha=1,t.strokeStyle=m.axisLine,t.lineWidth=1,t.strokeRect(N,B,C,S),t.restore(),N+=pt,B+=pt+T}else b?(N=s,B=G-s-y):ot?(N=s,B=s):Vt?(N=s,B=Math.max(s+Math.round((G-2*s-y)/2),s+n)):(N=R-s-_t+4,B=Math.max(s+Math.round((G-2*s-y)/2),s+n));if(st){const V=e.plotMode==="softBin"?It:Dt,{primary:F,secondary:T,note:C}=Ye(e,dt,V),S=so,K=[T,C].filter(M=>!!M),A=(M,E,Ct)=>K.forEach((Rt,ne)=>bt(Rt,M,E+ne*16,"left","top",Ct(E+ne*16),Ae(),m.text)),r=M=>Qt-Math.max(gt(M),gt(M-12))-8,O=M=>wt?R-s:r(M),X=w?at.y+at.h:B+y;if(ot){const M=X+S;bt(F,N,M,"left","top",Qt-Math.max(gt(M),gt(M+12))-8),A(N,M+16,r)}else if(w)bt(F,at.x+pt,at.y+pt,"left","top",at.x+at.w-pt),A(at.x,X+S,()=>at.x+at.w);else{const M=Math.max(B-S,s+no);bt(F,N,M,"left","bottom",O(M)),A(N,X+S,O)}}t.save(),t.font=ct();const yt=Q?8:0,ft=(V,F)=>{if(t.measureText(V).width<=F)return V;let T=0,C=V.length;const S="\u2026",K=t.measureText(S).width;for(;T<C;){const A=T+C+1>>1;t.measureText(V.slice(0,A)).width+K<=F?T=A:C=A-1}return T===0?S:V.slice(0,T)+S};if(Q){let V=0;for(let F=0;F<g;F++){let T=N;for(let C=0;C<L;C++){const S=i[V++];if(!S)break;const K=Nt.includes(S.key),A=!K&&S.key===J,r=T,O=T+Z+Tt,X=B+F*z+z/2,M=B+F*z+Math.round((z-Z)/2),E=I[C]-Z-Tt-ae;A&&(t.fillStyle=m.hoverRow,t.fillRect(T,B+F*z,I[C],z)),t.fillStyle=S.color,t.fillRect(r,M,Z,Z),t.strokeStyle=K?m.accent:"rgba(0,0,0,0.25)",t.lineWidth=K?2:.75,t.strokeRect(r,M,Z,Z),t.fillStyle=K?m.accent:m.text,t.font=K?`bold ${ct()}`:ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(ft(S.label,E),O,X),t.fillStyle=m.textMuted,t.font=ct(),t.textAlign="right",t.fillText(String(S.count),T+I[C]-2,X),Te.push({bin:S.key,x:T,y:B+F*z,w:I[C],h:z,label:S.tooltipLabel}),T+=I[C]+yt}}}else{const V=I[0],F=nt!=="compact",T=V-Z-Tt-(F?ae:0),C=N+V-2;let S=i;j>0&&(S=i.slice(0,l-1));let K=B;for(const A of S){const r=Nt.includes(A.key),O=!r&&A.key===J,X=N,M=N+Z+Tt,E=K+z/2,Ct=K+Math.round((z-Z)/2),Rt=A.label;O&&(t.fillStyle=m.hoverRow,t.fillRect(N-3,K,V+3,z)),t.fillStyle=A.color,t.fillRect(X,Ct,Z,Z),t.strokeStyle=r?m.accent:"rgba(0,0,0,0.25)",t.lineWidth=r?2:.75,t.strokeRect(X,Ct,Z,Z),t.fillStyle=r?m.accent:m.text,t.font=r?`bold ${ct()}`:ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(ft(Rt,T),M,E),(F||w)&&(t.fillStyle=m.textMuted,t.font=ct(),t.textAlign="right",t.fillText(String(A.count),C,E)),Te.push({bin:A.key,x:N,y:K,w:V,h:z,label:A.tooltipLabel}),K+=z}j>0&&(t.fillStyle=m.textMuted,t.font=ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(`+ ${j} more`,N+Z+Tt,K+z/2))}}i.length>0&&t.restore()}const ho={originX:lt,originY:it,ppm:P,snapDist:Zt},Fe=e.rectangles[0]?.width??1,Oe=e.rectangles[0]?.height??1,ut=e.dieBounds,ee=ut?ut.minX:tt.length?we(tt.map(o=>o.x)):0,oe=ut?ut.minY:tt.length?we(tt.map(o=>o.y)):0,go=ut?ut.maxX:tt.length?se(tt.map(o=>o.x)):1,mo=ut?ut.maxY:tt.length?se(tt.map(o=>o.y)):1,{cellW:Se,cellH:ke,nCols:Gt,nRows:Le}=Lo(go-ee,mo-oe,Fe*1.5,Oe*1.5,tt.length),He=Array.from({length:Gt*Le},()=>[]);for(let o=0;o<tt.length;o++){const c=Math.floor((tt[o].x-ee)/Se),x=Math.floor((tt[o].y-oe)/ke),u=Number.isFinite(c)?Math.max(0,Math.min(Gt-1,c)):0,k=Number.isFinite(x)?Math.max(0,Math.min(Le-1,x)):0;He[k*Gt+u].push(o)}function Ge(o,c,x){const u=Math.max(0,Math.floor((o-x-ee)/Se)),k=Math.min(Gt-1,Math.floor((o+x-ee)/Se)),p=Math.max(0,Math.floor((c-x-oe)/ke)),h=Math.min(Le-1,Math.floor((c+x-oe)/ke)),i=[];for(let a=p;a<=h;a++)for(let n=u;n<=k;n++)for(const l of He[a*Gt+n])i.push(l);return i}return{hitTarget:{getDieAtPoint(o,c){const x=(o-lt)/P,u=(it-c)/P,k=Math.max(Fe,Oe);for(const i of Ge(x,u,k)){const a=e.rectangles[i];if(a&&Math.abs(x-a.x)<=a.width/2&&Math.abs(u-a.y)<=a.height/2)return e.dies[i]??null}let p=null,h=Zt*Zt;for(const i of Ge(x,u,Zt)){const a=tt[i].x-x,n=tt[i].y-u,l=a*a+n*n;l<h&&(h=l,p=e.dies[i]??null)}return p}},viewport:ho,binLegendRows:Te,legendBox:at}}function Io(f,e,q,m,s,D,rt,d,Y,_,U,H,W,et,$,J){f.save(),f.font=Do(),f.fillStyle=$.text,f.strokeStyle=$.axisLine,f.lineWidth=.5;const Pt=_.bottom-d+rt+4,dt=_.left+Y-4,Bt=xo(W),Dt=$e(Bt,1,0),It=$e(Bt,0,1),St=1e-9;function st(b){return H?Math.abs(b.y)<St&&Math.abs(b.x)>St?{pitch:H.x,sign:Math.sign(b.x),axis:"x"}:Math.abs(b.x)<St&&Math.abs(b.y)>St?{pitch:H.y,sign:Math.sign(b.y),axis:"y"}:null:null}function Nt(b,ot){if(!J||!b)return null;const w=b.axis==="x"?J.columns:J.rows,_t=b.axis==="x"?J.columnBreaks:J.rowBreaks,Kt=b.axis==="x"?J.centreColumn:J.centreRow;return uo(w.length,_t,b.pitch*D,ot).map(Ft=>({mm:b.sign*(Ft-Kt)*b.pitch,label:String(w[Ft])}))}const R=st(Dt),G=st(It);function Wt(b){return R?Math.round(b*R.sign/R.pitch):b}function Et(b){return G?Math.round(b*G.sign/G.pitch):b}function kt(b){if(!b)return Yt(50/D);const ot=50/(b*D);return Math.max(1,Math.round(ot))*b}const xt=R?.pitch,Mt=G?.pitch,Lt=kt(xt),At=kt(Mt);f.textAlign="center",f.textBaseline="top";const ht=Math.ceil(Math.max((_.left-m)/D,U.minX)/Lt)*Lt,$t=Math.min((_.right-m)/D,U.maxX),v=Nt(R,36)??lo(ht,$t,Lt,b=>H?String(Wt(b)):qe(b));for(const{mm:b,label:ot}of v){const w=m+b*D;w<_.left||w>_.right||(f.beginPath(),f.moveTo(w,Pt-to),f.lineTo(w,Pt),f.stroke(),f.fillText(ot,w,Pt+2))}f.textAlign="right",f.textBaseline="middle";const nt=Math.ceil(Math.max((s-(_.bottom-d))/D,U.minY)/At)*At,wt=Math.min((s-_.top)/D,U.maxY),Vt=Nt(G,16)??lo(nt,wt,At,b=>H?String(Et(b)):qe(b));for(const{mm:b,label:ot}of Vt){const w=s-b*D;w<_.top||w>_.bottom-d||(f.beginPath(),f.moveTo(dt,w),f.lineTo(dt+to,w),f.stroke(),f.fillText(ot,dt-2,w))}f.restore()}function lo(f,e,q,m){const s=[];for(let D=f;D<=e;D+=q)s.push({mm:D,label:m(D)});return s}function No(f,e,q,m,s,D,rt){const d=[],Y=rt;if(Y<1){const W=Yt((e-f)*m/q);if(W>0){const et=Math.ceil(f/W)*W;for(let $=et;$<=e+W*1e-6;$+=W){if($<=f||$>=e)continue;const J=(1-(Math.log10($)-D)/rt)*q;J>s&&J<q-s&&d.push($)}}return d}const _=Y<3?[1,2,5]:[1],U=Math.floor(Math.log10(f)),H=Math.ceil(Math.log10(e));for(let W=U;W<=H;W++)for(const et of _){const $=et*Math.pow(10,W);if($<=f||$>=e)continue;const J=(1-(Math.log10($)-D)/rt)*q;J>s&&J<q-s&&d.push($)}return d}export{fmt,fmtColorbarAxis}from"../renderer/fmt.js";export const PATH_SHAPES=256;const io=new WeakMap;export function outlineSegments(f){const e=d=>Math.round(d*1e6),q=new Map,m=new Map,s=(d,Y,_,U)=>{const H=e(Y);let W=d.get(H);W||d.set(H,W={at:Y,spans:[]}),W.spans.push([_,U])};for(const d of f){const Y=d.x-d.width/2,_=d.x+d.width/2,U=d.y-d.height/2,H=d.y+d.height/2;s(q,U,Y,_),s(q,H,Y,_),s(m,Y,U,H),s(m,_,U,H)}const D=[],rt=(d,Y)=>{for(const{at:_,spans:U}of d.values()){U.sort((et,$)=>et[0]-$[0]);let[H,W]=U[0];for(let et=1;et<U.length;et++){const[$,J]=U[et];e($)<=e(W)?J>W&&(W=J):(Y(_,H,W),H=$,W=J)}Y(_,H,W)}};return rt(q,(d,Y,_)=>D.push(Y,d,_,d)),rt(m,(d,Y,_)=>D.push(d,Y,d,_)),Float64Array.from(D)}
1
+ import{fontPx as Xt}from"./toolbar.js";import{findTestDef as Xe,buildMapTitle as Ye}from"../renderer/buildView.js";import{niceStep as Yt,compactTickIndices as go}from"../renderer/axisTicks.js";import{sortBinsForDisplay as mo}from"../stats/binPareto.js";import{affineInvert as uo,affineVector as $e}from"../core/transforms.js";import{asList as po,compareNatural as xo,maxOf as se,minOf as we}from"../core/utils.js";import{valueColorFn as Mo}from"../renderer/dataColors.js";import{NO_DATA_FILL as yo}from"../renderer/colorMap.js";import{contrastTextColor as Ve}from"../renderer/colorMap.js";import{fmt as Ke,fmtColorbarAxis as ze}from"../renderer/fmt.js";import{resolveCanvasTheme as bo}from"./canvasTheme.js";import{hitGridDims as To}from"./hitGrid.js";const So=5,qe=4;function Ue(f,e,Y,u,s){f.moveTo(e,Y+s*u),f.lineTo(e-u*.9,Y-s*u*.6),f.lineTo(e+u*.9,Y-s*u*.6),f.closePath()}const ko=new Set(["value","stackedValues","stackedBins","stackedSoftBins","stackedFails"]),Lo=new Set(["hardBin","softBin","metadata"]),ct=()=>`${Xt(-2)}px system-ui, sans-serif`,Je=3,le=2,Ao=6,_o=20,Ro=()=>`600 ${Xt()}px system-ui, sans-serif`,je=36,Ae=()=>`${Xt(-1)}px system-ui, sans-serif`,Ze=()=>`600 ${Xt(-1)}px system-ui, sans-serif`,ie=128,Co=()=>`${Xt(-2)}px system-ui, sans-serif`,Qe=4,q=17,Z=11;export const BIN_LEGEND_W=110,BIN_LEGEND_W_COMPACT=64,BIN_LEGEND_MAP_GAP=12;const ve=8;export const BIN_LEGEND_ADAPT_COMPACT=280,BIN_LEGEND_ADAPT_FLOATING=180,BIN_LEGEND_MIN_CANVAS_W=150,BIN_LEGEND_MIN_CANVAS_H=120;const ae=28,Tt=5,pt=8,to=15,eo=12,oo=6;export function toCanvas(f,e,Y={}){return drawMapCanvas(f,e,Y)}export function drawMapCanvas(f,e,Y={}){const u=Y.theme??bo(f.parentElement??f),{padding:s=16,showColorbar:F=!0,markFailingDies:rt=!1,colorbarWidth:g=16,background:$=u.background,legendPosition:_="default",legendOffset:U,showAxes:H=!1,diePitchMm:N,viewport:et,activeBin:w,hoverBin:J,afterDies:Bt,fallbackFormat:dt,minRightReserve:Pt,hbinDefs:Ft,sbinDefs:Dt,metadataFields:St,showTitle:st=!0}=Y,It=po(w),C=Math.floor(f.clientWidth||f.width),G=Math.floor(f.clientHeight||f.height),Nt=C>=BIN_LEGEND_MIN_CANVAS_W&&G>=BIN_LEGEND_MIN_CANVAS_H,Wt=F&&Nt&&ko.has(e.plotMode)&&e.passFailDisplay==="off",kt=F&&Nt&&Lo.has(e.plotMode),xt=F&&Nt&&e.plotMode==="value"&&(e.passFailDisplay==="spec"&&e.specCounts!==void 0||e.passFailDisplay==="test"&&e.passFailCounts!==void 0),Mt=kt||xt,Lt=kt&&e.plotMode!=="metadata"&&e.binCounts?mo(e.binCounts.entries(),e.plotMode==="softBin"?e.binColors.pass.soft:e.binColors.pass.hard):[],At=kt&&e.plotMode==="metadata"&&e.metadataCounts?[...e.metadataColorMap?.keys()??[...e.metadataCounts.keys()].sort(xo)].map(o=>[o,e.metadataCounts.get(o)??0]):[],ht=[];if(xt&&e.passFailDisplay==="test"){const o=e.passFailCounts;ht.push({key:-1,color:e.passFailFills.pass,label:"Pass",compactLabel:"Pass",count:o.pass,tooltip:`Pass \xB7 ${o.pass} dies`}),ht.push({key:-2,color:e.passFailFills.failHigh,label:"Fail",compactLabel:"Fail",count:o.fail,tooltip:`Fail \xB7 ${o.fail} dies`})}else if(xt){const o=e.specCounts,a=Xe(e.testDefs,e.activeTest);ht.push({key:-1,color:e.passFailFills.pass,label:"Pass",compactLabel:"Pass",count:o.pass,tooltip:`Pass \xB7 ${o.pass} dies`}),a?.limitHigh!==void 0&&ht.push({key:-2,color:e.passFailFills.failHigh,label:"Fail high",compactLabel:"Fail hi",count:o.failHigh,tooltip:`Fail high \xB7 ${o.failHigh} dies`}),a?.limitLow!==void 0&&ht.push({key:-3,color:e.passFailFills.failLow,label:"Fail low",compactLabel:"Fail lo",count:o.failLow,tooltip:`Fail low \xB7 ${o.failLow} dies`})}const $t=xt?ht.length:e.plotMode==="metadata"?At.length:Lt.length,v=(f.ownerDocument.defaultView??window).devicePixelRatio??1;if(C<=0||G<=0)return{hitTarget:{getDieAtPoint:()=>null},viewport:{originX:0,originY:0,ppm:1,snapDist:1},binLegendRows:[]};const nt=_!=="default"?_:C<BIN_LEGEND_ADAPT_FLOATING?"floating":C<BIN_LEGEND_ADAPT_COMPACT?"compact":"default",wt=nt==="default"||nt==="compact",Vt=nt==="left",y=nt==="bottom",ot=nt==="top",V=nt==="floating",_t=nt==="compact"||nt==="floating"?BIN_LEGEND_W_COMPACT:BIN_LEGEND_W,Kt=Math.floor((G-2*s)/q),Et=$t>Kt?Kt-1:$t,ce=Mt&&y?Et*q+ve:0,zt=Mt&&ot?Et*q+ve:0,re=e.plotMode==="stackedBins"||e.plotMode==="stackedSoftBins"||e.plotMode==="stackedFails",fe=Xe(e.testDefs,e.activeTest),_e=re?"Count":fe?.name??(e.activeTest!=null?`Test ${e.activeTest}`:void 0),Re=re?void 0:fe?.unit,[Ot,Ht]=e.valueRange,he=o=>String(Math.round(o)),lo=e.logScale||e.allIntegerValues?void 0:Yt(Math.max(0,Ht-Ot)*je/Math.max(1,G))||void 0,de=e.allIntegerValues?he:ze(Ht,_e,Re,dt,lo).edgeFmt;let ge=0;if(Wt){const o=f.getContext("2d");o.font=ct();const a=[de(Ot),de(Ht)];Ot<0&&a.push(de(-Math.max(Math.abs(Ot),Math.abs(Ht))));for(const h of a)ge=Math.max(ge,o.measureText(h).width)}const Ce=Math.max(_o,Math.ceil(ge)+Je+le+Ao-s),me=Wt?g+Ce+8:Mt&&wt?_t+BIN_LEGEND_MAP_GAP:0,qt=Mt&&Vt?_t+BIN_LEGEND_MAP_GAP:0,ue=H?32:0,Ut=H?36:0,Be=Pt!=null?Math.max(me,Pt):me,io=C-2*s-Be-Ut-qt,Pe=G-2*s-ue-ce-zt;f.width=Math.round(C*v),f.height=Math.round(G*v);const t=f.getContext("2d");t.scale(v,v),t.fillStyle=$,t.fillRect(0,0,C,G);const tt=e.hoverPoints;if(!tt.length)return{hitTarget:{getDieAtPoint:()=>null},viewport:{originX:0,originY:0,ppm:1,snapDist:1},binLegendRows:[]};const Jt=e.rectangles[0],pe=Jt?Jt.width/2:0,xe=Jt?Jt.height/2:0,jt=e.dieBounds,Me=(jt?.minX??0)-pe,Fe=(jt?.maxX??0)+pe,De=(jt?.minY??0)-xe,ye=(jt?.maxY??0)+xe,Ie=Fe-Me,Ne=ye-De;let lt,it,B;if(et)({originX:lt,originY:it,ppm:B}=et);else{const a=e.notchDir,h=a&&a.y>.1?13:0,m=a&&a.y<-.1?13:0,k=a&&a.x<-.1?13:0,x=a&&a.x>.1?13:0,d=io-k-x,i=Pe-h-m;B=Math.min(d/Ie,i/Ne),lt=s+Ut+qt+k+(d-Ie*B)/2-Me*B,it=s+zt+h+(i-Ne*B)/2+ye*B}const Zt=et?.snapDist??Math.max(pe,xe,1)*1.5,Qt=lt+e.waferCenter.x*B,ao=it-e.waferCenter.y*B,be=e.waferRadius*B,gt=o=>{const a=Math.abs(o-ao);return a>=be?0:Math.sqrt(be*be-a*a)},yt=(o,a,h,m,k,x,d=Ro(),i=u.text)=>{if(!o)return;t.save(),t.fillStyle=i,t.font=d,t.textAlign=m,t.textBaseline=k;const c=m==="right"?a-x:x-a;let n=o;if(c>8&&t.measureText(n).width>c){for(;n.length>1&&t.measureText(n+"\u2026").width>c;)n=n.slice(0,-1);n=n+"\u2026"}c>8&&t.fillText(n,a,h),t.restore()};t.save(),t.setTransform(B*v,0,0,-B*v,lt*v,it*v);const mt=1/B;let vt=!1;const co=1/(B*v),te=e.rectangles.length>0&&e.dieGap*B*v<1;for(const o of e.overlays)if(!(o.kind!=="wafer-boundary"||!o.closed)){t.beginPath();for(const a of o.points)a.forEach((h,m)=>m===0?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y)),t.closePath();t.fillStyle=u.waferFill,t.fill()}if(e.rectangles.length>0){const o=new Map;for(const d of e.rectangles){const i=String(d.fill);let c=o.get(i);c||(c=[],o.set(i,c)),c.push(d)}const a=B*v,h=lt*v,m=it*v,k=e.dieGap/2;te&&(t.save(),t.setTransform(1,0,0,1,0,0));for(const[d,i]of o){t.fillStyle=d;for(let c=0;c<i.length;c+=PATH_SHAPES){t.beginPath();const n=Math.min(i.length,c+PATH_SHAPES);for(let l=c;l<n;l++){const p=i[l];if(te){const L=p.width/2+k,b=p.height/2+k,D=2*L*a>=qe?1:0,j=2*b*a>=qe?1:0,Q=Math.round(h+(p.x-L)*a),I=Math.max(Q+1,Math.round(h+(p.x+L)*a)-D),P=Math.round(m-(p.y+b)*a),bt=Math.max(P+1,Math.round(m-(p.y-b)*a)-j);t.rect(Q,P,I-Q,bt-P)}else t.rect(p.x-p.width/2,p.y-p.height/2,p.width,p.height)}t.fill()}}if(te&&t.restore(),!te){t.strokeStyle="rgba(0,0,0,0.18)",t.lineWidth=.5*co,t.lineCap="square";const d=so.get(e.rectangles)??outlineSegments(e.rectangles);so.set(e.rectangles,d);const i=PATH_SHAPES*4;for(let c=0;c<d.length;c+=i){t.beginPath();const n=Math.min(d.length,c+i);for(let l=c;l<n;l+=4)t.moveTo(d[l],d[l+1]),t.lineTo(d[l+2],d[l+3]);t.stroke()}t.lineCap="butt"}if(rt){const d=e.rectangles.filter(i=>i.binFail);if(d.length>0){const i=new Map;for(const c of d){const n=Ve(String(c.fill));let l=i.get(n);l||(l=[],i.set(n,l)),l.push(c)}t.save(),t.lineCap="butt";for(const[c,n]of i){t.strokeStyle=c,t.globalAlpha=.55,t.lineWidth=Math.max(.6*mt,Math.min(n[0].width,n[0].height)*.1);for(const l of n){const p=l.width/2,L=l.height/2,b=Math.max(1.6*mt,Math.min(l.width,l.height)/3);t.save(),t.beginPath(),t.rect(l.x-p,l.y-L,l.width,l.height),t.clip(),t.beginPath();for(let D=-(p+L);D<=p+L;D+=b)t.moveTo(l.x-p+D,l.y-L),t.lineTo(l.x-p+D+l.height,l.y+L);t.stroke(),t.restore()}}t.restore()}}const x=e.rectangles.filter(d=>d.specMark);if(vt=x.length>0&&Math.min(x[0].width,x[0].height)<So*mt,x.length>0&&!vt){const d=new Map;for(const c of x){const n=Ve(String(c.fill)),l=`${c.specMark}|${n}`;let p=d.get(l);p||(p=[],d.set(l,p)),p.push(c)}const i=2.5*mt;t.lineJoin="round";for(const[c,n]of d){const[l,p]=c.split("|"),L=p==="#000000"?"#ffffff":"#000000",b=l==="failHigh"?1:-1,D=Math.min(n[0].width,n[0].height),j=Math.max(2.5*mt,D*.3);t.beginPath();for(const Q of n)Ue(t,Q.x,Q.y,j,b);t.strokeStyle=L,t.lineWidth=i,t.stroke(),t.fillStyle=p,t.fill()}}}for(const o of e.overlays){t.beginPath();for(const a of o.points){for(let h=0;h<a.length;h++)h===0?t.moveTo(a[h].x,a[h].y):t.lineTo(a[h].x,a[h].y);o.closed&&t.closePath()}o.fill&&!o.fill.startsWith("rgba(0,0,0,0)")&&(t.fillStyle=o.fill,t.fill()),o.kind==="ring-boundary"||o.kind==="quadrant-boundary"||o.kind==="reticle"?(t.strokeStyle="rgba(0,0,0,0.45)",t.lineWidth=3*mt,t.stroke(),t.strokeStyle="rgba(255,255,255,0.8)",t.lineWidth=1*mt,t.stroke()):(t.strokeStyle=o.lineColor,t.lineWidth=o.lineWidth*mt,t.stroke())}if(t.restore(),e.notchDir){const o=lt+e.waferCenter.x*B,a=it-e.waferCenter.y*B,h=e.notchDir.x,m=-e.notchDir.y,k=e.waferRadius*B,x=4,d=9,i=5,c=o+h*(k+x),n=a+m*(k+x),l=c+h*d,p=n+m*d,L={x:-m,y:h},b=s+Ut+qt,D=C-s-me,j=s+zt,Q=G-s-ce-ue;t.save(),t.beginPath(),t.rect(b,j,D-b,Q-j),t.clip(),t.beginPath(),t.moveTo(c,n),t.lineTo(l+L.x*i,p+L.y*i),t.lineTo(l-L.x*i,p-L.y*i),t.closePath(),t.fillStyle=u.text,t.fill(),t.restore()}t.save(),t.textAlign="center",t.textBaseline="middle";let We=0;if(e.rectangles.length>0){let o=1;for(const x of e.texts)x.role!=="indicator"&&x.text.length>o&&(o=x.text.length);const a=e.rectangles[0].width*B,h=e.rectangles[0].height*B,m=Math.min(a,h),k=a/o;We=Math.max(8,Math.min(64,Math.round(Math.min(m*.55,k*1.8))))}for(const o of e.texts){const a=lt+o.x*B,h=it-o.y*B;t.font=`${o.role==="indicator"?o.fontSize:We}px system-ui, sans-serif`,t.fillStyle=o.color,t.fillText(o.text,a,h)}if(t.restore(),Bt?.(t,{originX:lt,originY:it,ppm:B},{background:$,text:u.text}),H&&Bo(t,C,G,lt,it,B,s,ue,Ut,{left:s+qt,right:C-s-Be,top:s+zt,bottom:G-s-ce},{minX:Me,maxX:Fe,minY:De,maxY:ye},N,e.gridToScreen,e.rotation,u,e.compact),Wt){const o=Mo(e.dataColors,e.valueRole,e.reverseValueScheme,e.darkTheme,e.greyscaleValues),a=Ce,h=Pe,m=Math.round(h*.75),k=s+Math.round((h-m)/2),x=C-s-g-a,d=Ot,i=Ht,c=i-d,n=e.plotMode==="stackedSoftBins"?Dt:Ft,{primary:l,secondary:p,note:L}=st?Ye(e,dt,n):{primary:"",secondary:"",note:void 0};if(st){const r=Math.max(k-6,s+11),O=Qt+Math.max(gt(r),gt(r-12))+8;yt(l,C-s,r,"right","bottom",O)}let b=k+m+4;const D=r=>Qt+Math.max(gt(r),gt(r+12))+8,j=e.logScale&&d>0?Math.log10(d):0,Q=e.logScale&&i>0?Math.log10(i)-j:1,I=r=>e.logScale?(1-(Math.log10(r)-j)/Q)*m:(1-(r-d)/c)*m;for(let r=0;r<ie;r++){const O=1-r/(ie-1),X=k+r/ie*m,M=m/ie+1;t.fillStyle=o(O),t.fillRect(x,X,g,M)}t.strokeStyle="rgba(0,0,0,0.25)",t.lineWidth=.5,t.strokeRect(x,k,g,m),t.fillStyle=u.text,t.font=ct(),t.textAlign="left",t.strokeStyle="rgba(0,0,0,0.35)",t.lineWidth=.5;const P=Je,bt=je,ft=14;let K;const E=e.logScale&&Q>0?Po(d,i,m,bt,ft,j,Q):e.allIntegerValues?(()=>{const r=Math.max(1,Yt(c*bt/m)),O=[],X=Math.ceil(d/r)*r;for(let M=X;M<=i+r*1e-6;M+=r){const W=(1-(M-d)/c)*m;W>ft&&W<m-ft&&O.push(Math.round(M))}return O})():(()=>{const r=c>0?Yt(c*bt/m):0,O=[];if(r>0){K=r;const X=Math.ceil(d/r)*r;for(let M=X;M<=i+r*1e-6;M+=r){const W=(1-(M-d)/c)*m;W>ft&&W<m-ft&&O.push(M)}}return O})(),T=fe,R=re,S=ze(i,_e,Re,dt,K),z=e.allIntegerValues?he:S.tickFmt,A=e.allIntegerValues?he:S.edgeFmt;t.textBaseline="middle";for(const r of E){const O=k+I(r);t.beginPath(),t.moveTo(x+g,O),t.lineTo(x+g+P,O),t.stroke(),t.fillText(z(r),x+g+P+le,O)}if(t.beginPath(),t.moveTo(x+g,k),t.lineTo(x+g+P,k),t.stroke(),t.textBaseline="top",t.fillText(A(i),x+g+P+le,k),t.beginPath(),t.moveTo(x+g,k+m),t.lineTo(x+g+P,k+m),t.stroke(),t.textBaseline="bottom",t.fillText(A(d),x+g+P+le,k+m),!R&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0)){const r=[],O=e.colorbarRangeMode==="spec";for(const[X,M]of[[T.limitLow,"Lo limit"],[T.limitHigh,"Hi limit"]]){if(X===void 0||e.logScale&&X<=0)continue;const W=I(X);!O&&(W<-ft||W>m+ft)||r.push({value:X,label:M,py:Math.max(0,Math.min(m,W))})}if(r.length>0){t.save(),t.font=ct(),t.textAlign="right",t.textBaseline="middle";for(const{py:X,label:M}of r){const W=k+X;if(O||(t.strokeStyle="rgba(255,255,255,0.85)",t.lineWidth=3,t.beginPath(),t.moveTo(x,W),t.lineTo(x+g,W),t.stroke(),t.strokeStyle="rgba(0,0,0,0.7)",t.lineWidth=1,t.beginPath(),t.moveTo(x,W),t.lineTo(x+g,W),t.stroke()),t.fillStyle=u.text,t.fillText(M,x-3,W),vt)continue;const Rt=M==="Hi limit"?-1:1,Ct=4,ne=x-3-t.measureText(M).width-Ct-4;t.beginPath(),Ue(t,ne,W,Ct,Rt),t.strokeStyle="#fff",t.lineWidth=2,t.lineJoin="round",t.stroke(),t.fillStyle=u.text,t.fill()}t.restore()}}if(!R){const r=e.logScale?"log\u2081\u2080":e.logScaleRequested?"linear \u2014 log n/a":null;r&&(t.save(),t.fillStyle=u.text,t.font=Ze(),t.textAlign="right",t.textBaseline="top",t.fillText(r,C-s,b),t.restore(),b+=15)}vt&&(t.save(),t.fillStyle=u.text,t.font=Ze(),t.textAlign="right",t.textBaseline="top",t.fillText("\u25BD\u25B3 limit marks: zoom in",C-s,b),t.restore(),b+=15),st&&p&&(yt(p,C-s,b,"right","top",D(b),Ae(),u.text),b+=15),st&&L&&yt(L,C-s,b,"right","top",D(b),Ae(),u.text)}const Te=[];let at;if(Mt){const o=nt==="compact",a=e.plotMode==="softBin"?Dt:Ft,h=a?new Map(a.map(n=>[n.bin,n])):null,m=e.plotMode==="softBin"?e.binColors.soft:e.binColors.hard,k=n=>m.get(n)??yo,x=(n,l)=>{const p=t.measureText(n).width,L=o?0:t.measureText(String(l)).width,b=Z+Tt+p+(L?ae:0);return{labelWidth:p,countWidth:L,totalWidth:b}},d=St?.find(n=>n.key===e.activeMetadataKey),i=xt?ht.map(n=>{const l=o?n.compactLabel:n.label;return{key:n.key,color:n.color,count:n.count,label:l,tooltipLabel:n.tooltip,...x(l,n.count)}}):e.plotMode==="metadata"?At.map(([n,l])=>{const L=d?.values?.find(j=>j.value===n)?.label??n,b=o?n:L,D=e.metadataColorMap?.get(n)??"#d6d9dd";return{key:n,color:D,count:l,label:b,tooltipLabel:`${L} \xB7 ${l} dies`,...x(b,l)}}):Lt.map(([n,l])=>{const p=h?.get(n),L=p?.name?`${n} \xB7 ${p.name}`:`Bin ${n}`,b=o?String(n):L;return{key:n,color:k(n),count:l,label:b,tooltipLabel:`${L} \xB7 ${l} dies`,...x(b,l)}}),c=C-s*2;if(i.length>0){const n=V?pt*2+(st?to:0):st&&!ot?eo+oo:0,l=Math.max(1,Math.floor((G-2*s-n)/q));let p=i.length,L=1,b=p*q,D=[],j=0;const Q=y||ot;if(Q){const K=se(i.map(T=>T.totalWidth)),E=Math.max(1,Math.min(i.length,Math.floor((c+8)/(K+8))));for(let T=E;T>=1;T--){const R=Math.ceil(i.length/T);if(R>l)continue;const S=new Array(T).fill(0);for(let A=0;A<i.length;A++){const r=A%T;S[r]=Math.max(S[r],i[A].totalWidth)}if(S.reduce((A,r)=>A+r,0)+(T-1)*8<=c||T===1){L=T,D=S,p=R,b=R*q;break}}}else p=Math.min(i.length,l),b=p*q,i.length>l&&(j=i.length-(l-1)),D=[_t];let I,P;if(V){const K=se(i.map(r=>Z+Tt+t.measureText(r.label).width+ae)),E=Math.ceil(K);D=[E];const T=st?to:0,R=E+pt*2,S=b+T+pt*2,z=U?.x??0,A=U?.y??0;I=Math.min(Math.max(C-s-R+z,s),C-s-R),P=Math.min(Math.max(G-s-S+A,s),G-s-S),at={x:I,y:P,w:R,h:S},t.save(),t.globalAlpha=.92,t.fillStyle=u.surface,t.fillRect(I,P,R,S),t.globalAlpha=1,t.strokeStyle=u.axisLine,t.lineWidth=1,t.strokeRect(I,P,R,S),t.restore(),I+=pt,P+=pt+T}else y?(I=s,P=G-s-b):ot?(I=s,P=s):Vt?(I=s,P=Math.max(s+Math.round((G-2*s-b)/2),s+n)):(I=C-s-_t+4,P=Math.max(s+Math.round((G-2*s-b)/2),s+n));if(st){const K=e.plotMode==="softBin"?Dt:Ft,{primary:E,secondary:T,note:R}=Ye(e,dt,K),S=oo,z=[T,R].filter(M=>!!M),A=(M,W,Rt)=>z.forEach((Ct,ne)=>yt(Ct,M,W+ne*16,"left","top",Rt(W+ne*16),Ae(),u.text)),r=M=>Qt-Math.max(gt(M),gt(M-12))-8,O=M=>wt?C-s:r(M),X=V?at.y+at.h:P+b;if(ot){const M=X+S;yt(E,I,M,"left","top",Qt-Math.max(gt(M),gt(M+12))-8),A(I,M+16,r)}else if(V)yt(E,at.x+pt,at.y+pt,"left","top",at.x+at.w-pt),A(at.x,X+S,()=>at.x+at.w);else{const M=Math.max(P-S,s+eo);yt(E,I,M,"left","bottom",O(M)),A(I,X+S,O)}}t.save(),t.font=ct();const bt=Q?8:0,ft=(K,E)=>{if(t.measureText(K).width<=E)return K;let T=0,R=K.length;const S="\u2026",z=t.measureText(S).width;for(;T<R;){const A=T+R+1>>1;t.measureText(K.slice(0,A)).width+z<=E?T=A:R=A-1}return T===0?S:K.slice(0,T)+S};if(Q){let K=0;for(let E=0;E<p;E++){let T=I;for(let R=0;R<L;R++){const S=i[K++];if(!S)break;const z=It.includes(S.key),A=!z&&S.key===J,r=T,O=T+Z+Tt,X=P+E*q+q/2,M=P+E*q+Math.round((q-Z)/2),W=D[R]-Z-Tt-ae;A&&(t.fillStyle=u.hoverRow,t.fillRect(T,P+E*q,D[R],q)),t.fillStyle=S.color,t.fillRect(r,M,Z,Z),t.strokeStyle=z?u.accent:"rgba(0,0,0,0.25)",t.lineWidth=z?2:.75,t.strokeRect(r,M,Z,Z),t.fillStyle=z?u.accent:u.text,t.font=z?`bold ${ct()}`:ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(ft(S.label,W),O,X),t.fillStyle=u.textMuted,t.font=ct(),t.textAlign="right",t.fillText(String(S.count),T+D[R]-2,X),Te.push({bin:S.key,x:T,y:P+E*q,w:D[R],h:q,label:S.tooltipLabel}),T+=D[R]+bt}}}else{const K=D[0],E=nt!=="compact",T=K-Z-Tt-(E?ae:0),R=I+K-2;let S=i;j>0&&(S=i.slice(0,l-1));let z=P;for(const A of S){const r=It.includes(A.key),O=!r&&A.key===J,X=I,M=I+Z+Tt,W=z+q/2,Rt=z+Math.round((q-Z)/2),Ct=A.label;O&&(t.fillStyle=u.hoverRow,t.fillRect(I-3,z,K+3,q)),t.fillStyle=A.color,t.fillRect(X,Rt,Z,Z),t.strokeStyle=r?u.accent:"rgba(0,0,0,0.25)",t.lineWidth=r?2:.75,t.strokeRect(X,Rt,Z,Z),t.fillStyle=r?u.accent:u.text,t.font=r?`bold ${ct()}`:ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(ft(Ct,T),M,W),(E||V)&&(t.fillStyle=u.textMuted,t.font=ct(),t.textAlign="right",t.fillText(String(A.count),R,W)),Te.push({bin:A.key,x:I,y:z,w:K,h:q,label:A.tooltipLabel}),z+=q}j>0&&(t.fillStyle=u.textMuted,t.font=ct(),t.textAlign="left",t.textBaseline="middle",t.fillText(`+ ${j} more`,I+Z+Tt,z+q/2))}}i.length>0&&t.restore()}const ro={originX:lt,originY:it,ppm:B,snapDist:Zt},Ee=e.rectangles[0]?.width??1,Oe=e.rectangles[0]?.height??1,ut=e.dieBounds,ee=ut?ut.minX:tt.length?we(tt.map(o=>o.x)):0,oe=ut?ut.minY:tt.length?we(tt.map(o=>o.y)):0,fo=ut?ut.maxX:tt.length?se(tt.map(o=>o.x)):1,ho=ut?ut.maxY:tt.length?se(tt.map(o=>o.y)):1,{cellW:Se,cellH:ke,nCols:Gt,nRows:Le}=To(fo-ee,ho-oe,Ee*1.5,Oe*1.5,tt.length),He=Array.from({length:Gt*Le},()=>[]);for(let o=0;o<tt.length;o++){const a=Math.floor((tt[o].x-ee)/Se),h=Math.floor((tt[o].y-oe)/ke),m=Number.isFinite(a)?Math.max(0,Math.min(Gt-1,a)):0,k=Number.isFinite(h)?Math.max(0,Math.min(Le-1,h)):0;He[k*Gt+m].push(o)}function Ge(o,a,h){const m=Math.max(0,Math.floor((o-h-ee)/Se)),k=Math.min(Gt-1,Math.floor((o+h-ee)/Se)),x=Math.max(0,Math.floor((a-h-oe)/ke)),d=Math.min(Le-1,Math.floor((a+h-oe)/ke)),i=[];for(let c=x;c<=d;c++)for(let n=m;n<=k;n++)for(const l of He[c*Gt+n])i.push(l);return i}return{hitTarget:{getDieAtPoint(o,a){const h=(o-lt)/B,m=(it-a)/B,k=Math.max(Ee,Oe);for(const i of Ge(h,m,k)){const c=e.rectangles[i];if(c&&Math.abs(h-c.x)<=c.width/2&&Math.abs(m-c.y)<=c.height/2)return e.dies[i]??null}let x=null,d=Zt*Zt;for(const i of Ge(h,m,Zt)){const c=tt[i].x-h,n=tt[i].y-m,l=c*c+n*n;l<d&&(d=l,x=e.dies[i]??null)}return x}},viewport:ro,binLegendRows:Te,legendBox:at}}function Bo(f,e,Y,u,s,F,rt,g,$,_,U,H,N,et,w,J){f.save(),f.font=Co(),f.fillStyle=w.text,f.strokeStyle=w.axisLine,f.lineWidth=.5;const Bt=_.bottom-g+rt+4,dt=_.left+$-4,Pt=uo(N),Ft=$e(Pt,1,0),Dt=$e(Pt,0,1),St=1e-9;function st(y){return H?Math.abs(y.y)<St&&Math.abs(y.x)>St?{pitch:H.x,sign:Math.sign(y.x),axis:"x"}:Math.abs(y.x)<St&&Math.abs(y.y)>St?{pitch:H.y,sign:Math.sign(y.y),axis:"y"}:null:null}function It(y,ot){if(!J||!y)return null;const V=y.axis==="x"?J.columns:J.rows,_t=y.axis==="x"?J.columnBreaks:J.rowBreaks,Kt=y.axis==="x"?J.centreColumn:J.centreRow;return go(V.length,_t,y.pitch*F,ot).map(Et=>({mm:y.sign*(Et-Kt)*y.pitch,label:String(V[Et])}))}const C=st(Ft),G=st(Dt);function Nt(y){return C?Math.round(y*C.sign/C.pitch):y}function Wt(y){return G?Math.round(y*G.sign/G.pitch):y}function kt(y){if(!y)return Yt(50/F);const ot=50/(y*F);return Math.max(1,Math.round(ot))*y}const xt=C?.pitch,Mt=G?.pitch,Lt=kt(xt),At=kt(Mt);f.textAlign="center",f.textBaseline="top";const ht=Math.ceil(Math.max((_.left-u)/F,U.minX)/Lt)*Lt,$t=Math.min((_.right-u)/F,U.maxX),v=It(C,36)??no(ht,$t,Lt,y=>H?String(Nt(y)):Ke(y));for(const{mm:y,label:ot}of v){const V=u+y*F;V<_.left||V>_.right||(f.beginPath(),f.moveTo(V,Bt-Qe),f.lineTo(V,Bt),f.stroke(),f.fillText(ot,V,Bt+2))}f.textAlign="right",f.textBaseline="middle";const nt=Math.ceil(Math.max((s-(_.bottom-g))/F,U.minY)/At)*At,wt=Math.min((s-_.top)/F,U.maxY),Vt=It(G,16)??no(nt,wt,At,y=>H?String(Wt(y)):Ke(y));for(const{mm:y,label:ot}of Vt){const V=s-y*F;V<_.top||V>_.bottom-g||(f.beginPath(),f.moveTo(dt,V),f.lineTo(dt+Qe,V),f.stroke(),f.fillText(ot,dt-2,V))}f.restore()}function no(f,e,Y,u){const s=[];for(let F=f;F<=e;F+=Y)s.push({mm:F,label:u(F)});return s}function Po(f,e,Y,u,s,F,rt){const g=[],$=rt;if($<1){const N=Yt((e-f)*u/Y);if(N>0){const et=Math.ceil(f/N)*N;for(let w=et;w<=e+N*1e-6;w+=N){if(w<=f||w>=e)continue;const J=(1-(Math.log10(w)-F)/rt)*Y;J>s&&J<Y-s&&g.push(w)}}return g}const _=$<3?[1,2,5]:[1],U=Math.floor(Math.log10(f)),H=Math.ceil(Math.log10(e));for(let N=U;N<=H;N++)for(const et of _){const w=et*Math.pow(10,N);if(w<=f||w>=e)continue;const J=(1-(Math.log10(w)-F)/rt)*Y;J>s&&J<Y-s&&g.push(w)}return g}export{fmt,fmtColorbarAxis}from"../renderer/fmt.js";export const PATH_SHAPES=256;const so=new WeakMap;export function outlineSegments(f){const e=g=>Math.round(g*1e6),Y=new Map,u=new Map,s=(g,$,_,U)=>{const H=e($);let N=g.get(H);N||g.set(H,N={at:$,spans:[]}),N.spans.push([_,U])};for(const g of f){const $=g.x-g.width/2,_=g.x+g.width/2,U=g.y-g.height/2,H=g.y+g.height/2;s(Y,U,$,_),s(Y,H,$,_),s(u,$,U,H),s(u,_,U,H)}const F=[],rt=(g,$)=>{for(const{at:_,spans:U}of g.values()){U.sort((et,w)=>et[0]-w[0]);let[H,N]=U[0];for(let et=1;et<U.length;et++){const[w,J]=U[et];e(w)<=e(N)?J>N&&(N=J):($(_,H,N),H=w,N=J)}$(_,H,N)}};return rt(Y,(g,$,_)=>F.push($,g,_,g)),rt(u,(g,$,_)=>F.push(g,$,g,_)),Float64Array.from(F)}
@@ -3,7 +3,7 @@ import type { Die } from '../core/dies.js';
3
3
  import type { TestDef, MetadataFieldDef } from '../renderer/buildWaferMap.js';
4
4
  import type { StatsSeverity } from '../stats/types.js';
5
5
  export declare function logWmapVersionOnce(): void;
6
- export declare const WMAP_TOKEN_NAMES: readonly ["z", "icon", "icon-hover", "icon-active", "bg-hover", "bg-active", "separator", "surface", "border", "control-border", "menu-hover", "menu-active", "font-family", "font-size", "density", "panel-bg", "text-muted", "text", "text-strong", "warn-bg", "warn-border", "warn-text", "err-bg", "err-border", "err-text", "info-bg", "info-text", "selected", "finding-indicator", "canvas-bg", "bar-fill"];
6
+ export declare const WMAP_TOKEN_NAMES: readonly ["z", "icon", "icon-hover", "icon-active", "bg-hover", "bg-active", "separator", "surface", "border", "control-border", "menu-hover", "menu-active", "font-family", "font-size", "density", "panel-bg", "text-muted", "text", "text-strong", "warn-bg", "warn-border", "warn-text", "err-bg", "err-border", "err-text", "info-bg", "info-text", "selected", "finding-indicator", "canvas-bg", "wafer-bg", "bar-fill"];
7
7
  export type WmapTokenName = (typeof WMAP_TOKEN_NAMES)[number];
8
8
  /**
9
9
  * The shapes an interactive element comes in. Nineteen sites set
@@ -234,10 +234,22 @@ export declare const Z_ABOVE2 = "calc(var(--wmap-z, 6000) + 3)";
234
234
  * and must still inherit the value.
235
235
  */
236
236
  export declare function applyOverlayZ(zIndex: number | undefined): () => void;
237
+ /**
238
+ * Put the data colour scheme's DOM-facing colours (the quantity bar, the shortfall tints, the signed ends) on `el`, so a
239
+ * table tint or a panel bar anywhere beneath it reads the reader's scheme with no plumbing, and a scheme change is one
240
+ * style update. The default values the readers fall back to are Classic's.
241
+ */
242
+ export declare function setDataColorVars(el: HTMLElement, dataColors: string | undefined, dark: boolean): void;
243
+ /**
244
+ * The data colour scheme the renderer above `el` set (`setDataColorVars`), for a surface that draws charts or reports of its
245
+ * own (the Summary panel's chart view and report buttons) and has no option carrying it. Undefined where none was set.
246
+ */
247
+ export declare function readDataColors(el: Element): string | undefined;
237
248
  /** Copy every `--wmap-*` custom property resolved on `src` onto `dest`, so an
238
249
  * element in a different document (e.g. a detached popup's `documentElement`)
239
250
  * renders with the same theme as the host page instead of silently reverting
240
- * to light-mode defaults. */
251
+ * to light-mode defaults.
252
+ * The data colour scheme's variables (`setDataColorVars`) are copied too. */
241
253
  export declare function copyWmapThemeTokens(src: Element, dest: HTMLElement): void;
242
254
  /**
243
255
  * Keeps a popup's copied `--wmap-*` tokens (`copyWmapThemeTokens`, above) in
@@ -301,6 +313,29 @@ export declare function setDetachWindowOpener(opener: DetachWindowOpener | null)
301
313
  export declare function openDetachWindow(label: string): Window | null;
302
314
  export declare const MODE_LABELS: Record<PlotMode, string>;
303
315
  export declare const BIN_LEGEND_MODES: Set<PlotMode>;
316
+ /**
317
+ * What the map is coloured by, in words, as the Plot mode button shows it: the test's name in value mode ("ioff_nA"),
318
+ * the field's name in metadata mode, else the mode's own name ("Hard bin", "Stacked test values").
319
+ */
320
+ export declare function plotModeName(opts: {
321
+ plotMode?: PlotMode;
322
+ activeTest?: number;
323
+ activeMetadataKey?: string;
324
+ }, testDefs?: TestDef[], metadataFields?: readonly MetadataFieldDef[]): string;
325
+ export interface ModeButtonName {
326
+ /** Show this name (the current mode's) on the button, if the row has room for it. */
327
+ update(name: string): void;
328
+ /** Re-judge the room, after a change the row's width does not show (controls shown or hidden). */
329
+ refit(): void;
330
+ }
331
+ /**
332
+ * The Plot mode button names what the map is coloured by — "Hard bin ▾", "ioff_nA ▾". The word and its ▾ are the first
333
+ * thing the chrome row drops when it runs short of width (step 1 of `fitChromeRow`, marked on the parts with
334
+ * `data-wmap-fit-hide`), so the word never costs the row a second line or the wafer its name. The button's accessible
335
+ * name and tooltip are "Plot mode: <name>" either way: it begins with the control's name, it contains the word shown,
336
+ * and the full name is always one hover away. `onChange` asks the row to fit again once the name has changed.
337
+ */
338
+ export declare function wireModeButtonName(btn: HTMLButtonElement, onChange: () => void): ModeButtonName;
304
339
  export declare const STACKED_MODES: Set<PlotMode>;
305
340
  /**
306
341
  * Host hook for persisting a rendered PNG. When supplied, the toolbar calls this
@@ -559,7 +594,8 @@ export type ModeEntry = {
559
594
  * items and can always offer them.
560
595
  */
561
596
  export declare function buildDataModeEntries(dies: Die[], testDefs: TestDef[] | undefined, options: {
562
- includeStacked: boolean;
597
+ includeStacked: boolean; /** Offer Stacked fails: the stack is built from the wafers themselves (a gallery). */
598
+ includeFails?: boolean;
563
599
  }): {
564
600
  testEntries: ModeEntry[];
565
601
  binEntries: ModeEntry[];
@@ -635,8 +671,27 @@ export interface ExpandToggleHandle {
635
671
  * content), this only owns the open/closed boolean and its triggers.
636
672
  */
637
673
  export declare function wireExpandToggle(trigger: HTMLElement, onChange: (open: boolean) => void): ExpandToggleHandle;
674
+ /**
675
+ * One choice in a `group` row: a small button laid out beside its neighbours, so a handful of related choices take
676
+ * one line of the menu instead of one each. Shows `text`, or the `icon` when it has no text; `label` is its accessible
677
+ * name and its tooltip.
678
+ */
679
+ export interface CheckMenuGroupItem {
680
+ label: string;
681
+ text?: string;
682
+ /** A key of `ICONS`. Used when there is no `text`. */
683
+ icon?: string;
684
+ active: boolean;
685
+ enabled?: boolean;
686
+ disabledHint?: string;
687
+ /** Does something rather than holding a state (Rotate, Reset): no selected look, a plain `menuitem`. */
688
+ action?: boolean;
689
+ onClick: (e: MouseEvent) => void;
690
+ }
638
691
  export type CheckMenuRow = {
639
692
  section: string;
693
+ } | {
694
+ group: CheckMenuGroupItem[];
640
695
  } | {
641
696
  label: string;
642
697
  active: boolean;
@@ -666,6 +721,8 @@ export type CheckMenuRow = {
666
721
  * one to a screen reader.
667
722
  */
668
723
  action?: boolean;
724
+ /** Colours drawn as a small strip after the label, so a choice between colour schemes can be seen. Decoration: the label names the choice. */
725
+ swatches?: readonly string[];
669
726
  onClick: (e: MouseEvent) => void;
670
727
  };
671
728
  /**
@@ -813,42 +870,39 @@ export interface ReparentModalOptions {
813
870
  * both call sites), this is defense in depth, not the primary guard.
814
871
  */
815
872
  export declare function openReparentedModal(elements: HTMLElement[], opts?: ReparentModalOptions): OverlayHandle | null;
816
- /**
817
- * `sync()` hides the button entirely in `'metadata'` mode — that mode never
818
- * consults `colorFns`/the active colour scheme at all (always the dedicated
819
- * ordered palette + `MetadataFieldDef.values[].color` overrides, see
820
- * `pushDieRectangles`), so every scheme choice would be a real control with
821
- * zero visible effect, not just a restricted one — worse than the existing
822
- * hardBin/softBin restriction (which still changes the die colours, just from
823
- * a smaller scheme set).
824
- */
825
- /** The colour preferences the palette menu reads and writes. */
873
+ /** The colour preferences the Data colours menu reads and writes. */
826
874
  export interface PaletteState {
827
875
  plotMode: PlotMode;
876
+ dataColors?: string;
828
877
  binColorScheme?: string;
829
878
  valueColorScheme?: string;
830
879
  reverseValueScheme?: boolean;
880
+ greyscaleValues?: boolean;
831
881
  useDefinedBinColors?: boolean;
882
+ /** The Insights view is showing, so the menu is about the charts' colours, not this map's. */
883
+ insightsOpen?: boolean;
832
884
  }
833
885
  /**
834
- * Colour-scheme picker. Lists bin palettes in `hardBin`/`softBin` and value
835
- * gradients everywhere else — including the stacked modes, whose maps are
836
- * values (a bin's occurrence rate per position), not bin categories. The two
837
- * are separate preferences, so choosing a gradient for values leaves the bin
838
- * palette alone and vice versa; nothing is reset on a mode switch.
886
+ * The Data colours menu. It sits beside the plot-mode button in the chrome row, reachable from both views, and it is the same menu in
887
+ * a map, the gallery and Insights: one choice, a complete data colour scheme, that reaches every map, chart, table tint
888
+ * and panel bar. Each row carries a small strip of the scheme's colours so the choice can be seen. Below the list:
839
889
  *
840
- * Colours that arrive with the data (`BinDef.color`) are a layer over the bin
841
- * palette, not a pseudo-palette: the "Use colours from bin definitions" row
842
- * appears only when some definition carries a colour, and turning it off
843
- * shows the palette's own colours for those bins.
890
+ * - **Greyscale**, with Reverse, draws that measured ramp in greys (it prints in black and white); bins and categories keep their colours;
891
+ * - **Reverse gradient**, when the map shows a measured value (a value map or stacked values; not in Insights, whose charts
892
+ * have their own Reverse colours where they colour a measurement); it flips the scheme's measured ramp only;
893
+ * - **Use colours from bin definitions**, when some definition carries a colour;
894
+ * - **Bin colours** (bin maps and Insights) and **Value colours** (value and stacked maps), when the host registered a bin
895
+ * palette or value gradient of its own, or one is chosen: each lists the host's under its own label, with **Scheme
896
+ * colours** to go back to the scheme's own. A choice here holds whichever scheme is picked above it.
844
897
  *
845
- * "Mark failing dies" used to live here too; it is in Overlays, beside the
846
- * pass/fail display rows it belongs with.
898
+ * Which entry is ticked comes from the rule the map draws by (`dataColorsName`).
847
899
  */
848
900
  export declare function makePaletteBtn(helpers: ToolbarHelpers, getState: () => PaletteState, hasDefinedBinColors: () => boolean, apply: (partial: {
901
+ dataColors?: string;
849
902
  binColorScheme?: string;
850
903
  valueColorScheme?: string;
851
904
  reverseValueScheme?: boolean;
905
+ greyscaleValues?: boolean;
852
906
  useDefinedBinColors?: boolean;
853
907
  }) => void): {
854
908
  btn: HTMLButtonElement;
@@ -937,18 +991,17 @@ export declare function makeLogScaleBtn(helpers: ToolbarHelpers, getOpts: () =>
937
991
  };
938
992
  export type LegendPosition = 'default' | 'compact' | 'left' | 'top' | 'bottom' | 'floating';
939
993
  /**
940
- * Per-map legend control, shared by the single map and the gallery.
994
+ * The legend rows of the View menu, shared by the single map and the gallery.
941
995
  *
942
996
  * `perMap` is supplied only by the gallery, which is the one context where a
943
997
  * single lot-level legend can stand in for every card's — and where the width
944
998
  * a per-card legend costs is multiplied by the card count. A single map has
945
999
  * nothing to stand in for it, so it never gets the toggle.
946
1000
  *
947
- * The menu mixes a position group with that toggle rather than being two
948
- * controls, because "how does the legend appear" is one question to the user
949
- * even though it is two options underneath.
1001
+ * Empty when there is nothing to choose: a single map coloured by a value has a
1002
+ * colour bar, whose placement is fixed.
950
1003
  */
951
- export declare function makeLegendStyleBtn(helpers: ToolbarHelpers, getOpts: () => {
1004
+ export declare function legendStyleRows(getOpts: () => {
952
1005
  plotMode?: PlotMode;
953
1006
  legendPosition?: LegendPosition;
954
1007
  }, setLegendPosition: (v: LegendPosition) => void, perMap?: {
@@ -956,12 +1009,9 @@ export declare function makeLegendStyleBtn(helpers: ToolbarHelpers, getOpts: ()
956
1009
  set: (v: boolean) => void;
957
1010
  /** Non-empty when the toggle cannot apply right now — shown as the reason. */
958
1011
  blockedReason: () => string | null;
959
- }): {
960
- btn: HTMLButtonElement;
961
- sync: () => void;
962
- };
963
- export declare function makeOverlaysBtn(helpers: ToolbarHelpers, getRows: () => CheckMenuRow[], isAnyOn: () => boolean): HTMLButtonElement;
964
- export declare function makeOrientationBtn(helpers: ToolbarHelpers, getOpts: () => {
1012
+ }): CheckMenuRow[];
1013
+ /** The orientation rows of the View menu: rotate, flip, and one exact way back. */
1014
+ export declare function orientationRows(getOpts: () => {
965
1015
  rotation?: number;
966
1016
  flipX?: boolean;
967
1017
  flipY?: boolean;
@@ -970,5 +1020,44 @@ export declare function makeOrientationBtn(helpers: ToolbarHelpers, getOpts: ()
970
1020
  flipX?: boolean;
971
1021
  flipY?: boolean;
972
1022
  showXYIndicator?: boolean;
973
- }) => void): HTMLButtonElement;
1023
+ }) => void): CheckMenuRow[];
1024
+ /** True when the map is turned or mirrored from the orientation it was built with. */
1025
+ export declare function isReoriented(o: {
1026
+ rotation?: number;
1027
+ flipX?: boolean;
1028
+ flipY?: boolean;
1029
+ }): boolean;
1030
+ /** One section of the View menu. A section with no rows is left out, heading and all. */
1031
+ export interface ViewMenuSection {
1032
+ title: string;
1033
+ rows: () => CheckMenuRow[];
1034
+ }
1035
+ /**
1036
+ * The View menu: how the map is drawn, apart from its colours — overlays, legend, orientation and, in the gallery,
1037
+ * columns. One labelled menu in the chrome row in place of a bare icon each, shared by the single map and the gallery.
1038
+ * The button shows pressed while anything in it differs from the map as built (`isChanged`).
1039
+ */
1040
+ export declare function makeViewBtn(helpers: ToolbarHelpers, sections: ViewMenuSection[], isChanged: () => boolean): HTMLButtonElement;
1041
+ /** One thing the Export menu can make: a report, the data tables, an image of the whole gallery. */
1042
+ export interface ExportAction {
1043
+ label: string;
1044
+ run: () => void;
1045
+ }
1046
+ /**
1047
+ * The Export menu: what can be taken away from the whole page — the Summary report, the data tables and, in the
1048
+ * gallery, an image of every wafer. Saving one map's image stays the camera in that map's own tools. Hidden while
1049
+ * there is nothing to export (`sync`).
1050
+ */
1051
+ export declare function makeExportBtn(helpers: ToolbarHelpers, getActions: () => ExportAction[]): {
1052
+ btn: HTMLButtonElement;
1053
+ sync: () => void;
1054
+ };
1055
+ /**
1056
+ * A category's importance as the Summary panel and Insights show it: a dot and the level's word ("● High"), High in the
1057
+ * warning colour and bold, Medium muted, Low (an item's impact) muted with a ring for the dot. The word is the meaning; the dot only lets the eye find it. Its accessible name
1058
+ * is "Importance: High". The one copy, so the two surfaces cannot drift apart.
1059
+ */
1060
+ export declare function importanceMark(doc: Document, level: 'high' | 'medium' | 'low', word: string, accessibleName: string): HTMLSpanElement;
1061
+ /** The stripe at a category's left edge, by its importance: the warning colour for High, a control edge for Medium. */
1062
+ export declare function importanceStripe(level: 'high' | 'medium' | undefined): string;
974
1063
  //# sourceMappingURL=toolbar.d.ts.map