export default class DirtyValueCalculator {
    setOriginalValue(value) {
        this._originalHashValue = this.computeHash(value);
    }
    isDirty(currentValue) {
        return this.computeHash(currentValue) !== this._originalHashValue;
    }
    computeHash(value) {
        return this.getStringHash(`${typeof value}_${JSON.stringify(value)}`);
    }
    getStringHash(str) {
        let hash1 = 5381;
        let hash2 = 52711;
        let i = str.length;
        while (i--) {
            const char = str.charCodeAt(i);
            hash1 = (hash1 * 33) ^ char;
            hash2 = (hash2 * 33) ^ char;
        }
        return ((hash1 >>> 0) << 12) + (hash2 >>> 0);
    }
}
export { DirtyValueCalculator };
//# sourceMappingURL=dirty-value-calculator.js.map