{
  "version": 3,
  "sources": ["../../../../../src/lib/shapes/arrow/toolStates/Idle.tsx"],
  "sourcesContent": ["import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo, TLShapeId } from '@tldraw/editor'\nimport { startEditingShape } from '../../../tools/SelectTool/selectHelpers'\nimport { ArrowShapeUtil } from '../ArrowShapeUtil'\nimport { clearArrowTargetState, updateArrowTargetState } from '../arrowTargetState'\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\tisPrecise = false\n\tisPreciseTimerId: number | null = null\n\tpreciseTargetId: TLShapeId | null = null\n\n\toverride onPointerMove() {\n\t\tthis.update()\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\t// A touch press arrives without a hover move, so the stored flag may belong to another target\n\t\tthis.update()\n\t\tthis.parent.transition('pointing', { ...info, isPrecise: this.isPrecise })\n\t}\n\n\toverride onEnter() {\n\t\tthis.editor.setCursor({ type: 'cross', rotation: 0 })\n\t\tthis.update()\n\t}\n\n\toverride onCancel() {\n\t\tthis.editor.setCurrentTool('select')\n\t}\n\n\toverride onExit() {\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.resetPrecise()\n\t}\n\n\t// Precise mode is earned by hovering one target; it must not carry over to the next\n\t// target or to the next arrow.\n\tprivate resetPrecise() {\n\t\tthis.isPrecise = false\n\t\tthis.preciseTargetId = null\n\t\tif (this.isPreciseTimerId !== null) {\n\t\t\tthis.editor.timers.clearTimeout(this.isPreciseTimerId)\n\t\t\tthis.isPreciseTimerId = null\n\t\t}\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tthis.update()\n\t\tif (info.key === 'Enter') {\n\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\tif (!this.editor.canEditShape(onlySelectedShape)) return\n\t\t\tstartEditingShape(this.editor, onlySelectedShape, { selectAll: true })\n\t\t}\n\t}\n\n\tupdate() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\n\t\tconst targetState = this.updateTargetState()\n\n\t\tif (targetState && targetState.target.id !== this.preciseTargetId) {\n\t\t\tconst wasPrecise = this.isPrecise\n\t\t\tthis.resetPrecise()\n\t\t\t// The hint above was published with the previous target's precise flag. Republish it\n\t\t\t// so the overlay matches the imprecise binding a click would now create.\n\t\t\tif (wasPrecise) this.updateTargetState()\n\t\t\tthis.preciseTargetId = targetState.target.id\n\t\t\tthis.isPreciseTimerId = this.editor.timers.setTimeout(() => {\n\t\t\t\tthis.isPrecise = true\n\t\t\t\tthis.update()\n\t\t\t}, arrowUtil.options.hoverPreciseTimeout)\n\t\t} else if (!targetState && this.preciseTargetId) {\n\t\t\tthis.resetPrecise()\n\t\t}\n\t}\n\n\tprivate updateTargetState() {\n\t\treturn updateArrowTargetState({\n\t\t\teditor: this.editor,\n\t\t\tpointInPageSpace: this.editor.inputs.getCurrentPagePoint(),\n\t\t\tarrow: undefined,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tcurrentBinding: undefined,\n\t\t\toppositeBinding: undefined,\n\t\t})\n\t}\n}\n"],
  "mappings": "AAAA,SAAS,iBAAqE;AAC9E,SAAS,yBAAyB;AAElC,SAAS,uBAAuB,8BAA8B;AAEvD,MAAM,aAAa,UAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,YAAY;AAAA,EACZ,mBAAkC;AAAA,EAClC,kBAAoC;AAAA,EAE3B,gBAAgB;AACxB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,cAAc,MAA0B;AAEhD,SAAK,OAAO;AACZ,SAAK,OAAO,WAAW,YAAY,EAAE,GAAG,MAAM,WAAW,KAAK,UAAU,CAAC;AAAA,EAC1E;AAAA,EAES,UAAU;AAClB,SAAK,OAAO,UAAU,EAAE,MAAM,SAAS,UAAU,EAAE,CAAC;AACpD,SAAK,OAAO;AAAA,EACb;AAAA,EAES,WAAW;AACnB,SAAK,OAAO,eAAe,QAAQ;AA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