
/*
* 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 env from 'tvrender/lib/core/env.js';
var margin = 8;
var TooltipTextHtmlContent = /** @class */function () {
  function TooltipTextHtmlContent(api) {
    this._show = false;
    this._enterable = true;
    if (env.wxa) {
      return null;
    }
    var el = document.createElement('div');
    // TODO: TYPE
    el.domBelongToZr = true;
    this.el = el;
    // const zr = this._zr = api.getZr();
    var container = api.getDom();
    (container || api.getDom()).appendChild(el);
    this._api = api;
    this._container = container;
  }
  TooltipTextHtmlContent.prototype.show = function (_a) {
    var x = _a.x,
      y = _a.y,
      text = _a.text,
      _b = _a.position,
      position = _b === void 0 ? "top" : _b;
    var el = this.el;
    var style = el.style;
    style.position = "absolute";
    style.left = x + "px";
    style.visibility = "visible";
    style.opacity = "1";
    var isTop = position === "top";
    var triangleStyle = "transform: translateX(-50%) translateY(50%) rotate(45deg); position: absolute; bottom: 0px;";
    if (isTop) {
      style.top = y - margin + "px";
      style.transform = "translateX(-50%) translateY(-100%)";
    } else {
      style.top = y + margin + "px";
      style.transform = "translateX(-50%)";
      triangleStyle = "transform: translateX(-50%) translateY(-50%) rotate(45deg); position: absolute; top: 0px;";
    }
    el.innerHTML = "<div style=\"max-width:300px\">\n        <div style=\"min-width: 32px; padding: 2px 8px; color: #fff; background-color: rgb(42, 46, 57); font-size: 12px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.08) 0px 6px 16px 0px, rgba(0, 0, 0, 0.12) 0px 3px 6px -4px, rgba(0, 0, 0, 0.05) 0px 9px 28px 8px; white-space: pre-wrap;\">" + text + "</div>\n        <div style=\"width: 6px; height: 6px; " + triangleStyle + " left: 50%; background-color: rgb(42, 46, 57);\"></div>\n        </div>";
  };
  TooltipTextHtmlContent.prototype.getSize = function () {
    var el = this.el;
    return [el.offsetWidth, el.offsetHeight];
  };
  TooltipTextHtmlContent.prototype.hide = function () {
    var style = this.el.style;
    style.visibility = 'hidden';
    style.opacity = '0';
    env.transform3dSupported && (style.willChange = '');
    this._show = false;
  };
  TooltipTextHtmlContent.prototype.isShow = function () {
    return this._show;
  };
  TooltipTextHtmlContent.prototype.dispose = function () {
    var parentNode = this.el.parentNode;
    parentNode && parentNode.removeChild(this.el);
    this.el = this._container = null;
  };
  return TooltipTextHtmlContent;
}();
export default TooltipTextHtmlContent;