'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var EventEmitter = require('events'); var sdk = require('@exposition/sdk'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter); const EventNames = { RESET: "reset", UPDATE: "update", UPDATE_SETTINGS: "updateSettings", INITIALIZED: "initialized" }; var __defProp = Object.defineProperty; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; class Exposition { constructor(config, options = {}) { this.emitter = new EventEmitter__default["default"](); this.settingsState = { active: true, restoreState: true }; this.initialized = false; this.state = sdk.createExpositionState(config); this.assignNewSettings((options == null ? void 0 : options.settings) || {}); } get values() { return sdk.getExpositionValues(this.state); } get initialValues() { return sdk.getInitialExpositionValues(this.state); } get settings() { return Object.freeze(__spreadValues({}, this.settingsState)); } emit(eventName) { this.emitter.emit(eventName, this.values, this.settings); } reset() { Object.assign(this.state, sdk.resetExpositionValues(this.state)); this.emit(EventNames.RESET); return this; } update(newValues) { Object.assign(this.state, sdk.updateExpositionValues(this.state, newValues)); this.emit(EventNames.UPDATE); return this; } updateSettings(newSettings) { this.assignNewSettings(newSettings); this.emit(EventNames.UPDATE_SETTINGS); return this; } getState() { return structuredClone(this.state); } assignNewSettings(newSettings) { Object.assign(this.settingsState, __spreadValues(__spreadValues({}, this.settingsState), newSettings)); } on(event, handler) { this.emitter.on(event, handler); return this; } use(integrationFunction, settings) { return integrationFunction(this, settings); } init() { if (!this.initialized) { this.initialized = true; this.emit(EventNames.INITIALIZED); } return this; } } exports.Exposition = Exposition;