{"version":3,"sources":["webpack:///./node_modules/lib-font/src/opentype/tables/simple/color/COLR.js"],"names":["COLR","constructor","dict","dataview","p","super","this","version","uint16","numBaseGlyphRecords","baseGlyphRecordsOffset","Offset32","layerRecordsOffset","numLayerRecords","getBaseGlyphRecord","glyphID","start","tableStart","parser","currentPosition","first","BaseGlyphRecord","firstID","gID","end","last","lastID","mid","middle","midID","getLayers","record","firstLayerIndex","Array","numLayers","map","_","LayerRecord","paletteIndex"],"mappings":"2FAAA,uDAOA,MAAMA,UAAa,IACjBC,YAAYC,EAAMC,GAChB,MACEC,EADaC,MAAMH,EAAMC,GACdC,EACbE,KAAKC,QAAUH,EAAEI,OACjBF,KAAKG,oBAAsBL,EAAEI,OAC7BF,KAAKI,uBAAyBN,EAAEO,SAChCL,KAAKM,mBAAqBR,EAAEO,SAC5BL,KAAKO,gBAAkBT,EAAEI,MAC3B,CACAM,mBAAmBC,GAGjB,IAAIC,EAAQV,KAAKW,WAAaX,KAAKI,uBACnCJ,KAAKY,OAAOC,gBAAkBH,EAC9B,IAAII,EAAQ,IAAIC,EAAgBf,KAAKY,QACjCI,EAAUF,EAAMG,IAChBC,EAAMlB,KAAKW,WAAaX,KAAKM,mBAAqB,EACtDN,KAAKY,OAAOC,gBAAkBK,EAC9B,IAAIC,EAAO,IAAIJ,EAAgBf,KAAKY,QAChCQ,EAASD,EAAKF,IAGlB,GAAID,IAAYP,EAAS,OAAOK,EAChC,GAAIM,IAAWX,EAAS,OAAOU,EAG/B,KACMT,IAAUQ,GADH,CAEX,IAAIG,EAAMX,GAASQ,EAAMR,GAAS,GAClCV,KAAKY,OAAOC,gBAAkBQ,EAC9B,IAAIC,EAAS,IAAIP,EAAgBf,KAAKY,QAClCW,EAAQD,EAAOL,IACnB,GAAIM,IAAUd,EAAS,OAAOa,EAErBC,EAAQd,EACfS,EAAMG,EACGE,EAAQd,IACjBC,EAAQW,EAEZ,CACA,OAAO,CACT,CACAG,UAAUf,GACR,IAAIgB,EAASzB,KAAKQ,mBAAmBC,GAErC,OADAT,KAAKY,OAAOC,gBAAkBb,KAAKW,WAAaX,KAAKM,mBAAqB,EAAImB,EAAOC,gBAC9E,IAAI,IAAIC,MAAMF,EAAOG,YAAYC,KAAIC,GAAK,IAAIC,EAAYjC,IACnE,EAEF,MAAMiB,EACJpB,YAAYG,GACVE,KAAKiB,IAAMnB,EAAEI,OACbF,KAAK0B,gBAAkB5B,EAAEI,OACzBF,KAAK4B,UAAY9B,EAAEI,MACrB,EAEF,MAAM6B,EACJpC,YAAYG,GACVE,KAAKiB,IAAMnB,EAAEI,OACbF,KAAKgC,aAAelC,EAAEI,MACxB,E","file":"js/20-78d7077ee787185464bc.chunk.js","sourcesContent":["import { SimpleTable } from \"../../simple-table.js\";\n\n/**\n * The OpenType `COLR` table.\n *\n * See https://docs.microsoft.com/en-us/typography/opentype/spec/COLR\n */\nclass COLR extends SimpleTable {\n constructor(dict, dataview) {\n const _super = super(dict, dataview),\n p = _super.p;\n this.version = p.uint16;\n this.numBaseGlyphRecords = p.uint16;\n this.baseGlyphRecordsOffset = p.Offset32; // from beginning of COLR table) to Base Glyph records.\n this.layerRecordsOffset = p.Offset32; // from beginning of COLR table) to Layer Records.\n this.numLayerRecords = p.uint16;\n }\n getBaseGlyphRecord(glyphID) {\n // the documentation recommends doing a binary search to find the record,\n // and so we shall. The size of a BaseGlyphRecord is 6 bytes, so off we go!\n let start = this.tableStart + this.baseGlyphRecordsOffset;\n this.parser.currentPosition = start;\n let first = new BaseGlyphRecord(this.parser);\n let firstID = first.gID;\n let end = this.tableStart + this.layerRecordsOffset - 6;\n this.parser.currentPosition = end;\n let last = new BaseGlyphRecord(this.parser);\n let lastID = last.gID;\n\n // right. Onward, to victory!\n if (firstID === glyphID) return first;\n if (lastID === glyphID) return last;\n\n // delayed gratification!\n while (true) {\n if (start === end) break;\n let mid = start + (end - start) / 12;\n this.parser.currentPosition = mid;\n let middle = new BaseGlyphRecord(this.parser);\n let midID = middle.gID;\n if (midID === glyphID) return middle;\n // curses!\n else if (midID > glyphID) {\n end = mid;\n } else if (midID < glyphID) {\n start = mid;\n }\n }\n return false;\n }\n getLayers(glyphID) {\n let record = this.getBaseGlyphRecord(glyphID);\n this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;\n return [...new Array(record.numLayers)].map(_ => new LayerRecord(p));\n }\n}\nclass BaseGlyphRecord {\n constructor(p) {\n this.gID = p.uint16;\n this.firstLayerIndex = p.uint16;\n this.numLayers = p.uint16;\n }\n}\nclass LayerRecord {\n constructor(p) {\n this.gID = p.uint16;\n this.paletteIndex = p.uint16;\n }\n}\nexport { COLR };"],"sourceRoot":""}