import{__awaiter as t,__extends as i,__generator as r}from"tslib";import{throttle as e}from"lodash";import{MOUSE as n}from"three";import{EventEmitter as o}from"events";import{Cartesian3 as s,Cartesian2 as a,Color as c}from"@msign/angularis";var h=function(o){function h(i,h){var u=o.call(this)||this;return u.t=!1,u.i=!1,u.o=!1,u.s=s.ZERO.clone(),u.h=s.ZERO.clone(),u.u={id:"target_entity_marker",position:void 0,v:{p:Number.POSITIVE_INFINITY,color:c.m,height:32,width:32}},u.l=s.ZERO.clone(),u.g=function(t){},u.k=function(t){},u._=.5,u.q=function(t){var i=t.button,r=t.layerX,e=t.layerY;switch(u.D={x:r,y:e},i){case n.H:u.t=!0,u.M("pan");break;case n.j:u.i=!0,u.M("rotate");break;case n.A:u.M("setting")}u.h=u.s.clone()},u.C=function(t){var i=t.layerX,r=t.layerY;u.t=!1,u.i=!1;var e=u.D;if(Math.abs(e.x-i)<3&&Math.abs(e.y-r)<3){var n=u.N;0===t.button&&(n?u.O("pick",n):u.O("picknone"))}u.M(!1)},u.T=function(t){},u.B=function(t){},u.F=function(t){t.stopPropagation(),t.returnValue=!1,t.cancelBubble=!0;var i=u.N;u.O("rightClick",{G:i||null,detail:t})},u.I=function(t){var i=u,r=i.J,e=i.s,n=t.K,o=t.L;if(n||o){var a=r.P,c=a.position,h=a.direction,f=a.R,v=s.ZERO.clone(),p=s.S(h,f,s.ZERO.clone()),m=f.clone(),l=s.U(e,c);n&&s.V(p,n,p),o&&s.V(m,o,m),n&&s.W(v,p,v),o&&s.add(v,m,v);try{a.move(v,.5*l/1e3)}catch(t){}}},u.X=function(i){return t(u,void 0,void 0,(function(){var t,e,n,o,a,c,h,u,f,v,p,m,l,d,g;return r(this,(function(r){return e=(t=this).J,(n=t.h)?(o=i.K,a=i.L,o||a?(c=e.P,h=c.position,u=c.direction,f=c.R,1,v=s.ZERO.clone(),p=s.S(u,f,s.ZERO.clone()),m=f.clone(),l=s.U(n,h),o&&s.V(p,o,p),a&&s.V(m,a,m),o&&s.W(v,p,v),a&&s.add(v,m,v),c.move(v,1*l/500),s.W(n,c.position,this.l),s.normalize(this.l,this.l),s.U(this.l,c.direction)>.1?(d=s.W(this.l,c.direction,s.ZERO.clone()),s.V(d,.1,d),s.add(c.direction,d,c.direction),s.normalize(c.direction,c.direction)):s.normalize(this.l,c.direction),g=s.U(n,c.position),c.move(c.direction,g-l),s.normalize(n,c.R),[2]):[2]):[2]}))}))},u.Y=e((function(t){if(u.t){var i=u.s;if(s.Z(i,s.ZERO))return;u.I(t)}else if(u.i){i=u.s;if(s.Z(i,s.ZERO))return;u.X(t)}else{var r=u,e=r.J.$,n=(i=r.s,t),o=n.layerX,c=n.layerY,h=new a(o,c);e.tt(h,i);var f=void 0;try{f=e.it(h)}catch(t){return}if(window.move_feat=f,u.N&&f!==u.N&&(u.N.setProperty&&u.N.setProperty("isHovered",!1),u.O("unhover",u.N)),f&&f!==u.N?(f.setProperty&&f.setProperty("isHovered",!0),u.O("hover",f),u.N=f):!f&&u.N&&(u.N=void 0),i)try{var v=s.ZERO.clone();e.rt(i,[],.1,v)}catch(t){}}}),10),u.et=function(t){var i=u,r=i.J,e=i.s,n=i.l,o=i._,a=t.deltaY;if(!s.Z(e,s.ZERO)&&a){var c=r.P,h=c.position,f=(c.direction,c.R,s.ZERO.clone(),s.U(e,h));if(!(f<=o&&a<0)){s.W(e,h,n),s.normalize(n,n);try{c.move(n,f/4*1*(a>0?-1:1))}catch(t){}}}},u.J=h,u.nt=i,u}return i(h,o),h.prototype.ot=function(){var t=this.J;t.$.at.st=!1,t.$.at.ct=!1,t.$.at.ht=!1,t.$.at.ut=!1,t.$.at.ft=!1,t.vt.addEventListener("pointermove",this.Y),t.vt.addEventListener("pointerdown",this.q),t.vt.addEventListener("pointerup",this.C),t.vt.addEventListener("wheel",this.et),t.vt.addEventListener("click",this.T),t.vt.addEventListener("dblclick",this.B),t.vt.addEventListener("contextmenu",this.F,!1)},h.prototype.pt=function(){var t=this.J;t.$.at.st=!0,t.$.at.ct=!0,t.$.at.ht=!0,t.$.at.ut=!0,t.$.at.ft=!0,t.vt.removeEventListener("pointermove",this.Y),t.vt.removeEventListener("pointerdown",this.q),t.vt.removeEventListener("pointerup",this.C),t.vt.removeEventListener("click",this.T),t.vt.removeEventListener("dblclick",this.B),t.vt.removeEventListener("contextmenu",this.F)},h.prototype.M=function(t){var i=this.J,r=this.s,e=this.u;e.position=r,i.entities.remove(e),!0===t?(e.v.lt=require("../../../assets/icon/marker_pan.png"),i.entities.add(e)):"pan"===t?(e.v.lt=require("../../../assets/icon/marker_pan.png"),i.entities.add(e)):"rotate"===t?(e.v.lt=require("../../../assets/icon/marker_rotate.png"),i.entities.add(e)):"zoom"===t?(e.v.lt=require("../../../assets/icon/marker_zoom.png"),i.entities.add(e)):"setting"===t?(e.v.lt=require("../../../assets/icon/marker_setting.png"),i.entities.add(e)):i.entities.remove(e)},Object.defineProperty(h.prototype,"dt",{get:function(){return this.o},set:function(t){this.nt;t!==this.o&&(t?this.ot():this.pt(),this.o=t)},gt:!0,kt:!0}),h}(o);export default h;