1import{r,e as x,t as n,j as e,P as L,h}from"./edge-BOITG1XR.js";import{P as R}from"./mod-BHbsKpbp.js";import{P as E}from"./mod-BVSlmYWv.js";import{L as v}from"./mod-DxqX0N6D.js";import{S as D}from"./mod-DwTpsUP4.js";import{T as M}from"./mod-BuHkwEt_.js";import{X as $}from"./mod-C3kaoPgB.js";import{S as G}from"./mod-C9xhOiHj.js";const z=({active:c})=>e.jsx("span",{className:h("rounded-full px-2 py-0.5 text-xs font-semibold",c?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-500"),children:c?"Active":"Inactive"}),w={name:"",slug:"",description:"",platform:"windows",license_type:"normal",max_activations_default:1,offline_grace_days:90,verify_interval_days:90,trial_enabled:!1,trial_days:14,trial_max_activations:1,trial_require_email_otp:!0,is_active:!0,generate_rsa:!1};function H(){const[c,_]=r.useState([]),[k,b]=r.useState(!0),[i,m]=r.useState(null),[t,u]=r.useState(w),[f,g]=r.useState(!1),[j,y]=r.useState(null),d=r.useCallback(async()=>{b(!0);try{const s=await x.get("/admin/digilicense/products");_(s.data?.data??s.data??[])}catch{n.error("Failed to load products")}finally{b(!1)}},[]);r.useEffect(()=>{d()},[d]);const N=()=>{u(w),m("create")},C=s=>{u({...s,generate_rsa:!1}),m(s)},p=()=>m(null),l=s=>a=>u(o=>({...o,[s]:a.target.type==="checkbox"?a.target.checked:a.target.value})),S=async()=>{g(!0);try{i==="create"?(await x.post("/admin/digilicense/products",t),n.success("Product created")):(await x.put(`/admin/digilicense/products/${i.id}`,t),n.success("Product updated")),p(),d()}catch(s){n.error(s.response?.data?.message??"Save failed")}finally{g(!1)}},P=async s=>{if(confirm("Generate new RSA key pair? This will replace any existing keys.")){y(s);try{await x.post(`/admin/digilicense/products/${s}/generate-rsa`,{force:!0}),n.success("RSA key pair generated"),d()}catch(a){n.error(a.response?.data?.message??"RSA generation failed")}finally{y(null)}}},A=async(s,a)=>{if(confirm(`Delete product "${a}"? This cannot be undone.`))try{await x.delete(`/admin/digilicense/products/${s}`),n.success("Product deleted"),d()}catch(o){n.error(o.response?.data?.message??"Delete failed")}};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:"License Products"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Software products with license configuration"})]}),e.jsxs("button",{onClick:N,className:"flex items-center gap-2 rounded-xl bg-blue-600 text-white px-4 py-2 text-sm font-medium hover:bg-blue-700 transition-colors",children:[e.jsx(R,{className:"h-4 w-4"})," New Product"]})]}),k?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,a)=>e.jsx("div",{className:"h-20 rounded-2xl bg-slate-100 animate-pulse"},a))}):c.length===0?e.jsxs("div",{className:"rounded-2xl bg-white border border-slate-100 p-12 text-center",children:[e.jsx(L,{className:"h-10 w-10 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-500",children:"No license products yet."}),e.jsx("button",{onClick:N,className:"mt-3 text-sm text-blue-600 underline",children:"Create one"})]}):e.jsx("div",{className:"rounded-2xl bg-white border border-slate-100 shadow-sm overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-100",children:e.jsx("tr",{children:["Product","Platform","Type","Max Act.","Trial","RSA","Status",""].map(s=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wide",children:s},s))})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:c.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50/50",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"font-medium text-slate-800",children:s.name}),e.jsx("p",{className:"text-xs text-slate-400",children:s.slug})]}),e.jsx("td",{className:"px-4 py-3 text-slate-600 capitalize",children:s.platform}),e.jsx("td",{className:"px-4 py-3 text-slate-600 capitalize",children:s.license_type}),e.jsx("td",{className:"px-4 py-3 text-slate-600",children:s.max_activations_default}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:h("text-xs font-medium",s.trial_enabled?"text-emerald-600":"text-slate-400"),children:s.trial_enabled?`${s.trial_days}d`:"No"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:h("text-xs font-medium",s.rsa_public_key?"text-emerald-600":"text-slate-400"),children:s.rsa_public_key?"â Set":"None"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(z,{active:s.is_active})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>C(s),className:"rounded-lg p-1.5 hover:bg-slate-100 text-slate-500",title:"Edit",children:e.jsx(E,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>P(s.id),disabled:j===s.id,className:"rounded-lg p-1.5 hover:bg-blue-50 text-blue-500",title:"Generate RSA keys",children:j===s.id?e.jsx(v,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(D,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>A(s.id,s.name),className:"rounded-lg p-1.5 hover:bg-rose-50 text-rose-400",title:"Delete",children:e.jsx(M,{className:"h-3.5 w-3.5"})})]})})]},s.id))})]})}),i!==null&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl bg-white shadow-xl overflow-y-auto max-h-[90vh]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 px-6 py-4",children:[e.jsx("h2",{className:"font-semibold text-slate-800",children:i==="create"?"New License Product":`Edit: ${i.name}`}),e.jsx("button",{onClick:p,children:e.jsx($,{className:"h-5 w-5 text-slate-400"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[[{label:"Name",key:"name",type:"text",placeholder:"TurboMTA Pro"},{label:"Slug",key:"slug",type:"text",placeholder:"turbomta-pro"},{label:"Description",key:"description",type:"text",placeholder:"Optional"}].map(({label:s,key:a,type:o,placeholder:T})=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:s}),e.jsx("input",{type:o,value:t[a]??"",onChange:l(a),placeholder:T,className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]},a)),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"Platform"}),e.jsx("select",{value:t.platform,onChange:l("platform"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:["windows","linux","macos","web","android","ios","cross"].map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"License Type"}
1),e.jsx("select",{value:t.license_type,onChange:l("license_type"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:["normal","rsa","advanced"].map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"Max Activations"}),e.jsx("input",{type:"number",min:"1",value:t.max_activations_default,onChange:l("max_activations_default"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"Grace Days"}),e.jsx("input",{type:"number",min:"0",value:t.offline_grace_days,onChange:l("offline_grace_days"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-4 pt-1",children:[{key:"trial_enabled",label:"Enable Trial"},{key:"is_active",label:"Active"},...i==="create"?[{key:"generate_rsa",label:"Generate RSA Keys"}]:[]].map(({key:s,label:a})=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!t[s],onChange:l(s),className:"h-4 w-4 rounded"}),e.jsx("span",{className:"text-sm text-slate-700",children:a})]},s))}),t.trial_enabled&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"Trial Days"}),e.jsx("input",{type:"number",min:"1",value:t.trial_days,onChange:l("trial_days"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600",children:"Trial Max Activations"}),e.jsx("input",{type:"number",min:"1",value:t.trial_max_activations,onChange:l("trial_max_activations"),className:"mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 border-t border-slate-100 px-6 py-4",children:[e.jsx("button",{onClick:p,className:"rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-600 hover:bg-slate-50",children:"Cancel"}),e.jsxs("button",{onClick:S,disabled:f,className:"flex items-center gap-2 rounded-xl bg-blue-600 text-white px-4 py-2 text-sm font-medium hover:bg-blue-700 disabled:opacity-60",children:[f?e.jsx(v,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"}),i==="create"?"Create":"Save"]})]})]})})]})}export{H 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.