"use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var M=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},w=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of B(n))!T.call(e,a)&&a!==t&&l(e,a,{get:()=>n[a],enumerable:!(r=y(n,a))||r.enumerable});return e};var A=e=>w(l({},"__esModule",{value:!0}),e);var O={};M(O,{BASEBOARD_SEMANTIC_NAME:()=>c,BASEBOARD_STRIP_QUANT_KEYS:()=>N,CABINET_QUANT_KEYS:()=>F,MASK_SEMANTIC_COLORS:()=>p,WALL_QUANT_KEYS:()=>K,classifyBgrPixelToSemantic:()=>k,getBaseboardStripQuantKeys:()=>I,getCabinetQuantKeys:()=>q,getSemanticColorByName:()=>_,getWallQuantKeys:()=>Q,isBaseboardPixel:()=>h,isStrictBaseboardPixel:()=>E});module.exports=A(O);var i=require("./maskSegmentRuntime");const p=[{name:"door",hex:"#E6194B",bgr:{b:75,g:25,r:230}},{name:"ceiling",hex:"#3CB44B",bgr:{b:75,g:180,r:60}},{name:"cabinet",hex:"#FFE119",bgr:{b:25,g:225,r:255}},{name:"wall",hex:"#4363D8",bgr:{b:216,g:99,r:67}},{name:"baseboard",hex:"#F58231",bgr:{b:49,g:130,r:245}},{name:"windowFrame",hex:"#911EB4",bgr:{b:180,g:30,r:145}},{name:"garageDoor",hex:"#46F0F0",bgr:{b:240,g:240,r:70}},{name:"roof",hex:"#F032E6",bgr:{b:230,g:50,r:240}},{name:"eave",hex:"#BCF60C",bgr:{b:12,g:246,r:188}}],c="baseboard";let f=-1,m=null;function D(e){return e.map(n=>({name:n.name,rgb:{r:n.bgr.r,g:n.bgr.g,b:n.bgr.b}}))}function S(e){const n=p.find(t=>t.name===e);return{name:n.name,rgb:{r:n.bgr.r,g:n.bgr.g,b:n.bgr.b}}}function C(){const e=(0,i.getMaskRuntimeRevision)();if(f===e&&m)return m;const n=(0,i.getMaskSegmentRuntimeConfig)().mask,t=D(n.semanticColors),r=t.find(o=>o.name===c)??S(c),a=t.find(o=>o.name==="cabinet")??S("cabinet"),b=t.find(o=>o.name==="wall")??S("wall"),g=n.baseboardMaxColorDist;return m={baseboardMaxColorDistSq:g*g,semanticRgb:t,baseboardRgb:r,cabinetRgb:a,wallRgb:b},f=e,m}function s(e,n){const t=e.r-n.r,r=e.g-n.g,a=e.b-n.b;return t*t+r*r+a*a}function k(e,n,t){const r=C(),a={r:t,g:n,b:e},b=s(a,r.baseboardRgb.rgb),g=s(a,r.cabinetRgb.rgb),o=s(a,r.wallRgb.rgb);if(b<=r.baseboardMaxColorDistSq&&b<g&&b<o)return c;let x=r.semanticRgb[0],d=Number.POSITIVE_INFINITY;for(const u of r.semanticRgb){if(u.name===c)continue;const R=s(a,u.rgb);R<d&&(d=R,x=u)}return x?.name??"wall"}function _(e){return(0,i.getMaskSegmentRuntimeConfig)().mask.semanticColors.find(t=>t.name===e)}function E(e,n,t){const r=C(),a={r:t,g:n,b:e},b=s(a,r.baseboardRgb.rgb),g=s(a,r.cabinetRgb.rgb),o=s(a,r.wallRgb.rgb);return b<=r.baseboardMaxColorDistSq&&b<g&&b<o}function h(e,n,t){return E(e,n,t)}const N=new Set(["0,255,255","64,255,255"]),K=new Set(["192,128,64","192,64,64","128,64,64","192,192,128","128,128,64"]),F=new Set(["0,192,255","64,192,255","128,192,255"]);function I(){return(0,i.getMaskSegmentRuntimeConfig)().mask.baseboardStripQuantKeys}function Q(){return(0,i.getMaskSegmentRuntimeConfig)().mask.wallQuantKeys}function q(){return(0,i.getMaskSegmentRuntimeConfig)().mask.cabinetQuantKeys}
