1import{a as $,r as l,e as b,t as d,j as e,L as y,G as A}from"./edge-BOITG1XR.js";import{L as N}from"./mod-DxqX0N6D.js";import{K as m}from"./mod-BBgDTOoh.js";import{C as I}from"./mod-qF7UVkYF.js";import{R as T}from"./mod-RPxq32x0.js";import{M as w}from"./mod-BeUkR8P5.js";import{C as E}from"./mod-E2spV6fa.js";import{C as M}from"./mod-CdBQyGbT.js";import{S as _}from"./mod-BhJ1UrQN.js";import{C as K}from"./mod-DKJSxncj.js";import{S as U}from"./mod-DdNgOIQN.js";const c=a=>a?new Date(a).toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"â",k=({p:a})=>{const t={windows:"ðª",linux:"ð§",macos:"ð",web:"ð",android:"ð¤",ios:"ð±"};return e.jsx("span",{className:"text-base",children:t[a?.toLowerCase()]??"ð»"})},G=({license:a})=>a.is_active?a.status==="suspended"?e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-orange-100 text-orange-700",children:"Suspended"}):a.status==="revoked"?e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-700",children:"Revoked"}):a.is_expired?e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600",children:"Expired"}):a.license_type==="lifetime"?e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-violet-100 text-violet-700",children:"Lifetime"}):e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-700",children:"Active"}):e.jsx("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-slate-100 text-slate-500",children:"Inactive"});function Z(){const{id:a}=$(),[t,n]=l.useState(null),[i,p]=l.useState(!0),[u,h]=l.useState(null),[f,C]=l.useState(!1),[v,j]=l.useState(!1),o=l.useCallback(async()=>{p(!0);try{const s=await b.get(`/customer/licenses/${a}`);n(s.data?.data??s.data)}catch(s){d.error(s.response?.data?.message??"Failed to load license")}finally{p(!1)}},[a]);l.useEffect(()=>{o()},[o]);const L=async s=>{h(s);try{await b.post(`/customer/licenses/${a}/deactivate-device`,{activation_id:s}),d.success("Device deactivated"),o()}catch(R){d.error(R.response?.data?.message??"Deactivation failed")}finally{h(null)}},S=()=>{t?.license_key&&(navigator.clipboard.writeText(t.license_key),j(!0),d.success("License key copied!"),setTimeout(()=>j(!1),2e3))};if(i)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(N,{className:"w-8 h-8 animate-spin text-violet-500"})});if(!t)return e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-20 text-center",children:[e.jsx(m,{className:"w-10 h-10 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500",children:"License not found."}),e.jsx(y,{to:"/licenses",className:"mt-4 inline-block text-violet-600 hover:underline text-sm",children:"â Back to My Licenses"})]});const D=t.license_key?t.license_key.slice(0,4)+"-****-****-"+t.license_key.slice(-4):"????-????-????-????",r=t.activations??[],g=r.filter(s=>s.is_active).length,P=t.activation_limit??t.license_product?.max_activations_default??"â";return e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs(y,{to:"/licenses",className:"inline-flex items-center gap-1.5 text-sm text-slate-500 hover:text-violet-600",children:[e.jsx(I,{className:"w-4 h-4"})," My Licenses"]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[t.product?.image_url&&e.jsx("img",{src:t.product.image_url,alt:"",className:"w-14 h-14 rounded-xl object-cover shrink-0"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900",children:t.license_product?.name??"Software License"}),e.jsxs("p",{className:"text-sm text-gray-400 capitalize mt-0.5",children:[t.license_type," · ",t.platform??"Any platform"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{license:t}),e.jsx("button",{onClick:o,className:"p-1.5 rounded-lg text-slate-400 hover:bg-slate-100",children:e.jsx(T,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-xl px-4 py-3 font-mono text-sm mb-5",children:[e.jsx(m,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-gray-800 select-all",children:f?t.license_key:D}),e.jsx("button",{onClick:()=>C(s=>!s),className:"text-xs text-gray-400 hover:text-gray-600 px-1.5 whitespace-nowrap",children:f?"Hide":"Reveal"}),e.jsx("button",{onClick:S,className:`text-xs font-medium px-3 py-1.5 rounded-lg transition-colors ${v?"bg-green-100 text-green-700":"bg-violet-100 text-violet-700 hover:bg-violet-200"}`,children:v?"Copied!":"Copy"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 text-center",children:[e.jsx(x,{icon:e.jsx(w,{className:"w-4 h-4"}),label:"Devices",value:`${g} / ${P}`}),e.jsx(x,{icon:e.jsx(E,{className:"w-4 h-4"}),label:"Expires",value:t.license_type==="lifetime"?"â Lifetime":c(t.expires_at)}),e.jsx(x,{icon:e.jsx(M,{className:"w-4 h-4"}),label:"Last Verified",value:c(t.offline_verified_at??t.last_verified_at),small:!0}),e.jsx(x,{icon:e.jsx(m,{className:"w-4 h-4"}),label:"Issued",value:c(t.created_at),small:!0})]}),t.status==="suspended"&&e.jsxs("div",{className:"mt-4 flex items-start gap-2 text-sm text-orange-700 bg-orange-50 rounded-xl px-4 py-3",children:[e.jsx(_,{className:"w-4 h-4 mt-0.5 shrink-0"}),"This license has been suspended. Please contact support for assistance."]}),t.is_suspected&&e.jsxs("div",{className:"mt-4 flex items-start gap-2 text-sm text-amber-700 bg-amber-50 rounded-xl px-4 py-3",children:[e.jsx(_,{className:"w-4 h-4 mt-0.5 shrink-0"}
1),"Suspicious activity was detected on this license. If this wasn't you, contact support immediately."]})]}),t.license_type==="lifetime"&&e.jsx("div",{className:"bg-blue-50 rounded-2xl border border-blue-100 p-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-100 flex items-center justify-center shrink-0 text-blue-600",children:e.jsx(K,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900 mb-1",children:"Transferring to a new PC?"}),e.jsxs("p",{className:"text-xs text-blue-700 leading-relaxed",children:["Your lifetime licence can be moved to any PC at any time â no extra cost, no support ticket needed. Simply ",e.jsx("strong",{children:"Deactivate"})," the old machine below, then run PULSAR on the new PC and enter your licence key to activate it. The key in the box above is yours forever."]})]})]})}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-900 mb-4",children:["Active Devices",e.jsxs("span",{className:"ml-2 text-sm font-normal text-slate-400",children:["(",g,")"]})]}),r.filter(s=>s.is_active).length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(w,{className:"w-8 h-8 text-slate-200 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No active devices"})]}):e.jsx("div",{className:"space-y-3",children:r.filter(s=>s.is_active).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-slate-100 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(k,{p:s.platform}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-800 truncate",children:s.hostname??"Unknown device"}),e.jsxs("p",{className:"text-xs text-slate-400 truncate",children:[s.os_info&&e.jsxs("span",{children:[s.os_info," · "]}),e.jsx(A,{className:"w-3 h-3 inline mr-0.5"}),s.ip_address??"â",s.country_code?` (${s.country_code})`:""]}),e.jsxs("p",{className:"text-xs text-slate-400",children:["Activated ",c(s.activated_at),s.last_verified_at&&e.jsxs("span",{children:[" · Verified ",c(s.last_verified_at)]})]})]})]}),e.jsxs("button",{onClick:()=>L(s.id),disabled:u===s.id,title:"Deactivate this device",className:"flex items-center gap-1.5 text-xs font-medium text-red-500 hover:text-red-700 hover:bg-red-50 px-3 py-1.5 rounded-lg transition-colors disabled:opacity-50 shrink-0",children:[u===s.id?e.jsx(N,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(U,{className:"w-3.5 h-3.5"}),"Deactivate"]})]},s.id))})]}),r.filter(s=>!s.is_active).length>0&&e.jsx(O,{activations:r.filter(s=>!s.is_active)})]})}function x({icon:a,label:t,value:n,small:i}){return e.jsxs("div",{className:"bg-gray-50 rounded-xl py-3 px-2",children:[e.jsx("div",{className:"flex justify-center text-slate-400 mb-1",children:a}),e.jsx("p",{className:`font-semibold text-gray-800 ${i?"text-xs":"text-sm"} leading-tight`,children:n}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:t})]})}function O({activations:a}){const[t,n]=l.useState(!1);return e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100",children:[e.jsxs("button",{onClick:()=>n(i=>!i),className:"w-full flex items-center justify-between px-6 py-4 text-sm font-medium text-slate-500 hover:text-slate-700",children:[e.jsxs("span",{children:["Inactive / Deactivated Devices (",a.length,")"]}),e.jsx("span",{className:"text-xs",children:t?"â²":"â¼"})]}),t&&e.jsx("div",{className:"px-6 pb-5 space-y-2 border-t border-slate-50",children:a.map(i=>e.jsxs("div",{className:"flex items-center gap-3 py-2.5 opacity-60",children:[e.jsx(k,{p:i.platform}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-600 truncate",children:i.hostname??"Unknown device"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Deactivated"})]})]},i.id))})]})}export{Z 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.