'use client';
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/Stepper/step-label.tsx
var step_label_exports = {};
__export(step_label_exports, {
  StepLabel: () => StepLabel
});
module.exports = __toCommonJS(step_label_exports);
var import_lib = require("@paalan/react-shared/lib");
var import_class_variance_authority = require("class-variance-authority");

// src/components/Stepper/use-stepper.ts
var React2 = __toESM(require("react"), 1);

// src/components/Stepper/context.tsx
var React = __toESM(require("react"), 1);
var import_jsx_runtime = require("react/jsx-runtime");
var StepperContext = React.createContext({
  steps: [],
  activeStep: 0,
  initialStep: 0,
  nextStep: () => {
  },
  prevStep: () => {
  },
  resetSteps: () => {
  },
  setStep: () => {
  }
});

// src/components/Stepper/use-stepper.ts
function usePrevious(value) {
  const ref = React2.useRef();
  React2.useEffect(() => {
    ref.current = value;
  }, [value]);
  return ref.current;
}
function useStepper() {
  const context = React2.useContext(StepperContext);
  if (context === void 0) {
    throw new Error("useStepper must be used within a StepperProvider");
  }
  const { children, className, ...rest } = context;
  const isLastStep = context.activeStep === context.steps.length - 1;
  const hasCompletedAllSteps = context.activeStep === context.steps.length;
  const previousActiveStep = usePrevious(context.activeStep);
  const currentStep = context.steps[context.activeStep];
  const isOptionalStep = !!currentStep?.optional;
  const isDisabledStep = context.activeStep === 0;
  return {
    ...rest,
    isLastStep,
    hasCompletedAllSteps,
    isOptionalStep,
    isDisabledStep,
    currentStep,
    previousActiveStep
  };
}

// src/components/Stepper/step-label.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var labelVariants = (0, import_class_variance_authority.cva)("", {
  variants: {
    size: {
      sm: "text-sm",
      md: "text-sm",
      lg: "text-base"
    }
  },
  defaultVariants: {
    size: "md"
  }
});
var descriptionVariants = (0, import_class_variance_authority.cva)("", {
  variants: {
    size: {
      sm: "text-xs",
      md: "text-xs",
      lg: "text-sm"
    }
  },
  defaultVariants: {
    size: "md"
  }
});
var StepLabel = ({ isCurrentStep, opacity, label, description }) => {
  const { variant, styles, size, orientation, isVerticalTimeline } = useStepper();
  const shouldRender = !!label || !!description;
  return shouldRender ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
    "div",
    {
      "aria-current": isCurrentStep ? "step" : void 0,
      className: (0, import_lib.cn)(
        "stepper__step-label-container",
        "flex flex-col",
        variant !== "line" ? "ms-2" : orientation === "horizontal" && "my-2",
        variant === "circle-alt" && "text-center",
        variant === "circle-alt" && orientation === "horizontal" && "ms-0",
        variant === "circle-alt" && orientation === "vertical" && "text-start",
        styles?.["step-label-container"]
      ),
      style: {
        opacity
      },
      children: [
        !!label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
          "span",
          {
            className: (0, import_lib.cn)(
              "stepper__step-label",
              "text-foreground",
              isVerticalTimeline && "word-break",
              labelVariants({ size }),
              styles?.["step-label"]
            ),
            children: label
          }
        ),
        !!description && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
          "span",
          {
            className: (0, import_lib.cn)(
              "stepper__step-description",
              "text-muted-foreground",
              isVerticalTimeline && "word-break",
              descriptionVariants({ size }),
              styles?.["step-description"]
            ),
            children: description
          }
        )
      ]
    }
  ) : null;
};
