{ "version": 3, "sources": ["../../../../../src/lib/tools/EraserTool/children/Pointing.ts"], "sourcesContent": ["import {\n\tHIT_TEST_MARGIN,\n\tStateNode,\n\tTLEventHandlers,\n\tTLFrameShape,\n\tTLGroupShape,\n\tTLShapeId,\n} from '@tldraw/editor'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\toverride onEnter = () => {\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t\tcurrentPageShapesSorted: sortedShapesOnCurrentPage,\n\t\t\tzoomLevel,\n\t\t} = this.editor\n\n\t\tconst erasing = new Set()\n\n\t\tconst initialSize = erasing.size\n\n\t\tfor (let n = sortedShapesOnCurrentPage.length, i = n - 1; i >= 0; i--) {\n\t\t\tconst shape = sortedShapesOnCurrentPage[i]\n\t\t\tif (\n\t\t\t\tthis.editor.isShapeOrAncestorLocked(shape) ||\n\t\t\t\tthis.editor.isShapeOfType(shape, 'group')\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tthis.editor.isPointInShape(shape, currentPagePoint, {\n\t\t\t\t\thitInside: false,\n\t\t\t\t\tmargin: HIT_TEST_MARGIN / zoomLevel,\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\tconst hitShape = this.editor.getOutermostSelectableShape(shape)\n\t\t\t\t// If we've hit a frame after hitting any other shape, stop here\n\t\t\t\tif (\n\t\t\t\t\tthis.editor.isShapeOfType(hitShape, 'frame') &&\n\t\t\t\t\terasing.size > initialSize\n\t\t\t\t) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\terasing.add(hitShape.id)\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.setErasingShapes([...erasing])\n\t}\n\n\toverride onPointerMove: TLEventHandlers['onPointerMove'] = (info) => {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tthis.parent.transition('erasing', info)\n\t\t}\n\t}\n\n\toverride onPointerUp: TLEventHandlers['onPointerUp'] = () => {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel: TLEventHandlers['onCancel'] = () => {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete: TLEventHandlers['onComplete'] = () => {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt: TLEventHandlers['onInterrupt'] = () => {\n\t\tthis.cancel()\n\t}\n\n\tcomplete() {\n\t\tconst { erasingShapeIds } = this.editor\n\n\t\tif (erasingShapeIds.length) {\n\t\t\tthis.editor.mark('erase end')\n\t\t\tthis.editor.deleteShapes(erasingShapeIds)\n\t\t}\n\n\t\tthis.editor.setErasingShapes([])\n\t\tthis.parent.transition('idle', {})\n\t}\n\n\tcancel() {\n\t\tthis.editor.setErasingShapes([])\n\t\tthis.parent.transition('idle', {})\n\t}\n}\n"], "mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,OAKM;AAEA,MAAM,iBAAiB,UAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAEZ,UAAU,MAAM;AACxB,UAAM;AAAA,MACL,QAAQ,EAAE,iBAAiB;AAAA,MAC3B,yBAAyB;AAAA,MACzB;AAAA,IACD,IAAI,KAAK;AAET,UAAM,UAAU,oBAAI,IAAe;AAEnC,UAAM,cAAc,QAAQ;AAE5B,aAAS,IAAI,0BAA0B,QAAQ,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK;AACtE,YAAM,QAAQ,0BAA0B,CAAC;AACzC,UACC,KAAK,OAAO,wBAAwB,KAAK,KACzC,KAAK,OAAO,cAA4B,OAAO,OAAO,GACrD;AACD;AAAA,MACD;AAEA,UACC,KAAK,OAAO,eAAe,OAAO,kBAAkB;AAAA,QACnD,WAAW;AAAA,QACX,QAAQ,kBAAkB;AAAA,MAC3B,CAAC,GACA;AACD,cAAM,WAAW,KAAK,OAAO,4BAA4B,KAAK;AAE9D,YACC,KAAK,OAAO,cAA4B,UAAU,OAAO,KACzD,QAAQ,OAAO,aACd;AACD;AAAA,QACD;AAEA,gBAAQ,IAAI,SAAS,EAAE;AAAA,MACx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