'use client';

// src/components/Stepper/step-label.tsx
import { cn } from "@paalan/react-shared/lib";
import { cva } from "class-variance-authority";

// src/components/Stepper/use-stepper.ts
import * as React2 from "react";

// src/components/Stepper/context.tsx
import * as React from "react";
import { jsx } from "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
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var labelVariants = cva("", {
  variants: {
    size: {
      sm: "text-sm",
      md: "text-sm",
      lg: "text-base"
    }
  },
  defaultVariants: {
    size: "md"
  }
});
var descriptionVariants = 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__ */ jsxs(
    "div",
    {
      "aria-current": isCurrentStep ? "step" : void 0,
      className: 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__ */ jsx2(
          "span",
          {
            className: cn(
              "stepper__step-label",
              "text-foreground",
              isVerticalTimeline && "word-break",
              labelVariants({ size }),
              styles?.["step-label"]
            ),
            children: label
          }
        ),
        !!description && /* @__PURE__ */ jsx2(
          "span",
          {
            className: cn(
              "stepper__step-description",
              "text-muted-foreground",
              isVerticalTimeline && "word-break",
              descriptionVariants({ size }),
              styles?.["step-description"]
            ),
            children: description
          }
        )
      ]
    }
  ) : null;
};
export {
  StepLabel
};
