{
  "version": 3,
  "sources": ["../../../src/lib/overlays/CollaboratorBrushOverlayUtil.ts"],
  "sourcesContent": ["import { OverlayUtil, TLOverlay } from '@tldraw/editor'\n\n/** @public */\nexport interface TLCollaboratorBrushOverlay extends TLOverlay {\n\tprops: {\n\t\tx: number\n\t\ty: number\n\t\tw: number\n\t\th: number\n\t\tcolor: string\n\t}\n}\n\n/**\n * Overlay util for collaborator selection brushes.\n *\n * @public\n */\nexport class CollaboratorBrushOverlayUtil extends OverlayUtil<TLCollaboratorBrushOverlay> {\n\tstatic override type = 'collaborator_brush'\n\toverride options = { zIndex: 700, lineWidth: 1 }\n\n\toverride isActive(): boolean {\n\t\treturn this.editor.getVisibleCollaboratorsOnCurrentPage().some((c) => c.brush !== null)\n\t}\n\n\toverride getOverlays(): TLCollaboratorBrushOverlay[] {\n\t\tconst overlays: TLCollaboratorBrushOverlay[] = []\n\t\tfor (const presence of this.editor.getVisibleCollaboratorsOnCurrentPage()) {\n\t\t\tconst { brush, color, userId } = presence\n\t\t\tif (!brush) continue\n\t\t\toverlays.push({\n\t\t\t\tid: `collaborator_brush:${userId}`,\n\t\t\t\ttype: 'collaborator_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\tcolor,\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn overlays\n\t}\n\n\toverride render(ctx: CanvasRenderingContext2D, overlays: TLCollaboratorBrushOverlay[]): void {\n\t\tconst zoom = this.editor.getZoomLevel()\n\t\tfor (const overlay of overlays) {\n\t\t\tconst { x, y, w, h, color } = overlay.props\n\n\t\t\t// Match the old SVG path: brush fill at 0.75 modulated by a parent\n\t\t\t// opacity of 0.1 gave an effective fill alpha of 0.075.\n\t\t\tctx.globalAlpha = 0.075\n\t\t\tctx.fillStyle = color\n\t\t\tctx.fillRect(x, y, w, h)\n\n\t\t\t// Stroke at 0.1 alpha matches the old parent opacity.\n\t\t\tctx.globalAlpha = 0.1\n\t\t\tctx.strokeStyle = color\n\t\t\tctx.lineWidth = this.options.lineWidth / zoom\n\t\t\tctx.strokeRect(x, y, w, h)\n\n\t\t\tctx.globalAlpha = 1\n\t\t}\n\t}\n\n\toverride renderMinimap(\n\t\tctx: CanvasRenderingContext2D,\n\t\toverlays: TLCollaboratorBrushOverlay[]\n\t): void {\n\t\tfor (const overlay of overlays) {\n\t\t\tconst { x, y, w, h, color } = overlay.props\n\t\t\tctx.globalAlpha = 0.75\n\t\t\tctx.fillStyle = color\n\t\t\tctx.fillRect(x, y, w, h)\n\t\t}\n\t\tctx.globalAlpha = 1\n\t}\n}\n"],
  "mappings": "AAAA,SAAS,mBAA8B;AAkBhC,MAAM,qCAAqC,YAAwC;AAAA,EACzF,OAAgB,OAAO;AAAA,EACd,UAAU,EAAE,QAAQ,KAAK,WAAW,EAAE;AAAA,EAEtC,WAAoB;AAC5B,WAAO,KAAK,OAAO,qCAAqC,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,IAAI;AAAA,EACvF;AAAA,EAES,cAA4C;AACpD,UAAM,WAAyC,CAAC;AAChD,eAAW,YAAY,KAAK,OAAO,qCAAqC,GAAG;AAC1E,YAAM,EAAE,OAAO,OAAO,OAAO,IAAI;AACjC,UAAI,CAAC,MAAO;AACZ,eAAS,KAAK;AAAA,QACb,IAAI,sBAAsB,MAAM;AAAA,QAChC,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,UACtB;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AACA,WAAO;AAAA,EACR;AAAA,EAES,OAAO,KAA+B,UAA8C;AAC5F,UAAM,OAAO,KAAK,OAAO,aAAa;AACtC,eAAW,WAAW,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