"use strict";
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 ClientNodePhysicalProperties_exports = {};
__export(ClientNodePhysicalProperties_exports, {
  ClientNodePhysicalProperties: () => ClientNodePhysicalProperties
});
module.exports = __toCommonJS(ClientNodePhysicalProperties_exports);
var import_EndpointInitializer = require("#endpoint/properties/EndpointInitializer.js");
var import_NodePhysicalProperties = require("#node/NodePhysicalProperties.js");
var import_general = require("@matter/general");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const cache = /* @__PURE__ */ new WeakMap();
function ClientNodePhysicalProperties(node) {
  const existing = cache.get(node);
  if (existing) {
    return existing;
  }
  let properties;
  let frozen = false;
  const result = {
    get supportsThread() {
      return props().supportsThread;
    },
    get supportsWifi() {
      return props().supportsWifi;
    },
    get supportsEthernet() {
      return props().supportsEthernet;
    },
    get rootEndpointServerList() {
      return props().rootEndpointServerList;
    },
    get isMainsPowered() {
      return props().isMainsPowered;
    },
    get isBatteryPowered() {
      return props().isBatteryPowered;
    },
    get isIntermittentlyConnected() {
      return props().isIntermittentlyConnected;
    },
    get isThreadSleepyEndDevice() {
      return props().isThreadSleepyEndDevice;
    },
    get threadActive() {
      return props().threadActive;
    },
    get threadPan() {
      return props().threadPan;
    },
    get threadChannel() {
      return props().threadChannel;
    }
  };
  cache.set(node, result);
  const structure = node.env.get(import_EndpointInitializer.EndpointInitializer).structure;
  structure.changed.on(() => {
    if (frozen) return;
    properties = void 0;
  });
  node.lifecycle.goingOffline.on(() => freeze());
  node.lifecycle.online.on(() => {
    frozen = false;
    properties = void 0;
  });
  node.lifecycle.destroyed.once(() => {
    freeze();
    cache.delete(node);
  });
  return result;
  function props() {
    if (properties === void 0) {
      properties = (0, import_NodePhysicalProperties.NodePhysicalProperties)(node);
    }
    return properties;
  }
  function freeze() {
    if (frozen) return;
    properties = (0, import_general.deepCopy)(props());
    frozen = true;
  }
}
//# sourceMappingURL=ClientNodePhysicalProperties.js.map
