import { h } from './index-CV0Pyo1O.js';
import { b as heading2 } from './parts-CPKMvyV_.js';
import { c as createStore } from './index-cDVGjRkU.js';

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

const insuranceValuesStore = createStore({});
const { state: insuranceValues, on: insuranceValuesOn } = insuranceValuesStore;
const insuranceErrorsStore = 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;
};

export { Header2 as H, insuranceErrors as a, insuranceValuesOn as b, hasInsuranceValueChanged as h, insuranceValues as i, validateInsuranceValues as v };
