'use strict';

var index = require('./index-p7cvUYAE.js');
var parts = require('./parts-BXshb_S-.js');
var index$1 = require('./index-W-zoNiyM.js');

const Header2 = (props) => {
    return index.h("h2", { class: `header-2 ${props === null || props === void 0 ? void 0 : props.class}`, part: parts.heading2 }, props.text);
};

const insuranceValuesStore = index$1.createStore({});
const { state: insuranceValues, on: insuranceValuesOn } = insuranceValuesStore;
const insuranceErrorsStore = index$1.createStore({});
const { state: insuranceErrors } = insuranceErrorsStore;
// Track previous values to detect actual changes vs initial setting
const previousInsuranceValues = {};
const validateInsuranceValues = () => {
    let valid = true;
    Object.keys(insuranceValues).forEach((key) => {
        const noSelection = insuranceValues[key] === null;
        if (noSelection) {
            insuranceErrors[key] = true;
            valid = false;
        }
        else {
            insuranceErrors[key] = false;
        }
    });
    return { isValid: valid };
};
// Helper function to check if a value has actually changed (not just initially set)
const hasInsuranceValueChanged = (key, newValue) => {
    const hadPreviousValue = Object.prototype.hasOwnProperty.call(previousInsuranceValues, key);
    const previousValue = previousInsuranceValues[key];
    if (!hadPreviousValue) {
        // First time setting this value, track it but don't consider it a "change"
        previousInsuranceValues[key] = newValue;
        return false;
    }
    const hasChanged = previousValue !== newValue;
    if (hasChanged) {
        previousInsuranceValues[key] = newValue;
    }
    return hasChanged;
};

exports.Header2 = Header2;
exports.hasInsuranceValueChanged = hasInsuranceValueChanged;
exports.insuranceErrors = insuranceErrors;
exports.insuranceValues = insuranceValues;
exports.insuranceValuesOn = insuranceValuesOn;
exports.validateInsuranceValues = validateInsuranceValues;
