1import{aL as z,cK as R,r as n,j as e,L as M,cL as U,cM as V,cN as B,aN as $,cO as F,cP as A}from"./main-Bo0oayNO.js";function _(){const a=z(),{slug:s}=R.useParams(),{details:r,installStatus:x,ratingBreakdown:i,reviewsData:d,userReview:c,session:j}=R.useLoaderData(),[b,u]=n.useState(!1),[N,w]=n.useState(r.latestVersion),[h,k]=n.useState("overview"),[y,p]=n.useState(d.reviews),[o,v]=n.useState(1),[C,m]=n.useState(!1),L=async()=>{u(!0);try{const t=await $({data:{slug:s,type:r.type,version:N}});t.success?a.invalidate():alert(t.error||"Installation failed")}catch(t){console.error("Installation error:",t),alert("Installation failed")}finally{u(!1)}},l=async()=>{if(confirm(`Are you sure you want to uninstall ${r.name}?`)){u(!0);try{const t=await B({data:{packageId:s,type:r.type}});t.success?a.invalidate():alert(t.error||"Uninstallation failed")}catch(t){console.error("Uninstallation error:",t),alert("Uninstallation failed")}finally{u(!1)}}},g=t=>new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric"}).format(new Date(t));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("nav",{className:"flex items-center gap-2 text-sm text-foreground-muted",children:[e.jsx(M,{to:"/admin/marketplace",search:{q:"",type:void 0,tag:void 0,page:1},className:"hover:text-primary",children:"Marketplace"}),e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-foreground",children:r.name})]}),e.jsxs("div",{className:"bg-background rounded-theme shadow-xs border border-border p-6",children:[e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-theme bg-background-alt flex items-center justify-center flex-shrink-0",children:r.iconUrl?e.jsx("img",{src:r.iconUrl,alt:"",className:"w-16 h-16 rounded-sm"}):e.jsx("svg",{className:"w-10 h-10 text-foreground-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.type==="plugin"?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"}):e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground font-heading",children:r.name}),r.isVerified&&e.jsx("svg",{className:"w-6 h-6 text-primary",fill:"currentColor",viewBox:"0 0 20 20","aria-label":"Verified",children:e.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})]}),e.jsx("p",{className:"text-foreground-muted mt-2",children:r.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-4 text-sm text-foreground-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})}),r.author.name]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4 text-yellow-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),r.averageRating.toFixed(1)," (",r.reviewCount," reviews)"]}
1),e.jsxs("span",{children:[r.downloadCount.toLocaleString()," downloads"]}),e.jsx("span",{className:"capitalize",children:r.type})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:x.isInstalled?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"px-4 py-2 text-sm text-center text-green-600 bg-green-100 rounded-theme",children:["Installed v",x.installedVersion]}),e.jsx("button",{onClick:l,disabled:b,className:"px-4 py-2 text-sm font-medium rounded-theme border border-red-500 text-red-500 hover:bg-red-50 disabled:opacity-50 transition-colors",children:b?"...":"Uninstall"})]}):e.jsxs(e.Fragment,{children:[e.jsx("select",{value:N,onChange:t=>w(t.target.value),className:"px-3 py-2 text-sm border border-border rounded-theme bg-background text-foreground",children:r.versions.map(t=>e.jsxs("option",{value:t.version,children:["v",t.version]},t.version))}),e.jsx("button",{onClick:L,disabled:b,className:"px-6 py-2 font-medium rounded-theme bg-primary text-white hover:bg-primary-dark disabled:opacity-50 transition-colors",children:b?"Installing...":r.isPremium&&r.price?`Buy $${(r.price/100).toFixed(2)}`:"Install"})]})})]}),r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-4 pt-4 border-t border-border",children:r.tags.map(t=>e.jsx(M,{to:"/admin/marketplace",search:{q:"",type:void 0,tag:t,page:1},className:"px-2 py-1 text-xs rounded-full bg-background-alt text-foreground-muted hover:bg-border transition-colors",children:t},t))})]}),e.jsx("div",{className:"border-b border-border",children:e.jsx("nav",{className:"flex gap-4",children:["overview","versions","reviews"].map(t=>e.jsxs("button",{onClick:()=>k(t),className:`px-4 py-3 text-sm font-medium border-b-2 -mb-px transition-colors ${h===t?"border-primary text-primary":"border-transparent text-foreground-muted hover:text-foreground"}`,children:[t.charAt(0).toUpperCase()+t.slice(1),t==="reviews"&&` (${r.reviewCount})`]},t))})}),e.jsxs("div",{className:"bg-background rounded-theme shadow-xs border border-border p-6",children:[h==="overview"&&e.jsxs("div",{className:"prose prose-sm max-w-none",children:[r.readme?e.jsx("div",{dangerouslySetInnerHTML:{__html:r.readme}}):e.jsx("p",{className:"text-foreground-muted",children:"No detailed description available."}),r.screenshots.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Screenshots"}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:r.screenshots.map((t,f)=>e.jsx("img",{src:t,alt:`Screenshot ${f+1}`,className:"rounded-theme border border-border"},f))})]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[r.homepage&&e.jsx("a",{href:r.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary-dark",children:"Homepage"}),r.repositoryUrl&&e.jsx("a",{href:r.repositoryUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary-dark",children:"Repository"})]})]}),h==="versions"&&e.jsx("div",{className:"space-y-4",children:r.versions.map(t=>e.jsx(D,{version:t,formatDate:g},t.version))}),h==="reviews"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{breakdown:i}),e.jsx(H,{slug:s,existingReview:c,session:j,latestVersion:r.latestVersion,onReviewSubmitted:t=>{p(f=>{const S=f.filter(P=>P.userId!==t.userId);return[t,...S]}),a.invalidate()},onReviewDeleted:()=>{a.invalidate()}}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground",children:["Reviews (",d.total,")"]}),y.length>0?e.jsxs(e.Fragment,{children:[y.map(t=>e.jsx(T,{review:t,formatDate:g,currentUserId:j?.id,onHelpful:async f=>{const S=await U({data:f});S.success&&p(P=>P.map(I=>I.id===f?{...I,helpfulCount:S.helpfulCount}:I))}},t.id)),d.totalPages>1&&e.jsxs("div",{className:"flex justify-center gap-2 pt-4",children:[e.jsx("button",{onClick:async()=>{if(o>1){m(!0);const t=await V({data:{packageId:s,page:o-1,perPage:10}});p(t.reviews),v(o-1),m(!1)}},disabled:o<=1||C,className:"px-3 py-1 text-sm rounded-theme border border-border hover:bg-background-alt disabled:opacity-50",children:"Previous"}),e.jsxs("span",{className:"px-3 py-1 text-sm text-foreground-muted",children:["Page ",o," of ",d.totalPages]}),e.jsx("button",{onClick:async()=>
1{if(o<d.totalPages){m(!0);const t=await V({data:{packageId:s,page:o+1,perPage:10}});p(t.reviews),v(o+1),m(!1)}},disabled:o>=d.totalPages||C,className:"px-3 py-1 text-sm rounded-theme border border-border hover:bg-background-alt disabled:opacity-50",children:"Next"})]})]}):e.jsx("p",{className:"text-foreground-muted text-center py-8",children:"No reviews yet. Be the first to review!"})]})]})]})]})}function D({version:a,formatDate:s}){return e.jsxs("div",{className:"border border-border rounded-theme p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"font-semibold text-foreground",children:["v",a.version]}),e.jsx("span",{className:"text-sm text-foreground-muted",children:s(a.releasedAt)})]}),a.changelog&&e.jsx("p",{className:"text-sm text-foreground-muted whitespace-pre-wrap",children:a.changelog})]})}function E({breakdown:a}){return e.jsx("div",{className:"border border-border rounded-theme p-6",children:e.jsxs("div",{className:"flex items-start gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-5xl font-bold text-foreground",children:a.average.toFixed(1)}),e.jsx("div",{className:"flex gap-0.5 justify-center mt-2",children:[1,2,3,4,5].map(s=>e.jsx("svg",{className:`w-5 h-5 ${s<=Math.round(a.average)?"text-yellow-500":"text-gray-300"}`,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})},s))}),e.jsxs("div",{className:"text-sm text-foreground-muted mt-1",children:[a.total," reviews"]})]}),e.jsx("div",{className:"flex-1 space-y-2",children:a.breakdown.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-foreground-muted w-12",children:[s.rating," star"]}),e.jsx("div",{className:"flex-1 h-2 bg-background-alt rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-yellow-500 transition-all",style:{width:`${s.percentage}%`}})}),e.jsx("span",{className:"text-sm text-foreground-muted w-12 text-right",children:s.count})]},s.rating))})]})})}function H({slug:a,existingReview:s,session:r,latestVersion:x,onReviewSubmitted:i,onReviewDeleted:d}){const[c,j]=n.useState(s?.rating||0),[b,u]=n.useState(0),[N,w]=n.useState(s?.title||""),[h,k]=n.useState(s?.content||""),[y,p]=n.useState(!1),[o,v]=n.useState(null),[C,m]=n.useState(!s);if(!r)return e.jsx("div",{className:"border border-border rounded-theme p-6 text-center",children:e.jsxs("p",{className:"text-foreground-muted",children:[e.jsx(M,{to:"/login",className:"text-primary hover:text-primary-dark",children:"Log in"})," ","to write a review"]})});if(s&&!C)return e.jsxs("div",{className:"border border-border rounded-theme p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Review"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>m(!0),className:"text-sm text-primary hover:text-primary-dark",children:"Edit"}),e.jsx("button",{onClick:async()=>{confirm("Are you sure you want to delete your review?")&&(await F({data:s.id})).success&&d()},className:"text-sm text-red-500 hover:text-red-600",children:"Delete"})]})]}),e.jsx("div",{className:"flex gap-0.5 mb-2",children:[1,2,3,4,5].map(l=>e.jsx("svg",{className:`w-5 h-5 ${l<=s.rating?"text-yellow-500":"text-gray-300"}`,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})},l))}),s.title&&e.jsx("h4",{className:"font-medium text-foreground",children:s.title}),s.content&&e.jsx("p",{className:"text-foreground-muted mt-1",children:s.content}),s.isVerifiedPurchase&&e.jsx("span",{className:"inline-block mt-2 text-xs text-green-600 bg-green-100 px-2 py-0.5 rounded-sm",children:"Verified Installation"})]});const L=async l=>{if(l.preventDefault(),c===0){v("Please select a rating");return}p(!0),v(null);const g=await A({data:{slug:a,rating:c,title:N||void 0,content:h||void 0,version:x}});p(!1),g.success&&g.review?(i(g.review),m(!1)):v(g.error||"Failed to submit review")};return e.jsxs("div",{className:"border border-border rounded-theme p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:s?"Edit Your Review":"Write a Review"}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",onClick:()=>j(l),onMouseEnter:()=>u(l),onMouseLeave:()=>u(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx("svg",{className:`w-8 h-8 ${l<=(b||c)?"text-yellow-500":"text-gray-300"}
1`,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})})},l))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"review-title",className:"block text-sm font-medium text-foreground mb-1",children:"Title (optional)"}),e.jsx("input",{id:"review-title",type:"text",value:N,onChange:l=>w(l.target.value),placeholder:"Summarize your experience",className:"w-full px-3 py-2 border border-border rounded-theme bg-background text-foreground placeholder:text-foreground-muted focus:outline-hidden focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"review-content",className:"block text-sm font-medium text-foreground mb-1",children:"Review (optional)"}),e.jsx("textarea",{id:"review-content",value:h,onChange:l=>k(l.target.value),placeholder:"Share your experience with this package...",rows:4,className:"w-full px-3 py-2 border border-border rounded-theme bg-background text-foreground placeholder:text-foreground-muted focus:outline-hidden focus:ring-2 focus:ring-primary resize-none"})]}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:y,className:"px-4 py-2 font-medium rounded-theme bg-primary text-white hover:bg-primary-dark disabled:opacity-50 transition-colors",children:y?"Submitting...":s?"Update Review":"Submit Review"}),s&&e.jsx("button",{type:"button",onClick:()=>{j(s.rating),w(s.title||""),k(s.content||""),m(!1)},className:"px-4 py-2 font-medium rounded-theme border border-border text-foreground hover:bg-background-alt transition-colors",children:"Cancel"})]})]})]})}
1function T({review:a,formatDate:s,currentUserId:r,onHelpful:x}){const[i,d]=n.useState(!1);return e.jsx("div",{className:"border border-border rounded-theme p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-background-alt flex items-center justify-center flex-shrink-0",children:a.userAvatar?e.jsx("img",{src:a.userAvatar,alt:"",className:"w-10 h-10 rounded-full"}):e.jsx("span",{className:"text-lg font-medium text-foreground-muted",children:a.userName.charAt(0).toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[e.jsx("span",{className:"font-medium text-foreground",children:a.userName}),e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(c=>e.jsx("svg",{className:`w-4 h-4 ${c<=a.rating?"text-yellow-500":"text-gray-300"}`,fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})},c))}),a.isVerifiedPurchase&&e.jsx("span",{className:"text-xs text-green-600 bg-green-100 px-2 py-0.5 rounded-sm",children:"Verified"}),e.jsx("span",{className:"text-sm text-foreground-muted",children:s(a.createdAt)})]}),a.title&&e.jsx("h4",{className:"font-medium text-foreground mt-1",children:a.title}),a.content&&e.jsx("p",{className:"text-sm text-foreground-muted mt-1 whitespace-pre-wrap",children:a.content}),a.version&&e.jsxs("p",{className:"text-xs text-foreground-muted mt-2",children:["Reviewed version: ",a.version]}),x&&a.userId!==r&&e.jsx("div",{className:"mt-3 pt-3 border-t border-border",children:e.jsx("button",{onClick:()=>{i||(x(a.id),d(!0))},disabled:i,className:`text-sm ${i?"text-foreground-muted cursor-default":"text-primary hover:text-primary-dark"}`,children:i?"Thanks for your feedback!":`Helpful (${a.helpfulCount})`})})]})]})})}export{_ as component};
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.