{
  "version": 3,
  "sources": ["../../../src/lib/overlays/ZoomBrushOverlayUtil.ts"],
  "sourcesContent": ["import { OverlayUtil, TLOverlay } from '@tldraw/editor'\n\n/** @public */\nexport interface TLZoomBrushOverlay extends TLOverlay {\n\tprops: {\n\t\tx: number\n\t\ty: number\n\t\tw: number\n\t\th: number\n\t}\n}\n\n/**\n * Overlay util for the zoom brush rectangle.\n *\n * @public\n */\nexport class ZoomBrushOverlayUtil extends OverlayUtil<TLZoomBrushOverlay> {\n\tstatic override type = 'zoom_brush'\n\toverride options = { zIndex: 400, lineWidth: 1 }\n\n\toverride isActive(): boolean {\n\t\treturn this.editor.getInstanceState().zoomBrush !== null\n\t}\n\n\toverride getOverlays(): TLZoomBrushOverlay[] {\n\t\tconst brush = this.editor.getInstanceState().zoomBrush\n\t\tif (!brush) return []\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'zoom_brush',\n\t\t\t\ttype: 'zoom_brush',\n\t\t\t\tprops: {\n\t\t\t\t\tx: brush.x,\n\t\t\t\t\ty: brush.y,\n\t\t\t\t\tw: Math.max(1, brush.w),\n\t\t\t\t\th: Math.max(1, brush.h),\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\t}\n\n\toverride render(ctx: CanvasRenderingContext2D, overlays: TLZoomBrushOverlay[]): void {\n\t\tconst overlay = overlays[0]\n\t\tif (!overlay) return\n\n\t\tconst { x, y, w, h } = overlay.props\n\t\tconst zoom = this.editor.getZoomLevel()\n\t\tconst colors = this.editor.getCurrentTheme().colors[this.editor.getColorMode()]\n\n\t\t// Use fillRect / strokeRect to avoid path construction overhead\n\t\tctx.fillStyle = colors.brushFill\n\t\tctx.fillRect(x, y, w, h)\n\n\t\tctx.lineWidth = this.options.lineWidth / zoom\n\t\tctx.strokeStyle = colors.brushStroke\n\t\tctx.strokeRect(x, y, w, h)\n\t}\n\n\toverride renderMinimap(\n\t\tctx: CanvasRenderingContext2D,\n\t\toverlays: TLZoomBrushOverlay[],\n\t\tzoom: number\n\t): void {\n\t\tconst overlay = overlays[0]\n\t\tif (!overlay) return\n\t\tconst { x, y, w, h } = overlay.props\n\t\tconst colors = this.editor.getCurrentTheme().colors[this.editor.getColorMode()]\n\t\tctx.fillStyle = colors.brushFill\n\t\tctx.fillRect(x, y, w, h)\n\t\tctx.lineWidth = this.options.lineWidth / zoom\n\t\tctx.strokeStyle = colors.brushStroke\n\t\tctx.strokeRect(x, y, w, h)\n\t}\n}\n"],
  "mappings": "AAAA,SAAS,mBAA8B;AAiBhC,MAAM,6BAA6B,YAAgC;AAAA,EACzE,OAAgB,OAAO;AAAA,EACd,UAAU,EAAE,QAAQ,KAAK,WAAW,EAAE;AAAA,EAEtC,WAAoB;AAC5B,WAAO,KAAK,OAAO,iBAAiB,EAAE,cAAc;AAAA,EACrD;AAAA,EAES,cAAoC;AAC5C,UAAM,QAAQ,KAAK,OAAO,iBAAiB,EAAE;AAC7C,QAAI,CAAC,MAAO,QAAO,CAAC;AACpB,WAAO;AAAA,MACN;AAAA,QACC,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,OAAO;AAAA,UACN,GAAG,MAAM;AAAA,UACT,GAAG,MAAM;AAAA,UACT,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC;AAAA,UACtB,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC;AAAA,QACvB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAES,OAAO,KAA+B,UAAsC;AACpF,UAAM,UAAU,SAAS,CAAC;AAC1B,QAAI,CAAC,QAAS;AAEd,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,QAAQ;AAC/B,UAAM,OAAO,KAAK,OAAO,aAAa;AACtC,UAAM,SAAS,KAAK,OAAO,gBAAgB,EAAE,OAAO,KAAK,OAAO,aAAa,CAAC;AAG9E,QAAI,YAAY,OAAO;AACvB,QAAI,SAAS,GAAG,GAAG,GAAG,CAAC;AAEvB,QAAI,YAAY,KAAK,QAAQ,YAAY;AACzC,QAAI,cAAc,OAAO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