/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../prosemirror-state/dist/index.js"),t=require("../../prosemirror-transform/dist/index.js");class i{constructor(e,t){var i;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(i=t.width)&&void 0!==i?i:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let i=e=>{this[t](e)};return e.dom.addEventListener(t,i),{name:t,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),i=!t.parent.inlineContent,s=this.editorView.dom,o=s.getBoundingClientRect(),r=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(i){let i=t.nodeBefore,s=t.nodeAfter;if(i||s){let t=this.editorView.nodeDOM(this.cursorPos-(i?i.nodeSize:0));if(t){let o=t.getBoundingClientRect(),r=i?o.bottom:o.top;i&&s&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let d=this.width/2*l;e={left:o.left,right:o.right,top:r-d,bottom:r+d}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),i=this.width/2*r;e={left:t.left-i,right:t.left+i,top:t.top,bottom:t.bottom}}let d,n,h=this.editorView.dom.offsetParent;if(this.element||(this.element=h.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",i),this.element.classList.toggle("prosemirror-dropcursor-inline",!i),!h||h==document.body&&"static"==getComputedStyle(h).position)d=-pageXOffset,n=-pageYOffset;else{let e=h.getBoundingClientRect(),t=e.width/h.offsetWidth,i=e.height/h.offsetHeight;d=e.left-h.scrollLeft*t,n=e.top-h.scrollTop*i}this.element.style.left=(e.left-d)/r+"px",this.element.style.top=(e.top-n)/l+"px",this.element.style.width=(e.right-e.left)/r+"px",this.element.style.height=(e.bottom-e.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let i=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=i&&i.inside>=0&&this.editorView.state.doc.nodeAt(i.inside),o=s&&s.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,i,e):o;if(i&&!r){let e=i.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=t.dropPoint(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=i&&(e=i)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}exports.dropCursor=function(t={}){return new e.Plugin({view:e=>new i(e,t)})};