1import{b as d,j as s}from"./client-DVJRcboz.js";import{T as g}from"./ToolPage-BLm8B96_.js";import{p as j,c as y,s as N,f as a,t as b}from"./cidr-Dtgpa46i.js";import"./SeoHead-DdgVrFEj.js";const v="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 font-mono";function h({value:c,prefix:m}){const o=b(c);return s.jsx("span",{className:"font-mono text-sm break-all",children:o.split("").map((x,r)=>s.jsxs("span",{className:r<m?"text-indigo-600":"text-gray-500",children:[x,(r+1)%8===0&&r<31?".":""]},r))})}function L({section:c,item:m}){const[o,x]=d.useState("192.168.1.10/24"),[r,u]=d.useState(""),l=d.useMemo(()=>j(o),[o]),e=d.useMemo(()=>l.error?null:y(l.ip,l.prefix),[l]),n=e&&Number(r)>e.prefix?Number(r):null,i=d.useMemo(()=>e&&n?N(e,n):null,[e,n]),f=e&&[["Network address",a(e.network)],["Network (CIDR)",`${a(e.network)}/${e.prefix}`],["Netmask",a(e.mask)],["Wildcard mask",a(e.wildcard)],["Broadcast address",e.broadcast===null?"Not used for /31 and /32":a(e.broadcast)],["First usable host",a(e.first)],["Last usable host",a(e.last)],["Total addresses",e.total.toLocaleString()],["Usable hosts",e.usable.toLocaleString()],["Address class",e.class],["Address type",e.type]];return s.jsxs(g,{section:c,item:m,children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"cidr-input",className:"block text-sm font-medium text-gray-700",children:"IPv4 address with prefix or netmask"}),s.jsx("input",{id:"cidr-input",type:"text",value:o,onChange:t=>x(t.target.value),spellCheck:!1,autoComplete:"off",placeholder:"192.168.1.10/24",className:`mt-1 ${v}`}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Examples: 10.0.0.0/8, 192.168.1.10 255.255.255.0, 172.16.5.4/255.255.0.0"}),l.error&&s.jsx("p",{role:"alert",className:"mt-2 text-sm text-red-600",children:l.error})]}),e&&s.jsxs(s.Fragment,{children:[s.jsx("dl",{className:"divide-y divide-gray-200 border border-gray-200 rounded-md",children:f.map(([t,p])=>s.jsxs("div",{className:"px-4 py-2 sm:grid sm:grid-cols-3 sm:gap-4",children:[s.jsx("dt",{className:"text-sm font-medium text-gray-500",children:t}),s.jsx("dd",{className:"mt-1 sm:mt-0 sm:col-span-2 text-sm text-gray-900 font-mono break-all",children:p})]},t))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-sm font-medium text-gray-700",children:"Binary"}),s.jsx("div",{className:"text-sm text-gray-500",children:"Address"}),s.jsx(h,{value:e.ip,prefix:e.prefix}),s.jsx("div",{className:"text-sm text-gray-500",children:"Netmask"}),s.jsx(h,{value:e.mask,prefix:e.prefix}),s.jsxs("p",{className:"text-xs text-gray-500",children:[s.jsx("span",{className:"text-indigo-600",children:"Network bits"})," and ",s.jsx("span",{children:"host bits"}),"."]})]}),e.prefix<32&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"cidr-split",className:"block text-sm font-medium text-gray-700",children:"Split into smaller subnets"}),s.jsxs("select",{id:"cidr-split",value:n??"",onChange:t=>u(t.target.value),className:"mt-1 block w-full sm:w-auto rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",children:[s.jsx("option",{value:"",children:"Do not split"}),Array.from({length:32-e.prefix},(t,p)=>e.prefix+1+p).map(t=>s.jsxs("option",{value:t,children:["/",t," (",(2**(t-e.prefix)).toLocaleString()," subnets)"]},t))]}),i&&s.jsxs("div",{className:"mt-4",children:[s.jsx("div",{className:"overflow-x-auto border border-gray-200 rounded-md",children:s.jsxs("table",{className:"min-w-full divide-y divide-gray-200 text-sm",children:[s.jsx("thead",{className:"bg-gray-50 text-left text-gray-500",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-4 py-2 font-medium",children:"Subnet"}),s.jsx("th",{className:"px-4 py-2 font-medium",children:"Usable range"}),s.jsx("th",{className:"px-4 py-2 font-medium",children:"Hosts"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-200 font-mono",children:i.items.map(t=>s.jsxs("tr",{children:[s.jsxs("td",{className:"px-4 py-2 whitespace-nowrap",children:[a(t.network),"/",t.prefix]}),s.jsxs("td",{className:"px-4 py-2 whitespace-nowrap",children:[a(t.first)," â ",a(t.last)]}),s.jsx("td",{className:"px-4 py-2",children:t.usable.toLocaleStr
1ing()})]},t.network))})]})}),i.count>i.items.length&&s.jsxs("p",{className:"mt-2 text-xs text-gray-500",children:["Showing the first ",i.items.length," of ",i.count.toLocaleString()," subnets."]})]})]})]})]})}export{L as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.