{
  "version": 3,
  "sources": ["../../../src/lib/overlays/CollaboratorShapeIndicatorOverlayUtil.ts"],
  "sourcesContent": ["import { OverlayUtil, strokeShapeIndicators, TLOverlay, TLShapeId } from '@tldraw/editor'\n\n/** @public */\nexport interface TLCollaboratorShapeIndicatorOverlay extends TLOverlay {\n\tprops: {\n\t\t// One entry per peer, batching the shape IDs they have selected so the\n\t\t// renderer can issue a single stroke call per collaborator.\n\t\tindicators: Array<{ color: string; shapeIds: TLShapeId[] }>\n\t}\n}\n\n/**\n * Overlay util for remote collaborators' shape selection indicators.\n *\n * Renders a per-peer outline around each shape another user has selected,\n * using the peer's color. Drawn under the local `ShapeIndicatorOverlayUtil`\n * (lower z-index) so the local user's selection always appears on top.\n *\n * Non-interactive: contributes no hit-test geometry.\n *\n * @public\n */\nexport class CollaboratorShapeIndicatorOverlayUtil extends OverlayUtil<TLCollaboratorShapeIndicatorOverlay> {\n\tstatic override type = 'collaborator_shape_indicator'\n\toverride options = { zIndex: 49, lineWidth: 1.5, alpha: 0.7 }\n\n\toverride isActive(): boolean {\n\t\treturn this.editor\n\t\t\t.getVisibleCollaboratorsOnCurrentPage()\n\t\t\t.some((presence) => presence.selectedShapeIds.length > 0)\n\t}\n\n\toverride getOverlays(): TLCollaboratorShapeIndicatorOverlay[] {\n\t\tconst editor = this.editor\n\t\tconst selectedPresences = editor\n\t\t\t.getVisibleCollaboratorsOnCurrentPage()\n\t\t\t.filter((presence) => presence.selectedShapeIds.length > 0)\n\t\tif (selectedPresences.length === 0) return []\n\n\t\tconst renderingShapeIds = new Set(editor.getRenderingShapes().map((s) => s.id))\n\n\t\tconst indicators: TLCollaboratorShapeIndicatorOverlay['props']['indicators'] = []\n\t\tfor (const presence of selectedPresences) {\n\t\t\tconst visibleShapeIds = presence.selectedShapeIds.filter(\n\t\t\t\t(id) => renderingShapeIds.has(id) && !editor.isShapeHidden(id)\n\t\t\t)\n\t\t\tif (visibleShapeIds.length === 0) continue\n\t\t\tindicators.push({ color: presence.color, shapeIds: visibleShapeIds })\n\t\t}\n\n\t\tif (indicators.length === 0) return []\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'collaborator_shape_indicator',\n\t\t\t\ttype: 'collaborator_shape_indicator',\n\t\t\t\tprops: { indicators },\n\t\t\t},\n\t\t]\n\t}\n\n\toverride render(\n\t\tctx: CanvasRenderingContext2D,\n\t\toverlays: TLCollaboratorShapeIndicatorOverlay[]\n\t): void {\n\t\tconst overlay = overlays[0]\n\t\tif (!overlay) return\n\n\t\tconst editor = this.editor\n\t\tconst zoom = editor.getZoomLevel()\n\n\t\tctx.lineCap = 'round'\n\t\tctx.lineJoin = 'round'\n\t\tctx.lineWidth = this.options.lineWidth / zoom\n\t\tctx.globalAlpha = this.options.alpha\n\n\t\t// One stroke call per collaborator.\n\t\tfor (const { color, shapeIds } of overlay.props.indicators) {\n\t\t\tctx.strokeStyle = color\n\t\t\tstrokeShapeIndicators(editor, ctx, shapeIds)\n\t\t}\n\n\t\tctx.globalAlpha = 1\n\t}\n}\n"],
  "mappings": "AAAA,SAAS,aAAa,6BAAmD;AAsBlE,MAAM,8CAA8C,YAAiD;AAAA,EAC3G,OAAgB,OAAO;AAAA,EACd,UAAU,EAAE,QAAQ,IAAI,WAAW,KAAK,OAAO,IAAI;AAAA,EAEnD,WAAoB;AAC5B,WAAO,KAAK,OACV,qCAAqC,EACrC,KAAK,CAAC,aAAa,SAAS,iBAAiB,SAAS,CAAC;AAAA,EAC1D;AAAA,EAES,cAAqD;AAC7D,UAAM,SAAS,KAAK;AACpB,UAAM,oBAAoB,OACxB,qCAAqC,EACrC,OAAO,CAAC,aAAa,SAAS,iBAAiB,SAAS,CAAC;AAC3D,QAAI,kBAAkB,WAAW,EAAG,QAAO,CAAC;AAE5C,UAAM,oBAAoB,IAAI,IAAI,OAAO,mBAAmB,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAE9E,UAAM,aAAyE,CAAC;AAChF,eAAW,YAAY,mBAAmB;AACzC,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