import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import "./style.scss";
import { useState } from "react";
import { ClickableText } from "../..";
import ProfileExperienceCard from "../../ProfileExperienceCard";
const ProfileDynamicExperienceCard = ({ experiences, initialItemsToShow, onCompanyClick, expIndustries = [], expSkills = [], }) => {
    const [count, setCount] = useState(initialItemsToShow);
    const [buttonText, setButtonText] = useState(`${experiences.length > initialItemsToShow
        ? experiences.length - initialItemsToShow
        : experiences.length} More`);
    return (_jsx(_Fragment, { children: _jsxs("ul", { className: "experience--ul--container", children: [experiences?.slice(0, count).map((exp, index) => (_jsx("li", { className: "experience-li", children: exp.map((item, key) => (_jsx(ProfileExperienceCard, { expNumber: key, totalExpInCompany: exp.length, iconUrl: item.iconUrl, iconAltText: item.iconAltText, position: item.position, company: item.company, from: item.from, to: item.to, separator: item.separator, universalName: item.universalName, urn: item.urn, onExperienceCompanyClick: onCompanyClick, industries: item.industries, expIndustries: expIndustries[index], expSkills: expSkills[index], location: item.location }))) }, index))), _jsx("li", { className: "experience-more-button-li", children: experiences.length > initialItemsToShow &&
                        experiences.length - initialItemsToShow >= 0 && (_jsx(ClickableText, { colorVariant: "gray", sizeVariant: "sm", text: buttonText, onClick: () => {
                            experiences.length === count
                                ? setButtonText(`${experiences.length - initialItemsToShow} More`)
                                : setButtonText("View less");
                            setCount(experiences.length === count
                                ? initialItemsToShow
                                : experiences.length);
                        } })) })] }) }));
};
export default ProfileDynamicExperienceCard;
