/** * Assert polyfill for browser environment. * Required by adaptivecards-templating (antlr4ts dependency). * * Sets assert globally so bundled libraries can access it. * * @module @burdenoff/fe-libs/shared/shims/assert */ function assert(condition: unknown, message?: string): asserts condition { if (!condition) { throw new Error(message || 'Assertion failed'); } } // Add methods for Node.js assert compatibility assert.ok = assert; assert.strictEqual = (actual: unknown, expected: unknown, message?: string) => { if (actual !== expected) { throw new Error(message || `Expected ${expected} but got ${actual}`); } }; assert.notStrictEqual = (actual: unknown, expected: unknown, message?: string) => { if (actual === expected) { throw new Error(message || `Expected ${actual} to not equal ${expected}`); } }; assert.deepStrictEqual = (actual: unknown, expected: unknown, message?: string) => { if (JSON.stringify(actual) !== JSON.stringify(expected)) { throw new Error(message || `Deep equality assertion failed`); } }; assert.fail = (message?: string) => { throw new Error(message || 'Assertion failed'); }; // Set as global for bundled libraries that expect it if (typeof window !== 'undefined') { (window as unknown as Record).assert = assert; } if (typeof globalThis !== 'undefined') { (globalThis as unknown as Record).assert = assert; } export { assert }; export default assert;