1import{r as f,Y as B,Z as G,Q as H,j as e,a as _,F as X,_ as z,$ as U,c as D,J as q,L as P}from"./index-D5v3HSjQ.js";import{a as J,u as L,d as Q}from"./outfitsClient-CbTqGp-A.js";import{u as Z}from"./AuthContext-C60EG9N9.js";import{u as K}from"./Toast-CMNMxlmA.js";import{P as T}from"./plus-BpytYkJ2.js";import{P as ee}from"./palette-Ds6NyIXN.js";import{P as te}from"./pen-line-hFYYJ2IP.js";import"./circle-alert-CH3PcJoa.js";import"./x-DNs9DRNX.js";const W=f.createContext(null);function se(t,l,s,o){if(!o)return t;const r=t.findIndex(y=>y.value===l);if(r===-1)return t;const d=o>0?1:-1,c=t[r+d];if(!c)return t;const u=t[r],i=c.layout,a=B(i.min,i.max,.5);return d===1&&u.layout.max+s>a||d===-1&&u.layout.min+s<a?G(t,r,r+d):t}function re({children:t,as:l="ul",axis:s="y",onReorder:o,values:r,...d},c){const u=H(()=>_[l]),i=[],a=f.useRef(!1),y=f.useRef(null),m={axis:s,groupRef:y,registerItem:(g,j)=>{const v=i.findIndex(x=>g===x.value);v!==-1?i[v].layout=j[s]:i.push({value:g,layout:j[s]}),i.sort(oe)},updateOrder:(g,j,v)=>{if(a.current)return;const x=se(i,g,j,v);if(i!==x){a.current=!0;const h=[...r];for(let p=0;p<x.length;p++)if(i[p].value!==x[p].value){const k=r.indexOf(i[p].value),n=r.indexOf(x[p].value);k!==-1&&n!==-1&&([h[k],h[n]]=[h[n],h[k]]);break}o(h)}}};f.useEffect(()=>{a.current=!1});const N=g=>{y.current=g,typeof c=="function"?c(g):c&&(c.current=g)},b={overflowAnchor:"none",...d.style};return e.jsx(u,{...d,style:b,ref:N,ignoreStrict:!0,children:e.jsx(W.Provider,{value:m,children:t})})}const ne=f.forwardRef(re);function oe(t,l){return t.layout.min-l.layout.min}const I=50,V=25,le=new Set(["auto","scroll"]),M=new WeakMap,E=new WeakMap;let R=null;function ie(){if(R){const t=O(R,"y");t&&(E.delete(t),M.delete(t));const l=O(R,"x");l&&l!==t&&(E.delete(l),M.delete(l)),R=null}}function ce(t,l){const s=getComputedStyle(t),o=l==="x"?s.overflowX:s.overflowY,r=t===document.body||t===document.documentElement;return le.has(o)||r}function O(t,l){let s=t?.parentElement;for(;s;){if(ce(s,l))return s;s=s.parentElement}return null}function ae(t,l,s){const o=l.getBoundingClientRect(),r=s==="x"?Math.max(0,o.left):Math.max(0,o.top),d=s==="x"?Math.min(window.innerWidth,o.right):Math.min(window.innerHeight,o.bottom),c=t-r,u=d-t;if(c<I){const i=1-c/I;return{amount:-V*i*i,edge:"start"}}else if(u<I){const i=1-u/I;return{amount:V*i*i,edge:"end"}}return{amount:0,edge:null}}function de(t,l,s,o){if(!t)return;R=t;const r=O(t,s);if(!r)return;const d=l-(s==="x"?window.scrollX:window.scrollY),{amount:c,edge:u}=ae(d,r,s);if(u===null){E.delete(r),M.delete(r);return}const i=E.get(r),a=r===document.body||r===document.documentElement;if(i!==u){if(!(u==="start"&&o<0||u==="end"&&o>0))return;E.set(r,u);const m=s==="x"?r.scrollWidth-(a?window.innerWidth:r.clientWidth):r.scrollHeight-(a?window.innerHeight:r.clientHeight);M.set(r,m)}if(c>0){const y=M.get(r);if((s==="x"?a?window.scrollX:r.scrollLeft:a?window.scrollY:r.scrollTop)>=y)return}s==="x"?a?window.scrollBy({left:c}):r.scrollLeft+=c:a?window.scrollBy({top:c}):r.scrollTop+=c}function $(t,l=0){return U(t)?t:z(l)}function ue({children:t,style:l={},value:s,as:o="li",onDrag:r,onDragEnd:d,layout:c=!0,...u},i){const a=H(()=>_[o]),y=f.useContext(W),m={x:$(l.x),y:$(l.y)},N=X([m.x,m.y],([x,h])=>x||h?1:"unset"),{axis:b,registerItem:g,updateOrder:j,groupRef:v}=y;return e.jsx(a,{drag:b,...u,dragSnapToOrigin:!0,style:{...l,x:m.x,y:m.y,zIndex:N},layout:c,onDrag:(x,h)=>{const{velocity:p,point:k}=h,n=m[b].get();j(s,n,p[b]),de(v.current,k[b],b,p[b]),r&&r(x,h)},onDragEnd:(x,h)=>{ie(),d&&d(x,h)},onLayoutMeasure:x=>{g(s,x)},ref:i,ignoreStrict:!0,children:t})}const me=f.forwardRef(ue);const xe=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],he=D("eye-off",xe);const pe=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],fe=D("eye",pe);const ye=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],be=D("grip-vertical",ye);const ge=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],we=D("trash-2",ge),Ie=()=>{const{user:t}
1=Z(),l=q(),s=K(),[o,r]=f.useState(null),[d,c]=f.useState(null),[u,i]=f.useState(null),[a,y]=f.useState("all"),[m,N]=f.useState("all"),b=async()=>{try{const n=await J();r(n),c(null)}catch(n){c(n.message),s(n.message,"error")}};f.useEffect(()=>{b()},[]);const g=async n=>{try{await L(n.id,{published:!n.published}),s(n.published?"Set to draft.":"Published.","success"),b()}catch(w){s(w.message,"error")}},j=async n=>{i(null);try{await Q(n.id),s(`"${n.name}" deleted.`,"success"),b()}catch(w){s(w.message,"error")}},v=async n=>{r(w=>{const S=[...w];let Y=0;for(let A=0;A<S.length;A++)x(S[A])&&(S[A]=n[Y++]);return S});try{await Promise.all(n.map((w,S)=>L(w.id,{sort_order:S}))),s("Order saved.","success")}catch{s("Could not save order.","error")}},x=n=>!(a!=="all"&&n.model_slug!==a||m==="published"&&!n.published||m==="draft"&&n.published),h=f.useMemo(()=>o?[...new Set(o.map(n=>n.model_slug))]:[],[o]),p=f.useMemo(()=>o?o.filter(x):[],[o,a,m]),k=a!=="all"||m!=="all";return e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-12",children:[e.jsxs(_.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.5},className:"flex items-end justify-between flex-wrap gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"w-8 h-px bg-sophey-cream/30"}),e.jsx("span",{className:"text-[10px] tracking-[0.3em] uppercase text-sophey-cream/40 font-medium",children:"Dashboard"})]}),e.jsx("h1",{className:"font-display font-bold text-sophey-cream tracking-[-0.04em] text-4xl md:text-5xl",children:t?.role==="admin"?"All outfits.":"Your outfits."}),o&&e.jsxs("p",{className:"text-sm text-sophey-cream/40 mt-2",children:[p.length," / ",o.length," entr",o.length!==1?"ies":"y"]})]}),e.jsxs(P,{to:"/outfits/manage/upload",className:"inline-flex items-center gap-2 px-5 py-2.5 bg-sophey-cream text-sophey-ink text-sm font-semibold hover:opacity-85 transition-opacity",style:{borderRadius:"2px"},children:[e.jsx(T,{className:"w-4 h-4"})," New outfit"]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex items-center gap-6 mb-8 pb-4 border-b border-white/8 flex-wrap",children:[h.length>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(C,{active:a==="all",onClick:()=>y("all"),children:"All"}),h.map(n=>e.jsx(C,{active:a===n,onClick:()=>y(n),children:n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(C,{active:m==="all",onClick:()=>N("all"),children:"All"}),e.jsx(C,{active:m==="published",onClick:()=>N("published"),children:"Published"}),e.jsx(C,{active:m==="draft",onClick:()=>N("draft"),children:"Draft"})]})]}),d&&e.jsx("div",{className:"mb-6 text-xs text-red-300/90 border border-red-400/30 bg-red-400/5 px-3 py-2",style:{borderRadius:"2px"},children:d}),o===null?e.jsx("div",{className:"py-20 flex justify-center",children:e.jsx("div",{className:"w-6 h-6 border border-white/30 border-t-white/80 rounded-full animate-spin"})}):o.length===0?e.jsxs("div",{className:"border border-white/8 py-20 px-6 text-center",style:{borderRadius:"2px"},children:[e.jsx("p",{className:"font-display text-2xl text-sophey-cream/25 tracking-[-0.02em] mb-2",children:"Nothing here yet."}),e.jsx("p",{className:"text-xs text-sophey-cream/30 mb-6",children:"Upload your first outfit to get started."}),e.jsxs(P,{to:"/outfits/manage/upload",className:"inline-flex items-center gap-2 px-4 py-2 border border-white/15 text-sm hover:border-white/30 transition-colors",style:{borderRadius:"2px"},children:[e.jsx(T,{className:"w-3.5 h-3.5"})," Upload outfit"]})]}):p.length===0?e.jsx("div",{className:"border border-white/8 py-16 px-6 text-center",style:{borderRadius:"2px"},children:e.jsx("p",{className:"text-sophey-cream/30 text-sm",children:"No outfits match this filter."})}):e.jsx(ne,{axis:"y",values:p,onReorder:v,className:"flex flex-col gap-3",as:"div",children:p.map((n,w)=>e.jsx(me,{value:n,as:"div",style:{borderRadius:"2px"},children:e.jsx(je,{outfit:n,index:w,onEdit:()=>l(`/outfits/manage/edit/${n.id}`),onTogglePublish:()=>g(n),onDeleteRequest:()=>i(n.id),onDeleteConfirm:()=>j(n),onDeleteCancel:()=>i(null),confirmDelete:u===n.id})},n.id))}),k&&o&&o.length>0&&p.length>0&&e.jsx("p",{className:"text-[11px] text-sophey-cream/25 mt-4 text-center",children:"Drag to reorder â applies within current filter."})]})},C=({active:t,onClick:l,children:s})=>e.jsxs("button",{onClick:l,className:"relative px-3 py-1.5 text-xs font-medium transition-colors",style:{color:t?"#F5F1E8":"rgba(245,241,232,0.35)"},children:[s,t&&e.jsx(_.span,{layoutId:"filter-underline",className:"absolute bottom-0 inset-x-3 h-px bg-sophey-cream/60"})]}),je=({outfit:t,index:l,onEdit:s,onTogglePublish:o,onDeleteRequest:r,onDeleteConfirm:d,onDeleteCancel:c,confirmDelete:u})=>e.jsxs("div",{className:"flex items-center gap-4 border border-white/8 bg-white/[0.02] group/row cursor-grab active:cursor-grabbing",style:{borderRadius:"2px",opacity:t.published?1:.6},children:[e.jsx("div",{className:"pl-3 py-4 text-sophey-cream/20 group-hover/row:text-sophey-cream/40 transition-colors flex-shrink-0",children:e.jsx(be,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative flex-shrink-0 bg-white/5 overflow-hidden",style:{width:56,height:56,borderRadius:"2px"},children:t.poster_url?e.jsx("img",{src:t.poster_url,alt:"",className:"absolute inset-0 w-full h-full object-cover object-top"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sophey-cream/20 text-[10px]",children:"â"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-display font-bold text-sophey-cream text-sm truncate",children:t.name}),t.colorswappable&&e.jsx(ee,{className:"w-3 h-3 flex-shrink-0",style:{color:"#7C5CFF"}}),!t.published&&e.jsx("span",{className:"text-[9px] tracking-[0.2em] uppercase text-yellow-300/70 font-medium",children:"Draft"})]}),e.jsxs("p",{className:"text-[11px] text-sophey-cream/35 mt-0.5",children:[t.model_slug," · ",t.category||"â"," · #",t.id]})]}),e.jsx("div",{className:"flex items-center gap-1 pr-3 flex-shrink-0",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[11px] text-red-300/80 mr-1",children:"Delete?"}),e.jsx("button",{onClick:d,className:"px-2 py-1.5 text-[11px] text-red-300 bg-red-400/15 hover:bg-red-400/25 transition-colors",style:{borderRadius:"2px"},children:"Yes"}),e.jsx("button",{onClick:c,className:"px-2 py-1.5 text-[11px] text-sophey-cream/50 hover:text-sophey-cream bg-white/5 hover:bg-white/10 transition-colors",style:{borderRadius:"2px"},children:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{onClick:s,icon:te,label:"Edit",primary:!0}),e.jsx(F,{onClick:o,icon:t.published?he:fe,label:t.published?"Hide":"Show"}),e.jsx(F,{onClick:r,icon:we,label:"Delete",danger:!0})]})})]}),F=({onClick:t,icon:l,label:s,primary:o,danger:r})=>e.jsx("button",{onClick:t,title:s,className:`w-8 h-8 inline-flex items-center justify-center transition-colors ${o?"text-sophey-cream/60 hover:text-sophey-cream hover:bg-white/8":r?"text-red-300/50 hover:text-red-300 hover:bg-red-400/10":"text-sophey-cream/35 hover:text-sophey-cream hover:bg-white/5"}`,style:{borderRadius:"2px"},children:e.jsx(l,{className:"w-3.5 h-3.5"})});
1export{Ie 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.