@wafertools/wafermap 0.35.1 → 0.37.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 (188) hide show
  1. package/AGENTS.md +13 -10
  2. package/CHANGELOG.md +474 -0
  3. package/README.md +7 -7
  4. package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
  5. package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
  6. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  7. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
  8. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
  9. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
  10. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  11. package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
  12. package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
  13. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
  15. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
  16. package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
  17. package/dist/packages/canvas-adapter/charts/index.js +1 -1
  18. package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
  19. package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
  20. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
  21. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
  23. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  26. package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
  27. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  28. package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
  29. package/dist/packages/canvas-adapter/dieList.js +2 -2
  30. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
  31. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
  32. package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
  33. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  34. package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
  35. package/dist/packages/canvas-adapter/filterButton.js +1 -0
  36. package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
  37. package/dist/packages/canvas-adapter/filterEditor.js +1 -0
  38. package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
  39. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  40. package/dist/packages/canvas-adapter/icons.js +1 -1
  41. package/dist/packages/canvas-adapter/index.d.ts +1 -0
  42. package/dist/packages/canvas-adapter/index.js +1 -1
  43. package/dist/packages/canvas-adapter/insightsTab.d.ts +57 -2
  44. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  45. package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
  46. package/dist/packages/canvas-adapter/pageFilter.js +2 -0
  47. package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
  48. package/dist/packages/canvas-adapter/patMaps.js +1 -0
  49. package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
  50. package/dist/packages/canvas-adapter/plotCard.js +1 -0
  51. package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
  52. package/dist/packages/canvas-adapter/plotEditor.js +1 -1
  53. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  54. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  55. package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
  56. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  57. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
  58. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  59. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +71 -37
  60. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  61. package/dist/packages/canvas-adapter/summaryPanel.d.ts +22 -9
  62. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  63. package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
  64. package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
  65. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  66. package/dist/packages/canvas-adapter/toolbar.d.ts +12 -6
  67. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  68. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  69. package/dist/packages/canvas-adapter/userGuideHtml.js +607 -117
  70. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  71. package/dist/packages/canvas-adapter/version.js +1 -1
  72. package/dist/packages/canvas-adapter/warnings.js +1 -1
  73. package/dist/packages/core/aggregates.d.ts +10 -0
  74. package/dist/packages/core/aggregates.js +1 -1
  75. package/dist/packages/core/classify.d.ts +11 -0
  76. package/dist/packages/core/classify.js +1 -1
  77. package/dist/packages/core/dieTable.d.ts +5 -0
  78. package/dist/packages/core/dieTable.js +1 -1
  79. package/dist/packages/core/dies.d.ts +2 -0
  80. package/dist/packages/core/dies.js +1 -1
  81. package/dist/packages/core/wafer.d.ts +10 -1
  82. package/dist/packages/core/wafer.js +1 -1
  83. package/dist/packages/renderer/buildView.d.ts +5 -0
  84. package/dist/packages/renderer/buildView.js +1 -1
  85. package/dist/packages/renderer/buildWaferMap.d.ts +21 -4
  86. package/dist/packages/renderer/buildWaferMap.js +1 -1
  87. package/dist/packages/renderer/deprecate.d.ts +2 -8
  88. package/dist/packages/renderer/deprecate.js +1 -1
  89. package/dist/packages/renderer/derivedTests/parser.js +1 -1
  90. package/dist/packages/renderer/fmt.d.ts +10 -0
  91. package/dist/packages/renderer/fmt.js +1 -1
  92. package/dist/packages/renderer/index.d.ts +1 -0
  93. package/dist/packages/renderer/index.js +1 -1
  94. package/dist/packages/renderer/testLabel.d.ts +0 -11
  95. package/dist/packages/renderer/testLabel.js +1 -1
  96. package/dist/packages/renderer/valueFilter.d.ts +1 -1
  97. package/dist/packages/renderer/valueFilter.js +1 -1
  98. package/dist/packages/stats/analyzeWaferLot.d.ts +22 -0
  99. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  100. package/dist/packages/stats/analyzeWaferMap.d.ts +26 -1
  101. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  102. package/dist/packages/stats/binPareto.d.ts +2 -54
  103. package/dist/packages/stats/binPareto.js +1 -1
  104. package/dist/packages/stats/binRows.js +1 -1
  105. package/dist/packages/stats/capability.d.ts +10 -0
  106. package/dist/packages/stats/capability.js +1 -1
  107. package/dist/packages/stats/cardSpec.d.ts +53 -0
  108. package/dist/packages/stats/cardSpec.js +1 -0
  109. package/dist/packages/stats/chartCatalogue.d.ts +37 -0
  110. package/dist/packages/stats/chartCatalogue.js +1 -0
  111. package/dist/packages/stats/clusterDetection.d.ts +9 -0
  112. package/dist/packages/stats/clusterDetection.js +1 -1
  113. package/dist/packages/stats/commonality.d.ts +62 -0
  114. package/dist/packages/stats/commonality.js +1 -0
  115. package/dist/packages/stats/connectedComponents.js +1 -1
  116. package/dist/packages/stats/control.d.ts +21 -0
  117. package/dist/packages/stats/control.js +1 -0
  118. package/dist/packages/stats/correlation.d.ts +42 -4
  119. package/dist/packages/stats/correlation.js +1 -1
  120. package/dist/packages/stats/dieRegions.d.ts +4 -1
  121. package/dist/packages/stats/dieRegions.js +1 -1
  122. package/dist/packages/stats/differenceMap.d.ts +22 -0
  123. package/dist/packages/stats/differenceMap.js +1 -0
  124. package/dist/packages/stats/examplePicks.d.ts +22 -0
  125. package/dist/packages/stats/examplePicks.js +1 -0
  126. package/dist/packages/stats/filterFile.d.ts +41 -0
  127. package/dist/packages/stats/filterFile.js +2 -0
  128. package/dist/packages/stats/filterFindings.d.ts +21 -6
  129. package/dist/packages/stats/filterFindings.js +1 -1
  130. package/dist/packages/stats/findingText.d.ts +8 -0
  131. package/dist/packages/stats/findingText.js +2 -2
  132. package/dist/packages/stats/groupCompare.d.ts +87 -0
  133. package/dist/packages/stats/groupCompare.js +1 -0
  134. package/dist/packages/stats/guideSections.d.ts +55 -0
  135. package/dist/packages/stats/guideSections.js +1 -0
  136. package/dist/packages/stats/index.d.ts +5 -2
  137. package/dist/packages/stats/index.js +1 -1
  138. package/dist/packages/stats/lotDrift.js +1 -1
  139. package/dist/packages/stats/math.d.ts +29 -4
  140. package/dist/packages/stats/math.js +1 -1
  141. package/dist/packages/stats/mergeTestDefs.js +1 -1
  142. package/dist/packages/stats/metadataColumns.d.ts +3 -0
  143. package/dist/packages/stats/metadataColumns.js +1 -1
  144. package/dist/packages/stats/pat.d.ts +58 -0
  145. package/dist/packages/stats/pat.js +1 -0
  146. package/dist/packages/stats/patSummary.d.ts +45 -0
  147. package/dist/packages/stats/patSummary.js +1 -0
  148. package/dist/packages/stats/patternClassification.d.ts +3 -3
  149. package/dist/packages/stats/patternClassification.js +1 -1
  150. package/dist/packages/stats/plotData.d.ts +294 -17
  151. package/dist/packages/stats/plotData.js +1 -1
  152. package/dist/packages/stats/plotId.d.ts +2 -0
  153. package/dist/packages/stats/plotId.js +1 -1
  154. package/dist/packages/stats/plotReferences.d.ts +17 -0
  155. package/dist/packages/stats/plotReferences.js +1 -0
  156. package/dist/packages/stats/plotSpec.d.ts +239 -3
  157. package/dist/packages/stats/plotSpec.js +4 -4
  158. package/dist/packages/stats/regions.js +1 -1
  159. package/dist/packages/stats/renderSummaryReport.js +33 -33
  160. package/dist/packages/stats/reportHtml.d.ts +5 -12
  161. package/dist/packages/stats/reportHtml.js +98 -40
  162. package/dist/packages/stats/synthesis.d.ts +48 -16
  163. package/dist/packages/stats/synthesis.js +1 -1
  164. package/dist/packages/stats/testPassRate.d.ts +7 -0
  165. package/dist/packages/stats/testPassRate.js +1 -1
  166. package/dist/packages/stats/testValueBudget.d.ts +15 -0
  167. package/dist/packages/stats/testValueBudget.js +1 -0
  168. package/dist/packages/stats/types.d.ts +90 -30
  169. package/dist/packages/stats/yield.d.ts +3 -11
  170. package/dist/packages/stats/yield.js +1 -1
  171. package/llms.txt +1 -1
  172. package/package.json +2 -1
  173. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
  174. package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
  175. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
  176. package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
  177. package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
  178. package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
  179. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
  180. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
  181. package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
  182. package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
  183. package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
  184. package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
  185. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
  186. package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
  187. package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
  188. package/dist/packages/canvas-adapter/charts/trend.js +0 -1
@@ -1,3 +1,3 @@
1
- export declare const WMAP_VERSION = "0.35.1";
2
- export declare const WMAP_BUILD_TIME = "2026-10-09T18:19:45.271Z";
1
+ export declare const WMAP_VERSION = "0.37.0";
2
+ export declare const WMAP_BUILD_TIME = "2026-10-20T13:45:09.045Z";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const WMAP_VERSION="0.35.1",WMAP_BUILD_TIME="2026-10-09T18:19:45.271Z";
1
+ export const WMAP_VERSION="0.37.0",WMAP_BUILD_TIME="2026-10-20T13:45:09.045Z";
@@ -1 +1 @@
1
- import{SHADOW as C,TRACKING as O,SPACE as r,RADIUS as v,FONT as y,CLR as d,Z_BASE as B}from"./toolbar.js";const E={error:0,warning:1,info:2};export function severityOf(t){return t.severity??"warning"}export function collectWarnings(t){const s=[],i=new Set,n=e=>{if(!e?.message)return;const o=`${e.code}\0${e.message}`;i.has(o)||(i.add(o),s.push(e))};for(const e of t.result?.warnings??[])n(e);for(const e of t.statsSummary?.stats.warnings??[])n(e);for(const e of t.lotStatsSummary?.perWafer??[])for(const o of e.summary.stats.warnings??[])n(o);for(const e of t.extra??[])n(e);return s.sort((e,o)=>E[severityOf(e)]-E[severityOf(o)])}function $(t){return t==="error"?{bg:d.errBg,border:d.errBorder,text:d.errText}:{bg:d.warnBg,border:d.warnBorder,text:d.warnText}}function S(t){return t==="error"?"\u26D4":t==="info"?"\u24D8":"\u26A0"}export const SHORT_LABEL={"partial-coverage":"Partial wafer coverage","geometry-conflict":"Geometry conflict","non-standard-diameter":"Non-standard wafer diameter","diameter-exceeds-die-extent":"Diameter exceeds die extent","edge-exclusion-exceeds-radius":"Edge exclusion exceeds radius","test-count-capped":"Test analysis skipped","test-def-collision":"Test definitions disagree","analysis-option-corrected":"Analysis option corrected","bin-colors-shared":"Bins share a colour","pass-bins-mixed":"Pass bins differ by wafer","ring-count-mixed":"Ring counts differ by wafer","input-field-removed":"Removed input name ignored","input-values-not-numbers":"Bins or test values are text","input-values-outside-stdf":"Values outside STDF ranges","retests-by-part-id":"Retests matched by part ID","derived-test-invalid":"Derived test not applied","values-excluded":"Values excluded by limits"};function w(t){const s=t.code?SHORT_LABEL[t.code]:void 0;if(s)return s;const i=t.message.split(/(?<=\.)\s/)[0]??t.message;return i.length>60?`${i.slice(0,57)}\u2026`:i}export function buildWarningsBanner(t,s=document){const i=s.createElement("div");Object.assign(i.style,{marginBottom:r.lg});for(const n of t){const e=severityOf(n),o=$(e),u=s.createElement("div");Object.assign(u.style,{background:o.bg,border:`1px solid ${o.border}`,borderRadius:v.control,marginBottom:r.sm,fontSize:y.body,color:o.text,lineHeight:"1.5"}),u.setAttribute("role","status");const a=s.createElement("button");a.type="button",Object.assign(a.style,{display:"flex",alignItems:"center",gap:r.sm,width:"100%",background:"none",border:"none",font:"inherit",color:"inherit",textAlign:"left",padding:`${r.sm} ${r.lg}`,cursor:"pointer"});const p=s.createElement("span");Object.assign(p.style,{flex:"1",minWidth:"0"}),p.textContent=`${S(e)} ${w(n)}`;const l=s.createElement("span");Object.assign(l.style,{flexShrink:"0"}),a.append(p,l);const g=s.createElement("div");Object.assign(g.style,{padding:`0 ${r.lg} ${r.sm}`}),g.textContent=n.message;let c=!1;const f=()=>{l.textContent=c?"\u25B4":"\u25BE",g.style.display=c?"block":"none",a.setAttribute("aria-expanded",String(c)),a.setAttribute("aria-label",`${w(n)}. ${c?"Click to collapse.":"Click to expand for detail."}`)};f(),a.addEventListener("click",()=>{c=!c,f()}),a.addEventListener("mouseenter",()=>{l.style.opacity="0.65"}),a.addEventListener("mouseleave",()=>{l.style.opacity="1"}),u.append(a,g),i.appendChild(u)}return i}export function buildWarningsMenuEl(t,s,i=window){const n=i.document,e=n.createElement("div"),o=280,a=t.left+o<=(i.innerWidth??1/0)?t.left:Math.max(4,t.right-o);Object.assign(e.style,{position:"fixed",top:`${t.bottom+4}px`,left:`${a}px`,background:d.menuBg,border:`1px solid ${d.menuBorder}`,borderRadius:v.control,boxShadow:C.menu,zIndex:B,width:`${o}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"}),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Data warnings");const p=n.createElement("div");Object.assign(p.style,{padding:`${r.sm} ${r.xl} ${r.xs}`,fontSize:y.body,fontWeight:"700",letterSpacing:O,textTransform:"uppercase",color:d.label}),p.textContent=s.length===1?"1 warning":`${s.length} warnings`,e.appendChild(p);for(const l of s){const g=severityOf(l),c=$(g),f=n.createElement("div");Object.assign(f.style,{display:"flex",gap:r.md,padding:`${r.md} ${r.xl}`,fontSize:y.body,lineHeight:"1.5",color:d.text,borderTop:`1px solid ${d.menuBorder}`,alignItems:"flex-start"});const m=n.createElement("span");Object.assign(m.style,{color:c.text,flexShrink:"0"}),m.textContent=S(g),f.appendChild(m);const x=n.createElement("div"),b=n.createElement("div");Object.assign(b.style,{fontWeight:"700",color:c.text,marginBottom:r.xxs}),b.textContent=l.code,x.appendChild(b);const h=n.createElement("div");h.textContent=l.message,x.appendChild(h),f.appendChild(x),e.appendChild(f)}return e}
1
+ import{SHADOW as C,TRACKING as O,SPACE as r,RADIUS as v,FONT as y,CLR as d,Z_BASE as B}from"./toolbar.js";const E={error:0,warning:1,info:2};export function severityOf(t){return t.severity??"warning"}export function collectWarnings(t){const s=[],i=new Set,n=e=>{if(!e?.message)return;const o=`${e.code}\0${e.message}`;i.has(o)||(i.add(o),s.push(e))};for(const e of t.result?.warnings??[])n(e);for(const e of t.statsSummary?.stats.warnings??[])n(e);for(const e of t.lotStatsSummary?.perWafer??[])for(const o of e.summary.stats.warnings??[])n(o);for(const e of t.extra??[])n(e);return s.sort((e,o)=>E[severityOf(e)]-E[severityOf(o)])}function $(t){return t==="error"?{bg:d.errBg,border:d.errBorder,text:d.errText}:{bg:d.warnBg,border:d.warnBorder,text:d.warnText}}function S(t){return t==="error"?"\u26D4":t==="info"?"\u24D8":"\u26A0"}export const SHORT_LABEL={"partial-coverage":"Partial wafer coverage","geometry-conflict":"Geometry conflict","non-standard-diameter":"Non-standard wafer diameter","diameter-exceeds-die-extent":"Diameter exceeds die extent","implausible-center":"Wafer centre ignored","edge-exclusion-exceeds-radius":"Edge exclusion exceeds radius","test-count-capped":"Test-value comparisons skipped","test-def-collision":"Test definitions disagree","analysis-option-corrected":"Analysis option corrected","bin-colors-shared":"Bins share a colour","pass-bins-mixed":"Pass bins differ by wafer","ring-count-mixed":"Ring counts differ by wafer","input-field-removed":"Removed input name ignored","input-values-not-numbers":"Bins or test values are text","input-values-outside-stdf":"Values outside STDF ranges","retests-by-part-id":"Retests matched by part ID","derived-test-invalid":"Derived test not applied","values-excluded":"Values excluded by limits"};function w(t){const s=t.code?SHORT_LABEL[t.code]:void 0;if(s)return s;const i=t.message.split(/(?<=\.)\s/)[0]??t.message;return i.length>60?`${i.slice(0,57)}\u2026`:i}export function buildWarningsBanner(t,s=document){const i=s.createElement("div");Object.assign(i.style,{marginBottom:r.lg});for(const n of t){const e=severityOf(n),o=$(e),u=s.createElement("div");Object.assign(u.style,{background:o.bg,border:`1px solid ${o.border}`,borderRadius:v.control,marginBottom:r.sm,fontSize:y.body,color:o.text,lineHeight:"1.5"}),u.setAttribute("role","status");const a=s.createElement("button");a.type="button",Object.assign(a.style,{display:"flex",alignItems:"center",gap:r.sm,width:"100%",background:"none",border:"none",font:"inherit",color:"inherit",textAlign:"left",padding:`${r.sm} ${r.lg}`,cursor:"pointer"});const p=s.createElement("span");Object.assign(p.style,{flex:"1",minWidth:"0"}),p.textContent=`${S(e)} ${w(n)}`;const l=s.createElement("span");Object.assign(l.style,{flexShrink:"0"}),a.append(p,l);const g=s.createElement("div");Object.assign(g.style,{padding:`0 ${r.lg} ${r.sm}`}),g.textContent=n.message;let c=!1;const f=()=>{l.textContent=c?"\u25B4":"\u25BE",g.style.display=c?"block":"none",a.setAttribute("aria-expanded",String(c)),a.setAttribute("aria-label",`${w(n)}. ${c?"Click to collapse.":"Click to expand for detail."}`)};f(),a.addEventListener("click",()=>{c=!c,f()}),a.addEventListener("mouseenter",()=>{l.style.opacity="0.65"}),a.addEventListener("mouseleave",()=>{l.style.opacity="1"}),u.append(a,g),i.appendChild(u)}return i}export function buildWarningsMenuEl(t,s,i=window){const n=i.document,e=n.createElement("div"),o=280,a=t.left+o<=(i.innerWidth??1/0)?t.left:Math.max(4,t.right-o);Object.assign(e.style,{position:"fixed",top:`${t.bottom+4}px`,left:`${a}px`,background:d.menuBg,border:`1px solid ${d.menuBorder}`,borderRadius:v.control,boxShadow:C.menu,zIndex:B,width:`${o}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"}),e.setAttribute("role","dialog"),e.setAttribute("aria-label","Data warnings");const p=n.createElement("div");Object.assign(p.style,{padding:`${r.sm} ${r.xl} ${r.xs}`,fontSize:y.body,fontWeight:"700",letterSpacing:O,textTransform:"uppercase",color:d.label}),p.textContent=s.length===1?"1 warning":`${s.length} warnings`,e.appendChild(p);for(const l of s){const g=severityOf(l),c=$(g),f=n.createElement("div");Object.assign(f.style,{display:"flex",gap:r.md,padding:`${r.md} ${r.xl}`,fontSize:y.body,lineHeight:"1.5",color:d.text,borderTop:`1px solid ${d.menuBorder}`,alignItems:"flex-start"});const m=n.createElement("span");Object.assign(m.style,{color:c.text,flexShrink:"0"}),m.textContent=S(g),f.appendChild(m);const x=n.createElement("div"),b=n.createElement("div");Object.assign(b.style,{fontWeight:"700",color:c.text,marginBottom:r.xxs}),b.textContent=l.code,x.appendChild(b);const h=n.createElement("div");h.textContent=l.message,x.appendChild(h),f.appendChild(x),e.appendChild(f)}return e}
@@ -5,6 +5,16 @@ export type AggregationMethod = 'mean' | 'median' | 'stddev' | 'min' | 'max' | '
5
5
  * count is a tally, so the test's limits say nothing about them.
6
6
  */
7
7
  export declare function stackHoldsMeasurements(method: string): boolean;
8
+ /**
9
+ * Whether the bins on a stack's dies are data. On a wafer and on a 'mode' stack
10
+ * (each position's most frequent bin) they are. A bin-occurrence stack
11
+ * ('countBin', 'percent') stamps the counted bin on every die so the map can name
12
+ * it; its data is the count in test 0, so it has no yield and no bin findings.
13
+ * A value stack ('mean' and the rest) keeps its template dies' bins, which
14
+ * describe one wafer, not the stack. The one rule for the build's yield and the
15
+ * analysis.
16
+ */
17
+ export declare function stackBinsAreData(isLotStack: boolean | undefined, method: string | undefined): boolean;
8
18
  /** Minimal die shape required by aggregation functions — satisfied by both Die and DieResult. */
9
19
  export interface DieLike {
10
20
  x: number;
@@ -1 +1 @@
1
- import{copyDie as p,testValue as m}from"./dieTable.js";import{minOf as M,maxOf as V}from"./utils.js";import{positionKey as d}from"./dies.js";export function stackHoldsMeasurements(n){return n!=="stddev"&&n!=="count"}export function aggregateValues(n,o,c=0){if(!n.length)return[];const a=new Map,f=new Map;for(const g of n)for(const t of g){const e=d(t),s=m(t,c);s!==void 0?(a.has(e)||(a.set(e,[]),f.set(e,t)),a.get(e).push(s)):f.has(e)||f.set(e,t)}const r=[];for(const[g,t]of f){const e=a.get(g);if(!e?.length){r.push(p(t,{testValues:void 0,testPass:void 0}));continue}let s;if(o==="mean")s=e.reduce((i,u)=>i+u,0)/e.length;else if(o==="median"){const i=[...e].sort((l,h)=>l-h),u=Math.floor(i.length/2);s=i.length%2?i[u]:(i[u-1]+i[u])/2}else if(o==="stddev"){if(e.length<2){r.push(p(t,{testValues:{0:0},testPass:void 0}));continue}const i=e.reduce((u,l)=>u+l,0)/e.length;s=Math.sqrt(e.reduce((u,l)=>u+(l-i)**2,0)/(e.length-1))}else o==="min"?s=M(e):o==="max"?s=V(e):s=e.length;r.push(p(t,{testValues:{0:s},testPass:void 0}))}return r}export function aggregateBinCounts(n,o,c="hard"){if(!n.length)return[];const a=new Map;for(const f of n)for(const r of f)if((c==="soft"?r.sbin:r.hbin)===o){const t=d(r);a.set(t,(a.get(t)??0)+1)}return(n[0]??[]).map(f=>p(f,{testValues:{0:a.get(d(f))??0},testPass:void 0,...c==="soft"?{sbin:o}:{hbin:o}}))}
1
+ import{copyDie as p,testValue as m}from"./dieTable.js";import{minOf as M,maxOf as x}from"./utils.js";import{positionKey as d}from"./dies.js";export function stackHoldsMeasurements(t){return t!=="stddev"&&t!=="count"}export function stackBinsAreData(t,s){return!t||s==="mode"}export function aggregateValues(t,s,l=0){if(!t.length)return[];const u=new Map,f=new Map;for(const g of t)for(const n of g){const e=d(n),o=m(n,l);o!==void 0?(u.has(e)||(u.set(e,[]),f.set(e,n)),u.get(e).push(o)):f.has(e)||f.set(e,n)}const a=[];for(const[g,n]of f){const e=u.get(g);if(!e?.length){a.push(p(n,{testValues:void 0,testPass:void 0}));continue}let o;if(s==="mean")o=e.reduce((i,r)=>i+r,0)/e.length;else if(s==="median"){const i=[...e].sort((c,h)=>c-h),r=Math.floor(i.length/2);o=i.length%2?i[r]:(i[r-1]+i[r])/2}else if(s==="stddev"){if(e.length<2){a.push(p(n,{testValues:{0:0},testPass:void 0}));continue}const i=e.reduce((r,c)=>r+c,0)/e.length;o=Math.sqrt(e.reduce((r,c)=>r+(c-i)**2,0)/(e.length-1))}else s==="min"?o=M(e):s==="max"?o=x(e):o=e.length;a.push(p(n,{testValues:{0:o},testPass:void 0}))}return a}export function aggregateBinCounts(t,s,l="hard"){if(!t.length)return[];const u=new Map;for(const f of t)for(const a of f)if((l==="soft"?a.sbin:a.hbin)===s){const n=d(a);u.set(n,(u.get(n)??0)+1)}return(t[0]??[]).map(f=>p(f,{testValues:{0:u.get(d(f))??0},testPass:void 0,...l==="soft"?{sbin:s}:{hbin:s}}))}
@@ -14,6 +14,17 @@ export interface ClassifyOptions {
14
14
  * the radius, a point on a boundary in the outer ring. The one ring rule; the edge ring is `ringCount`.
15
15
  */
16
16
  export declare function ringOf(dx: number, dy: number, radius: number, ringCount: number): number;
17
+ /**
18
+ * A die's offset from the wafer centre, in the wafer's own units, from its physical position (which follows the
19
+ * wafer's orientation, not the view's rotation). The one source of every radial and angular rule: ring, quadrant and
20
+ * radial position all read it.
21
+ */
22
+ export declare function centreOffset(die: PositionedDie, wafer: Wafer): {
23
+ dx: number;
24
+ dy: number;
25
+ };
26
+ /** A die's distance from the wafer centre as a share of the wafer radius: 0 at the centre, 1 at the edge. */
27
+ export declare function radialPosition(die: PositionedDie, wafer: Wafer): number;
17
28
  /**
18
29
  * Classify a die by its radial ring (1 = innermost) and physical wafer quadrant.
19
30
  *
@@ -1 +1 @@
1
- import{requireRingCount as h}from"./ringCount.js";export function ringOf(t,n,e,r){const a=Math.sqrt(t*t+n*n)/e;return Math.min(r,Math.max(1,Math.floor(a*r)+1))}const u=["NE","NW","SW","SE"];export function classifyDie(t,n,e){const r=Math.max(1,h(e,"classifyDie")),a=t.physX-n.center.x,o=t.physY-n.center.y,i=ringOf(a,o,n.radius,r),c=(Math.atan2(o,a)+2*Math.PI)%(2*Math.PI),s=u[Math.min(3,Math.floor(c/(Math.PI/2)))];return{ring:i,quadrant:s}}export function getRingLabel(t,n){return n===1?"Full Wafer":t===1?"Ring 1 (core)":t===n?`Ring ${t} (edge)`:`Ring ${t}`}
1
+ import{requireRingCount as u}from"./ringCount.js";export function ringOf(t,n,e,r){const o=Math.sqrt(t*t+n*n)/e;return Math.min(r,Math.max(1,Math.floor(o*r)+1))}export function centreOffset(t,n){return{dx:t.physX-n.center.x,dy:t.physY-n.center.y}}export function radialPosition(t,n){const{dx:e,dy:r}=centreOffset(t,n);return Math.sqrt(e*e+r*r)/n.radius}const f=["NE","NW","SW","SE"];export function classifyDie(t,n,e){const r=Math.max(1,u(e,"classifyDie")),{dx:o,dy:a}=centreOffset(t,n),i=ringOf(o,a,n.radius,r),s=(Math.atan2(a,o)+2*Math.PI)%(2*Math.PI),c=f[Math.min(3,Math.floor(s/(Math.PI/2)))];return{ring:i,quadrant:c}}export function getRingLabel(t,n){return n===1?"Full Wafer":t===1?"Ring 1 (core)":t===n?`Ring ${t} (edge)`:`Ring ${t}`}
@@ -69,6 +69,11 @@ export declare function excludedCounts(dies: readonly DieData[]): {
69
69
  counts: Map<number, number>;
70
70
  by: 'validity' | 'spec' | 'test';
71
71
  } | undefined;
72
+ /** How many of `dies` lost their value for `testNumber` to the value filter, and the limit set; `undefined` when none did. One column, not every test. */
73
+ export declare function excludedCountFor(dies: readonly DieData[], testNumber: number): {
74
+ count: number;
75
+ by: 'validity' | 'spec' | 'test';
76
+ } | undefined;
72
77
  /** The limit set the value filter excluded `die`'s values against, when it excluded any in its table. */
73
78
  export declare function excludedBy(die: DieData): 'validity' | 'spec' | 'test' | undefined;
74
79
  /** The value the filter excluded from `die` for `testNumber`, or `undefined` when none was. */
@@ -1 +1 @@
1
- import{hasAnyKey as P}from"./utils.js";const O=NaN;export const VERDICT_NONE=-1,VERDICT_FAIL=0,VERDICT_PASS=1,HAS_VALUES=1,HAS_VERDICTS=2;const l=Symbol("wmap.dieTable"),a=Symbol("wmap.dieRow");export function linkDie(e,t,s){return e[l]=t,e[a]=s,e}export function dieLink(e){const t=e[l];return t===void 0?void 0:{table:t,row:e[a]}}export function tableFromRows(e){const t=e.length,s=new Map,o=new Map,r=new Uint8Array(t),n=g(s,()=>new Float64Array(t).fill(O)),c=g(o,()=>new Int8Array(t).fill(VERDICT_NONE));for(let u=0;u<t;u++){const f=e[u].testValues;if(f){r[u]|=HAS_VALUES;const d=n(f),w=Object.values(f);for(let b=0;b<d.length;b++)d[b][u]=w[b]}const i=e[u].testPass;if(i){r[u]|=HAS_VERDICTS;const d=c(i),w=Object.values(i);for(let b=0;b<d.length;b++)d[b][u]=w[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:m(s),verdicts:m(o),fields:r}}function g(e,t){let s=[],o=[];return r=>{const n=Object.keys(r);let c=n.length===s.length;for(let u=0;c&&u<n.length;u++)c=n[u]===s[u];return c||(s=n,o=n.map(u=>{let f=e.get(u);return f===void 0&&e.set(u,f=t()),f})),o}}function m(e){return new Map([...e].map(([t,s])=>[Number(t),s]).sort((t,s)=>t[0]-s[0]))}export function extendTable(e,t,s){const o=new Map(e.values),r=new Map(e.verdicts);for(const[n,c]of t)o.set(n,c);for(const[n,c]of s)r.set(n,c);return{rows:e.rows,values:new Map([...o].sort((n,c)=>n[0]-c[0])),verdicts:new Map([...r].sort((n,c)=>n[0]-c[0])),fields:e.fields.slice(),...e.excluded?{excluded:e.excluded,excludedBy:e.excludedBy}:{}}}export function withExcluded(e,t,s,o){const r=new Map(e.values);for(const[c,u]of t)r.set(c,u);const n=new Map(e.excluded??[]);for(const[c,u]of s)n.set(c,u);return{...e,values:r,excluded:n,excludedBy:o}}export function excludedCounts(e){const t=new Map;let s;for(const o of e){const r=o[l];if(r?.excluded===void 0)continue;const n=o[a];for(const[c,u]of r.excluded)Number.isNaN(u[n])||(t.set(c,(t.get(c)??0)+1),s??=r.excludedBy)}return t.size===0||s===void 0?void 0:{counts:t,by:s}}export function excludedBy(e){return e[l]?.excludedBy}export function excludedValue(e,t){const o=e[l]?.excluded?.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function rowView(e){const t=linkDie({},e,0);return s=>(t[a]=s,t)}function v(e,t){const s={},o=[...e.values];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];Number.isNaN(n)||(s[o[r][0]]=n)}return s}function x(e,t){const s={},o=[...e.verdicts];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];n!==VERDICT_NONE&&(s[o[r][0]]=n===VERDICT_PASS)}return s}function j(){return Object.freeze(v(this[l],this[a]))}function k(){return Object.freeze(x(this[l],this[a]))}function N(e){return function(){throw new TypeError(`wafermap: die.${e} is read-only on a die built by buildWaferMap (die ${this.id}). Pass the values you want to buildWaferMap, or copy the die: { ...die, ${e}: yours }.`)}}const V={get:j,set:N("testValues"),enumerable:!0,configurable:!0},y={get:k,set:N("testPass"),enumerable:!0,configurable:!0},p=e=>({value:e,writable:!0,enumerable:!1,configurable:!0});export function finaliseDie(e){const t=e[l];if(t===void 0)return e;const s=e[a],o=t.fields[s],r=e.testValues!==void 0&&!(o&HAS_VALUES)||e.testPass!==void 0&&!(o&HAS_VERDICTS),n={};for(const c of Object.keys(e))c==="testValues"&&o&HAS_VALUES||c==="testPass"&&o&HAS_VERDICTS||(n[c]=e[c]);return r?(o&HAS_VALUES&&(n.testValues=v(t,s)),o&HAS_VERDICTS&&(n.testPass=x(t,s)),n):(Object.defineProperty(n,l,p(t)),Object.defineProperty(n,a,p(s)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",V),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",y),n)}export function copyDie(e,t){const s=e[l];if(s===void 0)return{...e,...t};const o=e[a],r=s.fields[o],n={};for(const c of Object.keys(e))c!=="testValues"&&c!=="testPass"&&(n[c]=e[c]);return"testValues"in t||"testPass"in t?(r&HAS_VALUES&&!("testValues"in t)&&(n.testValues=v(s,o)),r&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=x(s,o)),Object.assign(n,t)):(Object.assign(n,t),Object.defineProperty(n,l,p(s)),Object.defineProperty(n,a,p(o)),r&HAS_VALUES&&Object.defineProperty(n,"testValues",V),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",y),n)}export function detachTables(e){const t=[],s=new Map,o=e.reduce((u,f)=>u+f.length,0),r=new Int32Array(o*2);let n=0;for(const u of e)for(const f of u){const i=dieLink(f);if(i===void 0){r[n++]=-1,r[n++]=0;continue}let d=s.get(i.table);d===void 0&&(s.set(i.table,d=t.length),t.push(i.table)),r[n++]=d,r[n++]=i.row,delete f.testValues,delete f.testPass}const c=new Set;for(const u of t){for(const f of u.values.values())c.add(f.buffer);for(const f of u.verdicts.values())c.add(f.buffer);if(c.add(u.fields.buffer),u.excluded)for(const f of u.excluded.values())c.add(f.buffer)}return{tables:t,links:r,transfer:[...c]}}export function attachTables(e,t){let s=0;for(const o of e)for(const r of o){const n=t.links[s++],c=t.links[s++];if(n<0)continue;const u=t.tables[n],f=u.fields[c];Object.defineProperty(r,l,p(u)),Object.defineProperty(r,a,p(c)),f&HAS_VALUES&&Object.defineProperty(r,"testValues",V),f&HAS_VERDICTS&&Object.defineProperty(r,"testPass",y)}}export function testValue(e,t){const s=e[l];if(s===void 0)return e.testValues?.[t];const o=s.values.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function recordedVerdict(e,t){const s=e[l];if(s===void 0)return e.testPass?.[t];const o=s.verdicts.get(t)?.[e[a]];return o===void 0||o===VERDICT_NONE?void 0:o===VERDICT_PASS}export function dieHasAnyTestData(e){return dieHasValues(e)||dieHasVerdicts(e)}export function dieHasValues(e){const t=dieLink(e);if(t===void 0)return P(e.testValues);for(const s of t.table.values.values())if(!Number.isNaN(s[t.row]))return!0;return!1}export function dieHasVerdicts(e){const t=dieLink(e);if(t===void 0)return P(e.testPass);for(const s of t.table.verdicts.values())if(s[t.row]!==VERDICT_NONE)return!0;return!1}export function dieValueEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testValues;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.values){const n=r[t.row];Number.isNaN(n)||s.push([o,n])}return s}export function dieVerdictEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testPass;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.verdicts){const n=r[t.row];n!==VERDICT_NONE&&s.push([o,n===VERDICT_PASS])}return s}export function testValuesReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testValues;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?NaN:i}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.values.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?NaN:f[c.row]}return n}}export function recordedVerdictsReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testPass;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?VERDICT_NONE:i?VERDICT_PASS:VERDICT_FAIL}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.verdicts.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?VERDICT_NONE:f[c.row]}return n}}export function testsPresent(e,t="all"){const s=new Set,o=new Map;for(const r of e){const n=dieLink(r);if(n===void 0){if(r.testValues)for(const u in r.testValues)s.add(Number(u));if(t==="all"&&r.testPass)for(const u in r.testPass)s.add(Number(u));continue}let c=o.get(n.table);c===void 0&&o.set(n.table,c=[]),c.push(n.row)}for(const[r,n]of o){for(const[c,u]of r.values)!s.has(c)&&n.some(f=>!Number.isNaN(u[f]))&&s.add(c);if(t!=="values")for(const[c,u]of r.verdicts)!s.has(c)&&n.some(f=>u[f]!==VERDICT_NONE)&&s.add(c)}return[...s].sort((r,n)=>r-n)}
1
+ import{hasAnyKey as N}from"./utils.js";const O=NaN;export const VERDICT_NONE=-1,VERDICT_FAIL=0,VERDICT_PASS=1,HAS_VALUES=1,HAS_VERDICTS=2;const l=Symbol("wmap.dieTable"),a=Symbol("wmap.dieRow");export function linkDie(e,t,s){return e[l]=t,e[a]=s,e}export function dieLink(e){const t=e[l];return t===void 0?void 0:{table:t,row:e[a]}}export function tableFromRows(e){const t=e.length,s=new Map,o=new Map,r=new Uint8Array(t),n=P(s,()=>new Float64Array(t).fill(O)),c=P(o,()=>new Int8Array(t).fill(VERDICT_NONE));for(let u=0;u<t;u++){const f=e[u].testValues;if(f){r[u]|=HAS_VALUES;const d=n(f),x=Object.values(f);for(let b=0;b<d.length;b++)d[b][u]=x[b]}const i=e[u].testPass;if(i){r[u]|=HAS_VERDICTS;const d=c(i),x=Object.values(i);for(let b=0;b<d.length;b++)d[b][u]=x[b]?VERDICT_PASS:VERDICT_FAIL}}return{rows:t,values:g(s),verdicts:g(o),fields:r}}function P(e,t){let s=[],o=[];return r=>{const n=Object.keys(r);let c=n.length===s.length;for(let u=0;c&&u<n.length;u++)c=n[u]===s[u];return c||(s=n,o=n.map(u=>{let f=e.get(u);return f===void 0&&e.set(u,f=t()),f})),o}}function g(e){return new Map([...e].map(([t,s])=>[Number(t),s]).sort((t,s)=>t[0]-s[0]))}export function extendTable(e,t,s){const o=new Map(e.values),r=new Map(e.verdicts);for(const[n,c]of t)o.set(n,c);for(const[n,c]of s)r.set(n,c);return{rows:e.rows,values:new Map([...o].sort((n,c)=>n[0]-c[0])),verdicts:new Map([...r].sort((n,c)=>n[0]-c[0])),fields:e.fields.slice(),...e.excluded?{excluded:e.excluded,excludedBy:e.excludedBy}:{}}}export function withExcluded(e,t,s,o){const r=new Map(e.values);for(const[c,u]of t)r.set(c,u);const n=new Map(e.excluded??[]);for(const[c,u]of s)n.set(c,u);return{...e,values:r,excluded:n,excludedBy:o}}export function excludedCounts(e){const t=new Map;let s;for(const o of e){const r=o[l];if(r?.excluded===void 0)continue;const n=o[a];for(const[c,u]of r.excluded)Number.isNaN(u[n])||(t.set(c,(t.get(c)??0)+1),s??=r.excludedBy)}return t.size===0||s===void 0?void 0:{counts:t,by:s}}export function excludedCountFor(e,t){let s=0,o;for(const r of e){const n=r[l],c=n?.excluded?.get(t);c===void 0||Number.isNaN(c[r[a]])||(s++,o??=n.excludedBy)}return s>0&&o!==void 0?{count:s,by:o}:void 0}export function excludedBy(e){return e[l]?.excludedBy}export function excludedValue(e,t){const o=e[l]?.excluded?.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function rowView(e){const t=linkDie({},e,0);return s=>(t[a]=s,t)}function w(e,t){const s={},o=[...e.values];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];Number.isNaN(n)||(s[o[r][0]]=n)}return s}function v(e,t){const s={},o=[...e.verdicts];for(let r=o.length-1;r>=0;r--){const n=o[r][1][t];n!==VERDICT_NONE&&(s[o[r][0]]=n===VERDICT_PASS)}return s}function j(){return Object.freeze(w(this[l],this[a]))}function k(){return Object.freeze(v(this[l],this[a]))}function m(e){return function(){throw new TypeError(`wafermap: die.${e} is read-only on a die built by buildWaferMap (die ${this.id}). Pass the values you want to buildWaferMap, or copy the die: { ...die, ${e}: yours }.`)}}const y={get:j,set:m("testValues"),enumerable:!0,configurable:!0},V={get:k,set:m("testPass"),enumerable:!0,configurable:!0},p=e=>({value:e,writable:!0,enumerable:!1,configurable:!0});export function finaliseDie(e){const t=e[l];if(t===void 0)return e;const s=e[a],o=t.fields[s],r=e.testValues!==void 0&&!(o&HAS_VALUES)||e.testPass!==void 0&&!(o&HAS_VERDICTS),n={};for(const c of Object.keys(e))c==="testValues"&&o&HAS_VALUES||c==="testPass"&&o&HAS_VERDICTS||(n[c]=e[c]);return r?(o&HAS_VALUES&&(n.testValues=w(t,s)),o&HAS_VERDICTS&&(n.testPass=v(t,s)),n):(Object.defineProperty(n,l,p(t)),Object.defineProperty(n,a,p(s)),o&HAS_VALUES&&Object.defineProperty(n,"testValues",y),o&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),n)}export function copyDie(e,t){const s=e[l];if(s===void 0)return{...e,...t};const o=e[a],r=s.fields[o],n={};for(const c of Object.keys(e))c!=="testValues"&&c!=="testPass"&&(n[c]=e[c]);return"testValues"in t||"testPass"in t?(r&HAS_VALUES&&!("testValues"in t)&&(n.testValues=w(s,o)),r&HAS_VERDICTS&&!("testPass"in t)&&(n.testPass=v(s,o)),Object.assign(n,t)):(Object.assign(n,t),Object.defineProperty(n,l,p(s)),Object.defineProperty(n,a,p(o)),r&HAS_VALUES&&Object.defineProperty(n,"testValues",y),r&HAS_VERDICTS&&Object.defineProperty(n,"testPass",V),n)}export function detachTables(e){const t=[],s=new Map,o=e.reduce((u,f)=>u+f.length,0),r=new Int32Array(o*2);let n=0;for(const u of e)for(const f of u){const i=dieLink(f);if(i===void 0){r[n++]=-1,r[n++]=0;continue}let d=s.get(i.table);d===void 0&&(s.set(i.table,d=t.length),t.push(i.table)),r[n++]=d,r[n++]=i.row,delete f.testValues,delete f.testPass}const c=new Set;for(const u of t){for(const f of u.values.values())c.add(f.buffer);for(const f of u.verdicts.values())c.add(f.buffer);if(c.add(u.fields.buffer),u.excluded)for(const f of u.excluded.values())c.add(f.buffer)}return{tables:t,links:r,transfer:[...c]}}export function attachTables(e,t){let s=0;for(const o of e)for(const r of o){const n=t.links[s++],c=t.links[s++];if(n<0)continue;const u=t.tables[n],f=u.fields[c];Object.defineProperty(r,l,p(u)),Object.defineProperty(r,a,p(c)),f&HAS_VALUES&&Object.defineProperty(r,"testValues",y),f&HAS_VERDICTS&&Object.defineProperty(r,"testPass",V)}}export function testValue(e,t){const s=e[l];if(s===void 0)return e.testValues?.[t];const o=s.values.get(t)?.[e[a]];return o===void 0||Number.isNaN(o)?void 0:o}export function recordedVerdict(e,t){const s=e[l];if(s===void 0)return e.testPass?.[t];const o=s.verdicts.get(t)?.[e[a]];return o===void 0||o===VERDICT_NONE?void 0:o===VERDICT_PASS}export function dieHasAnyTestData(e){return dieHasValues(e)||dieHasVerdicts(e)}export function dieHasValues(e){const t=dieLink(e);if(t===void 0)return N(e.testValues);for(const s of t.table.values.values())if(!Number.isNaN(s[t.row]))return!0;return!1}export function dieHasVerdicts(e){const t=dieLink(e);if(t===void 0)return N(e.testPass);for(const s of t.table.verdicts.values())if(s[t.row]!==VERDICT_NONE)return!0;return!1}export function dieValueEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testValues;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.values){const n=r[t.row];Number.isNaN(n)||s.push([o,n])}return s}export function dieVerdictEntries(e){const t=dieLink(e);if(t===void 0){const o=e.testPass;return o===void 0?[]:Object.keys(o).map(r=>[Number(r),o[Number(r)]])}const s=[];for(const[o,r]of t.table.verdicts){const n=r[t.row];n!==VERDICT_NONE&&s.push([o,n===VERDICT_PASS])}return s}export function testValuesReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testValues;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?NaN:i}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.values.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?NaN:f[c.row]}return n}}export function recordedVerdictsReader(e){let t,s=[];return function(r,n){const c=dieLink(r);if(c===void 0){const u=r.testPass;for(let f=0;f<e.length;f++){const i=u?.[e[f]];n[f]=i===void 0?VERDICT_NONE:i?VERDICT_PASS:VERDICT_FAIL}return n}c.table!==t&&(t=c.table,s=e.map(u=>c.table.verdicts.get(u)));for(let u=0;u<s.length;u++){const f=s[u];n[u]=f===void 0?VERDICT_NONE:f[c.row]}return n}}export function testsPresent(e,t="all"){const s=new Set,o=new Map;for(const r of e){const n=dieLink(r);if(n===void 0){if(r.testValues)for(const u in r.testValues)s.add(Number(u));if(t==="all"&&r.testPass)for(const u in r.testPass)s.add(Number(u));continue}let c=o.get(n.table);c===void 0&&o.set(n.table,c=[]),c.push(n.row)}for(const[r,n]of o){for(const[c,u]of r.values)!s.has(c)&&n.some(f=>!Number.isNaN(u[f]))&&s.add(c);if(t!=="values")for(const[c,u]of r.verdicts)!s.has(c)&&n.some(f=>u[f]!==VERDICT_NONE)&&s.add(c)}return[...s].sort((r,n)=>r-n)}
@@ -45,6 +45,8 @@ export interface Die {
45
45
  insideWafer?: boolean;
46
46
  partial?: boolean;
47
47
  edgeExcluded?: boolean;
48
+ /** True on a die the page filter drops: a map draws it dimmed and no count, yield or statistic includes it. */
49
+ filteredOut?: boolean;
48
50
  probeIndex?: number;
49
51
  /** Number of times this die position appeared in the input results. Only set when > 1. */
50
52
  retestCount?: number;
@@ -1 +1 @@
1
- export function hasPosition(t){return t.x!=null&&t.y!=null}export function isPositionedDie(t){return t.x!=null&&t.y!=null}export function getDieKey(t){return hasPosition(t)?`${t.x},${t.y}`:`id:${t.id}`}export function gridKey(t,e){return t*4294967296+e}export function positionKey(t){const{x:e,y:n}=t;return Number.isInteger(e)&&Number.isInteger(n)&&Math.abs(e)<=32767&&Math.abs(n)<=32767?gridKey(e,n):getDieKey(t)}export function isYieldEligibleDie(t,e={}){return!(t.partial||!e.includeEdgeExcluded&&t.edgeExcluded)}export function diePassStatus(t,e){const n=t.hbin??t.sbin;return n===void 0?void 0:e.has(n)}export function generateDies(t,e){const{width:n,height:o,offset:s={x:0,y:0}}=e,u=e.gridSize??Math.ceil(t.radius/Math.min(n,o))+1,c=[];for(let r=-u;r<=u;r++)for(let i=-u;i<=u;i++){const l=t.center.x+i*n+s.x,x=t.center.y+r*o+s.y;c.push({id:`${i}_${r}`,x:i,y:r,physX:l,physY:x,width:n,height:o})}return c}
1
+ export function hasPosition(t){return t.x!=null&&t.y!=null}export function isPositionedDie(t){return t.x!=null&&t.y!=null}export function getDieKey(t){return hasPosition(t)?`${t.x},${t.y}`:`id:${t.id}`}export function gridKey(t,e){return t*4294967296+e}export function positionKey(t){const{x:e,y:n}=t;return Number.isInteger(e)&&Number.isInteger(n)&&Math.abs(e)<=32767&&Math.abs(n)<=32767?gridKey(e,n):getDieKey(t)}export function isYieldEligibleDie(t,e={}){return!(t.partial||t.filteredOut||!e.includeEdgeExcluded&&t.edgeExcluded)}export function diePassStatus(t,e){const n=t.hbin??t.sbin;return n===void 0?void 0:e.has(n)}export function generateDies(t,e){const{width:n,height:o,offset:s={x:0,y:0}}=e,u=e.gridSize??Math.ceil(t.radius/Math.min(n,o))+1,c=[];for(let r=-u;r<=u;r++)for(let i=-u;i<=u;i++){const l=t.center.x+i*n+s.x,x=t.center.y+r*o+s.y;c.push({id:`${i}_${r}`,x:i,y:r,physX:l,physY:x,width:n,height:o})}return c}
@@ -23,6 +23,13 @@ export interface WaferReticle {
23
23
  }
24
24
  export interface WaferSpec {
25
25
  diameter: number;
26
+ /**
27
+ * What `diameter` is measured in. `'normalized'` (die pitches, when no physical
28
+ * size is known) keeps the orientation mark's direction but gives it length 0:
29
+ * the SEMI flat and notch sizes are millimetres, and applied to a pitch count
30
+ * they would cut deep into a small wafer. Default `'mm'`.
31
+ */
32
+ units?: 'mm' | 'normalized';
26
33
  center?: {
27
34
  x: number;
28
35
  y: number;
@@ -41,7 +48,9 @@ export interface Wafer {
41
48
  };
42
49
  /**
43
50
  * Resolved orientation mark. `length` is the standard chord length (flat) or
44
- * half-width (V-notch), derived from the wafer diameter by `createWafer`.
51
+ * half-width (V-notch), derived from the wafer diameter by `createWafer`. 0 when
52
+ * the diameter is not in millimetres: the mark's side is known, its size is
53
+ * not, so nothing is cut into the outline (the side is still drawn as a marker).
45
54
  */
46
55
  notch?: {
47
56
  type: 'top' | 'bottom' | 'left' | 'right';
@@ -1 +1 @@
1
- function t(e){return e<=100?32.5:e<=150?57.5:1.75}export function createWafer(e){if(e.diameter<=0)throw new RangeError(`createWafer: diameter must be > 0 (got ${e.diameter})`);return{diameter:e.diameter,radius:e.diameter/2,center:e.center??{x:0,y:0},notch:e.notch?{type:e.notch.type,length:t(e.diameter)}:void 0,orientation:e.orientation??0,metadata:e.metadata,...e.reticle?{reticle:e.reticle}:{}}}
1
+ function t(e){return e<=100?32.5:e<=150?57.5:1.75}export function createWafer(e){if(e.diameter<=0)throw new RangeError(`createWafer: diameter must be > 0 (got ${e.diameter})`);return{diameter:e.diameter,radius:e.diameter/2,center:e.center??{x:0,y:0},notch:e.notch?{type:e.notch.type,length:e.units==="normalized"?0:t(e.diameter)}:void 0,orientation:e.orientation??0,metadata:e.metadata,...e.reticle?{reticle:e.reticle}:{}}}
@@ -115,6 +115,11 @@ export interface ViewOverlay {
115
115
  export interface View {
116
116
  /** Die rectangles to fill, in draw order, already carrying their resolved colour. */
117
117
  rectangles: ViewRect[];
118
+ /**
119
+ * The visual kerf between dies, in mm: each rectangle is its die's pitch less this.
120
+ * The drawer needs it to tile dies edge to edge when the kerf is too small to draw.
121
+ */
122
+ dieGap: number;
118
123
  /**
119
124
  * Transformed centre of each die, index-parallel with {@link dies}. Separate
120
125
  * from `rectangles` because a die always has a centre for hit-testing and
@@ -1 +1 @@
1
- import{requirePassBins as ge}from"../core/passBins.js";import{requireRingCount as ye}from"../core/ringCount.js";import{hasPosition as be}from"../core/dies.js";import{dieValueEntries as xe,dieVerdictEntries as Me,excludedBy as Se,excludedValue as ve,recordedVerdict as Be,testsPresent as Ot}from"../core/dieTable.js";import{limitSetName as $e}from"./valueFilter.js";import{getReticleCell as ke}from"../core/reticle.js";import{metadataCategoricalValue as Ie,metadataDisplayValue as Te}from"../core/metadata.js";import{affineRotation as xt,affineMirror as wt,affineCompose as ot,affinePoint as G,affineVector as De,affineSwapsAxes as Ve}from"../core/transforms.js";import{contrastTextColor as Q,SPEC_PASS_FILL as Mt,SPEC_FAIL_LOW as Ce,SPEC_FAIL_HIGH as St}from"./colorMap.js";import{resolveValueColorFn as Fe}from"./colorSchemes.js";import{resolveBinColors as Le,binColorsCover as Re}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Pe}from"../core/dies.js";import{compactView as Ne}from"./compactView.js";import{buildXYIndicator as Ee}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as U,isParametricTest as vt}from"./buildWaferMap.js";import{classifySpec as rt}from"./spec.js";export{rt as classifySpec};import{fmt as lt,fmtColorbarAxis as Bt,fmtAggregationMethod as qt}from"./fmt.js";import{metadataValueColor as Ae}from"./colorMap.js";import{asList as Kt,clamp01 as Wt,compareNatural as He,escHtml as R}from"../core/utils.js";import{prettyKey as zt}from"../core/utils.js";import{testLabel as ct,markedTestLabel as J,derivedTestNote as jt,isDerivedTest as _e,DERIVED_MARK as Oe,DERIVED_KEY as we}from"./testLabel.js";export function resolveTestNumber(t,e){return e?.length?{testNumber:(findTestDef(e,t)??e[0]).testNumber}:{testNumber:t}}export function collectMetadataValues(t,e){const n=new Set;for(const i of t){if(i.partial||i.edgeExcluded)continue;const s=ut(i,e);s!==void 0&&n.add(s)}return[...n].sort(He)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return Ot(t,"values")}const qe="#d3d6db",Xt="#e8e9ea",Ke="#aab0ba";function ut(t,e){return e?Ie(t.metadata?.[e]):void 0}function We(t,e,n){const{x:i,y:s}=t.center,a=xt(t.orientation,i,s),o=ot(wt(e?.x??!1,e?.y??!1,i,s),xt(t.orientation,i,s)),r=ot(wt(n?.flipX??!1,n?.flipY??!1,i,s),xt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:ot(r,a),gridToScreen:ot(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function ze(t,e){const{center:n,radius:i,notch:s}=t;let a=n.x+i*Math.cos(e),o=n.y+i*Math.sin(e);if(!s)return{x:a,y:o};const r=Math.sqrt(i**2-(s.length/2)**2),d=s.length/2,p=a-n.x,x=o-n.y;return s.type==="bottom"&&x<-r?(o=n.y-r,a=n.x+Math.max(-d,Math.min(d,p))):s.type==="top"&&x>r?(o=n.y+r,a=n.x+Math.max(-d,Math.min(d,p))):s.type==="left"&&p<-r?(a=n.x-r,o=n.y+Math.max(-d,Math.min(d,x))):s.type==="right"&&p>r&&(a=n.x+r,o=n.y+Math.max(-d,Math.min(d,x))),{x:a,y:o}}function Yt(t,e){return t.map(e).join(" / ")}function je(t,e=256){const n=Array.from({length:e},(i,s)=>t(s/(e-1)));return i=>n[Math.min(e-1,Math.max(0,Math.round(i*(e-1))))]}function Xe(t,e){const n=Math.max(1,Math.min(t.width,t.height)),i=t.width/Math.max(e.length,1);return Math.max(8,Math.min(16,Math.round(Math.min(n*.55,i*1.8))))}function Ye(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!vt(o)){const p=U(t,r,o);return p===void 0?[]:[{key:r,label:J(o,r),value:p?"Pass":"Fail"}]}const d=L(t,r);if(d===void 0){const p=ve(t,r);return p===void 0?[]:[{key:r,label:J(o,r),value:lt(p,o.unit,n),excludedBy:Se(t)}]}return[{key:r,label:J(o,r),value:lt(d,o.unit,n),recordedFail:Be(t,r)===!1}]});if(a.length)return a}const i=xe(t);if(i.length)return i.map(([a,o])=>({key:a,label:ct(void 0,a),value:lt(o,void 0,n)}));const s=Me(t);return s.length?s.map(([a,o])=>({key:a,label:ct(void 0,a),value:o?"Pass":"Fail"})):[]}export function buildHoverText(t,e,n={}){const{testDefs:i,hbinDefs:s,sbinDefs:a,fallbackFormat:o,aggrMethod:r,lotSize:d,activeTest:p,reticleConfig:x,metadataFields:$}=n,V=s?new Map(s.map(f=>[f.bin,f])):null,I=a?new Map(a.map(f=>[f.bin,f])):null,y=[R(`Die (${t.x}, ${t.y})`)];if(x&&be(t)){const f=ke(t,x);y.push(R(`Reticle (${f.column}, ${f.row})`))}if(e==="stackedValues"){const f=L(t,0);if(f!==void 0){const u=i?.[0],m=u?J(u,u.testNumber):"Value",S=r?` (${r})`:"";y.push(R(`${m}${S}: ${lt(f,u?.unit,o)}`));const h=jt(u);h&&y.push(`<i>${R(h)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const f=L(t,0),u=e==="stackedSoftBins"?t.sbin:t.hbin;if(f!==void 0){const m=e==="stackedSoftBins"?I:V,S=u!==void 0?m?.get(u)?.name?`${u} \xB7 ${m.get(u).name}`:`Bin ${u}`:"Bin";let h;if(r==="percent")h=`${f.toFixed(0)}%`;else{const D=d?` (${(f/d*100).toFixed(0)}% of stacked wafers)`:"";h=`${f}${D}`}const b=r?` [${qt(r)}]`:"";y.push(R(`${S}: ${h}${b}`))}}else{const f=Ye(t,i,o);if(e==="value"&&f.length){const{testNumber:u}=resolveTestNumber(p??0,i),m=findTestDef(i,u),S=L(t,u);let h=f.findIndex(A=>A.key===u);h<0&&(h=0);const b=f[h];let D=`<b>${R(`${b.label}: ${b.value}`)}${b.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(b.key===u&&m){const A=rt(S,m);(A==="failLow"||A==="failHigh")&&(D+=" <i>(outside test limits)</i>")}b.excludedBy&&(D+=` <i>(outside ${$e(b.excludedBy)}, excluded)</i>`),y.push(D);const E=jt(findTestDef(i,b.key));E&&y.push(`<i>${R(E)}</i>`);const g=f.length-1;g>0&&y.push(`<i>+${g} more test${g===1?"":"s"}</i>`)}else if(f.length){const u=f.length;y.push(`<i>${u} test result${u===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const u=[];if(t.hbin!==void 0){const m=V?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);u.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);u.push(`SBin: ${S}`)}y.push(u.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&y.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&y.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&y.push(R(`Part ID: ${t.partId}`)),t.partial&&y.push("<i>partial die</i>"),t.probeIndex!==void 0&&y.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[f,u]of Object.entries(B)){const m=Te(u);if(m===void 0)continue;const S=$?.find(h=>h.key===f)?.label??zt(f);y.push(R(`${S}: ${m}`))}return y.join("<br>")}function $t(t){return t?.name?J(t,t.testNumber):void 0}function kt(t){return _e(t)?{note:`${Oe} ${we}`}:{}}export function buildMapTitle(t,e="engineering",n){const i=t.isLotStack&&t.lotSize!==void 0?`stacked (${t.lotSize} ${t.lotSize===1?"wafer":"wafers"})`:"stacked",s=a=>{const o=n?.length===1?n[0]:void 0;return o===void 0?`${a} Bin`:o.name?`${a} Bin ${o.bin} \xB7 ${o.name}`:`${a} Bin ${o.bin}`};switch(t.plotMode){case"hardBin":return{primary:"Hard Bin",secondary:""};case"softBin":return{primary:"Soft Bin",secondary:""};case"stackedBins":return{primary:s("Hard"),secondary:i};case"stackedSoftBins":return{primary:s("Soft"),secondary:i};case"metadata":{const a=t.metadataFields?.find(r=>r.key===t.activeMetadataKey),o=t.activeMetadataKey?zt(t.activeMetadataKey):"Metadata";return{primary:a?.label??o,secondary:""}}case"stackedValues":{const a=t.testDefs?.[0],o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=Bt(o,$t(a),a?.unit,e),d=r||"Value",p=t.aggrMethod?` \xB7 ${qt(t.aggrMethod)}`:"";return{primary:`${d}${p}`,secondary:i,...kt(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=Bt(o,$t(a),a?.unit,e),d=r||$t(a);if(t.passFailDisplay!=="off"){const p=a?.testNumber??t.activeTest,x=d?`${d} \xB7 #${p}`:ct(void 0,p),$=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!vt(a)?"Functional pass/fail":"Tester pass/fail";return{primary:x,secondary:$,...kt(a)}}return{primary:d??ct(void 0,t.activeTest),secondary:"",...kt(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:d,fallbackFormat:p,passFailDisplay:x="off",activeMetadataKey:$,metadataColorMap:V,allIntegerValues:I}=n,y=findTestDef(d,o),{tickFmt:B}=Bt(r[1],y?.name,y?.unit,p),f=I?m=>String(Math.round(m)):B,{testNumber:u}=resolveTestNumber(o,d);return t.flatMap((m,S)=>{let h="",b="#111111";if(i==="value"&&x==="test"){const g=U(m,u,y);if(g===void 0)return[];h=g?"P":"F",b=Q(g?Mt:St)}else if(i==="value"){const g=L(m,u);if(g===void 0)return[];h=Yt([g],f),b=Q(s.forValue(a(g)))}else if(i==="hardBin"||i==="softBin"){const g=i==="softBin"?m.sbin:m.hbin;if(g===void 0)return[];h=String(g),b=Q(s.forBin(g))}else if(i==="metadata"){const g=ut(m,$);if(g===void 0)return[];h=g,b=Q(V?.get(h)??z)}else{const g=L(m,0);if(g===void 0)return[];h=Yt([g],f),b=Q(s.forValue(a(g)))}const D=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:D,y:E,text:h,fontSize:Xe(m,h),color:b,align:"center"}]})}function Gt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function Ge(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>G(e,B.x,B.y);if(!(a!==void 0&&t.diameter>150)){const B=[];for(let f=0;f<=n;f++){const u=2*Math.PI*f/n;B.push(o(ze(t,u)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const d=1.25,p=a.length,x=Gt(a.type),$=Math.atan2(p,s),V=s-d,I=[];let y=!1;for(let B=0;B<=n;B++){const f=2*Math.PI*B/n;let u=f-x;for(;u>Math.PI;)u-=2*Math.PI;for(;u<-Math.PI;)u+=2*Math.PI;if(Math.abs(u)<=$){if(!y){y=!0;const m={x:i.x+s*Math.cos(x-$),y:i.y+s*Math.sin(x-$)},S={x:i.x+V*Math.cos(x),y:i.y+V*Math.sin(x)},h={x:i.x+s*Math.cos(x+$),y:i.y+s*Math.sin(x+$)};I.push(o(m),o(S),o(h))}continue}I.push(o({x:i.x+s*Math.cos(f),y:i.y+s*Math.sin(f)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Qe(t,e,n,i=360){const s=[],a=Math.max(1,Math.floor(n));for(let o=1;o<a;o++){const r=t.radius*o/a,d=[];for(let p=0;p<=i;p++){const x=2*Math.PI*p/i,$={x:t.center.x+r*Math.cos(x),y:t.center.y+r*Math.sin(x)};d.push(G(e,$.x,$.y))}s.push({kind:"ring-boundary",...Y(d,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ue(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(f,u)=>G(e,f,u),d=n-s,p=Math.sqrt(Math.max(0,o*o-d*d)),x=r(n,a-p),$=r(n,a+p),V=i-a,I=Math.sqrt(Math.max(0,o*o-V*V)),y=r(s-I,i),B=r(s+I,i);return[{kind:"quadrant-boundary",...Y([x,$]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5},{kind:"quadrant-boundary",...Y([y,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function Je(t,e){return t.map(n=>{const i=n.width/2,s=n.height/2;return{kind:"reticle",points:[[[n.x-i,n.y-s],[n.x+i,n.y-s],[n.x+i,n.y+s],[n.x-i,n.y+s]].map(([o,r])=>G(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function Ze(t){const e=t.filter(n=>n.probeIndex!==void 0).sort((n,i)=>(n.probeIndex??0)-(i.probeIndex??0));return e.length?[{kind:"probe-path",...Y(e.map(n=>({x:n.physX,y:n.physY}))),lineColor:"rgba(220,80,0,0.55)",lineWidth:1}]:[]}function tn(t,e,n,i,s,a,o,r,d,p,x,$,V,I,y="off",B,f,u){const m=e.width-o,S=e.height-o,h=a?S:m,b=a?m:S,D=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ut(M,B);if(e.partial){t.push({x:n,y:i,width:h,height:b,fill:qe,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:h,height:b,fill:Ke,type:"stacked",metadata:e.metadata});return}if(d!==void 0&&(s==="hardBin"||s==="softBin")&&!d.has(D(e))){t.push({x:n,y:i,width:h,height:b,fill:Xt,type:"hardBin",metadata:e.metadata});return}if(u!==void 0&&s==="metadata"&&!u.has(E(e))){t.push({x:n,y:i,width:h,height:b,fill:Xt,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(y==="test"){const q=U(e,x,I),ft=q===void 0?z:q?Mt:St;t.push({x:n,y:i,width:h,height:b,fill:ft,type:"value",metadata:e.metadata});return}const M=L(e,x),P=rt(M,I);let w,Z;M===void 0?w=z:y==="spec"?w=P==="failLow"?Ce:P==="failHigh"?St:Mt:(w=r.forValue(p(M)),(P==="failLow"||P==="failHigh")&&(Z=P)),t.push({x:n,y:i,width:h,height:b,fill:w,type:"value",specMark:Z,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=D(e),P=M!=null?r.forBin(M):z,w=M!=null&&Pe(e,V)===!1?!0:void 0;t.push({x:n,y:i,width:h,height:b,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?f?.get(M)??z:z;t.push({x:n,y:i,width:h,height:b,fill:P,type:"metadata",metadata:e.metadata});return}const g=L(e,0),A=g!==void 0?r.forValue(p(g)):z;t.push({x:n,y:i,width:h,height:b,fill:A,type:"value",metadata:e.metadata})}function en(t,e,n){const i=t.radius;return Ee(e,i*.15,(s,a)=>({x:t.center.x+s*i*.9,y:t.center.y+a*i*.9}),n).overlays}export function buildView(t,e,n={},i){const s=n.reticles??[],{plotMode:a="value",showDieLabels:o=!1,showReticle:r=!1,showProbePath:d=!1,ringCount:p,showRingBoundaries:x=!1,showQuadrantBoundaries:$=!1,showXYIndicator:V=!1,binColorScheme:I="default",valueColorScheme:y="default",reverseValueScheme:B=!1,useDefinedBinColors:f=!0,binColors:u,passBins:m,highlightBin:S,highlightMetadataValue:h,interactiveTransform:b,valueRange:D,metadataValueOrder:E,testDefs:g,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:Z,dataAxisFlip:q,isLotStack:ft=!1,logScale:Qt,colorbarRangeMode:Ut="spec",passFailDisplay:Jt}=n,It=Jt??"off",dt=i?.hbinDefs,ht=i?.sbinDefs,Tt=i?.metadataFields,Zt=Tt?.find(l=>l.key===M),te={x:(q?.x??!1)!==(b?.flipX??!1),y:(q?.y??!1)!==(b?.flipY??!1)},ee=dt?new Map(dt.map(l=>[l.bin,l])):null,ne=ht?new Map(ht.map(l=>[l.bin,l])):null,ae=a==="softBin"?ne:ee,Dt=ge({passBins:m},"buildView"),ie=new Set(Dt),mt=u&&Re(u,e)?u:Le(e,{passBins:Dt,binColorScheme:I,hbinDefs:dt,sbinDefs:ht,useDefinedBinColors:f}),se=a==="softBin"?mt.soft:mt.hard,Vt={forValue:je(Fe(y,B)),forBin:l=>se.get(l)??z};let{testNumber:H}=resolveTestNumber(A,g);if(!g?.length&&a==="value"){const l=Ot(e,"values");!l.includes(H)&&l.length&&(H=l[0])}let tt;if(Array.isArray(D))tt=D;else if(D){const{testNumber:l}=resolveTestNumber(D.test,g);tt=l===H?D.range:void 0}const T=findTestDef(g,H),Ct=a==="value"&&T!==void 0&&!vt(T),oe=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let O="off";a==="value"&&(Ct?O="test":It==="spec"&&oe?O="spec":It==="test"&&e.some(l=>U(l,H,T)!==void 0)&&(O="test"));const Ft=O==="spec"?"spec":Ut,pt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,_,et=!1;if(tt){[N,_]=tt;let l=!0,c=!1;for(const v of e){const F=pt?L(v,0):L(v,H);if(F!==void 0&&(c=!0,!Number.isInteger(F))){l=!1;break}}et=c&&l}else{const l=!pt&&a==="value"&&Ft==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let c=1/0,v=-1/0,F=!0;for(const k of e){const W=pt?L(k,0):L(k,H);W!==void 0&&(W<c&&(c=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(c)||(F=!1),et=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(c)?c:0,_=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(c)?c:0,_=isFinite(v)?v:1)}N===_&&(_=N+1);const Lt=Ct?!1:Qt??T?.logScale??!1,Rt=Lt&&N>0&&_>0,re=Rt;let nt;if(Rt){const l=Math.log10(N),c=Math.log10(_)-l;nt=v=>v<=0?0:Wt((Math.log10(v)-l)/c)}else nt=l=>Wt((l-N)/(_-N));const C=We(t,q,b);let Pt=null;if(t.notch){const l=Gt(t.notch.type),c=De(C.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(c.x,c.y);v>0&&(Pt={x:c.x/v,y:c.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const c=e[l];c.width<j&&(j=c.width),c.height<j&&(j=c.height)}const Nt=1,le=j!==1/0?Math.min(Nt,j*.12):Nt,Et=[],gt=[],ce=C.bakedToScreen.a===1&&C.bakedToScreen.b===0&&C.bakedToScreen.c===0&&C.bakedToScreen.d===1&&C.bakedToScreen.e===0&&C.bakedToScreen.f===0;let K=null;if(!ce){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const c=G(C.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=c.x,K[l*2+1]=c.y}}const ue=Ve(C.gridToScreen),fe=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",de=a==="softBin"||a==="stackedSoftBins";let at=fe?new Map:void 0;const yt=a==="value"&&O==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,bt=a==="value"&&O==="test"?{pass:0,fail:0}:void 0,At=a==="metadata";let it=At?new Map:void 0,st=null;if(At&&M){const l=collectMetadataValues(e,M),c=E?.key===M?E.values:void 0,v=c?[...c,...l.filter(F=>!c.includes(F))]:l;st=new Map(v.map((F,k)=>[F,Zt?.values?.find(W=>W.value===F)?.color??Ae(k)]))}const he=S===void 0?void 0:new Set(Kt(S)),me=h===void 0?void 0:new Set(Kt(h));for(let l=0;l<e.length;l++){const c=e[l],v=K?K[l*2]:c.physX,F=K?K[l*2+1]:c.physY;if(gt.push({x:v,y:F}),at&&!c.partial&&!c.edgeExcluded){const k=de?c.sbin:c.hbin;k!=null&&at.set(k,(at.get(k)??0)+1)}if(yt&&!c.partial&&!c.edgeExcluded){const k=rt(L(c,H),T);k&&yt[k]++}if(bt&&!c.partial&&!c.edgeExcluded){const k=U(c,H,T);k!==void 0&&bt[k?"pass":"fail"]++}if(it&&!c.partial&&!c.edgeExcluded){const k=ut(c,M);k!==void 0&&it.set(k,(it.get(k)??0)+1)}tn(Et,c,v,F,a,ue,le,Vt,he,nt,H,ae,ie,T,O,M,st,me)}const Ht=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Vt,normalize:nt,activeTest:A,valueRange:[N,_],testDefs:g,fallbackFormat:P,passFailDisplay:O,activeMetadataKey:M,metadataColorMap:st,allIntegerValues:et}):[],X=Ge(t,C.physicalToScreen);x&&X.push(...Qe(t,C.physicalToScreen,ye({ringCount:p},"buildView"))),$&&X.push(...Ue(t,C.physicalToScreen,t.center.x,t.center.y)),r&&X.push(...Je(s,C.gridToScreen)),d&&X.push(...Ze(e)),V&&X.push(...en(t,C.gridToScreen,Ht));const pe=gt.length>0?{minX:t.center.x-t.radius,maxX:t.center.x+t.radius,minY:t.center.y-t.radius,maxY:t.center.y+t.radius}:null,_t={rectangles:Et,hoverPoints:gt,texts:Ht,overlays:X,plotMode:a,binColorScheme:I,valueColorScheme:y,reverseValueScheme:B,binColors:mt,metadata:t.metadata??null,dies:e,valueRange:[N,_],allIntegerValues:et,testDefs:g,activeTest:A,logScale:re,logScaleRequested:Lt,aggrMethod:w,lotSize:Z,axisFlip:te,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:C.gridToScreen,rotation:((t.orientation+(b?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:ft,passFailDisplay:O,colorbarRangeMode:Ft,waferCenter:t.center,waferRadius:t.radius,notchDir:Pt,binCounts:at,metadataCounts:it,metadataColorMap:st,activeMetadataKey:M,metadataFields:Tt,specCounts:yt,passFailCounts:bt,dieBounds:pe};return n.compact?Ne(_t,n.compact,{showXYIndicator:V}):_t}export{getDieKey}from"../core/dies.js";
1
+ import{requirePassBins as ye}from"../core/passBins.js";import{requireRingCount as be}from"../core/ringCount.js";import{hasPosition as xe}from"../core/dies.js";import{dieValueEntries as Me,dieVerdictEntries as Se,excludedBy as ve,excludedValue as Be,recordedVerdict as $e,testsPresent as qt}from"../core/dieTable.js";import{limitSetName as ke}from"./valueFilter.js";import{getReticleCell as Ie}from"../core/reticle.js";import{metadataCategoricalValue as Te,metadataDisplayValue as De}from"../core/metadata.js";import{affineRotation as Mt,affineMirror as Kt,affineCompose as rt,affinePoint as U,affineVector as Ve,affineSwapsAxes as Ce}from"../core/transforms.js";import{contrastTextColor as X,SPEC_PASS_FILL as St,SPEC_FAIL_LOW as Fe,SPEC_FAIL_HIGH as vt}from"./colorMap.js";import{resolveValueColorFn as Le}from"./colorSchemes.js";import{resolveBinColors as Re,binColorsCover as Pe}from"./binColors.js";import{NO_DATA_FILL as z}from"./colorMap.js";import{diePassStatus as Ne,isYieldEligibleDie as Q}from"../core/dies.js";import{compactView as Ee}from"./compactView.js";import{buildXYIndicator as Ae}from"./xyIndicator.js";import{getDieTestValue as L,getTestPassStatus as J,isParametricTest as Bt}from"./buildWaferMap.js";import{classifySpec as lt}from"./spec.js";export{lt as classifySpec};import{fmt as ct,fmtColorbarAxis as $t,fmtAggregationMethod as Wt}from"./fmt.js";import{metadataValueColor as _e}from"./colorMap.js";import{asList as zt,clamp01 as jt,compareNatural as Oe,escHtml as R}from"../core/utils.js";import{prettyKey as Gt}from"../core/utils.js";import{testLabel as ut,markedTestLabel as Z,derivedTestNote as Yt,isDerivedTest as He,DERIVED_MARK as we,DERIVED_KEY as qe}from"./testLabel.js";export function resolveTestNumber(t,e){return e?.length?{testNumber:(findTestDef(e,t)??e[0]).testNumber}:{testNumber:t}}export function collectMetadataValues(t,e){const n=new Set;for(const i of t){if(!Q(i))continue;const s=ft(i,e);s!==void 0&&n.add(s)}return[...n].sort(Oe)}export function findTestDef(t,e){return t?.find(n=>n.testNumber===e)}export function getUniqueTestNumbers(t){return qt(t,"values")}const Ke="#d3d6db",Ut="#e8e9ea",We="#d9dcdf",ze="#aab0ba";function ft(t,e){return e?Te(t.metadata?.[e]):void 0}function je(t,e,n){const{x:i,y:s}=t.center,a=Mt(t.orientation,i,s),o=rt(Kt(e?.x??!1,e?.y??!1,i,s),Mt(t.orientation,i,s)),r=rt(Kt(n?.flipX??!1,n?.flipY??!1,i,s),Mt(n?.rotation??0,i,s));return{bakedToScreen:r,physicalToScreen:rt(r,a),gridToScreen:rt(r,o)}}function Y(t,e=!1){return{points:[t],closed:e}}function Ge(t,e){const{center:n,radius:i,notch:s}=t;let a=n.x+i*Math.cos(e),o=n.y+i*Math.sin(e);if(!s)return{x:a,y:o};const r=Math.sqrt(i**2-(s.length/2)**2),h=s.length/2,p=a-n.x,x=o-n.y;return s.type==="bottom"&&x<-r?(o=n.y-r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="top"&&x>r?(o=n.y+r,a=n.x+Math.max(-h,Math.min(h,p))):s.type==="left"&&p<-r?(a=n.x-r,o=n.y+Math.max(-h,Math.min(h,x))):s.type==="right"&&p>r&&(a=n.x+r,o=n.y+Math.max(-h,Math.min(h,x))),{x:a,y:o}}function Xt(t,e){return t.map(e).join(" / ")}function Ye(t,e=256){const n=Array.from({length:e},(i,s)=>t(s/(e-1)));return i=>n[Math.min(e-1,Math.max(0,Math.round(i*(e-1))))]}function Ue(t,e){const n=Math.max(1,Math.min(t.width,t.height)),i=t.width/Math.max(e.length,1);return Math.max(8,Math.min(16,Math.round(Math.min(n*.55,i*1.8))))}function Xe(t,e,n){if(e?.length){const a=e.flatMap(o=>{const r=o.testNumber;if(!Bt(o)){const p=J(t,r,o);return p===void 0?[]:[{key:r,label:Z(o,r),value:p?"Pass":"Fail"}]}const h=L(t,r);if(h===void 0){const p=Be(t,r);return p===void 0?[]:[{key:r,label:Z(o,r),value:ct(p,o.unit,n),excludedBy:ve(t)}]}return[{key:r,label:Z(o,r),value:ct(h,o.unit,n),recordedFail:$e(t,r)===!1}]});if(a.length)return a}const i=Me(t);if(i.length)return i.map(([a,o])=>({key:a,label:ut(void 0,a),value:ct(o,void 0,n)}));const s=Se(t);return s.length?s.map(([a,o])=>({key:a,label:ut(void 0,a),value:o?"Pass":"Fail"})):[]}export function buildHoverText(t,e,n={}){const{testDefs:i,hbinDefs:s,sbinDefs:a,fallbackFormat:o,aggrMethod:r,lotSize:h,activeTest:p,reticleConfig:x,metadataFields:$}=n,V=s?new Map(s.map(u=>[u.bin,u])):null,I=a?new Map(a.map(u=>[u.bin,u])):null,b=[R(`Die (${t.x}, ${t.y})`)];if(x&&xe(t)){const u=Ie(t,x);b.push(R(`Reticle (${u.column}, ${u.row})`))}if(e==="stackedValues"){const u=L(t,0);if(u!==void 0){const c=i?.[0],m=c?Z(c,c.testNumber):"Value",S=r?` (${r})`:"";b.push(R(`${m}${S}: ${ct(u,c?.unit,o)}`));const d=Yt(c);d&&b.push(`<i>${R(d)}</i>`)}}else if(e==="stackedBins"||e==="stackedSoftBins"){const u=L(t,0),c=e==="stackedSoftBins"?t.sbin:t.hbin;if(u!==void 0){const m=e==="stackedSoftBins"?I:V,S=c!==void 0?m?.get(c)?.name?`${c} \xB7 ${m.get(c).name}`:`Bin ${c}`:"Bin";let d;if(r==="percent")d=`${u.toFixed(0)}%`;else{const D=h?` (${(u/h*100).toFixed(0)}% of stacked wafers)`:"";d=`${u}${D}`}const g=r?` [${Wt(r)}]`:"";b.push(R(`${S}: ${d}${g}`))}}else{const u=Xe(t,i,o);if(e==="value"&&u.length){const{testNumber:c}=resolveTestNumber(p??0,i),m=findTestDef(i,c),S=L(t,c);let d=u.findIndex(A=>A.key===c);d<0&&(d=0);const g=u[d];let D=`<b>${R(`${g.label}: ${g.value}`)}${g.recordedFail?" <i>(recorded fail)</i>":""}</b>`;if(g.key===c&&m){const A=lt(S,m);(A==="failLow"||A==="failHigh")&&(D+=" <i>(outside test limits)</i>")}g.excludedBy&&(D+=` <i>(outside ${ke(g.excludedBy)}, excluded)</i>`),b.push(D);const E=Yt(findTestDef(i,g.key));E&&b.push(`<i>${R(E)}</i>`);const y=u.length-1;y>0&&b.push(`<i>+${y} more test${y===1?"":"s"}</i>`)}else if(u.length){const c=u.length;b.push(`<i>${c} test result${c===1?"":"s"} recorded</i>`)}if(t.hbin!==void 0||t.sbin!==void 0){const c=[];if(t.hbin!==void 0){const m=V?.get(t.hbin)?.name,S=m?`${t.hbin} \xB7 ${m}`:String(t.hbin);c.push(`HBin: ${S}`)}if(t.sbin!==void 0){const m=I?.get(t.sbin)?.name,S=m?`${t.sbin} \xB7 ${m}`:String(t.sbin);c.push(`SBin: ${S}`)}b.push(c.map(R).join(" &nbsp;\xB7&nbsp; "))}}t.retestCount!==void 0&&b.push(R(`Retests: ${t.retestCount}`)),t.siteNum!==void 0&&b.push(R(`Site: ${t.siteNum}`)),t.partId!==void 0&&b.push(R(`Part ID: ${t.partId}`)),t.partial&&b.push("<i>partial die</i>"),t.probeIndex!==void 0&&b.push(R(`Probe: #${t.probeIndex}`));const B={...t.metadata??{}};for(const[u,c]of Object.entries(B)){const m=De(c);if(m===void 0)continue;const S=$?.find(d=>d.key===u)?.label??Gt(u);b.push(R(`${S}: ${m}`))}return b.join("<br>")}function kt(t){return t?.name?Z(t,t.testNumber):void 0}function It(t){return He(t)?{note:`${we} ${qe}`}:{}}export function buildMapTitle(t,e="engineering",n){const i=t.isLotStack&&t.lotSize!==void 0?`stacked (${t.lotSize} ${t.lotSize===1?"wafer":"wafers"})`:"stacked",s=a=>{const o=n?.length===1?n[0]:void 0;return o===void 0?`${a} Bin`:o.name?`${a} Bin ${o.bin} \xB7 ${o.name}`:`${a} Bin ${o.bin}`};switch(t.plotMode){case"hardBin":return{primary:"Hard Bin",secondary:""};case"softBin":return{primary:"Soft Bin",secondary:""};case"stackedBins":return{primary:s("Hard"),secondary:i};case"stackedSoftBins":return{primary:s("Soft"),secondary:i};case"metadata":{const a=t.metadataFields?.find(r=>r.key===t.activeMetadataKey),o=t.activeMetadataKey?Gt(t.activeMetadataKey):"Metadata";return{primary:a?.label??o,secondary:""}}case"stackedValues":{const a=t.testDefs?.[0],o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,kt(a),a?.unit,e),h=r||"Value",p=t.aggrMethod?` \xB7 ${Wt(t.aggrMethod)}`:"";return{primary:`${h}${p}`,secondary:i,...It(a)}}default:{const a=findTestDef(t.testDefs,t.activeTest),o=t.valueRange[1]||t.valueRange[0]||0,{axisLabel:r}=$t(o,kt(a),a?.unit,e),h=r||kt(a);if(t.passFailDisplay!=="off"){const p=a?.testNumber??t.activeTest,x=h?`${h} \xB7 #${p}`:ut(void 0,p),$=t.passFailDisplay==="spec"?"Limit pass/fail":a!==void 0&&!Bt(a)?"Functional pass/fail":"Tester pass/fail";return{primary:x,secondary:$,...It(a)}}return{primary:h??ut(void 0,t.activeTest),secondary:"",...It(a)}}}}export function generateTextOverlay(t,e,n){const{plotMode:i,colorFns:s,normalize:a,activeTest:o,valueRange:r,testDefs:h,fallbackFormat:p,passFailDisplay:x="off",activeMetadataKey:$,metadataColorMap:V,allIntegerValues:I}=n,b=findTestDef(h,o),{tickFmt:B}=$t(r[1],b?.name,b?.unit,p),u=I?m=>String(Math.round(m)):B,{testNumber:c}=resolveTestNumber(o,h);return t.flatMap((m,S)=>{let d="",g="#111111";if(i==="value"&&x==="test"){const y=J(m,c,b);if(y===void 0)return[];d=y?"P":"F",g=X(y?St:vt)}else if(i==="value"){const y=L(m,c);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}else if(i==="hardBin"||i==="softBin"){const y=i==="softBin"?m.sbin:m.hbin;if(y===void 0)return[];d=String(y),g=X(s.forBin(y))}else if(i==="metadata"){const y=ft(m,$);if(y===void 0)return[];d=y,g=X(V?.get(d)??z)}else{const y=L(m,0);if(y===void 0)return[];d=Xt([y],u),g=X(s.forValue(a(y)))}const D=e?e[S*2]:m.physX,E=e?e[S*2+1]:m.physY;return[{x:D,y:E,text:d,fontSize:Ue(m,d),color:g,align:"center"}]})}function Qt(t){return t==="top"?Math.PI/2:t==="bottom"?-Math.PI/2:t==="left"?Math.PI:0}function Qe(t,e,n=720){const{center:i,radius:s,notch:a}=t,o=B=>U(e,B.x,B.y);if(!(a!==void 0&&a.length>0&&t.diameter>150)){const B=[];for(let u=0;u<=n;u++){const c=2*Math.PI*u/n;B.push(o(Ge(t,c)))}return[{kind:"wafer-boundary",...Y(B,!0),lineColor:"#888888",lineWidth:1}]}const h=1.25,p=a.length,x=Qt(a.type),$=Math.atan2(p,s),V=s-h,I=[];let b=!1;for(let B=0;B<=n;B++){const u=2*Math.PI*B/n;let c=u-x;for(;c>Math.PI;)c-=2*Math.PI;for(;c<-Math.PI;)c+=2*Math.PI;if(Math.abs(c)<=$){if(!b){b=!0;const m={x:i.x+s*Math.cos(x-$),y:i.y+s*Math.sin(x-$)},S={x:i.x+V*Math.cos(x),y:i.y+V*Math.sin(x)},d={x:i.x+s*Math.cos(x+$),y:i.y+s*Math.sin(x+$)};I.push(o(m),o(S),o(d))}continue}I.push(o({x:i.x+s*Math.cos(u),y:i.y+s*Math.sin(u)}))}return[{kind:"wafer-boundary",...Y(I,!0),lineColor:"#888888",lineWidth:1}]}function Je(t,e,n,i=360){const s=[],a=Math.max(1,Math.floor(n));for(let o=1;o<a;o++){const r=t.radius*o/a,h=[];for(let p=0;p<=i;p++){const x=2*Math.PI*p/i,$={x:t.center.x+r*Math.cos(x),y:t.center.y+r*Math.sin(x)};h.push(U(e,$.x,$.y))}s.push({kind:"ring-boundary",...Y(h,!0),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5})}return s}function Ze(t,e,n,i){const{x:s,y:a}=t.center,o=t.radius,r=(u,c)=>U(e,u,c),h=n-s,p=Math.sqrt(Math.max(0,o*o-h*h)),x=r(n,a-p),$=r(n,a+p),V=i-a,I=Math.sqrt(Math.max(0,o*o-V*V)),b=r(s-I,i),B=r(s+I,i);return[{kind:"quadrant-boundary",...Y([x,$]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5},{kind:"quadrant-boundary",...Y([b,B]),lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5}]}function tn(t,e){return t.map(n=>{const i=n.width/2,s=n.height/2;return{kind:"reticle",points:[[[n.x-i,n.y-s],[n.x+i,n.y-s],[n.x+i,n.y+s],[n.x-i,n.y+s]].map(([o,r])=>U(e,o,r))],closed:!0,lineColor:"rgba(255,255,255,0.7)",lineWidth:1.5,fill:"rgba(0,0,0,0)"}})}function en(t){const e=t.filter(n=>n.probeIndex!==void 0).sort((n,i)=>(n.probeIndex??0)-(i.probeIndex??0));return e.length?[{kind:"probe-path",...Y(e.map(n=>({x:n.physX,y:n.physY}))),lineColor:"rgba(220,80,0,0.55)",lineWidth:1}]:[]}function nn(t,e,n,i,s,a,o,r,h,p,x,$,V,I,b="off",B,u,c){const m=e.width-o,S=e.height-o,d=a?S:m,g=a?m:S,D=M=>s==="softBin"?M.sbin:M.hbin,E=M=>ft(M,B);if(e.partial){t.push({x:n,y:i,width:d,height:g,fill:Ke,type:"stacked",metadata:e.metadata});return}if(e.filteredOut){t.push({x:n,y:i,width:d,height:g,fill:We,type:"stacked",metadata:e.metadata});return}if(e.edgeExcluded){t.push({x:n,y:i,width:d,height:g,fill:ze,type:"stacked",metadata:e.metadata});return}if(h!==void 0&&(s==="hardBin"||s==="softBin")&&!h.has(D(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"hardBin",metadata:e.metadata});return}if(c!==void 0&&s==="metadata"&&!c.has(E(e))){t.push({x:n,y:i,width:d,height:g,fill:Ut,type:"metadata",metadata:e.metadata});return}if(s==="value"){if(b==="test"){const q=J(e,x,I),dt=q===void 0?z:q?St:vt;t.push({x:n,y:i,width:d,height:g,fill:dt,type:"value",metadata:e.metadata});return}const M=L(e,x),P=lt(M,I);let w,tt;M===void 0?w=z:b==="spec"?w=P==="failLow"?Fe:P==="failHigh"?vt:St:(w=r.forValue(p(M)),(P==="failLow"||P==="failHigh")&&(tt=P)),t.push({x:n,y:i,width:d,height:g,fill:w,type:"value",specMark:tt,metadata:e.metadata});return}if(s==="hardBin"||s==="softBin"){const M=D(e),P=M!=null?r.forBin(M):z,w=M!=null&&Ne(e,V)===!1?!0:void 0;t.push({x:n,y:i,width:d,height:g,fill:P,type:s,binFail:w,metadata:e.metadata});return}if(s==="metadata"){const M=E(e),P=M!==void 0?u?.get(M)??z:z;t.push({x:n,y:i,width:d,height:g,fill:P,type:"metadata",metadata:e.metadata});return}const y=L(e,0),A=y!==void 0?r.forValue(p(y)):z;t.push({x:n,y:i,width:d,height:g,fill:A,type:"value",metadata:e.metadata})}function an(t,e,n){const i=t.radius;return Ae(e,i*.15,(s,a)=>({x:t.center.x+s*i*.9,y:t.center.y+a*i*.9}),n).overlays}export function buildView(t,e,n={},i){const s=n.reticles??[],{plotMode:a="value",showDieLabels:o=!1,showReticle:r=!1,showProbePath:h=!1,ringCount:p,showRingBoundaries:x=!1,showQuadrantBoundaries:$=!1,showXYIndicator:V=!1,binColorScheme:I="default",valueColorScheme:b="default",reverseValueScheme:B=!1,useDefinedBinColors:u=!0,binColors:c,passBins:m,highlightBin:S,highlightMetadataValue:d,interactiveTransform:g,valueRange:D,metadataValueOrder:E,testDefs:y,activeTest:A=0,activeMetadataKey:M,fallbackFormat:P="engineering",aggregationMethod:w,lotSize:tt,dataAxisFlip:q,isLotStack:dt=!1,logScale:Jt,colorbarRangeMode:Zt="spec",passFailDisplay:te}=n,Tt=te??"off",ht=i?.hbinDefs,mt=i?.sbinDefs,Dt=i?.metadataFields,ee=Dt?.find(l=>l.key===M),ne={x:(q?.x??!1)!==(g?.flipX??!1),y:(q?.y??!1)!==(g?.flipY??!1)},ae=ht?new Map(ht.map(l=>[l.bin,l])):null,ie=mt?new Map(mt.map(l=>[l.bin,l])):null,se=a==="softBin"?ie:ae,Vt=ye({passBins:m},"buildView"),oe=new Set(Vt),pt=c&&Pe(c,e)?c:Re(e,{passBins:Vt,binColorScheme:I,hbinDefs:ht,sbinDefs:mt,useDefinedBinColors:u}),re=a==="softBin"?pt.soft:pt.hard,Ct={forValue:Ye(Le(b,B)),forBin:l=>re.get(l)??z};let{testNumber:_}=resolveTestNumber(A,y);if(!y?.length&&a==="value"){const l=qt(e,"values");!l.includes(_)&&l.length&&(_=l[0])}let et;if(Array.isArray(D))et=D;else if(D){const{testNumber:l}=resolveTestNumber(D.test,y);et=l===_?D.range:void 0}const T=findTestDef(y,_),Ft=a==="value"&&T!==void 0&&!Bt(T),le=T!==void 0&&(T.limitLow!==void 0||T.limitHigh!==void 0);let H="off";a==="value"&&(Ft?H="test":Tt==="spec"&&le?H="spec":Tt==="test"&&e.some(l=>J(l,_,T)!==void 0)&&(H="test"));const Lt=H==="spec"?"spec":Zt,gt=a==="stackedValues"||a==="stackedBins"||a==="stackedSoftBins";let N,O,nt=!1;if(et){[N,O]=et;let l=!0,f=!1;for(const v of e){const F=gt?L(v,0):L(v,_);if(F!==void 0&&(f=!0,!Number.isInteger(F))){l=!1;break}}nt=f&&l}else{const l=!gt&&a==="value"&&Lt==="spec"&&T&&(T.limitLow!==void 0||T.limitHigh!==void 0);let f=1/0,v=-1/0,F=!0;for(const k of e){const W=gt?L(k,0):L(k,_);W!==void 0&&(W<f&&(f=W),W>v&&(v=W),Number.isInteger(W)||(F=!1))}isFinite(f)||(F=!1),nt=F,l?(N=T.limitLow!==void 0?T.limitLow:isFinite(f)?f:0,O=T.limitHigh!==void 0?T.limitHigh:isFinite(v)?v:1):(N=isFinite(f)?f:0,O=isFinite(v)?v:1)}N===O&&(O=N+1);const Rt=Ft?!1:Jt??T?.logScale??!1,Pt=Rt&&N>0&&O>0,ce=Pt;let at;if(Pt){const l=Math.log10(N),f=Math.log10(O)-l;at=v=>v<=0?0:jt((Math.log10(v)-l)/f)}else at=l=>jt((l-N)/(O-N));const C=je(t,q,g);let Nt=null;if(t.notch){const l=Qt(t.notch.type),f=Ve(C.physicalToScreen,Math.cos(l)*t.radius,Math.sin(l)*t.radius),v=Math.hypot(f.x,f.y);v>0&&(Nt={x:f.x/v,y:f.y/v})}let j=1/0;for(let l=0;l<e.length;l++){const f=e[l];f.width<j&&(j=f.width),f.height<j&&(j=f.height)}const Et=1,At=j!==1/0?Math.min(Et,j*.12):Et,_t=[],yt=[],ue=C.bakedToScreen.a===1&&C.bakedToScreen.b===0&&C.bakedToScreen.c===0&&C.bakedToScreen.d===1&&C.bakedToScreen.e===0&&C.bakedToScreen.f===0;let K=null;if(!ue){K=new Float64Array(e.length*2);for(let l=0;l<e.length;l++){const f=U(C.bakedToScreen,e[l].physX,e[l].physY);K[l*2]=f.x,K[l*2+1]=f.y}}const fe=Ce(C.gridToScreen),de=a==="hardBin"||a==="softBin"||a==="stackedBins"||a==="stackedSoftBins",he=a==="softBin"||a==="stackedSoftBins";let it=de?new Map:void 0;const bt=a==="value"&&H==="spec"?{pass:0,failHigh:0,failLow:0}:void 0,xt=a==="value"&&H==="test"?{pass:0,fail:0}:void 0,Ot=a==="metadata";let st=Ot?new Map:void 0,ot=null;if(Ot&&M){const l=collectMetadataValues(e,M),f=E?.key===M?E.values:void 0,v=f?[...f,...l.filter(F=>!f.includes(F))]:l;ot=new Map(v.map((F,k)=>[F,ee?.values?.find(W=>W.value===F)?.color??_e(k)]))}const me=S===void 0?void 0:new Set(zt(S)),pe=d===void 0?void 0:new Set(zt(d));for(let l=0;l<e.length;l++){const f=e[l],v=K?K[l*2]:f.physX,F=K?K[l*2+1]:f.physY;if(yt.push({x:v,y:F}),it&&Q(f)){const k=he?f.sbin:f.hbin;k!=null&&it.set(k,(it.get(k)??0)+1)}if(bt&&Q(f)){const k=lt(L(f,_),T);k&&bt[k]++}if(xt&&Q(f)){const k=J(f,_,T);k!==void 0&&xt[k?"pass":"fail"]++}if(st&&Q(f)){const k=ft(f,M);k!==void 0&&st.set(k,(st.get(k)??0)+1)}nn(_t,f,v,F,a,fe,At,Ct,me,at,_,se,oe,T,H,M,ot,pe)}const Ht=o?generateTextOverlay(e,K,{plotMode:a,colorFns:Ct,normalize:at,activeTest:A,valueRange:[N,O],testDefs:y,fallbackFormat:P,passFailDisplay:H,activeMetadataKey:M,metadataColorMap:ot,allIntegerValues:nt}):[],G=Qe(t,C.physicalToScreen);x&&G.push(...Je(t,C.physicalToScreen,be({ringCount:p},"buildView"))),$&&G.push(...Ze(t,C.physicalToScreen,t.center.x,t.center.y)),r&&G.push(...tn(s,C.gridToScreen)),h&&G.push(...en(e)),V&&G.push(...an(t,C.gridToScreen,Ht));const ge=yt.length>0?{minX:t.center.x-t.radius,maxX:t.center.x+t.radius,minY:t.center.y-t.radius,maxY:t.center.y+t.radius}:null,wt={rectangles:_t,dieGap:At,hoverPoints:yt,texts:Ht,overlays:G,plotMode:a,binColorScheme:I,valueColorScheme:b,reverseValueScheme:B,binColors:pt,metadata:t.metadata??null,dies:e,valueRange:[N,O],allIntegerValues:nt,testDefs:y,activeTest:A,logScale:ce,logScaleRequested:Rt,aggrMethod:w,lotSize:tt,axisFlip:ne,dataAxisFlip:{x:q?.x??!1,y:q?.y??!1},gridToScreen:C.gridToScreen,rotation:((t.orientation+(g?.rotation??0))%360+360)%360,hasReticle:s.length>0,isLotStack:dt,passFailDisplay:H,colorbarRangeMode:Lt,waferCenter:t.center,waferRadius:t.radius,notchDir:Nt,binCounts:it,metadataCounts:st,metadataColorMap:ot,activeMetadataKey:M,metadataFields:Dt,specCounts:bt,passFailCounts:xt,dieBounds:ge};return n.compact?Ee(wt,n.compact,{showXYIndicator:V}):wt}export{getDieKey}from"../core/dies.js";
@@ -583,9 +583,15 @@ export interface WaferWarning {
583
583
  * lands in ring 1 — and ring/quadrant/edge findings then describe the assumed
584
584
  * wafer, not the probed area. A genuinely partial map looks identical and is
585
585
  * equally worth reporting, so the message names both causes.
586
- * - `'test-count-capped'` — raised by `analyzeWaferMap`: more tests were found in
587
- * the die data than the analysis cap allows, so test-value analysis was skipped
588
- * entirely and NO test findings were produced. Pass `testNumbers` to scope it.
586
+ * - `'implausible-center'` — a supplied `waferConfig.center`, with no diameter, lies
587
+ * more than the dies' own span outside their bounding box on either axis. It
588
+ * was ignored and the centre inferred from the dies, since sizing the wafer to
589
+ * reach the dies from it would draw a wafer many times the die extent. Typical
590
+ * source: a placeholder centre in a tester's WCR record. Supply
591
+ * `waferConfig.diameter` too if the centre is real.
592
+ * - `'test-count-capped'` — no longer raised. A skipped test-value analysis is
593
+ * recorded in `StatsSummary.stats.testValueAnalysis` and offered in the
594
+ * renderers' Findings section instead.
589
595
  * - `'analysis-option-corrected'` — raised by `analyzeWaferMap` (or `buildWaferMap`, for `ringCount`): a numeric option
590
596
  * was outside the range that can produce a meaningful analysis and was clamped.
591
597
  * The message names each correction. Only reachable from untyped callers now
@@ -641,7 +647,7 @@ export interface WaferWarning {
641
647
  * The union is intentionally open to string so future advisory codes can be
642
648
  * added without a breaking change; switch with a `default` branch.
643
649
  */
644
- code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | 'values-excluded' | (string & {});
650
+ code: 'partial-coverage' | 'geometry-conflict' | 'non-standard-diameter' | 'diameter-exceeds-die-extent' | 'test-count-capped' | 'edge-exclusion-exceeds-radius' | 'analysis-option-corrected' | 'bin-colors-shared' | 'pass-bins-mixed' | 'ring-count-mixed' | 'input-field-removed' | 'input-values-not-numbers' | 'input-values-outside-stdf' | 'retests-by-part-id' | 'derived-test-invalid' | 'values-excluded' | 'implausible-center' | (string & {});
645
651
  /** Human-readable explanation, suitable for direct display. */
646
652
  message: string;
647
653
  /**
@@ -798,6 +804,8 @@ export interface WaferMapResult {
798
804
  * structured clone, which is why it tests a field and not object identity.
799
805
  */
800
806
  export declare function isBuiltMap(map: object): map is WaferMapResult;
807
+ export declare function computeCoverage(dies: Die[]): WaferMapResult['dataCoverage'];
808
+ export declare function computeYield(dies: Die[], passBins: number[], edgeDieYieldMode?: 'exclude' | 'denominator-only', binsAreData?: boolean): YieldSummary;
801
809
  /** Read a test value from a die by test number. */
802
810
  export declare function getDieTestValue(die: Die, testNumber: number): number | undefined;
803
811
  /**
@@ -830,6 +838,15 @@ export declare function testPassStatusReader(testDefs: readonly TestDef[]): (die
830
838
  * availability checks.
831
839
  */
832
840
  export declare function dieHasTestData(die: Pick<Die, 'testValues' | 'testPass'>): boolean;
841
+ /**
842
+ * The bin mode a map opens in when it has no test values: hard bins when any die has one, else soft bins
843
+ * when any die has one, else hard bins. The one rule for `buildWaferMap`'s own mode and for the renderers
844
+ * (single map and gallery), over one or several die lists.
845
+ */
846
+ export declare function defaultBinMode(dieLists: ReadonlyArray<ReadonlyArray<{
847
+ hbin?: number | null;
848
+ sbin?: number | null;
849
+ }>>): 'hardBin' | 'softBin';
833
850
  /**
834
851
  * Nominal wafer diameters in mm, used to sanity-check an *inferred* diameter.
835
852
  * Override per build with {@link WaferMapInputBase.standardDiameters}.
@@ -1 +1 @@
1
- import{createWafer as q}from"../core/wafer.js";import{isYieldEligibleDie as De,getDieKey as Y,hasPosition as E}from"../core/dies.js";import{applyOrientation as ne,transformDies as ve,clipDiesToWafer as Me}from"../core/transforms.js";import{generateDies as Se}from"../core/dies.js";import{dieHasAnyTestData as Ce,dieLink as K,finaliseDie as H,linkDie as ke,recordedVerdict as Oe,recordedVerdictsReader as Ae,tableFromRows as Ne,testValue as J,testsPresent as $e,VERDICT_FAIL as Fe,VERDICT_NONE as Re,VERDICT_PASS as Te}from"../core/dieTable.js";import{isDieColumns as Ee,linkColumns as We,linkRows as ie,relink as se}from"./columnarInput.js";import{affineRotation as Ie,affineMirror as _e,affineCompose as Pe,affinePoint as Ve}from"../core/transforms.js";import{inferWaferFromXY as Be}from"../core/inference/wafer.js";import{resolveGridPitch as Le}from"../core/inference/pitch.js";import{assignGridIndices as Ye}from"../core/inference/grid.js";import{generateReticleGrid as Xe}from"../core/reticle.js";import{applyDerivedTests as je}from"./derivedTests/apply.js";import{isStdfBin as Ke,isStdfCoord as re,isStdfTestNumber as oe,isStdfSite as He,STDF_BIN_MAX as ze,STDF_COORD_MAX as ae,STDF_TEST_NUM_MAX as Ue,STDF_SITE_MAX as Ge}from"../core/stdf.js";import{hasAnyKey as qe,maxOf as Q,minOf as de,modeOf as Je}from"../core/utils.js";import{aggregateValues as fe,aggregateBinCounts as Qe,stackHoldsMeasurements as Ze}from"../core/aggregates.js";import{normalizePassBins as le}from"../core/passBins.js";import{defaultRingCount as Z}from"../core/ringCount.js";import{applyValueFilter as et,mergeValueFilterTests as tt,valueFilterWarning as nt}from"./valueFilter.js";export function isParametricTest(t){return t?.testType!=="F"}export function isBuiltMap(t){return"wafer"in t&&"dies"in t&&"dataAxisFlip"in t}function it(t){const e=(i,d)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(t)} ${d} (using ${i}).`}});if(t===void 0)return{ringCount:Z(),ringCountWarning:void 0};if(typeof t!="number"||!Number.isFinite(t))return e(Z(),"is not a finite number");const n=Math.max(1,Math.round(t));return n===t?{ringCount:t,ringCountWarning:void 0}:e(n,"is not a whole number of at least 1")}function st(t,e){const n=Array.isArray(t)?{}:t,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let d;const r=(c,S)=>{i[c]++,d??=`${c} ${JSON.stringify(S)}`},a={bins:0,positions:0,values:0,sites:0,orientation:0},s=new Set;let h=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(d??=e.example),a.values+=e.nonFinite;for(const c of e.badTestNumbers)s.add(c)}const p=c=>c==null?!0:typeof c!="number"?!1:Number.isNaN(c)?(h++,!1):Ke(c)?!0:(a.bins++,!1);function u(c){const S=new Set,D=new Set;for(let $=0;$<c.length;$+=$<50?1:100){const A=c[$];if(!(A===null||typeof A!="object")){if(A.testValues&&typeof A.testValues=="object")for(const w of Object.keys(A.testValues))S.add(w);if(A.testPass&&typeof A.testPass=="object")for(const w of Object.keys(A.testPass))D.add(w)}}const m=[...S],b=[...D],O=$=>oe(Number($));for(const $ of new Set([...m,...b]))O($)||s.add($);const F=m.map(O),M=b.map(O),W=m.map(Number),T=b.map(Number);let P;for(let $=0;$<c.length;$++){const A=c[$];if(A===null||typeof A!="object")continue;const w=A;let B;const I=()=>B??={...w};w.hbin!=null&&typeof w.hbin!="number"&&r("hbin",w.hbin),w.sbin!=null&&typeof w.sbin!="number"&&r("sbin",w.sbin),p(w.hbin)||(I().hbin=void 0),p(w.sbin)||(I().sbin=void 0);const X=typeof w.x=="number"&&!re(w.x),L=typeof w.y=="number"&&!re(w.y);if(X||L){a.positions+=(X?1:0)+(L?1:0);const x=I();x.x=void 0,x.y=void 0}w.siteNum!=null&&typeof w.siteNum!="number"?(r("siteNum",w.siteNum),I().siteNum=void 0):typeof w.siteNum=="number"&&!He(w.siteNum)&&(a.sites++,I().siteNum=void 0);const o=w.testValues;if(o&&typeof o=="object"){let x;for(let k=0;k<m.length;k++){const R=m[k],N=o[W[k]];if(N!=null){if(!F[k]){x??={...o},delete x[R];continue}typeof N!="number"?(r("testValues",N),x??={...o},delete x[R]):Number.isFinite(N)||(a.values++,x??={...o},delete x[R])}}x&&(I().testValues=x)}const C=w.testPass;if(C&&typeof C=="object"){let x;for(let k=0;k<b.length;k++){const R=b[k],N=C[T[k]];if(N!=null){if(!M[k]){x??={...C},delete x[R];continue}typeof N!="boolean"&&(r("testPass",N),x??={...C},delete x[R])}}x&&(I().testPass=x)}B&&((P??=c.slice())[$]=B)}return P}const l={warnings:[]};if(Array.isArray(t))l.results=u(t);else{Array.isArray(n.results)&&(l.results=u(n.results)),Array.isArray(n.dies)&&(l.dies=u(n.dies));const c=n.lotStack?.results;if(Array.isArray(c)){const S=c.map(D=>Array.isArray(D)?u(D):void 0);S.some(Boolean)&&(l.stackResults=S.map((D,m)=>D??c[m]))}}if(Array.isArray(n.testDefs)){const c=n.testDefs,S=c.filter(D=>D==null||typeof D.testNumber!="number"||oe(D.testNumber));for(const D of c)S.includes(D)||s.add(String(D.testNumber));S.length!==c.length&&(l.testDefs=S)}const g=n.waferConfig?.orientation;if(typeof g=="number"){const c=Number.isFinite(g)?(g%360+360)%360:NaN;c===0||c===90||c===180||c===270?l.orientation=c:(a.orientation++,l.orientation=0)}const f=(c,S,D=`${S}s`)=>`${c} ${c===1?S:D}`,y=[];if(i.hbin&&y.push(f(i.hbin,"hard bin")),i.sbin&&y.push(f(i.sbin,"soft bin")),i.siteNum&&y.push(f(i.siteNum,"site number")),i.testValues&&y.push(f(i.testValues,"test value")),i.testPass&&y.push(f(i.testPass,"pass/fail verdict")),y.length){const c=`buildWaferMap received ${y.join(", ")} of the wrong type (for example ${d}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${c}`),l.warnings.push({code:"input-values-not-numbers",message:c,severity:"error"})}const v=[];if(a.bins&&v.push(`${f(a.bins,"bin")} (legal: whole numbers 0\u2013${ze}) \u2014 those dies have no bin`),a.positions&&v.push(`${f(a.positions,"coordinate")} (legal: whole numbers \u2212${ae} to ${ae}) \u2014 those dies have no position`),s.size&&v.push(`${f(s.size,"test number")} (legal: whole numbers 0\u2013${Ue}) \u2014 those tests are left out`),a.values&&v.push(`${f(a.values,"test value")} that ${a.values===1?"is":"are"} not finite \u2014 left out`),a.sites&&v.push(`${f(a.sites,"site number")} (legal: 0\u2013${Ge}) \u2014 those dies have no site`),a.orientation&&v.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),v.length||h){const c=[];v.length&&c.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${v.join("; ")}.`),h&&c.push(`${f(h,"bin was","bins were")} NaN and ${h===1?"is":"are"} treated as no bin.`);const S=c.join(" ");console.warn(`[wafermap] ${S}`),l.warnings.push({code:"input-values-outside-stdf",message:S,severity:"warning"})}return l}function ue(t){const e=(p,u)=>p!==null&&typeof p=="object"&&p[u]!==void 0,n=Array.isArray(t)?{}:t,i=[],d=(p,u,l)=>{p&&i.push(`\`${u}\` (now \`${l}\`)`)};d(e(n,"data"),"data","results"),d(e(n,"die"),"die","dieConfig"),d(e(n,"stack"),"stack","lotStack"),d(e(n.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),d(e(n.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),d(e(n.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),d(e(n.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),d(Array.isArray(n.testDefs)&&n.testDefs.some(p=>e(p,"index")&&!e(p,"testNumber")),"TestDef.index","TestDef.testNumber");const r=e(n.lotStack,"results")?n.lotStack.results:[],a=(Array.isArray(t)?[t]:[n.results,...Array.isArray(r)?r:[]]).filter(p=>Array.isArray(p));if(d(a.some(p=>p.slice(0,100).some(u=>e(u,"values"))),"values","testValues"),!i.length)return;const s=i.length>1,h=`buildWaferMap ignored ${i.join(", ")}: ${s?"these names were":"that name was"} removed in an earlier release, so what ${s?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${h}`),{code:"input-field-removed",message:h,severity:"error"}}function rt(t){if(t.results!==void 0||t.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=t.waferConfig?.diameter,n=t.dieConfig?.width,i=t.dieConfig?.height;if(!(e>0&&n>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const d=q({diameter:e,notch:t.waferConfig?.notch,orientation:0}),r=Me(Se(d,{width:n,height:i}),d,{width:n,height:i}).filter(u=>!u.partial),{flipX:a,flipY:s}=ce(t.dieConfig,{type:"center"}),{layout:h,...p}=t;return{...p,results:r.map(u=>({x:a?-u.x:u.x,y:s?-u.y:u.y})),waferConfig:{...t.waferConfig,center:{x:0,y:0}},dieConfig:{...t.dieConfig,coordinateOrigin:{type:"center"}}}}function ot(t){if(!Array.isArray(t)&&"results"in t&&t.results!==void 0&&"lotStack"in t&&t.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},n=!Array.isArray(t)&&Ee(t.results)?{...t,results:We(t.results,e).records}:t,i=st(n,e);return Array.isArray(n)?{results:ee(i.results??n),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:le(void 0),ringCount:Z(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:ue(n),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ee(i.results??n.results??[]),waferOpts:i.orientation===void 0||n.waferConfig===void 0?n.waferConfig:{...n.waferConfig,orientation:i.orientation},dieOpts:n.dieConfig,explicitDies:i.dies??n.dies,reticleOpts:n.reticleConfig,lotStackOpts:n.lotStack?{...n.lotStack,results:(i.stackResults??n.lotStack.results).map(ee)}:void 0,passBins:le(n.passBins),valueFilter:n.valueFilter??"validity",...it(n.ringCount),removedFieldWarning:ue(n),inputValueWarnings:i.warnings,standardDiameters:n.standardDiameters,testDefs:(i.testDefs??n.testDefs)?.length?i.testDefs??n.testDefs:void 0,hbinDefs:n.hbinDefs,sbinDefs:n.sbinDefs,metadataFields:n.metadataFields,derivedTests:n.derivedTests?.length?n.derivedTests:void 0,retestPolicy:n.retestPolicy??"last",edgeDieYieldMode:n.edgeDieYieldMode??"exclude"}}function ee(t){return t.length>0&&K(t[0])!==void 0?t:ie(t).records}function at(t,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function dt(t,e,n){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,d=-1/0,r=1/0,a=-1/0;for(const s of t)s.x<i&&(i=s.x),s.x>d&&(d=s.x),s.y<r&&(r=s.y),s.y>a&&(a=s.y);return{offsetX:Math.round((d+i)/2),offsetY:Math.round((a+r)/2)}}return{offsetX:n.offsetX,offsetY:n.offsetY}}function ft(t,e,n,i,d,r){if(r)return{colMidX:(Math.round(r.x)-e)*i,colMidY:(Math.round(r.y)-n)*d,anchored:!0};if(t.length===0)return{colMidX:0,colMidY:0,anchored:!1};let a=1/0,s=-1/0,h=1/0,p=-1/0;for(const u of t){const l=Math.round(u.x)-e,g=Math.round(u.y)-n;l<a&&(a=l),l>s&&(s=l),g<h&&(h=g),g>p&&(p=g)}return{colMidX:(a+s)/2*i,colMidY:(h+p)/2*d,anchored:!1}}function lt(t,e,n){let i=1/0,d=-1/0,r=1/0,a=-1/0,s=0,h=0;for(const l of t){const g=Math.round(l.x)-e,f=Math.round(l.y)-n;s+=g,h+=f,g<i&&(i=g),g>d&&(d=g),f<r&&(r=f),f>a&&(a=f)}const p=t.length,u=(l,g,f)=>{const y=(f-g)/2;return y<=0?0:Math.abs(l/p-(g+f)/2)/y};return u(s,i,d)>.11||u(h,r,a)>.11}function ce(t,e){let n=t?.xAxisDirection==="left",i=t?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(n=!0),{flipX:n,flipY:i}}function ut(t){const e={...t};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function ct(t,e){const{method:n,targetBin:i}=t,d=t.results.map(r=>r.filter(E));if(n==="mean"||n==="median"||n==="stddev"||n==="min"||n==="max"||n==="count"){const r=new Set((e??[]).filter(u=>!isParametricTest(u)).map(u=>u.testNumber)),a=new Set;for(const u of d)for(const l of $e(u,"values"))r.has(l)||a.add(l);if(a.size===0)return fe(d,n);const s=[...a],h=s.map(u=>fe(d,n,u)),p=new Map;for(let u=0;u<s.length;u++){const l=s[u];for(const g of h[u]){const f=Y(g);p.has(f)||p.set(f,{template:g,testValues:{}});const y=p.get(f),v=g.testValues?.[0];v!==void 0&&(y.testValues[l]=v)}}return[...p.values()].map(({template:u,testValues:l})=>({...u,testValues:qe(l)?l:void 0}))}if(n==="countBin"||n==="percent"){if(i===void 0)return[];const r=Qe(d,i,"hard");if(n==="countBin")return r;const a=d.length;return r.map(s=>({...s,testValues:{0:a>0?(s.testValues?.[0]??0)/a*100:0}}))}if(n==="mode"){const r=new Map;for(const s of d)for(const h of s){const p=Y(h);r.has(p)||r.set(p,[]),r.get(p).push(h)}const a=[];for(const[s,h]of r){const p=s.split(","),u=Number(p[0]),l=Number(p[1]),g=h.map(y=>y.hbin).filter(y=>y!==void 0),f=Je(g);f!==null&&a.push({x:u,y:l,hbin:f})}return a}return[]}function pe(t){const e=t.filter(E),n=e.length,i=e.filter(r=>r.edgeExcluded).length,d=e.filter(r=>r.hbin!==void 0||r.sbin!==void 0||dieHasTestData(r)).length;return{filledDies:d,totalDies:n,edgeExcludedDies:i,unpositionedDies:t.length-e.length,ratio:n>0?d/n:0}}function he(t,e,n="exclude"){const i=new Set(e),r=t.filter(f=>!f.partial).filter(f=>f.edgeExcluded).length,a=t.filter(f=>f.partial).length;let s=0,h=0,p=!1;for(const f of t){if(!De(f))continue;const y=f.hbin??f.sbin;y!==void 0&&(p=!0,i.has(y)?s++:h++)}const u=s+h,l=p&&u>0?s/u*100:null;let g=null;if(n==="denominator-only"){const f=u+r;g=p&&f>0?s/f*100:null}return{passDies:s,failDies:h,edgeExcludedDies:r,partialDies:a,totalDies:u,yieldPercent:l,yieldPercentGross:g}}function me(t,e,n,i,d,r=0,a=0,s=0,h=0,p=0,u=!1,l=!1){if(!t)return[];const g=t.anchorDie??{x:0,y:0},f=Xe(e,{width:t.width,height:t.height,diePitchX:i,diePitchY:d,anchorDie:{x:g.x-r,y:g.y-a},gridOrigin:{x:-s,y:-h}}),y=Pe(_e(u,l,e.center.x,e.center.y),Ie(p,e.center.x,e.center.y));return f.filter(v=>{const c=v.width/2,S=v.height/2,D=[[v.x-c,v.y-S],[v.x+c,v.y-S],[v.x+c,v.y+S],[v.x-c,v.y+S]].map(([M,W])=>Ve(y,M,W)),m=de(D.map(M=>M.x)),b=Q(D.map(M=>M.x)),O=de(D.map(M=>M.y)),F=Q(D.map(M=>M.y));return n.some(M=>M.physX>=m&&M.physX<b&&M.physY>=O&&M.physY<F)})}function pt(t,e,n){const d=Math.max(0,e.radius-n)**2;return t.map(r=>{const a=r.physX-e.center.x,s=r.physY-e.center.y;return a*a+s*s>d?{...r,edgeExcluded:!0}:r})}const ht=.2;function mt(t,e,n){const i=new Set(n);function d(m,b){if(e==="last")return!0;if(e==="first")return!1;const O=z(m.hbin),F=z(b.hbin);if(O===void 0||F===void 0)return!1;const M=i.has(O),W=i.has(F);return e==="best"?W!==M?W:F<O:W!==M?M:F>O}const r=(m,b)=>b.supersedes!==void 0||d(m,b),a=m=>{const b=m.partId===void 0?"":String(m.partId).trim();return b===""?void 0:b},s=t.filter(m=>!E(m)),h=new Map;for(const m of s){const b=a(m);b!==void 0&&h.set(b,(h.get(b)??0)+1)}const u=(s.length===0?0:Math.max(0,...h.values())/s.length)<=ht,l=new Map,g=[],f=new Map;let y=0,v=0;for(const m of t){const b=a(m);let O;if(E(m)?O=`p:${Y(m)}`:u&&b!==void 0?O=`i:${b}`:O=`u:${v++}`,m.supersedes==="partId"&&b!==void 0){const M=f.get(b);M!==void 0&&M!==O&&l.has(M)&&l.delete(M)}const F=l.get(O);F===void 0?(l.set(O,{winner:m,count:1}),g.push(O)):(F.count++,O.startsWith("i:")&&y++,r(F.winner,m)&&(F.winner=m)),b!==void 0&&f.set(b,O)}const c=[],S=[...g.filter(m=>m.startsWith("p:")),...g.filter(m=>!m.startsWith("p:"))];for(const m of S){const b=l.get(m);b!==void 0&&c.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=y>0?{code:"retests-by-part-id",severity:"info",message:`${y} record${y===1?"":"s"} with no position shared a part ID with an earlier record and ${y===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:c,warning:D}}export function getDieTestValue(t,e){return J(t,e)}export function getTestPassStatus(t,e,n){const i=Oe(t,e);return i!==void 0?i:n!==void 0&&!isParametricTest(n)?ge(J(t,e)):void 0}function ge(t){return t===0||t===1?t===1:void 0}export function testPassStatusReader(t){const e=t.map(d=>d.testNumber),n=Ae(e),i=t.map(d=>!isParametricTest(d));return function(r,a){n(r,a);for(let s=0;s<a.length;s++){if(a[s]!==Re||!i[s])continue;const h=ge(J(r,e[s]));h!==void 0&&(a[s]=h?Te:Fe)}return a}}export function dieHasTestData(t){return Ce(t)}function z(t){return t===void 0||Number.isNaN(t)?void 0:t}function U(t,e){const n={},i=z(e.hbin),d=z(e.sbin);i!==void 0&&(n.hbin=i),d!==void 0&&(n.sbin=d),e.retestCount!==void 0&&(n.retestCount=e.retestCount),e.siteNum!==void 0&&(n.siteNum=e.siteNum),e.partId!==void 0&&(n.partId=e.partId),e.metadata!==void 0&&(n.metadata=e.metadata);const r=K(e);return ke({...t,...n},r.table,r.row)}function ye(t){return t.some(dieHasTestData)?"value":t.some(e=>e.hbin!==void 0&&e.hbin!==null)?"hardBin":t.some(e=>e.sbin!==void 0&&e.sbin!==null)?"softBin":"hardBin"}function be(t,e){return t.map(({code:n,message:i})=>({code:n,message:i,severity:n==="non-standard-diameter"||n==="diameter-exceeds-die-extent"?"warning":"error",confidence:e.wafer.confidence}))}const gt="do not fit inside the supplied",yt="Inferred wafer diameter",bt="The probed dies reach only",wt=.75,xt=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const Dt=.02;function we(t,e){return e.reduce((n,i)=>Math.abs(i-t)<Math.abs(n-t)?i:n)}function vt(t,e){if(!e.length)return!0;const n=we(t,e);return Math.abs(n-t)/n<=Dt}function Mt(t){return t===void 0?STANDARD_WAFER_DIAMETERS_MM:t.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(t){const e=ot(!Array.isArray(t)&&t.layout?rt(t):t),n=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const o=e.valueFilter,C=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(k=>{const R=k.length>0?K(k[0]):void 0;if(!R)return[];const N=et(R.table,e.testDefs,o);return N.tests.length>0&&se(k,N.table),N.tests}),x=tt(C);if(x.length>0){i={mode:o,tests:x};const k=nt(o,x,e.testDefs);k&&n.push(k)}}if(e.derivedTests){const o=new Set(e.passBins),C=R=>{const N=R.length>0?K(R[0]):void 0,j=je(R,N?.table??Ne([]),e.testDefs,e.derivedTests,o);return N&&se(R,j.table),j},k=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(C);e.testDefs=k[0]?.testDefs??e.testDefs,n.push(...k[0]?.warnings??[])}e.lotStackOpts&&!Ze(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(ut));const d=e.lotStackOpts?ie(ct(e.lotStackOpts,e.testDefs)).records:e.results;for(let o=0;o<Math.min(5,d.length);o++){const C=d[o];if(typeof C.x=="string"||typeof C.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const o of d)if(o.x==null!=(o.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(o.x)}, y=${String(o.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:r,warning:a}=mt(d,e.retestPolicy,e.passBins),s={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},h=[];if(e.explicitDies){let o=e.explicitDies.filter(E);const C=e.explicitDies.filter(V=>!E(V)),x=r.filter(E),k=r.filter(V=>!E(V));if(x.length>0){const V=new Map(x.map(_=>[Y(_),_]));o=o.map(_=>{const te=V.get(Y(_));return te?U(_,te):_})}const R=e.waferOpts?.diameter??300,N=q({diameter:R,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});N.orientation!==0&&(o=ne(o,N)),o=o.map(H);const j=me(e.reticleOpts,N,o,1,1,0,0,0,0,N.orientation),xe=k.map((V,_)=>H(U({id:`unpositioned_${_}`,width:o[0]?.width??1,height:o[0]?.height??1},V))),G=[...o,...C,...xe];return{wafer:N,dies:G,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...a?[a]:[],...be(h,s),...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:ye(r),metadata:N.metadata??null,isLotStack:!1,dataCoverage:pe(G),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:he(G,e.passBins,e.edgeDieYieldMode),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const p=r.filter(E),u=r.filter(o=>!E(o)),l=p.map(o=>({x:o.x,y:o.y})),g=Le(l,e.dieOpts,e.waferOpts?.diameter);s.diePitch={confidence:g.confidence,units:g.units};const{pitchX:f,pitchY:y}=g,v=g.units,c=at(p,e.dieOpts),S=Ye(l);s.grid={confidence:S.confidence};const{offsetX:D,offsetY:m}=dt(l,c,S),{flipX:b,flipY:O}=ce(e.dieOpts,c),{colMidX:F,colMidY:M,anchored:W}=ft(l,D,m,f,y,e.waferOpts?.center);let T=e.waferOpts?.diameter;const P=l.map(o=>({x:(Math.round(o.x)-D)*f-F,y:(Math.round(o.y)-m)*y-M})),$=Q(P.map(({x:o,y:C})=>Math.hypot(Math.abs(o)+f/2,Math.abs(C)+y/2)));if(T===void 0)if(l.length>0)if(v==="mm"){const o=Be(P,{minRadius:$});T=o.diameter,s.wafer={confidence:o.confidence,method:o.method};const C=Mt(e.standardDiameters);if(!vt(T,C)){const x=we(T,C);h.push({code:"non-standard-diameter",message:`${yt} ${T.toFixed(1)} mm is not a standard wafer size (nearest is ${x} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else T=$*2,s.wafer={confidence:g.confidence*.8,method:"extent"};else T=v==="mm"?300:30,s.wafer={confidence:0,method:"default"};if(!W&&l.length>0&&lt(l,D,m)&&(s.wafer.method="inferred-partial",h.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&e.waferOpts.center===void 0&&$>0&&l.length>=xt){const o=$/(T/2);o<wt&&h.push({code:"diameter-exceeds-die-extent",message:`${bt} ${(o*100).toFixed(0)}% of the ${T} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const o=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(o&&$>T/2+1e-9){const C=P.filter(({x,y:k})=>Math.hypot(Math.abs(x)+f/2,Math.abs(k)+y/2)>T/2+1e-9).length;h.push({code:"geometry-conflict",message:`${C} of ${P.length} probed die positions ${gt} ${T} mm wafer at the supplied die pitch of ${f} \xD7 ${y} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${($*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const A=q({diameter:T,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let w=p.map(o=>{const C=Math.round(o.x)-D,x=Math.round(o.y)-m,k={id:`${C}_${x}`,x:C,y:x,physX:C*f-F,physY:x*y-M,width:f,height:y,insideWafer:!0,partial:!1};return U(k,o)});(D!==0||m!==0)&&(w=w.map(o=>({...o,x:o.x+D,y:o.y+m,id:`${o.x+D}_${o.y+m}`}))),w=ne(w,A),(b||O)&&(w=ve(w,{flipX:b,flipY:O},A.center));const B=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&(w=pt(w,A,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>A.radius&&B.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${A.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),w=w.map(H);const I=me(e.reticleOpts,A,w,f,y,D,m,F,M,A.orientation,b,O),X=u.map((o,C)=>H(U({id:`unpositioned_${C}`,width:f,height:y},o))),L=[...w,...X];return{wafer:A,dies:L,dataAxisFlip:{x:b,y:O},reticleConfig:e.reticleOpts,units:v,inference:s,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...a?[a]:[],...be(h,s),...B,...n,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:ye(r),metadata:A.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:pe(L),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:he(L,e.passBins,e.edgeDieYieldMode),reticles:I,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
1
+ import{createWafer as Q}from"../core/wafer.js";import{isYieldEligibleDie as ve,getDieKey as X,hasPosition as W,positionKey as Se}from"../core/dies.js";import{applyOrientation as se,transformDies as Ce,clipDiesToWafer as ke}from"../core/transforms.js";import{generateDies as Oe}from"../core/dies.js";import{dieHasAnyTestData as Ae,dieLink as U,finaliseDie as z,linkDie as $e,recordedVerdict as Ne,recordedVerdictsReader as Re,tableFromRows as Fe,testValue as Z,testsPresent as Ee,VERDICT_FAIL as Te,VERDICT_NONE as We,VERDICT_PASS as Ie}from"../core/dieTable.js";import{isDieColumns as _e,linkColumns as Pe,linkRows as re,relink as oe}from"./columnarInput.js";import{affineRotation as Ve,affineMirror as Be,affineCompose as Le,affinePoint as Ye}from"../core/transforms.js";import{inferWaferFromXY as Xe}from"../core/inference/wafer.js";import{resolveGridPitch as Ke}from"../core/inference/pitch.js";import{assignGridIndices as je}from"../core/inference/grid.js";import{generateReticleGrid as He}from"../core/reticle.js";import{applyDerivedTests as Ue}from"./derivedTests/apply.js";import{isStdfBin as ze,isStdfCoord as ae,isStdfTestNumber as de,isStdfSite as Ge,STDF_BIN_MAX as qe,STDF_COORD_MAX as fe,STDF_TEST_NUM_MAX as Je,STDF_SITE_MAX as Qe}from"../core/stdf.js";import{hasAnyKey as Ze,maxOf as ee,minOf as le,modeOf as et}from"../core/utils.js";import{aggregateValues as ue,aggregateBinCounts as tt,stackHoldsMeasurements as nt,stackBinsAreData as it}from"../core/aggregates.js";import{normalizePassBins as ce}from"../core/passBins.js";import{defaultRingCount as te}from"../core/ringCount.js";import{applyValueFilter as st,mergeValueFilterTests as rt,valueFilterWarning as ot}from"./valueFilter.js";export function isParametricTest(n){return n?.testType!=="F"}export function isBuiltMap(n){return"wafer"in n&&"dies"in n&&"dataAxisFlip"in n}function at(n){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(n)} ${a} (using ${i}).`}});if(n===void 0)return{ringCount:te(),ringCountWarning:void 0};if(typeof n!="number"||!Number.isFinite(n))return e(te(),"is not a finite number");const t=Math.max(1,Math.round(n));return t===n?{ringCount:n,ringCountWarning:void 0}:e(t,"is not a whole number of at least 1")}function dt(n,e){const t=Array.isArray(n)?{}:n,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const d=(u,C)=>{i[u]++,a??=`${u} ${JSON.stringify(C)}`},o={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let p=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),o.values+=e.nonFinite;for(const u of e.badTestNumbers)r.add(u)}const h=u=>u==null?!0:typeof u!="number"?!1:Number.isNaN(u)?(p++,!1):ze(u)?!0:(o.bins++,!1);function l(u){const C=new Set,D=new Set;for(let S=0;S<u.length;S+=S<50?1:100){const N=u[S];if(!(N===null||typeof N!="object")){if(N.testValues&&typeof N.testValues=="object")for(const M of Object.keys(N.testValues))C.add(M);if(N.testPass&&typeof N.testPass=="object")for(const M of Object.keys(N.testPass))D.add(M)}}const g=[...C],b=[...D],k=S=>de(Number(S));for(const S of new Set([...g,...b]))k(S)||r.add(S);const R=g.map(k),v=b.map(k),T=g.map(Number),L=b.map(Number);let K;for(let S=0;S<u.length;S++){const N=u[S];if(N===null||typeof N!="object")continue;const M=N;let F;const $=()=>F??={...M};M.hbin!=null&&typeof M.hbin!="number"&&d("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&d("sbin",M.sbin),h(M.hbin)||($().hbin=void 0),h(M.sbin)||($().sbin=void 0);const Y=typeof M.x=="number"&&!ae(M.x),j=typeof M.y=="number"&&!ae(M.y);if(Y||j){o.positions+=(Y?1:0)+(j?1:0);const s=$();s.x=void 0,s.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(d("siteNum",M.siteNum),$().siteNum=void 0):typeof M.siteNum=="number"&&!Ge(M.siteNum)&&(o.sites++,$().siteNum=void 0);const P=M.testValues;if(P&&typeof P=="object"){let s;for(let x=0;x<g.length;x++){const A=g[x],O=P[T[x]];if(O!=null){if(!R[x]){s??={...P},delete s[A];continue}typeof O!="number"?(d("testValues",O),s??={...P},delete s[A]):Number.isFinite(O)||(o.values++,s??={...P},delete s[A])}}s&&($().testValues=s)}const I=M.testPass;if(I&&typeof I=="object"){let s;for(let x=0;x<b.length;x++){const A=b[x],O=I[L[x]];if(O!=null){if(!v[x]){s??={...I},delete s[A];continue}typeof O!="boolean"&&(d("testPass",O),s??={...I},delete s[A])}}s&&($().testPass=s)}F&&((K??=u.slice())[S]=F)}return K}const f={warnings:[]};if(Array.isArray(n))f.results=l(n);else{Array.isArray(t.results)&&(f.results=l(t.results)),Array.isArray(t.dies)&&(f.dies=l(t.dies));const u=t.lotStack?.results;if(Array.isArray(u)){const C=u.map(D=>Array.isArray(D)?l(D):void 0);C.some(Boolean)&&(f.stackResults=C.map((D,g)=>D??u[g]))}}if(Array.isArray(t.testDefs)){const u=t.testDefs,C=u.filter(D=>D==null||typeof D.testNumber!="number"||de(D.testNumber));for(const D of u)C.includes(D)||r.add(String(D.testNumber));C.length!==u.length&&(f.testDefs=C)}const y=t.waferConfig?.orientation;if(typeof y=="number"){const u=Number.isFinite(y)?(y%360+360)%360:NaN;u===0||u===90||u===180||u===270?f.orientation=u:(o.orientation++,f.orientation=0)}const m=(u,C,D=`${C}s`)=>`${u} ${u===1?C:D}`,c=[];if(i.hbin&&c.push(m(i.hbin,"hard bin")),i.sbin&&c.push(m(i.sbin,"soft bin")),i.siteNum&&c.push(m(i.siteNum,"site number")),i.testValues&&c.push(m(i.testValues,"test value")),i.testPass&&c.push(m(i.testPass,"pass/fail verdict")),c.length){const u=`buildWaferMap received ${c.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${u}`),f.warnings.push({code:"input-values-not-numbers",message:u,severity:"error"})}const w=[];if(o.bins&&w.push(`${m(o.bins,"bin")} (legal: whole numbers 0\u2013${qe}) \u2014 those dies have no bin`),o.positions&&w.push(`${m(o.positions,"coordinate")} (legal: whole numbers \u2212${fe} to ${fe}) \u2014 those dies have no position`),r.size&&w.push(`${m(r.size,"test number")} (legal: whole numbers 0\u2013${Je}) \u2014 those tests are left out`),o.values&&w.push(`${m(o.values,"test value")} that ${o.values===1?"is":"are"} not finite \u2014 left out`),o.sites&&w.push(`${m(o.sites,"site number")} (legal: 0\u2013${Qe}) \u2014 those dies have no site`),o.orientation&&w.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),w.length||p){const u=[];w.length&&u.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${w.join("; ")}.`),p&&u.push(`${m(p,"bin was","bins were")} NaN and ${p===1?"is":"are"} treated as no bin.`);const C=u.join(" ");console.warn(`[wafermap] ${C}`),f.warnings.push({code:"input-values-outside-stdf",message:C,severity:"warning"})}return f}function pe(n){const e=(h,l)=>h!==null&&typeof h=="object"&&h[l]!==void 0,t=Array.isArray(n)?{}:n,i=[],a=(h,l,f)=>{h&&i.push(`\`${l}\` (now \`${f}\`)`)};a(e(t,"data"),"data","results"),a(e(t,"die"),"die","dieConfig"),a(e(t,"stack"),"stack","lotStack"),a(e(t.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(t.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(t.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(t.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(t.testDefs)&&t.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const d=e(t.lotStack,"results")?t.lotStack.results:[],o=(Array.isArray(n)?[n]:[t.results,...Array.isArray(d)?d:[]]).filter(h=>Array.isArray(h));if(a(o.some(h=>h.slice(0,100).some(l=>e(l,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,p=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${p}`),{code:"input-field-removed",message:p,severity:"error"}}function ft(n){if(n.results!==void 0||n.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=n.waferConfig?.diameter,t=n.dieConfig?.width,i=n.dieConfig?.height;if(!(e>0&&t>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=Q({diameter:e,notch:n.waferConfig?.notch,orientation:0}),d=ke(Oe(a,{width:t,height:i}),a,{width:t,height:i}).filter(l=>!l.partial),{flipX:o,flipY:r}=me(n.dieConfig,{type:"center"}),{layout:p,...h}=n;return{...h,results:d.map(l=>({x:o?-l.x:l.x,y:r?-l.y:l.y})),waferConfig:{...n.waferConfig,center:{x:0,y:0}},dieConfig:{...n.dieConfig,coordinateOrigin:{type:"center"}}}}function lt(n){if(!Array.isArray(n)&&"results"in n&&n.results!==void 0&&"lotStack"in n&&n.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},t=!Array.isArray(n)&&_e(n.results)?{...n,results:Pe(n.results,e).records}:n,i=dt(t,e);return Array.isArray(t)?{results:ne(i.results??t),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:ce(void 0),ringCount:te(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ne(i.results??t.results??[]),waferOpts:i.orientation===void 0||t.waferConfig===void 0?t.waferConfig:{...t.waferConfig,orientation:i.orientation},dieOpts:t.dieConfig,explicitDies:i.dies??t.dies,reticleOpts:t.reticleConfig,lotStackOpts:t.lotStack?{...t.lotStack,results:(i.stackResults??t.lotStack.results).map(ne)}:void 0,passBins:ce(t.passBins),valueFilter:t.valueFilter??"validity",...at(t.ringCount),removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:t.standardDiameters,testDefs:(i.testDefs??t.testDefs)?.length?i.testDefs??t.testDefs:void 0,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,metadataFields:t.metadataFields,derivedTests:t.derivedTests?.length?t.derivedTests:void 0,retestPolicy:t.retestPolicy??"last",edgeDieYieldMode:t.edgeDieYieldMode??"exclude"}}function ne(n){return n.length>0&&U(n[0])!==void 0?n:re(n).records}function ut(n,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function ct(n,e,t){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,d=1/0,o=-1/0;for(const r of n)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<d&&(d=r.y),r.y>o&&(o=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((o+d)/2)}}return{offsetX:t.offsetX,offsetY:t.offsetY}}function pt(n,e){if(n.length<xe)return!1;const t=he(n),i=(a,d,o)=>{const r=o-d+1;return a<d-r||a>o+r};return i(Math.round(e.x),t.xMin,t.xMax)||i(Math.round(e.y),t.yMin,t.yMax)}function he(n){let e=1/0,t=-1/0,i=1/0,a=-1/0;for(const d of n){const o=Math.round(d.x),r=Math.round(d.y);o<e&&(e=o),o>t&&(t=o),r<i&&(i=r),r>a&&(a=r)}return{xMin:e,xMax:t,yMin:i,yMax:a}}const ht="The supplied wafer centre";function mt(n,e){const t=he(n);return`${ht} (${e.x}, ${e.y}) is far outside the probed dies (X ${t.xMin}\u2026${t.xMax}, Y ${t.yMin}\u2026${t.yMax}), so it was ignored and the centre was inferred from the dies. Used as given, it would draw a wafer many times the die extent with the dies in one corner. If it is the real centre, supply waferConfig.diameter as well.`}function gt(n,e,t,i,a,d){if(d)return{colMidX:(Math.round(d.x)-e)*i,colMidY:(Math.round(d.y)-t)*a,anchored:!0};if(n.length===0)return{colMidX:0,colMidY:0,anchored:!1};let o=1/0,r=-1/0,p=1/0,h=-1/0;for(const l of n){const f=Math.round(l.x)-e,y=Math.round(l.y)-t;f<o&&(o=f),f>r&&(r=f),y<p&&(p=y),y>h&&(h=y)}return{colMidX:(o+r)/2*i,colMidY:(p+h)/2*a,anchored:!1}}function yt(n,e,t){let i=1/0,a=-1/0,d=1/0,o=-1/0,r=0,p=0;for(const f of n){const y=Math.round(f.x)-e,m=Math.round(f.y)-t;r+=y,p+=m,y<i&&(i=y),y>a&&(a=y),m<d&&(d=m),m>o&&(o=m)}const h=n.length,l=(f,y,m)=>{const c=(m-y)/2;return c<=0?0:Math.abs(f/h-(y+m)/2)/c};return l(r,i,a)>.11||l(p,d,o)>.11}function me(n,e){let t=n?.xAxisDirection==="left",i=n?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(t=!0),{flipX:t,flipY:i}}function bt(n){const e={...n};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function wt(n,e){const{method:t,targetBin:i}=n,a=n.results.map(d=>d.filter(W));if(t==="mean"||t==="median"||t==="stddev"||t==="min"||t==="max"||t==="count"){const d=new Set((e??[]).filter(l=>!isParametricTest(l)).map(l=>l.testNumber)),o=new Set;for(const l of a)for(const f of Ee(l,"values"))d.has(f)||o.add(f);if(o.size===0)return ue(a,t);const r=[...o],p=r.map(l=>ue(a,t,l)),h=new Map;for(let l=0;l<r.length;l++){const f=r[l];for(const y of p[l]){const m=X(y);h.has(m)||h.set(m,{template:y,testValues:{}});const c=h.get(m),w=y.testValues?.[0];w!==void 0&&(c.testValues[f]=w)}}return[...h.values()].map(({template:l,testValues:f})=>({...l,testValues:Ze(f)?f:void 0}))}if(t==="countBin"||t==="percent"){if(i===void 0)return[];const d=tt(a,i,"hard");if(t==="countBin")return d;const o=a.length;return d.map(r=>({...r,testValues:{0:o>0?(r.testValues?.[0]??0)/o*100:0}}))}if(t==="mode"){const d=new Map;for(const r of a)for(const p of r){const h=X(p);d.has(h)||d.set(h,[]),d.get(h).push(p)}const o=[];for(const[r,p]of d){const h=r.split(","),l=Number(h[0]),f=Number(h[1]),y=p.map(c=>c.hbin).filter(c=>c!==void 0),m=et(y);m!==null&&o.push({x:l,y:f,hbin:m})}return o}return[]}export function computeCoverage(n){const e=n.filter(W),t=e.length,i=e.filter(d=>d.edgeExcluded).length,a=e.filter(d=>d.hbin!==void 0||d.sbin!==void 0||dieHasTestData(d)).length;return{filledDies:a,totalDies:t,edgeExcludedDies:i,unpositionedDies:n.length-e.length,ratio:t>0?a/t:0}}export function computeYield(n,e,t="exclude",i=!0){const a=new Set(e),o=n.filter(c=>!c.partial).filter(c=>c.edgeExcluded).length,r=n.filter(c=>c.partial).length;if(!i)return{passDies:0,failDies:0,edgeExcludedDies:o,partialDies:r,totalDies:0,yieldPercent:null,yieldPercentGross:null};let p=0,h=0,l=!1;for(const c of n){if(!ve(c))continue;const w=c.hbin??c.sbin;w!==void 0&&(l=!0,a.has(w)?p++:h++)}const f=p+h,y=l&&f>0?p/f*100:null;let m=null;if(t==="denominator-only"){const c=f+o;m=l&&c>0?p/c*100:null}return{passDies:p,failDies:h,edgeExcludedDies:o,partialDies:r,totalDies:f,yieldPercent:y,yieldPercentGross:m}}function ge(n,e,t,i,a,d=0,o=0,r=0,p=0,h=0,l=!1,f=!1){if(!n)return[];const y=n.anchorDie??{x:0,y:0},m=He(e,{width:n.width,height:n.height,diePitchX:i,diePitchY:a,anchorDie:{x:y.x-d,y:y.y-o},gridOrigin:{x:-r,y:-p}}),c=Le(Be(l,f,e.center.x,e.center.y),Ve(h,e.center.x,e.center.y));return m.filter(w=>{const u=w.width/2,C=w.height/2,D=[[w.x-u,w.y-C],[w.x+u,w.y-C],[w.x+u,w.y+C],[w.x-u,w.y+C]].map(([v,T])=>Ye(c,v,T)),g=le(D.map(v=>v.x)),b=ee(D.map(v=>v.x)),k=le(D.map(v=>v.y)),R=ee(D.map(v=>v.y));return t.some(v=>v.physX>=g&&v.physX<b&&v.physY>=k&&v.physY<R)})}function xt(n,e,t){const a=Math.max(0,e.radius-t)**2;return n.map(d=>{const o=d.physX-e.center.x,r=d.physY-e.center.y;return o*o+r*r>a?{...d,edgeExcluded:!0}:d})}const Dt=.2;function Mt(n){const e=new Set;for(const t of n){if(t.supersedes!==void 0||!W(t))return!1;const i=Se(t);if(e.has(i))return!1;e.add(i)}return!0}function vt(n,e,t){if(Mt(n))return{results:n.slice(),warning:void 0};const i=new Set(t);function a(g,b){if(e==="last")return!0;if(e==="first")return!1;const k=G(g.hbin),R=G(b.hbin);if(k===void 0||R===void 0)return!1;const v=i.has(k),T=i.has(R);return e==="best"?T!==v?T:R<k:T!==v?v:R>k}const d=(g,b)=>b.supersedes!==void 0||a(g,b),o=g=>{const b=g.partId===void 0?"":String(g.partId).trim();return b===""?void 0:b},r=n.filter(g=>!W(g)),p=new Map;for(const g of r){const b=o(g);b!==void 0&&p.set(b,(p.get(b)??0)+1)}const l=(r.length===0?0:Math.max(0,...p.values())/r.length)<=Dt,f=new Map,y=[],m=new Map;let c=0,w=0;for(const g of n){const b=o(g);let k;if(W(g)?k=`p:${X(g)}`:l&&b!==void 0?k=`i:${b}`:k=`u:${w++}`,g.supersedes==="partId"&&b!==void 0){const v=m.get(b);v!==void 0&&v!==k&&f.has(v)&&f.delete(v)}const R=f.get(k);R===void 0?(f.set(k,{winner:g,count:1}),y.push(k)):(R.count++,k.startsWith("i:")&&c++,d(R.winner,g)&&(R.winner=g)),b!==void 0&&m.set(b,k)}const u=[],C=[...y.filter(g=>g.startsWith("p:")),...y.filter(g=>!g.startsWith("p:"))];for(const g of C){const b=f.get(g);b!==void 0&&u.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=c>0?{code:"retests-by-part-id",severity:"info",message:`${c} record${c===1?"":"s"} with no position shared a part ID with an earlier record and ${c===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:u,warning:D}}export function getDieTestValue(n,e){return Z(n,e)}export function getTestPassStatus(n,e,t){const i=Ne(n,e);return i!==void 0?i:t!==void 0&&!isParametricTest(t)?ye(Z(n,e)):void 0}function ye(n){return n===0||n===1?n===1:void 0}export function testPassStatusReader(n){const e=n.map(a=>a.testNumber),t=Re(e),i=n.map(a=>!isParametricTest(a));return function(d,o){t(d,o);for(let r=0;r<o.length;r++){if(o[r]!==We||!i[r])continue;const p=ye(Z(d,e[r]));p!==void 0&&(o[r]=p?Ie:Te)}return o}}export function dieHasTestData(n){return Ae(n)}function G(n){return n===void 0||Number.isNaN(n)?void 0:n}function q(n,e){const t={},i=G(e.hbin),a=G(e.sbin);i!==void 0&&(t.hbin=i),a!==void 0&&(t.sbin=a),e.retestCount!==void 0&&(t.retestCount=e.retestCount),e.siteNum!==void 0&&(t.siteNum=e.siteNum),e.partId!==void 0&&(t.partId=e.partId),e.metadata!==void 0&&(t.metadata=e.metadata);const d=U(e);return $e({...n,...t},d.table,d.row)}function be(n){return n.some(dieHasTestData)?"value":defaultBinMode([n])}export function defaultBinMode(n){const e=t=>n.some(i=>i.some(a=>t(a)!=null));return e(t=>t.hbin)?"hardBin":e(t=>t.sbin)?"softBin":"hardBin"}function we(n,e){return n.map(({code:t,message:i})=>({code:t,message:i,severity:t==="non-standard-diameter"||t==="diameter-exceeds-die-extent"||t==="implausible-center"?"warning":"error",confidence:e.wafer.confidence}))}const St="do not fit inside the supplied",Ct="Inferred wafer diameter",kt="The probed dies reach only",Ot=.75,xe=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const At=.02;function De(n,e){return e.reduce((t,i)=>Math.abs(i-n)<Math.abs(t-n)?i:t)}function $t(n,e){if(!e.length)return!0;const t=De(n,e);return Math.abs(t-n)/t<=At}function Nt(n){return n===void 0?STANDARD_WAFER_DIAMETERS_MM:n.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(n){const e=lt(!Array.isArray(n)&&n.layout?ft(n):n),t=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const s=e.valueFilter,x=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(O=>{const _=O.length>0?U(O[0]):void 0;if(!_)return[];const E=st(_.table,e.testDefs,s);return E.tests.length>0&&oe(O,E.table),E.tests}),A=rt(x);if(A.length>0){i={mode:s,tests:A};const O=ot(s,A,e.testDefs);O&&t.push(O)}}if(e.derivedTests){const s=new Set(e.passBins),x=_=>{const E=_.length>0?U(_[0]):void 0,H=Ue(_,E?.table??Fe([]),e.testDefs,e.derivedTests,s);return E&&oe(_,H.table),H},O=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(x);e.testDefs=O[0]?.testDefs??e.testDefs,t.push(...O[0]?.warnings??[])}e.lotStackOpts&&!nt(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(bt));const a=e.lotStackOpts?re(wt(e.lotStackOpts,e.testDefs)).records:e.results;for(let s=0;s<Math.min(5,a.length);s++){const x=a[s];if(typeof x.x=="string"||typeof x.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const s of a)if(s.x==null!=(s.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(s.x)}, y=${String(s.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:d,warning:o}=vt(a,e.retestPolicy,e.passBins),r={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},p=[];if(e.explicitDies){let s=e.explicitDies.filter(W);const x=e.explicitDies.filter(B=>!W(B)),A=d.filter(W),O=d.filter(B=>!W(B));if(A.length>0){const B=new Map(A.map(V=>[X(V),V]));s=s.map(V=>{const ie=B.get(X(V));return ie?q(V,ie):V})}const _=e.waferOpts?.diameter??300,E=Q({diameter:_,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});E.orientation!==0&&(s=se(s,E)),s=s.map(z);const H=ge(e.reticleOpts,E,s,1,1,0,0,0,0,E.orientation),Me=O.map((B,V)=>z(q({id:`unpositioned_${V}`,width:s[0]?.width??1,height:s[0]?.height??1},B))),J=[...s,...x,...Me];return{wafer:E,dies:J,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:E.metadata??null,isLotStack:!1,dataCoverage:computeCoverage(J),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(J,e.passBins,e.edgeDieYieldMode),reticles:H,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const h=d.filter(W),l=d.filter(s=>!W(s)),f=h.map(s=>({x:s.x,y:s.y})),y=Ke(f,e.dieOpts,e.waferOpts?.diameter);r.diePitch={confidence:y.confidence,units:y.units};const{pitchX:m,pitchY:c}=y,w=y.units,u=ut(h,e.dieOpts),C=je(f);r.grid={confidence:C.confidence};const{offsetX:D,offsetY:g}=ct(f,u,C),{flipX:b,flipY:k}=me(e.dieOpts,u),R=e.waferOpts?.diameter===void 0&&e.waferOpts?.center!==void 0&&pt(f,e.waferOpts.center),v=R?void 0:e.waferOpts?.center;R&&p.push({code:"implausible-center",message:mt(f,e.waferOpts.center)});const{colMidX:T,colMidY:L,anchored:K}=gt(f,D,g,m,c,v);let S=e.waferOpts?.diameter;const N=f.map(s=>({x:(Math.round(s.x)-D)*m-T,y:(Math.round(s.y)-g)*c-L})),M=ee(N.map(({x:s,y:x})=>Math.hypot(Math.abs(s)+m/2,Math.abs(x)+c/2)));if(S===void 0)if(f.length>0)if(w==="mm"){const s=Xe(N,{minRadius:M});S=s.diameter,r.wafer={confidence:s.confidence,method:s.method};const x=Nt(e.standardDiameters);if(!$t(S,x)){const A=De(S,x);p.push({code:"non-standard-diameter",message:`${Ct} ${S.toFixed(1)} mm is not a standard wafer size (nearest is ${A} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else S=M*2,r.wafer={confidence:y.confidence*.8,method:"extent"};else S=w==="mm"?300:30,r.wafer={confidence:0,method:"default"};if(!K&&f.length>0&&yt(f,D,g)&&(r.wafer.method="inferred-partial",p.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&v===void 0&&M>0&&f.length>=xe){const s=M/(S/2);s<Ot&&p.push({code:"diameter-exceeds-die-extent",message:`${kt} ${(s*100).toFixed(0)}% of the ${S} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const s=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(s&&M>S/2+1e-9){const x=N.filter(({x:A,y:O})=>Math.hypot(Math.abs(A)+m/2,Math.abs(O)+c/2)>S/2+1e-9).length;p.push({code:"geometry-conflict",message:`${x} of ${N.length} probed die positions ${St} ${S} mm wafer at the supplied die pitch of ${m} \xD7 ${c} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(M*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const F=Q({diameter:S,units:w,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let $=h.map(s=>{const x=Math.round(s.x)-D,A=Math.round(s.y)-g,O={id:`${x}_${A}`,x,y:A,physX:x*m-T,physY:A*c-L,width:m,height:c,insideWafer:!0,partial:!1};return q(O,s)});(D!==0||g!==0)&&($=$.map(s=>({...s,x:s.x+D,y:s.y+g,id:`${s.x+D}_${s.y+g}`}))),$=se($,F),(b||k)&&($=Ce($,{flipX:b,flipY:k},F.center));const Y=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&($=xt($,F,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>F.radius&&Y.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${F.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),$=$.map(z);const j=ge(e.reticleOpts,F,$,m,c,D,g,T,L,F.orientation,b,k),P=l.map((s,x)=>z(q({id:`unpositioned_${x}`,width:m,height:c},s))),I=[...$,...P];return{wafer:F,dies:I,dataAxisFlip:{x:b,y:k},reticleConfig:e.reticleOpts,units:w,inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...Y,...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:F.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:computeCoverage(I),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(I,e.passBins,e.edgeDieYieldMode,it(e.lotStackOpts!==void 0,e.lotStackOpts?.method)),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
@@ -13,11 +13,10 @@ export declare const DEPRECATED_REMOVAL_VERSION = "0.32.0";
13
13
  */
14
14
  export declare const DEPRECATED_REMOVALS: Map<string, string>;
15
15
  /**
16
- * @internal Every name deprecated through this module, and whether it is a function
17
- * (which logs a notice) or a value (which cannot). tests/deprecations.test.mjs pins
16
+ * @internal Every name deprecated through this module. tests/deprecations.test.mjs pins
18
17
  * it to the announced list, so a deprecation cannot be added or dropped silently.
19
18
  */
20
- export declare const DEPRECATED_EXPORTS: Map<string, "function" | "value">;
19
+ export declare const DEPRECATED_EXPORTS: Map<string, "function">;
21
20
  /**
22
21
  * @internal Log `message` once per `key` for the life of the page — the one
23
22
  * copy of the once-only rule, for export deprecations (`deprecated`) and for
@@ -31,9 +30,4 @@ export declare function noticeOnce(key: string, message: string): void;
31
30
  * deprecated export's signature does not change until it is removed.
32
31
  */
33
32
  export declare function deprecated<F extends (...args: never[]) => unknown>(fn: F, name: string, advice: string, removal?: string): F;
34
- /**
35
- * @internal Register a deprecated constant. A value cannot log on use, so its
36
- * `@deprecated` tag and the changelog are the only announcement.
37
- */
38
- export declare function deprecatedValue<T>(value: T, name: string, removal?: string): T;
39
33
  //# sourceMappingURL=deprecate.d.ts.map
@@ -1 +1 @@
1
- export const DEPRECATED_REMOVAL_VERSION="0.32.0",DEPRECATED_REMOVALS=new Map,DEPRECATED_EXPORTS=new Map;const r=new Set;export function noticeOnce(t,e){r.has(t)||(r.add(t),console.warn(`[wafermap] ${e}`))}export function deprecated(t,e,n,o=DEPRECATED_REMOVAL_VERSION){DEPRECATED_EXPORTS.set(e,"function"),DEPRECATED_REMOVALS.set(e,o);const c=t;return((...E)=>(noticeOnce(e,`${e} is deprecated and will be removed in ${o}. ${n}`),c(...E)))}export function deprecatedValue(t,e,n=DEPRECATED_REMOVAL_VERSION){return DEPRECATED_EXPORTS.set(e,"value"),DEPRECATED_REMOVALS.set(e,n),t}
1
+ export const DEPRECATED_REMOVAL_VERSION="0.32.0",DEPRECATED_REMOVALS=new Map,DEPRECATED_EXPORTS=new Map;const o=new Set;export function noticeOnce(t,e){o.has(t)||(o.add(t),console.warn(`[wafermap] ${e}`))}export function deprecated(t,e,c,n=DEPRECATED_REMOVAL_VERSION){DEPRECATED_EXPORTS.set(e,"function"),DEPRECATED_REMOVALS.set(e,n);const r=t;return((...E)=>(noticeOnce(e,`${e} is deprecated and will be removed in ${n}. ${c}`),r(...E)))}