var w = Object.defineProperty, v = Object.defineProperties;
var b = Object.getOwnPropertyDescriptors;
var g = Object.getOwnPropertySymbols;
var E = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
var c = (s, i, t) => i in s ? w(s, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[i] = t, l = (s, i) => {
  for (var t in i || (i = {}))
    E.call(i, t) && c(s, t, i[t]);
  if (g)
    for (var t of g(i))
      D.call(i, t) && c(s, t, i[t]);
  return s;
}, d = (s, i) => v(s, b(i));
var r = (s, i, t) => (c(s, typeof i != "symbol" ? i + "" : i, t), t);
import { hotkeys as u } from "../../../vendor/hotkeys-js/dist/hotkeys.esm.js";
import { globalModules as n } from "../../utils/Modules/Global.js";
import { IObject3D as x } from "../../../shared-utils/three/IObject3D.js";
import { localToWorld as S, worldToLocal as W } from "../../../shared-utils/three/applyObjectMatrixWorld.js";
import "../../../shared-utils/tag.js";
import "three";
import "../../../vendor/hammerjs/hammer.js";
import "../../../shared-utils/three/PointSelector/index.js";
import "../../../shared-utils/three/CSS3DRenderer/index.js";
import "../../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
import "@realsee/five/line";
import { notNil as y } from "../../../shared-utils/isNil.js";
import "../../../shared-utils/three/core/Five_LineMaterial2.js";
import "../../../shared-utils/three/core/Sphere.js";
import "../../../shared-utils/three/blink.js";
import "../../../vendor/@tweenjs/tween/dist/tween.esm.js.js";
import "../../../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
import "../../../vendor/earcut/src/earcut.js";
import "../../../shared-utils/five/FivePuppet.js";
const p = /* @__PURE__ */ new Map();
class M extends x {
  constructor(t, e) {
    var o, a;
    super();
    r(this, "name", "Sculpt");
    r(this, "isSculptObject", !0);
    r(this, "draggable");
    /**
     * @description 是否被选中
     */
    r(this, "selected");
    /**
     * @description 配置
     */
    r(this, "config");
    r(this, "on", (t, e, o) => n.fiveDomEvents.addEventListener(this, t, e, o));
    r(this, "off", (...t) => n.fiveDomEvents.removeEventListener(this, ...t));
    r(this, "applyObjectMatrixWorld", (t, e) => {
      const o = e != null ? e : this;
      return o.updateMatrixWorld(), S(o, t);
    });
    r(this, "applyObjectReversalMatrixWorld", (t, e) => {
      const o = e != null ? e : this;
      return o.updateMatrixWorld(), W(o, t);
    });
    t != null && t.id && (this.uuid = t.id), this.config = l({ defaultAction: !0, occlusionVisibility: !0, occlusionMode: "translucence" }, e), t && (y((o = this.config) == null ? void 0 : o.occlusionMode) && (t.style = d(l({}, t.style), { occlusionMode: this.config.occlusionMode })), y((a = this.config) == null ? void 0 : a.occlusionVisibility) && (t.style = d(l({}, t.style), { occlusionVisibility: this.config.occlusionVisibility }))), u("esc", () => {
      this.stopCreating();
    }), this.config.defaultAction && (u("backspace, delete", () => {
      this.selected && this.delete();
    }), this.on("click", () => {
      var f;
      this.editing || (this.select({ only: !0 }), this.editor.enable(), (f = this.parent) == null || f.children.forEach((h) => {
        var m;
        h instanceof M && h !== this && ((m = h._editor) == null || m.disable());
      }));
    }), u("esc", () => {
      this.selected && this.unselect();
    }));
  }
  get editing() {
    return this.pointSelector.enabled;
  }
  get baseData() {
    return {
      id: this.uuid,
      type: this.type
    };
  }
  get pointSelector() {
    return n.pointSelector;
  }
  /**
   * @description 撤销
   */
  undo() {
    throw new Error("Method not implemented.");
  }
  /**
   * @description 重做
   */
  redo() {
    throw new Error("Method not implemented.");
  }
  /**
   * @description 是否可以撤销
   */
  canUndo() {
    throw new Error("Method not implemented.");
  }
  /**
   * @description 是否可以重做
   */
  canRedo() {
    throw new Error("Method not implemented.");
  }
  /**
   * @description 停止创建当前物体，等同于`esc`
   */
  stopCreating() {
    n.pointSelector.disable();
  }
  /**
   * @description 从场景中删除当前物体，并且移除事件监听
   */
  delete() {
    var t;
    this.stopCreating(), this.removeFromParent(), this.off(), (t = this.editor) == null || t.disable();
  }
  /**
   * @description 选择当前物体
   * @param params.only 只选择当前物体，自动取消选择其他物体；默认 `false`
   *
   */
  select(t = { only: !1 }) {
    if (this.selected)
      return;
    this.selected = !0, this.highlight(), p.has(this.parent.uuid) || p.set(this.parent.uuid, []);
    const e = p.get(this.parent.uuid);
    e.push(this), t.only && (e == null || e.forEach((o) => {
      o !== this && o.unselect();
    }));
  }
  /**
   * @description 取消选择当前物体
   */
  unselect() {
    var t;
    this.selected && (this.selected = !1, this.unhighlight(), (t = this._editor) == null || t.disable());
  }
  /**
   * @description 高亮当前物体
   */
  highlight() {
  }
  /**
   * @description 取消高亮当前物体
   */
  unhighlight() {
  }
  /**
   * @description 显示删除按钮
   */
  showDeleteButton(t, e) {
    n.cursor.showDeleteButton({ clientX: t, clientY: e, container: document.body, onClick: () => this.delete() }), n.five.once("cameraUpdate", () => {
      n.cursor.removeDeleteButton();
    });
  }
}
export {
  M as BaseObject
};
