import{jsxs as t,jsx as e,Fragment as u}from"react/jsx-runtime";import{B as h}from"./button-BvFBRYHq.js";import{C as f,b as x,c as b,d as g,a as y}from"./card-Zg0WOx-j.js";import{I as C}from"./input-qMvM9qch.js";import{L as i}from"./label-DMnntKPk.js";import{S as d}from"./separator-BDLxzoJ8.js";import{Calculator as c}from"lucide-react";import{useState as m}from"react";import{toast as F}from"sonner";import"@radix-ui/react-slot";import"class-variance-authority";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-label";import"@radix-ui/react-separator";function N(o){const l=new Float32Array(1);l[0]=o;const r=new Uint8Array(l.buffer);let a="";for(let n=r.length-1;n>=0;n--)a+=r[n].toString(16).padStart(2,"0").toUpperCase();return a+"h"}function v(){const[o,l]=m(""),[r,a]=m("");return{floatInput:o,setFloatInput:l,hexResult:r,convertFloat:()=>{const s=parseFloat(o);if(isNaN(s)){a("Masukkan angka float yang valid!"),F.error("Invalid float number!");return}const p=N(s);a(`Hexadecimal: ${p}`)}}}function M(){const{floatInput:o,setFloatInput:l,hexResult:r,convertFloat:a}=v();return t(f,{children:[t(x,{children:[t(b,{className:"flex items-center gap-2",children:[e(c,{className:"h-5 w-5"}),"Float to Hexadecimal Converter"]}),e(g,{children:"Convert floating point numbers to hexadecimal format"})]}),t(y,{className:"space-y-6",children:[t("div",{className:"space-y-2 rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/50",children:[e("p",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Examples:"}),t("div",{className:"space-y-1 font-mono text-sm text-blue-800 dark:text-blue-200",children:[t("p",{children:[e("strong",{children:"Float:"})," 10.0 → ",e("strong",{children:"Hex:"})," 41200000h"]}),t("p",{children:[e("strong",{children:"Float:"})," 12.5 → ",e("strong",{children:"Hex:"})," 41480000h"]}),t("p",{children:[e("strong",{children:"Float:"})," -3.25 → ",e("strong",{children:"Hex:"})," C0480000h"]})]})]}),e(d,{}),t("div",{className:"space-y-2",children:[e(i,{htmlFor:"floatInput",children:"Enter Float Value"}),e(C,{id:"floatInput",type:"number",step:"any",placeholder:"Example: 12.5",value:o,onChange:n=>l(n.target.value),className:"font-mono"})]}),t(h,{onClick:a,size:"default",className:"w-full sm:w-auto",children:[e(c,{className:"h-4 w-4"}),e("span",{className:"ml-2 hidden md:inline",children:"Convert to Hexadecimal"})]}),r&&t(u,{children:[e(d,{}),t("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 p-4 dark:border-yellow-900 dark:bg-yellow-950/50",children:[e(i,{className:"mb-2 block text-base text-yellow-900 dark:text-yellow-100",children:"Result:"}),e("p",{className:"font-mono text-lg font-bold text-yellow-900 dark:text-yellow-100",children:r})]})]})]})]})}export{M as FloatToHexConverter};
