File size: 1,425 Bytes
68185ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * Generate a random integer between min and max (inclusive).
 * @param {number} min - Minimum value (inclusive).
 * @param {number} max - Maximum value (inclusive).
 * @returns {number} A random integer.
 */
export function random_number(min, max) {
  min = Math.ceil(Number(min));
  max = Math.floor(Number(max));
  if (isNaN(min) || isNaN(max) || min > max) {
    throw new Error("Invalid min or max value.");
  }
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

export default (input, output) =>
  React.createElement(
    "div",
    { className: "bg-indigo-50 border border-indigo-200 rounded-lg p-4" },
    React.createElement(
      "div",
      { className: "flex items-center mb-2" },
      React.createElement(
        "div",
        {
          className:
            "w-8 h-8 bg-indigo-100 rounded-full flex items-center justify-center mr-3",
        },
        "🎲",
      ),
      React.createElement(
        "h3",
        { className: "text-indigo-900 font-semibold" },
        "Random Number",
      ),
    ),
    React.createElement(
      "div",
      { className: "text-center" },
      React.createElement(
        "div",
        { className: "text-3xl font-bold text-indigo-600 mb-1" },
        output,
      ),
      React.createElement(
        "p",
        { className: "text-indigo-500 text-xs" },
        `Range: ${input.min || "?"} - ${input.max || "?"}`,
      ),
    ),
  );