var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var SwcObjectObject_exports = {};
__export(SwcObjectObject_exports, {
  SwcObjectObject: () => SwcObjectObject
});
module.exports = __toCommonJS(SwcObjectObject_exports);
var import__ = require("../index");
var import_SwcHTMLObjectElementBase = require("../elements/base/SwcHTMLObjectElementBase");
var __decorate = function(decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = function(k, v) {
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let SwcObjectObject = class SwcObjectObject2 extends import_SwcHTMLObjectElementBase.SwcHTMLObjectElementBase {
  constructor() {
    super(...arguments);
    this._swcValue = {};
    this._renderedNodes = [];
  }
  onValueChange() {
    if (typeof this._swcValue !== "object" || this._swcValue === null)
      this._swcValue = {};
    this._swcValue = this.createReactiveProxy(this._swcValue, () => this.updateUI());
    if (this._masterTplNodes.length === 0)
      this.initCore();
    this.render();
  }
  set swcValue(val) {
    this._swcValue = val;
  }
  get swcValue() {
    return this._swcValue;
  }
  renderTemplate() {
    return `<slot id="tpl-slot" style="display:none;"></slot>`;
  }
  connectedCallback() {
    this.initCore();
    if (this._masterTplNodes.length > 0) {
      this.innerHTML = "";
      this.render();
    }
  }
  updateUI() {
    this._renderedNodes.forEach((node) => {
      this.applyData(node, this._swcValue);
    });
  }
  render() {
    this.innerHTML = "";
    this._renderedNodes = [];
    if (this._masterTplNodes.length === 0)
      return;
    this._masterTplNodes.forEach((tplNode) => {
      const clone = tplNode.cloneNode(true);
      this.appendChild(clone);
      if (clone.style)
        clone.style.display = "contents";
      this._renderedNodes.push(clone);
      this.applyData(clone, this._swcValue);
    });
  }
};
__decorate([
  (0, import__.attribute)("swc-value"),
  __metadata("design:type", Object)
], SwcObjectObject.prototype, "_swcValue", void 0);
__decorate([
  (0, import__.onAttributeChanged)("swc-value"),
  __metadata("design:type", Function),
  __metadata("design:paramtypes", []),
  __metadata("design:returntype", void 0)
], SwcObjectObject.prototype, "onValueChange", null);
__decorate([
  import__.innerHtml,
  __metadata("design:type", Function),
  __metadata("design:paramtypes", []),
  __metadata("design:returntype", void 0)
], SwcObjectObject.prototype, "renderTemplate", null);
SwcObjectObject = __decorate([
  (0, import__.elementDefine)({ name: "swc-object-object", extends: "object" })
], SwcObjectObject);
//# sourceMappingURL=SwcObjectObject.js.map
