/** @license MIT | @cube-dev/ui-kit v0.147.0 | Cube Dev Team */
//#region src/components/layout/Board/board-store.ts
/**
* A tiny external store mapping widget id -> registration.
*
* Boards read from it via `useSyncExternalStore`, so a change to any widget's
* content or config re-renders the hosting board without prop drilling through
* the (possibly cross-board) tree.
*/
var BoardWidgetStore = class {
	map = /* @__PURE__ */ new Map();
	owners = /* @__PURE__ */ new Map();
	listeners = /* @__PURE__ */ new Set();
	version = 0;
	register(reg, owner) {
		const prev = this.map.get(reg.id);
		this.map.set(reg.id, reg);
		this.owners.set(reg.id, owner);
		if (!prev || prev.content !== reg.content || prev.isDraggable !== reg.isDraggable || prev.isResizable !== reg.isResizable || prev.resizeHandles !== reg.resizeHandles || prev.isCard !== reg.isCard || prev.minW !== reg.minW || prev.maxW !== reg.maxW || prev.minH !== reg.minH || prev.maxH !== reg.maxH || prev.constraints !== reg.constraints || prev.qa !== reg.qa || prev.styles !== reg.styles || prev.isAutoHeight !== reg.isAutoHeight || prev.dragCancel !== reg.dragCancel || prev.dragHandle !== reg.dragHandle) {
			this.version++;
			this.emit();
		}
	}
	unregister(id, owner) {
		if (this.owners.get(id) !== owner) return;
		this.owners.delete(id);
		if (this.map.delete(id)) {
			this.version++;
			this.emit();
		}
	}
	get(id) {
		return this.map.get(id);
	}
	getVersion = () => this.version;
	subscribe = (listener) => {
		this.listeners.add(listener);
		return () => {
			this.listeners.delete(listener);
		};
	};
	emit() {
		this.listeners.forEach((listener) => listener());
	}
};

//#endregion
export { BoardWidgetStore };
//# sourceMappingURL=board-store.js.map