import Control from"./Control.js";import EventType from"../events/EventType.js";import{CLASS_CONTROL,CLASS_UNSELECTABLE}from"../css.js";import{easeOut}from"../easing.js";class Zoom extends Control{constructor(t){var t=t||{},e=(super({element:document.createElement("div"),target:t.target}),void 0!==t.className?t.className:"ol-zoom"),o=void 0!==t.delta?t.delta:1,a=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",n=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",i=void 0!==t.zoomInLabel?t.zoomInLabel:"+",s=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",m=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",d=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out";const l=document.createElement("button"),r=(l.className=a,l.setAttribute("type","button"),l.title=m,l.appendChild("string"==typeof i?document.createTextNode(i):i),l.addEventListener(EventType.CLICK,this.handleClick_.bind(this,o),!1),document.createElement("button")),u=(r.className=n,r.setAttribute("type","button"),r.title=d,r.appendChild("string"==typeof s?document.createTextNode(s):s),r.addEventListener(EventType.CLICK,this.handleClick_.bind(this,-o),!1),this.element);u.className=e+" "+CLASS_UNSELECTABLE+" "+CLASS_CONTROL,u.appendChild(l),u.appendChild(r),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap(),o=e.getView();var a;!o||void 0!==(a=o.getZoom())&&(a=o.getConstrainedZoom(a+t),0<this.duration_?(o.getAnimating()&&o.cancelAnimations(),o.animate({zoom:a,duration:this.duration_,easing:easeOut})):o.setZoom(a))}}export default Zoom;