
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import ComponentModel from '../../model/Component.js';
import ComponentView from '../../view/Component.js';
var CursorPointerModel = /** @class */function (_super) {
  __extends(CursorPointerModel, _super);
  function CursorPointerModel() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = CursorPointerModel.type;
    return _this;
  }
  CursorPointerModel.type = 'cursorPointer';
  // readonly layoutMode = {type: 'box', ignoreSize: true} as const;
  CursorPointerModel.defaultOption = {
    // zlevel: 0,
    z: 6,
    r: 20,
    show: true,
    backgroundColor: 'rgba(242, 54, 69, 0.2)'
  };
  return CursorPointerModel;
}(ComponentModel);
// View
var CursorPointerView = /** @class */function (_super) {
  __extends(CursorPointerView, _super);
  function CursorPointerView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = CursorPointerView.type;
    return _this;
  }
  CursorPointerView.prototype.init = function (ecModel, api) {
    this.element = new graphic.Circle();
    this.group.add(this.element);
  };
  CursorPointerView.prototype.render = function (cursorPointerModel, ecModel, api) {
    if (!cursorPointerModel.get('show')) {
      this.group.removeAll();
      api.getZr().off('mousemove', this.handleMove);
      api.getZr().off('globalout', this.handleGlobalOut);
      return;
    }
    var backgroundColor = cursorPointerModel.get('backgroundColor');
    var r = cursorPointerModel.get('r');
    var element = this.element;
    element.attr({
      style: {
        fill: backgroundColor
      },
      shape: {
        r: r
      },
      silent: true
    });
    api.getZr().on('mousemove', this.handleMove, this);
    api.getZr().on('globalout', this.handleGlobalOut, this);
    // const group = this.group;
  };

  CursorPointerView.prototype.dispose = function (ecModel, api) {
    this.group.removeAll();
    this.element = null;
    api.getZr().off('mousemove', this.handleMove);
    api.getZr().off('globalout', this.handleGlobalOut);
  };
  CursorPointerView.prototype.handleMove = function (event) {
    var x = event.offsetX;
    var y = event.offsetY;
    if (!this.group.childCount()) {
      this.group.add(this.element);
    }
    this.element.attr({
      shape: {
        cx: x,
        cy: y
      }
    });
  };
  CursorPointerView.prototype.handleGlobalOut = function () {
    this.group.remove(this.element);
  };
  CursorPointerView.type = 'cursorPointer';
  return CursorPointerView;
}(ComponentView);
export function install(registers) {
  registers.registerComponentModel(CursorPointerModel);
  registers.registerComponentView(CursorPointerView);
}