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AAG;gBAClB,OAAO,CACL,CAAC,IAAI,CACH,KAAK,CAAC,CAAC;wBACL,UAAU,EAAE,QAAQ;qBACrB,CAAC,CAEF;YAAA,CAAC,iCAAe,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EACjC;YAAA,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CACxC;UAAA,EAAE,IAAI,CAAC,CACR,CAAA;YACH,CAAC,CAAA;YAED,IAAI,CAAC,SAAS;gBAAE,OAAO,IAAI,CAAA;YAE3B,OAAO,MAAM,CAAC,MAAM,KAAK,mBAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC/C,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAC5C;UAAA,CAAC,WAAW,EAAE,CAChB;QAAA,EAAE,GAAG,CAAC,CACP,CAAC,CAAC,CAAC,IAAI,CAAA;QACV,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEW,QAAA,WAAW,GAAG,IAAA,2BAAa,EAAC,IAAA,uBAAQ,EAAC,oBAAoB,CAAC,EAAE;IACvE,WAAW,EAAE,aAAa;CAC3B,CAAC,CAAA","sourcesContent":["import { useCursor, usePrefix, useDesigner } from '../../hooks'\nimport { CursorStatus } from '@designable/core'\nimport { autorun, observe } from '@formily/reactive'\nimport { observer } from '@formily/reactive-vue'\nimport { NodeTitleWidget } from '../NodeTitleWidget'\nimport './styles.less'\nimport { composeExport } from '@jeamn/formily-components/src/__builtins__'\nimport { defineComponent, ref, unref, onBeforeUnmount } from 'vue-demi'\nimport { useEffect } from '../../shared/useEffect'\n\nconst GhostWidgetComponent = defineComponent({\n  setup() {\n    const designerRef = useDesigner()\n    const cursorRef = useCursor()\n    const refInstance = ref<HTMLDivElement>()\n    const prefixRef = usePrefix('ghost')\n\n    useEffect(\n      () =>\n        autorun(() => {\n          const cursor = unref(cursorRef)\n          const ref = refInstance.value\n          const transform = `perspective(1px) translate3d(${cursor.position!.topClientX! - 18\n            }px,${cursor.position!.topClientY! - 12}px,0) scale(0.8)`\n          if (!ref) return\n          ref.style.transform = transform\n        }),\n      [designerRef, cursorRef]\n    )\n\n    return () => {\n      const designer = unref(designerRef)\n      const cursor = unref(cursorRef)\n\n      const draggingNodes = designer.findDraggingNodes()\n      const firstNode = draggingNodes[0]\n\n      const renderNodes = () => {\n        return (\n          <span\n            style={{\n              whiteSpace: 'nowrap',\n            }}\n          >\n            <NodeTitleWidget node={firstNode} />\n            {draggingNodes.length > 1 ? '...' : ''}\n          </span>\n        )\n      }\n\n      if (!firstNode) return null\n\n      return cursor.status === CursorStatus.Dragging ? (\n        <div class={prefixRef.value} ref={refInstance}>\n          {renderNodes()}\n        </div>\n      ) : null\n    }\n  },\n})\n\nexport const GhostWidget = composeExport(observer(GhostWidgetComponent), {\n  displayName: 'GhostWidget',\n})\n"]}