"use client"
import{a as b}from"./chunk-K4MP745I.mjs";import{a as p}from"./chunk-2TGXECZQ.mjs";import{a as m,d as g,g as f}from"./chunk-34A7ZDQZ.mjs";import{Link2 as y}from"lucide-react";import{useRouter as R,useSearchParams as k}from"next/navigation";import{useEffect as E,useMemo as P,useRef as W}from"react";import M from"swr";import{useDebounce as U}from"use-debounce";import{Fragment as h,jsx as e,jsxs as r}from"react/jsx-runtime";function H({defaultUrl:t}){let x=R(),l=k(),s=t||(l==null?void 0:l.get("url"))||"https://github.com/dubinc/dub",[a]=U(m(s),500),i=P(()=>g(a||""),[a]),{data:N,isValidating:w}=M(a&&`/api/metatags?url=${encodeURIComponent(a)}`,f,{revalidateOnFocus:!1}),{title:d,description:n,image:u}=N||{},o=W(null);E(()=>{!t&&o.current&&o.current.select()},[t]);let{isMobile:L}=b();return r(h,{children:[!t&&r("div",{className:"relative flex items-center",children:[e(y,{className:"absolute inset-y-0 left-0 my-2 ml-3 w-5 text-gray-400"}),e("input",{ref:o,name:"url",id:"url",type:"url",autoFocus:!L,className:"block w-full rounded-md border-gray-200 pl-10 text-sm text-gray-900 placeholder-gray-400 shadow-lg focus:border-gray-500 focus:outline-none focus:ring-gray-500",placeholder:"Enter your URL",defaultValue:s,onChange:c=>x.replace(`/tools/metatags${c.target.value.length>0?`?url=${c.target.value}`:""}`),"aria-invalid":"true"})]}),r("div",{className:"relative overflow-hidden rounded-md border border-gray-300 bg-gray-50",children:[w&&e("div",{className:"absolute flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-50",children:e(v,{})}),u?e("img",{src:u,alt:"Preview",className:"h-[250px] w-full border-b border-gray-300 object-cover"}):r("div",{className:"flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300",children:[e(p,{className:"h-8 w-8 text-gray-400"}),e("p",{className:"text-sm text-gray-400",children:"Enter a link to generate a preview."})]}),r("div",{className:"grid gap-1 bg-white p-3 text-left",children:[i?e("p",{className:"text-sm text-[#536471]",children:i}):e("div",{className:"mb-1 h-4 w-24 rounded-md bg-gray-100"}),d?e("h3",{className:"truncate text-sm font-medium text-[#0f1419]",children:d}):e("div",{className:"mb-1 h-4 w-full rounded-md bg-gray-100"}),n?e("p",{className:"line-clamp-2 text-sm text-[#536471]",children:n}):r("div",{className:"grid gap-2",children:[e("div",{className:"h-4 w-full rounded-md bg-gray-100"}),e("div",{className:"h-4 w-48 rounded-md bg-gray-100"})]})]})]})]})}function O({defaultUrl:t}){return r(h,{children:[r("div",{className:"relative flex items-center",children:[e(y,{className:"absolute inset-y-0 left-0 my-2 ml-3 w-5 text-gray-400"}),e("input",{name:"url",id:"url",type:"url",disabled:!0,className:"block w-full rounded-md border-gray-200 pl-10 text-sm text-gray-900 placeholder-gray-400 shadow-lg focus:border-gray-500 focus:outline-none focus:ring-gray-500",placeholder:"Enter your URL",defaultValue:t||"https://github.com/dubinc/dub"})]}),e("div",{className:"relative overflow-hidden rounded-md border border-gray-300 bg-gray-50",children:e("div",{className:"absolute flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-50",children:e(v,{})})})]})}export{H as a,O as b};
