PageSourceSearch

https://fanflowy.co/assets/merchandise-Ckc3htZU.js

js fanflowy.co collected 2026-10-07 19:00:19 UTC 112,036 bytes, 5 lines download raw bytes

1import{j as n,x as Yn,y as Kn,z as jt,A as Xn,C as Wn,D as sn,F as Vn,b as on,G as qn,H as Ut,J as _n,K as Hn,M as Gn,N as Jn,O as Qn,P as zt,Q as Bt,R as Yt,S as Zn,T as er,U as tr,V as nr,W as rr,X as sr,Y as or,Z as ar}from"./dashboard-CqpNaWIC.js";import{r as i,f as z,d as Ye,u as an,L as ir,e as ln}from"./react-vendor-BwQoNBTn.js";import{C as lr}from"./email-campaigns-BICBzrKd.js";function cr({isOpen:e,title:t,message:r,buttonText:s="OK",variant:a="info",onClose:o}){if(!e)return null;const l={info:"bg-blue-500/10 border-blue-500/30 text-blue-300",success:"bg-green-500/10 border-green-500/30 text-green-300",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-300",error:"bg-red-500/10 border-red-500/30 text-red-300"};return n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 max-w-md w-full",children:[n.jsx("h3",{className:"text-xl font-bold text-white mb-4",children:t}),n.jsx("div",{className:`rounded-lg p-4 mb-6 border ${l[a]}`,children:n.jsx("p",{className:"text-sm whitespace-pre-line",children:r})}),n.jsx("button",{onClick:o,className:"w-full px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors",children:s})]})})}function dr({orders:e,isLoading:t,error:r,searchQuery:s,setSearchQuery:a,onOrderClick:o,formatPrice:l,formatDate:c,getStatusColor:d,page:u,totalPages:f,total:h,onPrevPage:x,onNextPage:g}){return n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h2",{className:"text-xl font-semibold text-white",children:"Orders"}),n.jsx("input",{type:"text",placeholder:"Search by name, email, or source...",value:s,onChange:p=>a(p.target.value),className:"px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff] w-80"})]}),t?n.jsxs("div",{className:"text-center py-12",children:[n.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-purple-500 border-r-transparent"}),n.jsx("p",{className:"mt-2 text-sm text-gray-400",children:"Loading orders..."})]}):r?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:r})}):e.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx("div",{className:"text-5xl mb-4",children:"📦"}),n.jsx("p",{className:"text-gray-400 mb-2",children:"No orders yet"}),n.jsx("p",{className:"text-sm text-gray-500",children:"Orders will appear here when fans make purchases"})]}):n.jsxs("div",{className:"overflow-x-auto",children:[n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-white/10",children:[n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Customer"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Source"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Items"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Order Date"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Amount"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Status"})]})}),n.jsx("tbody",{children:e.map(p=>n.jsxs("tr",{onClick:()=>o(p),className:"border-b border-white/5 hover:bg-white/5 transition-colors cursor-pointer",children:[n.jsxs("td",{className:"py-3 px-4",children:[n.jsx("div",{className:"text-white",children:p.fullName||"Unknown"}),n.jsx("div",{className:"text-xs text-gray-400",children:p.email})]}),n.jsx("td",{className:"py-3 px-4 text-gray-300 text-sm",children:p.source==="WEBSITE"?"Website":p.source==="FANPACK"?"FanPack Funnel":p.source??"—"}),n.jsx("td",{className:"py-3 px-4 text-gray-300 text-sm",children:(()=>{var m;const w=((m=p.items)==null?void 0:m.reduce((E,C)=>E+(C.quantity||0),0))??0;return`${w} item${w!==1?"s":""}`})()}),n.jsx("td",{className:"py-3 px-4 text-gray-300 text-sm",children:c(p.createdAt)}),n.jsx("td",{className:"py-3 px-4 text-white text-sm font-medium",children:l(p.totalCents)}),n.jsx("td",{className:"py-3 px-4",children:n.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full border ${d(p.status)}`,children:p.status})})]}
1,p.id))})]}),n.jsxs("div",{className:"flex items-center justify-between mt-4",children:[n.jsxs("div",{className:"text-sm text-gray-400",children:["Page ",u," of ",f," • ",h," total"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"button",onClick:x,disabled:u<=1,className:"px-3 py-1.5 rounded-lg border border-white/10 text-sm text-white/80 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-white/5",children:"Prev"}),n.jsx("button",{type:"button",onClick:g,disabled:u>=f,className:"px-3 py-1.5 rounded-lg border border-white/10 text-sm text-white/80 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-white/5",children:"Next"})]})]})]})]})}function ur(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i.useMemo(()=>s=>{t.forEach(a=>a(s))},t)}const ut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Te(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Et(e){return"nodeType"in e}function _(e){var t,r;return e?Te(e)?e:Et(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function kt(e){const{Document:t}=_(e);return e instanceof t}function He(e){return Te(e)?!1:e instanceof _(e).HTMLElement}function cn(e){return e instanceof _(e).SVGElement}function Oe(e){return e?Te(e)?e.document:Et(e)?kt(e)?e:He(e)||cn(e)?e.ownerDocument:document:document:document}const ae=ut?i.useLayoutEffect:i.useEffect;function ft(e){const t=i.useRef(e);return ae(()=>{t.current=e}),i.useCallback(function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return t.current==null?void 0:t.current(...s)},[])}function fr(){const e=i.useRef(null),t=i.useCallback((s,a)=>{e.current=setInterval(s,a)},[]),r=i.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function Ve(e,t){t===void 0&&(t=[e]);const r=i.useRef(e);return ae(()=>{r.current!==e&&(r.current=e)},t),r}function Ge(e,t){const r=i.useRef();return i.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function ot(e){const t=ft(e),r=i.useRef(null),s=i.useCallback(a=>{a!==r.current&&(t==null||t(a,r.current)),r.current=a},[]);return[r,s]}function at(e){const t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}let vt={};function Je(e,t){return i.useMemo(()=>{if(t)return t;const r=vt[e]==null?0:vt[e]+1;return vt[e]=r,e+"-"+r},[e,t])}function dn(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return s.reduce((o,l)=>{const c=Object.entries(l);for(const[d,u]of c){const f=o[d];f!=null&&(o[d]=f+e*u)}return o},{...t})}}const Ie=dn(1),qe=dn(-1);function hr(e){return"clientX"in e&&"clientY"in e}function ht(e){if(!e)return!1;const{KeyboardEvent:t}=_(e.target);return t&&e instanceof t}function gr(e){if(!e)return!1;const{TouchEvent:t}=_(e.target);return t&&e instanceof t}function it(e){if(gr(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return hr(e)?{x:e.clientX,y:e.clientY}:null}const Ce=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Ce.Translate.toString(e),Ce.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),Kt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xr(e){return e.matches(Kt)?e:e.querySelector(Kt)}const mr={display:"none"};function pr(e){let{id:t,value:r}=e;return z.createElement("div",{id:t,style:mr},r)}function br(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return z.createElement("div",{id:t,style:a,role:"status","aria-live":s,"aria-atomic":!0},r)}function vr(){const[e,t]=i.useState("");return{announce:i.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const un=i.createContext(null);function yr(e){const t=i.useContext(un);i.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function wr(){const[e]=i.useState(()=>new Set),t=i.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[i.useCallback(s=>{let{type:a,event:o}=s;e.forEach(l=>{var c;return(c=l[a])==null?void 0:c.call(l,o)})},[e]),t]}const Nr={draggable:`
2    To pick up a draggable item, press the space bar.
3    While dragging, use the arrow keys to move the item.
4    Press space again to drop the item in its new position, or press escape to cancel.
5  `},jr={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Sr(e){let{announcements:t=jr,container:r,hiddenTextDescribedById:s,screenReaderInstructions:a=Nr}=e;const{announce:o,announcement:l}=vr(),c=Je("DndLiveRegion"),[d,u]=i.useState(!1);if(i.useEffect(()=>{u(!0)},[]),yr(i.useMemo(()=>({onDragStart(h){let{active:x}=h;o(t.onDragStart({active:x}))},onDragMove(h){let{active:x,over:g}=h;t.onDragMove&&o(t.onDragMove({active:x,over:g}))},onDragOver(h){let{active:x,over:g}=h;o(t.onDragOver({active:x,over:g}))},onDragEnd(h){let{active:x,over:g}=h;o(t.onDragEnd({active:x,over:g}))},onDragCancel(h){let{active:x,over:g}=h;
5o(t.onDragCancel({active:x,over:g}))}}),[o,t])),!d)return null;const f=z.createElement(z.Fragment,null,z.createElement(pr,{id:s,value:a.draggable}),z.createElement(br,{id:c,announcement:l}));return r?Ye.createPortal(f,r):f}var B;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(B||(B={}));function lt(){}function Xt(e,t){return i.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Cr(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const ie=Object.freeze({x:0,y:0});function fn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Dr(e,t){const r=it(e);if(!r)return"0 0";const s={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return s.x+"% "+s.y+"%"}function hn(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return r-s}
5function Er(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function Wt(e){let{left:t,top:r,height:s,width:a}=e;return[{x:t,y:r},{x:t+a,y:r},{x:t,y:r+s},{x:t+a,y:r+s}]}function gn(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Vt(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const kr=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const a=Vt(t,t.left,t.top),o=[];for(const l of s){const{id:c}=l,d=r.get(c);if(d){const u=fn(Vt(d),a);o.push({id:c,data:{droppableContainer:l,value:u}})}}return o.sort(hn)},Pr=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const a=Wt(t),o=[];for(const l of s){const{id:c}=l,d=r.get(c);if(d){const u=Wt(d),f=a.reduce((x,g,p)=>x+fn(u[p],g),0),h=Number((f/4).toFixed(4));o.push({id:c,data:{droppableContainer:l,value:h}})}}return o.sort(hn)};function Rr(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),l=a-s,c=o-r;if(s<a&&r<o){const d=t.width*t.height,u=e.width*e.height,f=l*c,h=f/(d+u-f);return Number(h.toFixed(4))}return 0}const Ar=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const a=[];for(const o of s){const{id:l}=o,c=r.get(l);if(c){const d=Rr(c,t);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(Er)};function Lr(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function xn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ie}function Ir(e){return function(r){for(var s=arguments.length,a=new Array(s>1?s-1:0),o=1;o<s;o++)a[o-1]=arguments[o];return a.reduce((l,c)=>({...l,top:l.top+e*c.y,bottom:l.bottom+e*c.y,left:l.left+e*c.x,right:l.right+e*c.x}),{...r})}}const Tr=Ir(1);function mn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Or(e,t,r){const s=mn(t);if(!s)return e;const{scaleX:a,scaleY:o,x:l,y:c}=s,d=e.left-l-(1-a)*parseFloat(r),u=e.top-c-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),f=a?e.width/a:e.width,h=o?e.height/o:e.height;return{width:f,height:h,top:u,right:d+f,bottom:u+h,left:d}}const Mr={ignoreTransform:!1};function Me(e,t){t===void 0&&(t=Mr);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=_(e).getComputedStyle(e);u&&(r=Or(r,u,f))}const{top:s,left:a,width:o,height:l,bottom:c,right:d}=r;return{top:s,left:a,width:o,height:l,bottom:c,right:d}}function qt(e){return Me(e,{ignoreTransform:!0})}function Fr(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function $r(e,t){return t===void 0&&(t=_(e).getComputedStyle(e)),t.position==="fixed"}function Ur(e,t){t===void 0&&(t=_(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=t[a];return typeof o=="string"?r.test(o):!1})}function gt(e,t){const r=[];function s(a){if(t!=null&&r.length>=t||!a)return r;if(kt(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!He(a)||cn(a)||r.includes(a))return r;const o=_(e).getComputedStyle(a);return a!==e&&Ur(a,o)&&r.push(a),$r(a,o)?r:s(a.parentNode)}return e?s(e):r}function pn(e){const[t]=gt(e,1);return t??null}function yt(e){return!ut||!e?null:Te(e)?e:Et(e)?kt(e)||e===Oe(e).scrollingElement?window:He(e)?e:null:null}function bn(e){return Te(e)?e.scrollX:e.scrollLeft}function vn(e){return Te(e)?e.scrollY:e.scrollTop}function St(e){return{x:bn(e),y:vn(e)}}var Y;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Y||(Y={}));function yn(e){return!ut||!e?!1:e===document.scrollingElement}function wn(e){const t={x:0,y:0},r=yn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},a=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,l=e.scrollTop>=s.y,c=e.scrollLeft>=s.x;return{isTop:a,isLeft:o,isBottom:l,isRight:c,maxScroll:s,minScroll:t}}const zr={x:.2,y:.2};function Br(e,t,r,s,a){let{top:o,left:l,right:c,bottom:d}=r;s===void 0&&(s=10),a===void 0&&(a=zr);const{isTop:u,isBottom:f,isLeft:h,isRight:x}=wn(e),g={x:0,y:0},p={x:0,y:0},w={height:t.height*a.y,width:t.width*a.x};
5return!u&&o<=t.top+w.height?(g.y=Y.Backward,p.y=s*Math.abs((t.top+w.height-o)/w.height)):!f&&d>=t.bottom-w.height&&(g.y=Y.Forward,p.y=s*Math.abs((t.bottom-w.height-d)/w.height)),!x&&c>=t.right-w.width?(g.x=Y.Forward,p.x=s*Math.abs((t.right-w.width-c)/w.width)):!h&&l<=t.left+w.width&&(g.x=Y.Backward,p.x=s*Math.abs((t.left+w.width-l)/w.width)),{direction:g,speed:p}}function Yr(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:t,left:r,right:s,bottom:a}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:a,width:e.clientWidth,height:e.clientHeight}}function Nn(e){return e.reduce((t,r)=>Ie(t,St(r)),ie)}function Kr(e){return e.reduce((t,r)=>t+bn(r),0)}function Xr(e){return e.reduce((t,r)=>t+vn(r),0)}function jn(e,t){if(t===void 0&&(t=Me),!e)return;const{top:r,left:s,bottom:a,right:o}=t(e);pn(e)&&(a<=0||o<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Wr=[["x",["left","right"],Kr],["y",["top","bottom"],Xr]];class Pt{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=gt(r),a=Nn(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,l,c]of Wr)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=c(s),f=a[o]-u;return this.rect[d]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ke{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var a;(a=this.target)==null||a.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function Vr(e){const{EventTarget:t}=_(e);return e instanceof t?e:Oe(e)}function wt(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var re;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(re||(re={}));function _t(e){e.preventDefault()}function qr(e){e.stopPropagation()}var O;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(O||(O={}));const Sn={start:[O.Space,O.Enter],cancel:[O.Esc],end:[O.Space,O.Enter,O.Tab]},_r=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case O.Right:return{...r,x:r.x+25};case O.Left:return{...r,x:r.x-25};case O.Down:return{...r,y:r.y+25};case O.Up:return{...r,y:r.y-25}}};class Rt{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new Ke(Oe(r)),this.windowListeners=new Ke(_(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(re.Resize,this.handleCancel),this.windowListeners.add(re.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(re.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&jn(s),r(ie)}handleKeyDown(t){if(ht(t)){const{active:r,context:s,options:a}=this.props,{keyboardCodes:o=Sn,coordinateGetter:l=_r,scrollBehavior:c="smooth"}=a,{code:d}=t;if(o.end.includes(d)){this.handleEnd(t);return}if(o.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:u}=s.current,f=u?{x:u.left,y:u.top}:ie;this.referenceCoordinates||(this.referenceCoordinates=f);const h=l(t,{active:r,context:s.current,currentCoordinates:f});if(h){const x=qe(h,f),g={x:0,y:0},{scrollableAncestors:p}=s.current;for(const w of p){const m=t.code,{isTop:E,isRight:C,isLeft:D,isBottom:b,maxScroll:v,minScroll:k}=wn(w),y=Yr(w),N={x:Math.min(m===O.Right?y.right-y.width/2:y.right,Math.max(m===O.Right?y.left:y.left+y.width/2,h.x)),y:Math.min(m===O.Down?y.bottom-y.height/2:y.bottom,Math.max(m===O.Down?y.top:y.top+y.height/2,h.y))}
5,R=m===O.Right&&!C||m===O.Left&&!D,T=m===O.Down&&!b||m===O.Up&&!E;if(R&&N.x!==h.x){const L=w.scrollLeft+x.x,j=m===O.Right&&L<=v.x||m===O.Left&&L>=k.x;if(j&&!x.y){w.scrollTo({left:L,behavior:c});return}j?g.x=w.scrollLeft-L:g.x=m===O.Right?w.scrollLeft-v.x:w.scrollLeft-k.x,g.x&&w.scrollBy({left:-g.x,behavior:c});break}else if(T&&N.y!==h.y){const L=w.scrollTop+x.y,j=m===O.Down&&L<=v.y||m===O.Up&&L>=k.y;if(j&&!x.x){w.scrollTo({top:L,behavior:c});return}j?g.y=w.scrollTop-L:g.y=m===O.Down?w.scrollTop-v.y:w.scrollTop-k.y,g.y&&w.scrollBy({top:-g.y,behavior:c});break}}this.handleMove(t,Ie(qe(h,this.referenceCoordinates),g))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Rt.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=Sn,onActivation:a}=t,{active:o}=r;const{code:l}=e.nativeEvent;if(s.start.includes(l)){const c=o.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),a==null||a({event:e.nativeEvent}),!0)}return!1}}];function Ht(e){return!!(e&&"distance"in e)}function Gt(e){return!!(e&&"delay"in e)}class At{constructor(t,r,s){var a;s===void 0&&(s=Vr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:o}=t,{target:l}=o;this.props=t,this.events=r,this.document=Oe(l),this.documentListeners=new Ke(this.document),this.listeners=new Ke(s),this.windowListeners=new Ke(_(l)),this.initialCoordinates=(a=it(o))!=null?a:ie,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(re.Resize,this.handleCancel),this.windowListeners.add(re.DragStart,_t),this.windowListeners.add(re.VisibilityChange,this.handleCancel),this.windowListeners.add(re.ContextMenu,_t),this.documentListeners.add(re.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Gt(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Ht(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:s,onPending:a}=this.props;a(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(re.Click,qr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(re.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:c}}=o;if(!a)return;const d=(r=it(t))!=null?r:ie,u=qe(a,d);if(!s&&c){if(Ht(c)){if(c.tolerance!=null&&wt(u,c.tolerance))return this.handleCancel();if(wt(u,c.distance))return this.handleStart()}if(Gt(c)&&wt(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}t.cancelable&&t.preventDefault(),l(d)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===O.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Hr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Lt extends At{constructor(t){const{event:r}=t,s=Oe(r.target);super(t,Hr,s)}}Lt.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s==null||s({event:r}),!0)}}];const Gr={move:{name:"mousemove"},end:{name:"mouseup"}};var Ct;(function(e){e[e.RightClick=2]="RightClick"})(Ct||(Ct={}));class Jr extends At{constructor(t){super(t,Gr,Oe(t.event.target))}}Jr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===Ct.RightClick?!1:(s==null||s({event:r}),!0)}}];const Nt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Qr extends At{constructor(t){super(t,Nt)}static setup(){return window.addEventListener(Nt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Nt.move.name,t)};function t(){}}}Qr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:a}=r;return a.length>1?!1:(s==null||s({event:r}),!0)}}];var Xe;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xe||(Xe={}));var ct;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="Rever
5sedTreeOrder"})(ct||(ct={}));function Zr(e){let{acceleration:t,activator:r=Xe.Pointer,canScroll:s,draggingRect:a,enabled:o,interval:l=5,order:c=ct.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:f,delta:h,threshold:x}=e;const g=ts({delta:h,disabled:!o}),[p,w]=fr(),m=i.useRef({x:0,y:0}),E=i.useRef({x:0,y:0}),C=i.useMemo(()=>{switch(r){case Xe.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Xe.DraggableRect:return a}},[r,a,d]),D=i.useRef(null),b=i.useCallback(()=>{const k=D.current;if(!k)return;const y=m.current.x*E.current.x,N=m.current.y*E.current.y;k.scrollBy(y,N)},[]),v=i.useMemo(()=>c===ct.TreeOrder?[...u].reverse():u,[c,u]);i.useEffect(()=>{if(!o||!u.length||!C){w();return}for(const k of v){if((s==null?void 0:s(k))===!1)continue;const y=u.indexOf(k),N=f[y];if(!N)continue;const{direction:R,speed:T}=Br(k,N,C,t,x);for(const L of["x","y"])g[L][R[L]]||(T[L]=0,R[L]=0);if(T.x>0||T.y>0){w(),D.current=k,p(b,l),m.current=T,E.current=R;return}}m.current={x:0,y:0},E.current={x:0,y:0},w()},[t,b,s,w,o,l,JSON.stringify(C),JSON.stringify(g),p,u,v,f,JSON.stringify(x)])}const es={x:{[Y.Backward]:!1,[Y.Forward]:!1},y:{[Y.Backward]:!1,[Y.Forward]:!1}};function ts(e){let{delta:t,disabled:r}=e;const s=at(t);return Ge(a=>{if(r||!s||!a)return es;const o={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Y.Backward]:a.x[Y.Backward]||o.x===-1,[Y.Forward]:a.x[Y.Forward]||o.x===1},y:{[Y.Backward]:a.y[Y.Backward]||o.y===-1,[Y.Forward]:a.y[Y.Forward]||o.y===1}}},[r,t,s])}function ns(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return Ge(a=>{var o;return t==null?null:(o=s??a)!=null?o:null},[s,t])}function rs(e,t){return i.useMemo(()=>e.reduce((r,s)=>{const{sensor:a}=s,o=a.activators.map(l=>({eventName:l.eventName,handler:t(l.handler,s)}));return[...r,...o]},[]),[e,t])}var _e;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(_e||(_e={}));var Dt;(function(e){e.Optimized="optimized"})(Dt||(Dt={}));const Jt=new Map;function ss(e,t){let{dragging:r,dependencies:s,config:a}=t;const[o,l]=i.useState(null),{frequency:c,measure:d,strategy:u}=a,f=i.useRef(e),h=m(),x=Ve(h),g=i.useCallback(function(E){E===void 0&&(E=[]),!x.current&&l(C=>C===null?E:C.concat(E.filter(D=>!C.includes(D))))},[x]),p=i.useRef(null),w=Ge(E=>{if(h&&!r)return Jt;if(!E||E===Jt||f.current!==e||o!=null){const C=new Map;for(let D of e){if(!D)continue;if(o&&o.length>0&&!o.includes(D.id)&&D.rect.current){C.set(D.id,D.rect.current);continue}const b=D.node.current,v=b?new Pt(d(b),b):null;D.rect.current=v,v&&C.set(D.id,v)}return C}return E},[e,o,r,h,d]);return i.useEffect(()=>{f.current=e},[e]),i.useEffect(()=>{h||g()},[r,h]),i.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),i.useEffect(()=>{h||typeof c!="number"||p.current!==null||(p.current=setTimeout(()=>{g(),p.current=null},c))},[c,h,g,...s]),{droppableRects:w,measureDroppableContainers:g,measuringScheduled:o!=null};function m(){switch(u){case _e.Always:return!1;case _e.BeforeDragging:return r;default:return!r}}}function It(e,t){return Ge(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function os(e,t){return It(e,t)}function as(e){let{callback:t,disabled:r}=e;const s=ft(t),a=i.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(s)},[s,r]);return i.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function xt(e){let{callback:t,disabled:r}=e;const s=ft(t),a=i.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(s)},[r]);return i.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function is(e){return new Pt(Me(e),e)}function Qt(e,t,r){t===void 0&&(t=is);const[s,a]=i.useState(null);function o(){a(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??r)!=null?u:null}const f=t(e);return JSON.stringify(d)===JSON.stringify(f)?d:f})}const l=as({callback(d){if(e)for(const u of d){const{type:f,target:h}=u;if(f==="childList"&&h instanceof HTMLElement&&h.contains(e)){o();break}}}}),c=xt({callback:o});return ae(()=>{o(),e?(c==null||c.observe(e),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(c==null||c.disconnect(),l==null||l.disconnect())},[e]),s}function ls(e){const t=It(e);return xn(e,t)}const Zt=[];function cs(e){const t=i.useRef(e),r=Ge(s=>e?s&&s!==Zt&&e&&t.current&&e.parentNode===t.current.parentNode?s:gt(e):Zt,[e]);return i.useEffect(()=>{t.current=e},[e]),r}function ds(e){const[t,r]=i.useState(null),s=i.useRef(e),a=i.useCallback(o=>{const l=yt(o.target);l&&r(c=>c?(c.set(l,St(l)),new Map(c)):null)},[]);return i.useEffect(()=>{const o=s.current;if(e!==o){l(o);const c=e.map(d=>{const u=yt(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,St(u)]):null}).filter(d=>d!=null);r(c.length?new Map(c):null),s.current=e}return()=>{l(e),l(o)};
5function l(c){c.forEach(d=>{const u=yt(d);u==null||u.removeEventListener("scroll",a)})}},[a,e]),i.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,l)=>Ie(o,l),ie):Nn(e):ie,[e,t])}function en(e,t){t===void 0&&(t=[]);const r=i.useRef(null);return i.useEffect(()=>{r.current=null},t),i.useEffect(()=>{const s=e!==ie;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?qe(e,r.current):ie}function us(e){i.useEffect(()=>{if(!ut)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r==null||r()}},e.map(t=>{let{sensor:r}=t;return r}))}function fs(e,t){return i.useMemo(()=>e.reduce((r,s)=>{let{eventName:a,handler:o}=s;return r[a]=l=>{o(l,t)},r},{}),[e,t])}function Cn(e){return i.useMemo(()=>e?Fr(e):null,[e])}const tn=[];function hs(e,t){t===void 0&&(t=Me);const[r]=e,s=Cn(r?_(r):null),[a,o]=i.useState(tn);function l(){o(()=>e.length?e.map(d=>yn(d)?s:new Pt(t(d),d)):tn)}const c=xt({callback:l});return ae(()=>{c==null||c.disconnect(),l(),e.forEach(d=>c==null?void 0:c.observe(d))},[e]),a}function Dn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return He(t)?t:e}function gs(e){let{measure:t}=e;const[r,s]=i.useState(null),a=i.useCallback(u=>{for(const{target:f}of u)if(He(f)){s(h=>{const x=t(f);return h?{...h,width:x.width,height:x.height}:x});break}},[t]),o=xt({callback:a}),l=i.useCallback(u=>{const f=Dn(u);o==null||o.disconnect(),f&&(o==null||o.observe(f)),s(f?t(f):null)},[t,o]),[c,d]=ot(l);return i.useMemo(()=>({nodeRef:c,rect:r,setRef:d}),[r,c,d])}const xs=[{sensor:Lt,options:{}},{sensor:Rt,options:{}}],ms={current:{}},st={draggable:{measure:qt},droppable:{measure:qt,strategy:_e.WhileDragging,frequency:Dt.Optimized},dragOverlay:{measure:Me}};class We extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const ps={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new We,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:lt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:st,measureDroppableContainers:lt,windowRect:null,measuringScheduled:!1},En={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:lt,draggableNodes:new Map,over:null,measureDroppableContainers:lt},Qe=i.createContext(En),kn=i.createContext(ps);function bs(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new We}}}function vs(e,t){switch(t.type){case B.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case B.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case B.DragEnd:case B.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case B.RegisterDroppable:{const{element:r}=t,{id:s}=r,a=new We(e.droppable.containers);return a.set(s,r),{...e,droppable:{...e.droppable,containers:a}}}case B.SetDroppableDisabled:{const{id:r,key:s,disabled:a}=t,o=e.droppable.containers.get(r);if(!o||s!==o.key)return e;const l=new We(e.droppable.containers);return l.set(r,{...o,disabled:a}),{...e,droppable:{...e.droppable,containers:l}}}case B.UnregisterDroppable:{const{id:r,key:s}=t,a=e.droppable.containers.get(r);if(!a||s!==a.key)return e;const o=new We(e.droppable.containers);return o.delete(r),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function ys(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:a}=i.useContext(Qe),o=at(s),l=at(r==null?void 0:r.id);return i.useEffect(()=>{if(!t&&!s&&o&&l!=null){if(!ht(o)||document.activeElement===o.target)return;const c=a.get(l);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[d.current,u.current]){if(!f)continue;const h=xr(f);if(h){h.focus();break}}})}},[s,t,a,l,o]),null}function Pn(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((a,o)=>o({transform:a,...s}),r):r}function ws(e){return i.useMemo(()=>({draggable:{...st.draggable,...e==null?void 0:e.draggable},droppable:{...st.droppable,...e==null?void 0:e.droppable},dragOverlay:{...st.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Ns(e){let{activeNode:t,measure:r,initialRect:s,config:a=!0}=e;const o=i.useRef(!1),{x:l,y:c}=typeof a=="boolean"?{x:a,y:a}:a;ae(()=>{if(!l&&!c||!t){o.current=!1;return}if(o.current||!s)return;const u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;const f=r(u),h=xn(f,s);if(l||(h.x=0),c||(h.y=0),o.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const x=pn(u);x&&x.scrollBy({top:h.y,left:h.x})}},[t,l,c,s,r])}const mt=i.createContext({...ie,scaleX:1,scaleY:1}
5);var Se;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Se||(Se={}));const js=i.memo(function(t){var r,s,a,o;let{id:l,accessibility:c,autoScroll:d=!0,children:u,sensors:f=xs,collisionDetection:h=Ar,measuring:x,modifiers:g,...p}=t;const w=i.useReducer(vs,void 0,bs),[m,E]=w,[C,D]=wr(),[b,v]=i.useState(Se.Uninitialized),k=b===Se.Initialized,{draggable:{active:y,nodes:N,translate:R},droppable:{containers:T}}=m,L=y!=null?N.get(y):null,j=i.useRef({initial:null,translated:null}),F=i.useMemo(()=>{var q;return y!=null?{id:y,data:(q=L==null?void 0:L.data)!=null?q:ms,rect:j}:null},[y,L]),U=i.useRef(null),[S,P]=i.useState(null),[I,H]=i.useState(null),W=Ve(p,Object.values(p)),le=Je("DndDescribedBy",l),Pe=i.useMemo(()=>T.getEnabled(),[T]),V=ws(x),{droppableRects:se,measureDroppableContainers:he,measuringScheduled:De}=ss(Pe,{dragging:k,dependencies:[R.x,R.y],config:V.droppable}),K=ns(N,y),Ee=i.useMemo(()=>I?it(I):null,[I]),ee=Bn(),oe=os(K,V.draggable.measure);Ns({activeNode:y!=null?N.get(y):null,config:ee.layoutShiftCompensation,initialRect:oe,measure:V.draggable.measure});const M=Qt(K,V.draggable.measure,oe),ke=Qt(K?K.parentElement:null),G=i.useRef({activatorEvent:null,active:null,activeNode:K,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pe=T.getNodeFor((r=G.current.over)==null?void 0:r.id),te=gs({measure:V.dragOverlay.measure}),ge=(s=te.nodeRef.current)!=null?s:K,xe=k?(a=te.rect)!=null?a:M:null,Ze=!!(te.nodeRef.current&&te.rect),et=ls(Ze?null:M),Fe=Cn(ge?_(ge):null),ce=cs(k?pe??K:null),Re=hs(ce),Ae=Pn(g,{transform:{x:R.x-et.x,y:R.y-et.y,scaleX:1,scaleY:1},activatorEvent:I,active:F,activeNodeRect:M,containerNodeRect:ke,draggingNodeRect:xe,over:G.current.over,overlayNodeRect:te.rect,scrollableAncestors:ce,scrollableAncestorRects:Re,windowRect:Fe}),tt=Ee?Ie(Ee,R):null,be=ds(ce),$e=en(be),A=en(be,[M]),$=Ie(Ae,$e),de=xe?Tr(xe,Ae):null,ve=F&&de?h({active:F,collisionRect:de,droppableRects:se,droppableContainers:Pe,pointerCoordinates:tt}):null,Ot=gn(ve,"id"),[ye,Mt]=i.useState(null),Mn=Ze?Ae:Ie(Ae,A),Fn=Lr(Mn,(o=ye==null?void 0:ye.rect)!=null?o:null,M),pt=i.useRef(null),Ft=i.useCallback((q,J)=>{let{sensor:Q,options:we}=J;if(U.current==null)return;const ne=N.get(U.current);if(!ne)return;const Z=q.nativeEvent,ue=new Q({active:U.current,activeNode:ne,event:Z,options:we,context:G,onAbort(X){if(!N.get(X))return;const{onDragAbort:fe}=W.current,me={id:X};fe==null||fe(me),C({type:"onDragAbort",event:me})},onPending(X,Ne,fe,me){if(!N.get(X))return;const{onDragPending:ze}=W.current,je={id:X,constraint:Ne,initialCoordinates:fe,offset:me};ze==null||ze(je),C({type:"onDragPending",event:je})},onStart(X){const Ne=U.current;if(Ne==null)return;const fe=N.get(Ne);if(!fe)return;const{onDragStart:me}=W.current,Ue={activatorEvent:Z,active:{id:Ne,data:fe.data,rect:j}};Ye.unstable_batchedUpdates(()=>{me==null||me(Ue),v(Se.Initializing),E({type:B.DragStart,initialCoordinates:X,active:Ne}),C({type:"onDragStart",event:Ue}),P(pt.current),H(Z)})},onMove(X){E({type:B.DragMove,coordinates:X})},onEnd:Le(B.DragEnd),onCancel:Le(B.DragCancel)});pt.current=ue;function Le(X){return async function(){const{active:fe,collisions:me,over:Ue,scrollAdjustedTranslate:ze}=G.current;let je=null;if(fe&&ze){const{cancelDrop:Be}=W.current;je={activatorEvent:Z,active:fe,collisions:me,delta:ze,over:Ue},X===B.DragEnd&&typeof Be=="function"&&await Promise.resolve(Be(je))&&(X=B.DragCancel)}U.current=null,Ye.unstable_batchedUpdates(()=>{E({type:X}),v(Se.Uninitialized),Mt(null),P(null),H(null),pt.current=null;const Be=X===B.DragEnd?"onDragEnd":"onDragCancel";if(je){const bt=W.current[Be];bt==null||bt(je),C({type:Be,event:je})}})}}},[N]),$n=i.useCallback((q,J)=>(Q,we)=>{const ne=Q.nativeEvent,Z=N.get(we);if(U.current!==null||!Z||ne.dndKit||ne.defaultPrevented)return;const ue={active:Z};q(Q,J.options,ue)===!0&&(ne.dndKit={capturedBy:J.sensor},U.current=we,Ft(Q,J))},[N,Ft]),$t=rs(f,$n);us(f),ae(()=>{M&&b===Se.Initializing&&v(Se.Initialized)},[M,b]),i.useEffect(()=>{const{onDragMove:q}=W.current,{active:J,activatorEvent:Q,collisions:we,over:ne}=G.current;if(!J||!Q)return;const Z={active:J,activatorEvent:Q,collisions:we,delta:{x:$.x,y:$.y},over:ne};Ye.unstable_batchedUpdates(()=>{q==null||q(Z),C({type:"onDragMove",event:Z})})},[$.x,$.y]),i.useEffect(()=>{const{active:q,activatorEvent:J,collisions:Q,droppableContainers:we,scrollAdjustedTranslate:ne}=G.current;if(!q||U.current==null||!J||!ne)return;const{onDragOver:Z}=W.current,ue=we.get(Ot),Le=ue&&ue.rect.current?{id:ue.id,rect:ue.rect.current,data:ue.data,disabled:ue.disabled}:null,X={active:q,activatorEvent:J,collisions:Q,delta:{x:ne.x,y:ne.y},over:Le};Ye.unstable_batchedUpdates(()=>{Mt(Le),Z==null||Z(X),C({type:"onDragOver",event:X})})},[Ot]),ae(()=>{G.current={activatorEvent:I,active:F,activeNode:K,collisionRect:de,collisions:ve,droppableRects:se,draggableNodes:N,draggingNode:ge,draggingNodeRect:xe,droppableContainers:T,over:ye,scrollableAncestors:ce,scrollAdjustedTranslate:$},j.current={initial:xe,translated:de}},[F,K,ve,de,N,ge,xe,se,T,ye,ce,$]),Zr({...ee,delta:R,draggingRect:de,pointerCoordinates:tt,scrollableAncestors:ce,scrollableAncestorRects:Re});const Un=i.useMemo(()=>({active:F,activeNode:K,activeNodeRect:M,activatorEvent:I,collisions:ve,containerNodeRect:ke,dragOverlay:te,draggableNodes:N,droppableContainers:T,droppableRects:se,over:ye,measureDroppableContainers:he,scrollableAncestors:ce,scrollableAncestorRects:Re,measuringConfiguration:V,measuringScheduled:De,windowRect:Fe}),[F,K,M,I,ve,ke,te,N,T,se,ye,he,ce,Re,V,De,Fe]),zn=i.useMemo(()=>({activatorEvent:I,activators:$t,active:F,activeNodeRect:M,ariaDescribedById:{draggable:le},dispatch:E,draggableNodes:N,over:ye,measureDroppableContainers:he}),[I,$t,F,M,E,le,N,ye,he]);return z.createElement(un.Provider,{value:D},z.createElement(Qe.Provider,{value:zn},z.createElement(kn.Provider,{value:Un},z.createElement(mt.Provider,{value:Fn},u)),z.createElement(ys,{disabled:(c==null?void 0:c.restoreFocus)===!1})),z.createElement(Sr,{...c,hiddenTextDescribedById:le}));function Bn(){const q=(S==null?void 0:S.autoScrollEnabled)===!1,J=typeof d=="object"?d.enabled===!1:d===!1,Q=k&&!q&&!J;return typeof d=="object"?{...d,enabled:Q}:{enabled:Q}}}),Ss=i.createContext(null),nn="button",Cs="Draggable";function Ds(e){let{id:t,data:r,disabled:s=!1,attributes:a}=e;const o=Je(Cs),{activators:l,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:f,draggableNodes:h,over:x}=i.useContext(Qe),{role:g=nn,roleDescription:p="draggable",tabIndex:w=0}=a??{},m=(d==null?void 0:d.id)===t,E=i.useContext(m?mt:Ss),[C,D]=ot(),[b,v]=ot(),k=fs(l,t),y=Ve(r);ae(()=>(h.set(t,{id:t,key:o,node:C,activatorNode:b,data:y}),()=>{const R=h.get(t);R&&R.key===o&&h.delete(t)}),[h,t]);const N=i.useMemo(()=>({role:g,tabIndex:w,"aria-disabled":s,"aria-pressed":m&&g===nn?!0:void 0,"aria-roledescription":p,"aria-describedby":f.draggable}),[s,g,w,m,p,f.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:N,isDragging:m,listeners:s?void 0:k,node:C,over:x,setNodeRef:D,setActivatorNodeRef:v,transform:E}}function Rn(){return i.useContext(kn)}const Es="Droppable",ks={timeout:25};function Ps(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:a}=e;const o=Je(Es),{active:l,dispatch:c,over:d,measureDroppableContainers:u}=i.useContext(Qe),f=i.useRef({disabled:r}),h=i.useRef(!1),x=i.useRef(null),g=i.useRef(null),{disabled:p,updateMeasurementsFor:w,timeout:m}={...ks,...a},E=Ve(w??s),C=i.useCallback(()=>
5{if(!h.current){h.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(E.current)?E.current:[E.current]),g.current=null},m)},[m]),D=xt({callback:C,disabled:p||!l}),b=i.useCallback((N,R)=>{D&&(R&&(D.unobserve(R),h.current=!1),N&&D.observe(N))},[D]),[v,k]=ot(b),y=Ve(t);return i.useEffect(()=>{!D||!v.current||(D.disconnect(),h.current=!1,D.observe(v.current))},[v,D]),i.useEffect(()=>(c({type:B.RegisterDroppable,element:{id:s,key:o,disabled:r,node:v,rect:x,data:y}}),()=>c({type:B.UnregisterDroppable,key:o,id:s})),[s]),i.useEffect(()=>{r!==f.current.disabled&&(c({type:B.SetDroppableDisabled,id:s,key:o,disabled:r}),f.current.disabled=r)},[s,o,r,c]),{active:l,rect:x,isOver:(d==null?void 0:d.id)===s,node:v,over:d,setNodeRef:k}}function Rs(e){let{animation:t,children:r}=e;const[s,a]=i.useState(null),[o,l]=i.useState(null),c=at(r);return!r&&!s&&c&&a(c),ae(()=>{if(!o)return;const d=s==null?void 0:s.key,u=s==null?void 0:s.props.id;if(d==null||u==null){a(null);return}Promise.resolve(t(u,o)).then(()=>{a(null)})},[t,s,o]),z.createElement(z.Fragment,null,r,s?i.cloneElement(s,{ref:l}):null)}const As={x:0,y:0,scaleX:1,scaleY:1};function Ls(e){let{children:t}=e;return z.createElement(Qe.Provider,{value:En},z.createElement(mt.Provider,{value:As},t))}const Is={position:"fixed",touchAction:"none"},Ts=e=>ht(e)?"transform 250ms ease":void 0,Os=i.forwardRef((e,t)=>{let{as:r,activatorEvent:s,adjustScale:a,children:o,className:l,rect:c,style:d,transform:u,transition:f=Ts}=e;if(!c)return null;const h=a?u:{...u,scaleX:1,scaleY:1},x={...Is,width:c.width,height:c.height,top:c.top,left:c.left,transform:Ce.Transform.toString(h),transformOrigin:a&&s?Dr(s,c):void 0,transition:typeof f=="function"?f(s):f,...d};return z.createElement(r,{className:l,style:x,ref:t},o)}),Ms=e=>t=>{let{active:r,dragOverlay:s}=t;const a={},{styles:o,className:l}=e;if(o!=null&&o.active)for(const[c,d]of Object.entries(o.active))d!==void 0&&(a[c]=r.node.style.getPropertyValue(c),r.node.style.setProperty(c,d));if(o!=null&&o.dragOverlay)for(const[c,d]of Object.entries(o.dragOverlay))d!==void 0&&s.node.style.setProperty(c,d);return l!=null&&l.active&&r.node.classList.add(l.active),l!=null&&l.dragOverlay&&s.node.classList.add(l.dragOverlay),function(){for(const[d,u]of Object.entries(a))r.node.style.setProperty(d,u);l!=null&&l.active&&r.node.classList.remove(l.active)}},Fs=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:Ce.Transform.toString(t)},{transform:Ce.Transform.toString(r)}]},$s={duration:250,easing:"ease",keyframes:Fs,sideEffects:Ms({styles:{active:{opacity:"0"}}})};function Us(e){let{config:t,draggableNodes:r,droppableContainers:s,measuringConfiguration:a}=e;return ft((o,l)=>{if(t===null)return;const c=r.get(o);if(!c)return;const d=c.node.current;if(!d)return;const u=Dn(l);if(!u)return;const{transform:f}=_(l).getComputedStyle(l),h=mn(f);if(!h)return;const x=typeof t=="function"?t:zs(t);return jn(d,a.draggable.measure),x({active:{id:o,data:c.data,node:d,rect:a.draggable.measure(d)},draggableNodes:r,dragOverlay:{node:l,rect:a.dragOverlay.measure(u)},droppableContainers:s,measuringConfiguration:a,transform:h})})}function zs(e){const{duration:t,easing:r,sideEffects:s,keyframes:a}={...$s,...e};return o=>{let{active:l,dragOverlay:c,transform:d,...u}=o;if(!t)return;const f={x:c.rect.left-l.rect.left,y:c.rect.top-l.rect.top},h={scaleX:d.scaleX!==1?l.rect.width*d.scaleX/c.rect.width:1,scaleY:d.scaleY!==1?l.rect.height*d.scaleY/c.rect.height:1},x={x:d.x-f.x,y:d.y-f.y,...h},g=a({...u,active:l,dragOverlay:c,transform:{initial:d,final:x}}),[p]=g,w=g[g.length-1];if(JSON.stringify(p)===JSON.stringify(w))return;const m=s==null?void 0:s({active:l,dragOverlay:c,...u}),E=c.node.animate(g,{duration:t,easing:r,fill:"forwards"});return new Promise(C=>{E.onfinish=()=>{m==null||m(),C()}})}}let rn=0;function Bs(e){return i.useMemo(()=>{if(e!=null)return rn++,rn},[e])}const vo=z.memo(e=>
5{let{adjustScale:t=!1,children:r,dropAnimation:s,style:a,transition:o,modifiers:l,wrapperElement:c="div",className:d,zIndex:u=999}=e;const{activatorEvent:f,active:h,activeNodeRect:x,containerNodeRect:g,draggableNodes:p,droppableContainers:w,dragOverlay:m,over:E,measuringConfiguration:C,scrollableAncestors:D,scrollableAncestorRects:b,windowRect:v}=Rn(),k=i.useContext(mt),y=Bs(h==null?void 0:h.id),N=Pn(l,{activatorEvent:f,active:h,activeNodeRect:x,containerNodeRect:g,draggingNodeRect:m.rect,over:E,overlayNodeRect:m.rect,scrollableAncestors:D,scrollableAncestorRects:b,transform:k,windowRect:v}),R=It(x),T=Us({config:s,draggableNodes:p,droppableContainers:w,measuringConfiguration:C}),L=R?m.setRef:void 0;return z.createElement(Ls,null,z.createElement(Rs,{animation:T},h&&y?z.createElement(Os,{key:y,id:h.id,ref:L,as:c,activatorEvent:f,adjustScale:t,className:d,transition:o,rect:R,style:{zIndex:u,...a},transform:N},r):null))});function Tt(e,t,r){const s=e.slice();return s.splice(r<0?s.length+r:r,0,s.splice(t,1)[0]),s}function Ys(e,t){return e.reduce((r,s,a)=>{const o=t.get(s);return o&&(r[a]=o),r},Array(e.length))}function nt(e){return e!==null&&e>=0}function Ks(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Xs(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const An=e=>{let{rects:t,activeIndex:r,overIndex:s,index:a}=e;const o=Tt(t,s,r),l=t[a],c=o[a];return!c||!l?null:{x:c.left-l.left,y:c.top-l.top,scaleX:c.width/l.width,scaleY:c.height/l.height}},rt={scaleX:1,scaleY:1},Ws=e=>{var t;let{activeIndex:r,activeNodeRect:s,index:a,rects:o,overIndex:l}=e;const c=(t=o[r])!=null?t:s;if(!c)return null;if(a===r){const u=o[l];return u?{x:0,y:r<l?u.top+u.height-(c.top+c.height):u.top-c.top,...rt}:null}const d=Vs(o,a,r);return a>r&&a<=l?{x:0,y:-c.height-d,...rt}:a<r&&a>=l?{x:0,y:c.height+d,...rt}:{x:0,y:0,...rt}};function Vs(e,t,r){const s=e[t],a=e[t-1],o=e[t+1];return s?r<t?a?s.top-(a.top+a.height):o?o.top-(s.top+s.height):0:o?o.top-(s.top+s.height):a?s.top-(a.top+a.height):0:0}const Ln="Sortable",In=z.createContext({activeIndex:-1,containerId:Ln,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:An,disabled:{draggable:!1,droppable:!1}});function qs(e){let{children:t,id:r,items:s,strategy:a=An,disabled:o=!1}=e;const{active:l,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:f}=Rn(),h=Je(Ln,r),x=c.rect!==null,g=i.useMemo(()=>s.map(k=>typeof k=="object"&&"id"in k?k.id:k),[s]),p=l!=null,w=l?g.indexOf(l.id):-1,m=u?g.indexOf(u.id):-1,E=i.useRef(g),C=!Ks(g,E.current),D=m!==-1&&w===-1||C,b=Xs(o);ae(()=>{C&&p&&f(g)},[C,g,p,f]),i.useEffect(()=>{E.current=g},[g]);const v=i.useMemo(()=>({activeIndex:w,containerId:h,disabled:b,disableTransforms:D,items:g,overIndex:m,useDragOverlay:x,sortedRects:Ys(g,d),strategy:a}),[w,h,b.draggable,b.droppable,D,g,m,d,x,a]);return z.createElement(In.Provider,{value:v},t)}const _s=e=>{let{id:t,items:r,activeIndex:s,overIndex:a}=e;return Tt(r,s,a).indexOf(t)},Hs=e=>{let{containerId:t,isSorting:r,wasDragging:s,index:a,items:o,newIndex:l,previousItems:c,previousContainerId:d,transition:u}=e;return!u||!s||c!==o&&a===l?!1:r?!0:l!==a&&t===d},Gs={duration:200,easing:"ease"},Tn="transform",Js=Ce.Transition.toString({property:Tn,duration:0,easing:"linear"}),Qs={roleDescription:"sortable"};function Zs(e){let{disabled:t,index:r,node:s,rect:a}=e;const[o,l]=i.useState(null),c=i.useRef(r);return ae(()=>{if(!t&&r!==c.current&&s.current){const d=a.current;if(d){const u=Me(s.current,{ignoreTransform:!0}),f={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(f.x||f.y)&&l(f)}}r!==c.current&&(c.current=r)},[t,r,s,a]),i.useEffect(()=>{o&&l(null)},[o]),o}function eo(e){let{animateLayoutChanges:t=Hs,attributes:r,disabled:s,data:a,getNewIndex:o=_s,id:l,strategy:c,resizeObserverConfig:d,transition:u=Gs}=e;const{items:f,containerId:h,activeIndex:x,disabled:g,disableTransforms:p,sortedRects:w,overIndex:m,useDragOverlay:E,strategy:C}=i.useContext(In),D=to(s,g),b=f.indexOf(l),v=i.useMemo(()=>({sortable:{containerId:h,index:b,items:f},...a}),[h,a,b,f]),k=i.useMemo(()=>f.slice(f.indexOf(l)),[f,l]),{rect:y,node:N,isOver:R,setNodeRef:T}=Ps({id:l,data:v,disabled:D.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...d}}),{active:L,activatorEvent:j,activeNodeRect:F,attributes:U,setNodeRef:S,listeners:P,isDragging:I,over:H,setA
5ctivatorNodeRef:W,transform:le}=Ds({id:l,data:v,attributes:{...Qs,...r},disabled:D.draggable}),Pe=ur(T,S),V=!!L,se=V&&!p&&nt(x)&&nt(m),he=!E&&I,De=he&&se?le:null,Ee=se?De??(c??C)({rects:w,activeNodeRect:F,activeIndex:x,overIndex:m,index:b}):null,ee=nt(x)&&nt(m)?o({id:l,items:f,activeIndex:x,overIndex:m}):b,oe=L==null?void 0:L.id,M=i.useRef({activeId:oe,items:f,newIndex:ee,containerId:h}),ke=f!==M.current.items,G=t({active:L,containerId:h,isDragging:I,isSorting:V,id:l,index:b,items:f,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),pe=Zs({disabled:!G,index:b,node:N,rect:y});return i.useEffect(()=>{V&&M.current.newIndex!==ee&&(M.current.newIndex=ee),h!==M.current.containerId&&(M.current.containerId=h),f!==M.current.items&&(M.current.items=f)},[V,ee,h,f]),i.useEffect(()=>{if(oe===M.current.activeId)return;if(oe!=null&&M.current.activeId==null){M.current.activeId=oe;return}const ge=setTimeout(()=>{M.current.activeId=oe},50);return()=>clearTimeout(ge)},[oe]),{active:L,activeIndex:x,attributes:U,data:v,rect:y,index:b,newIndex:ee,items:f,isOver:R,isSorting:V,isDragging:I,listeners:P,node:N,overIndex:m,over:H,setNodeRef:Pe,setActivatorNodeRef:W,setDroppableNodeRef:T,setDraggableNodeRef:S,transform:pe??Ee,transition:te()};function te(){if(pe||ke&&M.current.newIndex===b)return Js;if(!(he&&!ht(j)||!u)&&(V||G))return Ce.Transition.toString({...u,property:Tn})}}function to(e,t){var r,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function dt(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const no=[O.Down,O.Right,O.Up,O.Left],ro=(e,t)=>{let{context:{active:r,collisionRect:s,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:c}}=t;if(no.includes(e.code)){if(e.preventDefault(),!r||!s)return;const d=[];o.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const x=a.get(h.id);if(x)switch(e.code){case O.Down:s.top<x.top&&d.push(h);break;case O.Up:s.top>x.top&&d.push(h);break;case O.Left:s.left>x.left&&d.push(h);break;case O.Right:s.left<x.left&&d.push(h);break}});const u=Pr({collisionRect:s,droppableRects:a,droppableContainers:d});let f=gn(u,"id");if(f===(l==null?void 0:l.id)&&u.length>1&&(f=u[1].id),f!=null){const h=o.get(r.id),x=o.get(f),g=x?a.get(x.id):null,p=x==null?void 0:x.node.current;if(p&&g&&h&&x){const m=gt(p).some((k,y)=>c[y]!==k),E=On(h,x),C=so(h,x),D=m||!E?{x:0,y:0}:{x:C?s.width-g.width:0,y:C?s.height-g.height:0},b={x:g.left,y:g.top};return D.x&&D.y?b:qe(b,D)}}}};function On(e,t){return!dt(e)||!dt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function so(e,t){return!dt(e)||!dt(t)||!On(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function oo({product:e,onEditClick:t,onDeleteClick:r,onToggleVisibility:s,formatPrice:a,artistSlug:o}){const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:f,isDragging:h}=eo({id:e.id}),x={transform:Ce.Transform.toString(u),transition:f,opacity:h?.5:1},g=e.slug||e.id,w=`https://${o}.fanflowy.co/shop/${g}`;return n.jsxs("tr",{ref:d,style:x,className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[n.jsx("td",{className:"py-3 px-4 w-12",children:n.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing text-gray-400 hover:text-white text-xl",title:"Drag to reorder",children:"⋮⋮"})}),n.jsx("td",{className:"py-3 px-4",children:n.jsx("button",{onClick:()=>t(e.id),className:"text-white hover:text-purple-400 transition-colors text-left font-medium",children:e.name})}),n.jsx("td",{className:"py-3 px-4 text-gray-300 text-sm",children:e.type==="MANUAL"?"Manual":"Printful"}),n.jsx("td",{className:"py-3 px-4 text-gray-300 text-sm",children:a(e.priceCents)}),n.jsx("td",{className:"py-3 px-4",children:n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:e.isActive,onChange:m=>s(e.id,m.target.checked),className:"sr-only peer"}),n.jsx("div",{className:"w-11 h-6 bg-gray-600 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-800 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-purple-600"}),n.jsx("span",{className:"ml-3 text-sm text-gray-400",children:e.isActive?"Visible":"Hidden"})]})}),n.jsxs("td",{className:"py-3 px-4 text-right",children:[e.isActive&&n.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1 text-sm text-blue-300 bg-blue-500/10 rounded-lg hover:bg-blue-500/20 transition-colors mr-2 inline-block",title:"View on site",children:"View"}),n.jsx("button",{onClick:()=>t(e.id),className:"px-3 py-1 text-sm text-white bg-white/10 rounded-lg hover:bg-white/20 transition-colors mr-2",children:"Edit"}),e.isActive&&n.jsx("button",{onClick:()=>r(e.id),className:"px-3 py-1 text-sm text-red-300 bg-red-500/10 rounded-lg hover:bg-red-500/20 transition-colors",children:"Delete"})]})]})}function ao({products:e,isLoading:t,error:r,onCreateClick:s,onEditClick:a,onDeleteClick:o,formatPrice:l,searchQuery:c,setSearchQuery:d,filterType:u,setFilterType:f,filterStatus:h,setFilterStatus:x,artistSlug:g,artistId:p}){const[w,m]=i.useState(e);i.useEffect(()=>{m(e)},[e]);
5const E=Cr(Xt(Lt),Xt(Rt,{coordinateGetter:ro})),C=async v=>{const{active:k,over:y}=v;k.id!==(y==null?void 0:y.id)&&m(N=>{const R=N.findIndex(j=>j.id===k.id),T=N.findIndex(j=>j.id===(y==null?void 0:y.id)),L=Tt(N,R,T);return Yn(p,L.map(j=>j.id)).catch(j=>{console.error("Failed to reorder products:",j),m(e)}),L})},D=async(v,k)=>{m(y=>y.map(N=>N.id===v?{...N,isActive:k}:N));try{await Kn(p,v,k)}catch(y){console.error("Failed to toggle visibility:",y),m(e)}},b=w.filter(v=>{var k,y;if(c){const N=c.toLowerCase();if(!(v.name.toLowerCase().includes(N)||((k=v.description)==null?void 0:k.toLowerCase().includes(N))||((y=v.slug)==null?void 0:y.toLowerCase().includes(N))))return!1}return!(u!=="ALL"&&v.type!==u||h==="ACTIVE"&&!v.isActive||h==="INACTIVE"&&v.isActive)});return n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h2",{className:"text-xl font-semibold text-white",children:"Products"}),n.jsx("button",{onClick:s,className:"px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium",children:"Add product"})]}),n.jsxs("div",{className:"mb-6 space-y-4",children:[n.jsx("div",{children:n.jsx("input",{type:"text",placeholder:"Search products by name, description, or slug...",value:c,onChange:v=>d(v.target.value),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})}),n.jsxs("div",{className:"flex gap-4 flex-wrap",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-2",children:"Type"}),n.jsxs("select",{value:u,onChange:v=>f(v.target.value),className:"px-3 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"ALL",children:"All Types"}),n.jsx("option",{value:"MANUAL",children:"Manual"}),n.jsx("option",{value:"PRINTFUL",children:"Printful"})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-2",children:"Status"}),n.jsxs("select",{value:h,onChange:v=>x(v.target.value),className:"px-3 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"ALL",children:"All Status"}),n.jsx("option",{value:"ACTIVE",children:"Active"}),n.jsx("option",{value:"INACTIVE",children:"Inactive"})]})]}),(c||u!=="ALL"||h!=="ALL")&&n.jsx("div",{className:"flex items-end",children:n.jsx("button",{onClick:()=>{d(""),f("ALL"),x("ALL")},className:"px-3 py-2 text-sm text-gray-400 hover:text-white transition-colors",children:"Clear filters"})})]}),!t&&n.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",b.length," of ",e.length," products"]})]}),t?n.jsxs("div",{className:"text-center py-8",children:[n.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-purple-500 border-r-transparent"}),n.jsx("p",{className:"mt-2 text-sm text-gray-400",children:"Loading products..."})]}):r?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:r})}):b.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx("div",{className:"text-5xl mb-4",children:"📦"}),n.jsx("p",{className:"text-gray-400 mb-4",children:e.length===0?"No products yet":"No products match your filters"}),e.length===0?n.jsx("button",{onClick:s,className:"px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium",children:"Create your first product"}):n.jsx("button",{onClick:()=>{d(""),f("ALL"),x("ALL")},className:"px-4 py-2 bg-white/10 text-white rounded-lg hover:bg-white/20 transition-colors text-sm font-medium",children:"Clear filters"})]}):n.jsx("div",{className:"overflow-x-auto",children:n.jsx(js,{sensors:E,collisionDetection:kr,onDragEnd:C,children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-white/10",children:[n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400 w-12"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Name"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Type"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Price"}),n.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-400",children:"Visibility"}),n.jsx("th",{className:"text-right py-3 px-4 text-sm font-medium text-gray-400",children:"Actions"})]})}),n.jsx("tbody",{children:n.jsx(qs,{items:b.map(v=>v.id),strategy:Ws,children:b.map(v=>n.jsx(oo,{product:v,onEditClick:a,onDeleteClick:o,onToggleVisibility:D,formatPrice:l,artistSlug:g},v.id))})})]})})})]})}function io({artistId:e,artistSlug:t}){var L;const r=an(),[s,a]=i.useState([]),[o,l]=i.useState(!1),[c,d]=i.useState(!1),[u,f]=i.useState(!1),[h,x]=i.useState(null),[g,p]=i.useState(!1),[w,m]=i.useState(null),[E,C]=i.useState(null),D=s.find(j=>{const F=j.name.toLowerCase();return F.includes("fanpack")||F.includes("fan pack")}),[b,v]=i.useState({primaryProductId:"",upsellProductId:"",upsell2ProductId:"",upsell3ProductId:"",itemCount:"",itemsList:"",heroTitle:"",heroSubtitle:"",contentsCopy:"",confirmationCopy:""});i.useEffect(()=>{if(!e)return;(async()=>{var F;try{l(!0),d(!0),x(null);
5const[U,S,P,I]=await Promise.all([jt(e),Xn(e),Wn(e),sn(e).catch(()=>!1)]);a(U),C(P),m(I);const H=U.find(W=>{const le=W.name.toLowerCase();return le.includes("fanpack")||le.includes("fan pack")});v({primaryProductId:S.primaryProductId||(H==null?void 0:H.id)||"",upsellProductId:S.upsellProductId||"",upsell2ProductId:S.upsell2ProductId||"",upsell3ProductId:S.upsell3ProductId||"",itemCount:((F=S.itemCount)==null?void 0:F.toString())||"",itemsList:S.itemsList?JSON.parse(S.itemsList).join(", "):"",heroTitle:S.heroTitle||"",heroSubtitle:S.heroSubtitle||"",contentsCopy:S.contentsCopy||"",confirmationCopy:S.confirmationCopy||""})}catch(U){console.error("Failed to fetch config:",U),x(U instanceof Error?U.message:"Failed to load config")}finally{l(!1),d(!1)}})()},[e]);const k=()=>{r(`/${t}/merchandise/products/new?fanpack=true`)},y=async j=>{if(j.preventDefault(),!!e)try{f(!0),x(null),p(!1);let F=null;if(b.itemsList.trim()){const S=b.itemsList.split(",").map(P=>P.trim()).filter(P=>P.length>0);F=JSON.stringify(S)}const U={primaryProductId:b.primaryProductId||null,upsellProductId:b.upsellProductId||null,upsell2ProductId:b.upsell2ProductId||null,upsell3ProductId:b.upsell3ProductId||null,itemCount:b.itemCount?parseInt(b.itemCount,10):null,itemsList:F,heroTitle:b.heroTitle||null,heroSubtitle:b.heroSubtitle||null,contentsCopy:b.contentsCopy||null,confirmationCopy:b.confirmationCopy||null};await Vn(e,U),p(!0),setTimeout(()=>p(!1),3e3)}catch(F){console.error("Failed to save config:",F),x(F instanceof Error?F.message:"Failed to save config")}finally{f(!1)}},N=j=>j==null?"-":`$${(j/100).toFixed(2)}`,R=s.filter(j=>j.isActive),T=(L=E==null?void 0:E.domain)!=null&&L.hostname?`https://${E.domain.hostname}/fanpack`:null;return!o&&!D?n.jsx("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-8 shadow-lg",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"Create Your FanPack Product"}),n.jsx("p",{className:"text-gray-400 mb-6 max-w-md mx-auto",children:"You need to create a FanPack product first before you can set up your FanPack funnel."}),n.jsx("button",{onClick:k,className:"px-6 py-3 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium",children:"Create FanPack Product"})]})}):n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Shippo:"}),w===null?n.jsx("span",{className:"text-sm text-gray-400",children:"Checking..."}):w?n.jsxs("span",{className:"flex items-center gap-2 text-sm text-green-400",children:[n.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 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"})}),"Connected"]}):n.jsxs("span",{className:"flex items-center gap-2 text-sm text-red-400",children:[n.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),"Not Connected"]})]}),!w&&n.jsx("button",{onClick:()=>r(`/${t}/merchandise?tab=settings`),className:"text-sm text-[#6d60ff] hover:text-[#5d50ef] transition-colors",children:"Connect in Settings →"})]})}),n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsx("h2",{className:"text-xl font-semibold text-white mb-6",children:"FanPack Funnel Configuration"}),c?n.jsxs("div",{className:"text-center py-8",children:[n.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-purple-500 border-r-transparent"}),n.jsx("p",{className:"mt-2 text-sm text-gray-400",children:"Loading configuration..."})]}):h?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:h})}):n.jsxs("form",{onSubmit:y,className:"space-y-6",children:[T&&n.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[n.jsx("p",{className:"text-xs font-medium text-gray-400 mb-2",children:"Your FanPack Page URL"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 px-3 py-2 bg-black/40 border border-white/10 rounded text-sm text-gray-100",children:T}),n.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(T),className:"px-3 py-2 text-xs rounded-lg border border-white/10 text-gray-200 bg-white/5 hover:bg-white/10 transition-colors",children:"Copy"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["FanPack Product ",n.jsx("span",{className:"text-red-400",children:"*"})]}),n.jsxs("select",{value:b.primaryProductId,onChange:j=>v({...b,primaryProductId:j.target.value}),required:!0,className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"",children:"Select a product"}),R.map(j=>n.jsxs("option",{value:j.id,children:[j.name," - ",N(j.priceCents)]},j.id))]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Upsell 1 (optional)"}),n.jsxs("select",{value:b.upsellProductId,onChange:j=>v({...b,upsellProductId:j.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"",children:"None"}),R.map(j=>n.jsxs("option",{value:j.id,children:[j.name," - ",N(j.priceCents)]},j.id))]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Upsell 2 (optional)"}),n.jsxs("select",{value:b.upsell2ProductId,onChange:j=>v({...b,upsell2ProductId:j.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"",children:"None"}),R.map(j=>n.jsxs("option",{value:j.id,children:[j.name," - ",N(j.priceCents)]},j.id))]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Upsell 3 (optional)"}),n.jsxs("select",{value:b.upsell3ProductId,onChange:j=>v({...b,upsell3ProductId:j.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"",children:"None"}),R.map(j=>n.jsxs("option",{value:j.id,children:[j.name," - ",N(j.priceCents)]},j.id))]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Number of Items"}),n.jsx("input",{type:"number",min:"0",value:b.itemCount,onChange:j=>v({...b,itemCount:j.target.value}),placeholder:"5",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Items List (comma-separated)"}),n.jsx("input",{type:"text",value:b.itemsList,onChange:j=>v({...b,itemsList:j.target.value}),placeholder:"guitar picks, signed photo, magnet, stickers",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"}),n.jsx("p",{className:"mt-1 text-xs text-gray-500",children:'List the items included in your FanPack (e.g., "guitar picks, signed photo, magnet")'})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Hero Title"}),n.jsx("input",{type:"text",value:b.heroTitle,onChange:j=>v({...b,heroTitle:j.target.value}),placeholder:"Join Our FanPack!",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Hero Subtitle"}),n.jsx("input",{type:"text",value:b.heroSubtitle,onChange:j=>v({...b,heroSubtitle:j.target.value}),placeholder:"Get exclusive merch and content",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"What's Inside"}),n.jsx("textarea",{value:b.contentsCopy,onChange:j=>v({...b,contentsCopy:j.target.value}),placeholder:"List what fans will get in the FanPack...",rows:4,className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff] resize-none"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Confirmation Message"}),n.jsx("textarea",{value:b.confirmationCopy,onChange:j=>v({...b,confirmationCopy:j.target.value}),placeholder:"Thanks for joining! Check your email...",rows:3,className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff] resize-none"})]}),h&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:h})}),g&&n.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-green-300 text-sm",children:"FanPack configuration saved successfully!"})}),n.jsx("button",{type:"submit",disabled:u,className:"px-6 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Saving...":"Save FanPack Config"})]})]})]})}function lo(){const{artistSlug:e}=on(),t=[{id:"store",label:"Store Info",path:"store-info"},{id:"shipping",label:"Shipping Origin",path:"shipping"},{id:"tax",label:"Tax Settings",path:"tax"},{id:"receipts",label:"Order Receipts",path:"receipts"}];return n.jsx("div",{className:"mt-6",children:n.jsx("div",{className:"grid grid-cols-1 gap-6",children:n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-8 shadow-lg",children:[n.jsx("h2",{className:"text-xl font-semibold text-white mb-4",children:"Store Settings"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Configure your merchandise store settings, integrations, and FanPack funnel."}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(r=>n.jsx(ir,{to:`/${e}/merchandise/settings/${r.path}`,className:qn("block p-6 rounded-xl border transition-all hover:border-purple-600/60 hover:bg-purple-600/5","bg-[#0a0a0a] border-white/10"),children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-medium text-white mb-1",children:r.label}),n.jsxs("p",{className:"text-sm text-gray-400",children:[r.id==="store"&&"Business name, contact details, and currency",r.id==="shipping"&&"Configure shipping origin address",r.id==="tax"&&"Tax calculation and settings",r.id==="receipts"&&"Receipt and confirmation email settings"]})]}),n.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})},r.id))})]})})})}function co({artistId:e,config:t,isLoading:r,error:s,onConfigChange:a}){const[o,l]=i.useState(""),[c,d]=i.useState(!1),[u,f]=i.useState(!1),[h,x]=i.useState(null),[g,p]=i.useState(null),w=async()=>
5{if(!o.trim()){p("API key is required");return}try{d(!0),p(null),await Ut(e,o.trim()),a(),l("")}catch(D){console.error("Failed to connect Shippo:",D),p(D instanceof Error?D.message:"Failed to connect Shippo account")}finally{d(!1)}},m=async()=>{if(!o.trim()){p("API key is required");return}try{f(!0),p(null),x(null),await Ut(e,o.trim());const D=await _n(e);x(D),D?a():p("API key test failed. Please check your key and try again.")}catch(D){console.error("Failed to test Shippo connection:",D),p(D instanceof Error?D.message:"Failed to test connection"),x(!1)}finally{f(!1)}},C=t?t.apiKey?t.isConfigured?{text:"Connected! You can now create shipping labels",color:"text-green-400",step:4}:{text:"Enter your API key once Shippo approves access",color:"text-yellow-400",step:3}:{text:"Request API access from Shippo",color:"text-yellow-400",step:2}:{text:"Create your Shippo account first",color:"text-gray-400",step:1};return n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsxs("div",{className:"flex items-start justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"text-3xl",children:"📮"}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-semibold text-white",children:"Shippo"}),n.jsx("p",{className:"text-sm text-gray-400",children:"Create shipping labels for orders"})]})]}),n.jsx("span",{className:`px-3 py-1 text-xs font-medium rounded-full border ${t!=null&&t.isConfigured?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-500/20 text-gray-300 border-gray-500/30"}`,children:t!=null&&t.isConfigured?"Connected":"Not connected"})]}),r?n.jsx("div",{className:"text-center py-4",children:n.jsx("div",{className:"inline-block h-6 w-6 animate-spin rounded-full border-2 border-solid border-purple-500 border-r-transparent"})}):s?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3 mb-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:s})}):t!=null&&t.isConfigured?n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-gray-300",children:"Shippo is connected and ready to use. You can create shipping labels from the Orders tab."})}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4 space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${C.step>=1?"bg-[#6d60ff] text-white":"bg-gray-600/50 text-gray-400"}`,children:"1"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-white mb-1",children:"Create Shippo Account"}),n.jsx("p",{className:"text-xs text-gray-400 mb-2",children:"Sign up for a Shippo account if you don't have one"}),n.jsx("a",{href:"https://goshippo.com/signup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#6d60ff] hover:text-[#5d50ef] transition-colors",children:"Create Account →"})]})]}),n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${C.step>=2?"bg-[#6d60ff] text-white":"bg-gray-600/50 text-gray-400"}`,children:"2"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-white mb-1",children:"Request API Access"}),n.jsx("p",{className:"text-xs text-gray-400 mb-2",children:"Request API access from Shippo (this may take a few days to be approved)"}),n.jsx("a",{href:"https://goshippo.com/api/access",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#6d60ff] hover:text-[#5d50ef] transition-colors",children:"Request API Access →"})]})]}),n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${C.step>=3?"bg-[#6d60ff] text-white":"bg-gray-600/50 text-gray-400"}`,children:"3"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-white mb-1",children:"Connect Your Account"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Once approved, enter your Shippo API key below"})]})]}),n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${C.step>=4?"bg-[#6d60ff] text-white":"bg-gray-600/50 text-gray-400"}`,children:"4"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-white mb-1",children:"Test Connection"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Verify your API key works correctly"})]})]})]}),n.jsx("div",{className:`p-3 rounded-lg border ${C.color.includes("green")?"bg-green-500/10 border-green-500/30":C.color.includes("yellow")?"bg-yellow-500/10 border-yellow-500/30":"bg-gray-500/10 border-gray-500/30"}`,children:n.jsx("p",{className:`text-sm ${C.color}`,children:C.text})}),(C.step>=3||(t==null?void 0:t.apiKey))&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Shippo API Key"}),n.jsx("input",{type:"password",value:o||(t==null?void 0:t.apiKey)||"",onChange:D=>l(D.target.value),placeholder:"shippo_live_...",disabled:!!(t!=null&&t.apiKey),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff] disabled:opacity-50 disabled:cursor-not-allowed"}),n.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Find your API key in your Shippo account settings"})]}),g&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:g})}),h===!0&&n.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-green-300 text-sm",children:"✓ Connection successful! Shippo is now connected."})}),n.jsx("div",{className:"flex gap-3",children:!(t!=null&&t.isConfigured)&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:m,disabled:u||c||!o&&!(t!=null&&t.apiKey),className:"flex-1 px-4 py-2 bg-[#6d60ff] hover:bg-[#5d50ef] text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:u?"Testing...":"Test & Connect"}),(t==null?void 0:t.apiKey)&&n.jsx("button",{type:"button",onClick:w,disabled:c||u,className:"flex-1 px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Connecting...":"Update Key"})]})})]})]})]})}function uo({artistId:e,config:t,isLoading:r,error:s,onConfigChange:a}){const[o,l]=ln(),[c,d]=i.useState(!1),[u,f]=i.useState(!1),[h,x]=i.useState(!1),[g,p]=i.useState(!1),[w,m]=i.useState(null);i.useEffect(()=>{const y=o.get("stripe");if(y==="connected"){a();const N=new URLSearchParams(o);N.delete("stripe"),l(N,{replace:!0})}else if(y==="error"){const N=o.get("msg");m(N||"Failed to connect Stripe account");const R=new URLSearchParams(o);R.delete("stripe"),R.delete("msg"),l(R,{replace:!0})}},[o,a,l]);const E=async()=>
5{if(!e||e.trim()===""){m("Artist ID is missing. Please refresh the page.");return}try{d(!0),m(null);const y=await Qn(e);window.location.href=y}catch(y){console.error("Failed to start Stripe connection:",y),m(y instanceof Error?y.message:"Failed to connect to Stripe"),d(!1)}},C=async()=>{if(!e||e.trim()===""){m("Artist ID is missing. Please refresh the page.");return}try{f(!0),m(null),await Gn(e)?a():m("Connection test failed. Please reconnect your Stripe account.")}catch(y){console.error("Failed to test Stripe connection:",y),m(y instanceof Error?y.message:"Failed to test connection")}finally{f(!1)}},D=async()=>{if(!(!e||e.trim()==="")&&window.confirm("Disconnect your Stripe account? You can reconnect anytime."))try{x(!0),m(null),await Jn(e),a()}catch(y){console.error("Failed to disconnect Stripe:",y),m(y instanceof Error?y.message:"Failed to disconnect")}finally{x(!1)}},b=async y=>{if(!(!e||!(t!=null&&t.testModeAvailable)||g)&&t.stripeLiveMode!==y)try{p(!0),m(null),await Hn(e,y),a()}catch(N){console.error("Failed to update Stripe mode:",N),m(N instanceof Error?N.message:"Failed to update mode")}finally{p(!1)}},v=(t==null?void 0:t.stripeLiveMode)!==!1,k=(t==null?void 0:t.testModeAvailable)===!0;return n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsxs("div",{className:"flex items-start justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"text-3xl",children:"💳"}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-semibold text-white",children:"Stripe"}),n.jsx("p",{className:"text-sm text-gray-400",children:"Accept payments - money goes directly to you"})]})]}),n.jsx("span",{className:`px-3 py-1 text-xs font-medium rounded-full border ${t!=null&&t.isConfigured?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-500/20 text-gray-300 border-gray-500/30"}`,children:t!=null&&t.isConfigured?"Connected":"Not connected"})]}),r?n.jsx("div",{className:"text-center py-4",children:n.jsx("div",{className:"inline-block h-6 w-6 animate-spin rounded-full border-2 border-solid border-purple-500 border-r-transparent"})}):s?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3 mb-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:s})}):t!=null&&t.isConfigured?n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-gray-300",children:"Your Stripe account is connected. All payments go directly to your Stripe account - FanFlowy never touches your money."}),k&&n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"text-sm text-gray-400",children:"Payment mode"}),n.jsxs("div",{className:"flex items-center rounded-lg border border-white/10 bg-white/5 p-0.5",role:"switch","aria-checked":v,"aria-label":v?"Live mode (real charges)":"Test mode (Stripe test cards)",children:[n.jsx("button",{type:"button",onClick:()=>b(!1),disabled:g||!v,className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${v?"text-gray-400 hover:text-white disabled:opacity-50":"bg-amber-500/30 text-amber-200"}`,children:"Test"}),n.jsx("button",{type:"button",onClick:()=>b(!0),disabled:g||v,className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${v?"bg-green-500/30 text-green-200":"text-gray-400 hover:text-white disabled:opacity-50"}`,children:"Live"})]})]}),k&&n.jsx("p",{className:"text-xs text-gray-500",children:v?"Live: real charges. Switch to Test to use Stripe test cards (e.g. 4242…).":"Test mode: use Stripe test cards only. No real charges."}),t.connectedAccountId&&n.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-3",children:[n.jsx("p",{className:"text-xs text-gray-400 mb-1",children:"Connected Account ID"}),n.jsx("p",{className:"text-xs text-white font-mono",children:t.connectedAccountId})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("button",{type:"button",onClick:C,disabled:u||h,className:"flex-1 px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:u?"Testing...":"Test Connection"}),n.jsx("button",{type:"button",onClick:D,disabled:h||u,className:"flex-1 px-4 py-2 bg-red-600/80 hover:bg-red-600 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors border border-red-500/30",children:h?"Disconnecting...":"Disconnect"})]})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[n.jsx("p",{className:"text-sm text-gray-300 mb-3",children:"Connect your Str
5ipe account to accept payments. When customers pay, the money goes directly to your Stripe account - FanFlowy never touches it."}),n.jsxs("ul",{className:"text-xs text-gray-400 space-y-1 list-disc list-inside mb-3",children:[n.jsx("li",{children:"Secure OAuth connection - no API keys needed"}),n.jsx("li",{children:"Money goes directly to your Stripe account"}),n.jsx("li",{children:"You manage your own payouts and settings"})]}),n.jsx("a",{href:"https://stripe.com",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#6d60ff] hover:text-[#5d50ef] transition-colors",children:"Don't have a Stripe account? Sign up →"})]}),w&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:w})}),n.jsx("button",{type:"button",onClick:E,disabled:c||!e||e.trim()==="",className:"w-full px-4 py-2 bg-[#6d60ff] hover:bg-[#5d50ef] text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Connecting...":"Connect Stripe Account"})]})]})}function fo({artistId:e,printfulConfig:t,isLoadingPrintful:r,printfulError:s,onConnectPrintful:a,isConnectingPrintful:o,onDisconnectPrintful:l,isDisconnectingPrintful:c,onSyncPrintful:d,isSyncingPrintful:u,printfulSyncMessage:f,shippoConfig:h,isLoadingShippo:x,shippoError:g,onShippoConfigChange:p,stripeConfig:w,isLoadingStripe:m,stripeError:E,onStripeConfigChange:C,sectionRef:D}){return n.jsxs("div",{ref:D,id:"integrations",className:"scroll-mt-24 space-y-4",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-200",children:"Integrations"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Connect your payment processor, shipping provider, and Printful store."}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(uo,{artistId:e,config:w,isLoading:m,error:E,onConfigChange:C}),n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/5 p-6 shadow-lg",children:[n.jsxs("div",{className:"flex items-start justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"text-3xl",children:"📦"}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-semibold text-white",children:"Printful"}),n.jsx("p",{className:"text-sm text-gray-400",children:"Print-on-demand fulfillment"})]})]}),n.jsx("span",{className:`px-3 py-1 text-xs font-medium rounded-full border ${t!=null&&t.isActive&&(t!=null&&t.hasTokens)?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-500/20 text-gray-300 border-gray-500/30"}`,children:t!=null&&t.isActive&&(t!=null&&t.hasTokens)?"Connected via Printful":"Not connected"})]}),r?n.jsx("div",{className:"text-center py-4",children:n.jsx("div",{className:"inline-block h-6 w-6 animate-spin rounded-full border-2 border-solid border-purple-500 border-r-transparent"})}):s?n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3 mb-4",children:n.jsx("p",{className:"text-red-300 text-sm",children:s})}):t!=null&&t.isActive&&(t!=null&&t.hasTokens)?n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-gray-300",children:"Products from your connected Printful store can be synced into your merch catalog."}),f&&n.jsx("div",{className:`border rounded-lg p-3 ${f.startsWith("Error")?"bg-red-500/10 border-red-500/30":"bg-green-500/10 border-green-500/30"}`,children:n.jsx("p",{className:`text-sm ${f.startsWith("Error")?"text-red-300":"text-green-300"}`,children:f})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"button",onClick:d,disabled:u||c,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:u?"Syncing...":"Sync Products"}),n.jsx("button",{type:"button",onClick:l,disabled:u||c,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Disconnecting...":"Disconnect"})]})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-gray-300",children:"Connect your Printful account to sync products and fulfill orders."}),f&&n.jsx("div",{className:`border rounded-lg p-3 ${f.startsWith("Error")?"bg-red-500/10 border-red-500/30":"bg-green-500/10 border-green-500/30"}`,children:n.jsx("p",{className:`text-sm ${f.startsWith("Error")?"text-red-300":"text-green-300"}`,children:f})}),n.jsx("button",{type:"button",onClick:a,disabled:o,className:"w-full px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:o?"Connecting...":"Connect Printful"})]})]}),n.jsx(co,{artistId:e,config:h,isLoading:x,error:g,onConfigChange:p})]})]})}function ho({artistId:e}){const[t,r]=i.useState(null),[s,a]=i.useState(!1),[o,l]=i.useState(null),[c,d]=i.useState(!1),[u,f]=i.useState(!1),[h,x]=i.useState(!1),[g,p]=i.useState(null),[w,m]=i.useState(null),[E,C]=i.useState(!1),[D,b]=i.useState(null),[v,k]=i.useState(null),[y,N]=i.useState(!1),[R,T]=i.useState(null);i.useEffect(()=>{if(!e)return;(async()=>{try{a(!0),l(null);const I=await zt(e);r(I)}catch(I){console.error("Failed to fetch Printful config:",I),l(I instanceof Error?I.message:"Failed to load Printful config")}finally{a(!1)}try{C(!0),b(null);const I=await Bt(e);m(I)}catch(I){console.error("Failed to fetch Shippo config:",I),b(I instanceof Error?I.message:"Failed to load Shippo config")}finally{C(!1)}try{N(!0),T(null);const I=await Yt(e);k(I)}catch(I){console.error("Failed to fetch Stripe config:",I),T(I instanceof Error?I.message:"Failed to load Stripe config")}finally{N(!1)}})()},[e]);const L=async()=>
5{if(e)try{const P=await Bt(e);m(P)}catch(P){console.error("Failed to refresh Shippo config:",P)}},j=async()=>{if(e)try{const P=await Yt(e);k(P)}catch(P){console.error("Failed to refresh Stripe config:",P)}},F=async()=>{if(e)try{d(!0),l(null);const P=await tr(e);window.location.href=P}catch(P){console.error("Failed to start Printful connection:",P),l(P instanceof Error?P.message:"Failed to connect to Printful"),d(!1)}},U=async()=>{if(e)try{f(!0),p(null);const P=await Zn(e);p(`Successfully synced ${P.summary.productsSynced} products and ${P.summary.variantsSynced} variants from Printful!`),setTimeout(()=>p(null),5e3)}catch(P){console.error("Failed to sync Printful products:",P),p(`Error: ${P instanceof Error?P.message:"Failed to sync products"}`),setTimeout(()=>p(null),5e3)}finally{f(!1)}},S=async()=>{if(e)try{x(!0),l(null),await er(e);const P=await zt(e);r(P),p("Printful disconnected successfully"),setTimeout(()=>p(null),5e3)}catch(P){console.error("Failed to disconnect Printful:",P),l(P instanceof Error?P.message:"Failed to disconnect Printful")}finally{x(!1)}};return n.jsxs("div",{children:[n.jsx("div",{className:"mb-6",children:n.jsx("p",{className:"text-gray-400",children:"Connect your payment processor, shipping provider, and Printful store to start selling merchandise."})}),n.jsx(fo,{artistId:e,printfulConfig:t,isLoadingPrintful:s,printfulError:o,onConnectPrintful:F,isConnectingPrintful:c,onDisconnectPrintful:S,isDisconnectingPrintful:h,onSyncPrintful:U,isSyncingPrintful:u,printfulSyncMessage:g,shippoConfig:w,isLoadingShippo:E,shippoError:D,onShippoConfigChange:L,stripeConfig:v,isLoadingStripe:y,stripeError:R,onStripeConfigChange:j,sectionRef:()=>{}})]})}function go({artistId:e,order:t,orderForm:r,setOrderForm:s,onSave:a,onClose:o,isSaving:l,error:c,success:d,formatPrice:u,formatDate:f,getStatusColor:h,onOrderUpdate:x}){var U;const[g,p]=i.useState(null),[w,m]=i.useState(!1),[E,C]=i.useState(!1),[D,b]=i.useState([]),[v,k]=i.useState(""),[y,N]=i.useState(null),[R,T]=i.useState(!1),L=((U=t.items)==null?void 0:U.some(S=>{var P;return!((P=S.product)!=null&&P.printfulProductId)}))??!1;i.useEffect(()=>{e&&sn(e).then(S=>p(S)).catch(()=>p(!1))},[e]);const j=async()=>{if(!(!e||!t.id)){if(!t.addressLine1||!t.city||!t.state||!t.postalCode||!t.country){N("Order is missing shipping address");return}try{m(!0),N(null);const S=await nr(e,t.id);b(S),T(!0),S.length>0&&k(S[0].id)}catch(S){console.error("Failed to load shipping rates:",S),N(S instanceof Error?S.message:"Failed to load shipping rates")}finally{m(!1)}}},F=async()=>{if(!(!e||!t.id||!v))try{C(!0),N(null);const S=await rr(e,t.id,v);s({...r,trackingNumber:S.trackingNumber,trackingUrl:S.trackingUrl,status:"FULFILLED",shippedAt:new Date().toISOString()}),x&&x({...t,trackingNumber:S.trackingNumber,trackingUrl:S.trackingUrl,status:"FULFILLED",shippedAt:new Date().toISOString()}),window.open(S.labelUrl,"_blank"),T(!1)}catch(S){console.error("Failed to create shipping label:",S),N(S instanceof Error?S.message:"Failed to create shipping label")}finally{C(!1)}};return n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-[#161616] rounded-2xl border border-white/10 p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-xl font-semibold text-white",children:"Order Details"}),n.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white transition-colors text-2xl leading-none",children:"×"})]}),n.jsxs("div",{className:"mb-6 pb-6 border-b border-white/10",children:[n.jsxs("div",{className:"flex items-start justify-between mb-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Order ID"}),n.jsx("p",{className:"text-white font-mono text-sm",children:t.id})]}),n.jsx("span",{className:`px-3 py-1 text-xs font-medium rounded-full border ${h(t.status)}`,children:t.status})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Order Date"}),n.jsx("p",{className:"text-white",children:f(t.createdAt)})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Total Amount"}),n.jsx("p",{className:"text-white font-semibold",children:u(t.totalCents)})]})]})]}),n.jsxs("div",{className:"mb-6 pb-6 border-b border-white/10",children:[n.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Customer Information"}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Name"}),n.jsx("p",{className:"text-white",children:t.fullName||"—"})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Email"}),n.jsx("p",{className:"text-white",children:t.email||"—"})]})]}),(t.addressLine1||t.city)&&n.jsxs("div",{className:"mt-4",children:[n.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Shipping Address"}),n.jsxs("div",{className:"text-white text-sm",children:[t.addressLine1&&n.jsx("div",{children:t.addressLine1}),t.addressLine2&&n.jsx("div",{children:t.addressLine2}),(t.city||t.state||t.postalCode)&&n.jsxs("div",{children:[t.city,t.state&&`, ${t.state}`," ",t.postalCode]}),t.country&&n.jsx("div",{children:t.country})]})]})]}),n.jsxs("div",{className:"mb-6 pb-6 border-b border-white/10",children:[n.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Order Items"}),t.items&&t.items.length>0?n.jsx("div",{className:"space-y-3",children:t.items.map(S=>{var P,I,H,W;return n.jsxs("div",{className:"flex items-center justify-between bg-white/5 rounded-lg p-3",children:[n.jsxs("div",{className:"flex-1",children:[((P=S.product)==null?void 0:P.name)==="_CSV Import Items"?n.jsx("div",{className:"text-white font-medium",children:((I=S.variant)==null?void 0:I.name)||((H=S.product)==null?void 0:H.name)||"Unknown Product"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"text-white font-medium",children:((W=S.product)==null?void 0:W.name)||"Unknown Product"}),S.variant&&n.jsx("div",{className:"text-sm text-gray-400",children:S.variant.name})]}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Qty: ",S.quantity]})]}),n.jsx("div",{className:"text-white font-medium",children:u(S.lineTotalCents)})]},S.id)})}):n.jsx("p",{className:"text-gray-400 text-sm",children:"No items"})]}),g&&L&&!t.trackingNumber&&n.jsxs("div",{className:"mb-6 pb-6 border-b border-white/10",children:[n.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Shipping Label"}),R?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Select Shipping Method"}
5),n.jsx("select",{value:v,onChange:S=>k(S.target.value),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:D.map(S=>n.jsxs("option",{value:S.id,children:[S.name," - $",S.amount," (",S.minDays,"-",S.maxDays," days)"]},S.id))})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("button",{type:"button",onClick:()=>{T(!1),b([]),N(null)},className:"flex-1 px-4 py-2 bg-white/10 text-white rounded-lg hover:bg-white/20 transition-colors text-sm font-medium",children:"Cancel"}),n.jsx("button",{type:"button",onClick:F,disabled:E||!v,className:"flex-1 px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:E?"Creating...":"Create Label"})]}),y&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:y})})]}):n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"text-sm text-gray-400",children:"Create a shipping label for this order using Shippo."}),n.jsx("button",{type:"button",onClick:j,disabled:w,className:"px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:w?"Loading rates...":"Create Shipping Label"}),y&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:y})})]})]}),!L&&n.jsx("div",{className:"mb-6 pb-6 border-b border-white/10",children:n.jsx("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:n.jsx("p",{className:"text-blue-300 text-sm",children:"ℹ️ This order contains Printful products. Printful handles shipping for these items automatically."})})}),n.jsxs("form",{onSubmit:a,className:"space-y-4",children:[n.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Tracking & Status"}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Status"}),n.jsxs("select",{value:r.status,onChange:S=>s({...r,status:S.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[n.jsx("option",{value:"PENDING",children:"Pending"}),n.jsx("option",{value:"PAID",children:"Paid"}),n.jsx("option",{value:"COMPLETED",children:"Completed"}),n.jsx("option",{value:"FULFILLED",children:"Fulfilled"}),n.jsx("option",{value:"CANCELLED",children:"Cancelled"}),n.jsx("option",{value:"REFUNDED",children:"Refunded"}),n.jsx("option",{value:"FAILED",children:"Failed"})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Tracking Number"}),n.jsx("input",{type:"text",value:r.trackingNumber,onChange:S=>s({...r,trackingNumber:S.target.value}),placeholder:"Enter tracking number",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Tracking URL"}),n.jsx("input",{type:"url",value:r.trackingUrl,onChange:S=>s({...r,trackingUrl:S.target.value}),placeholder:"https://tracking.example.com/...",className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Shipped Date"}),n.jsx("input",{type:"date",value:r.shippedAt?r.shippedAt.split("T")[0]:"",onChange:S=>s({...r,shippedAt:S.target.value?new Date(S.target.value).toISOString():""}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]"})]}),c&&n.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-red-300 text-sm",children:c})}),d&&n.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-3",children:n.jsx("p",{className:"text-green-300 text-sm",children:"Order updated successfully!"})}),n.jsxs("div",{className:"flex gap-3 pt-2",children:[n.jsx("button",{type:"button",onClick:o,className:"flex-1 px-4 py-2 bg-white/10 text-white rounded-lg hover:bg-white/20 transition-colors text-sm font-medium",children:"Close"}),n.jsx("button",{type:"submit",disabled:l,className:"flex-1 px-4 py-2 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:l?"Saving...":"Save Changes"})]})]})]})})}function xo(){const{artistId:e,artistSlug:t}=on(),r=an(),[s,a]=ln(),[o,l]=i.useState(s.get("tab")||"orders");i.useEffect(()=>{const A=s.get("tab");A&&A!==o&&l(A)},[s,o]);const[c,d]=i.useState([]),[u,f]=i.useState(!1),[h,x]=i.useState(null),[g,p]=i.useState(null),[w,m]=i.useState(1),[E,C]=i.useState(null),[D,b]=i.useState(!1),[v,k]=i.useState(null),[y,N]=i.useState(!1),[R,T]=i.useState(""),[L,j]=i.useState({status:"",trackingNumber:"",trackingUrl:"",shippedAt:""}),[F,U]=i.useState([]),[S,P]=i.useState(!1),[I,H]=i.useState(null),[W,le]=i.useState(""),[Pe,V]=i.useState("ALL"),[se,he]=i.useState("ALL"),[De,K]=i.useState(!1),[Ee,ee]=i.useState(null),[oe,M]=i.useState(!1),[ke,G]=i.useState(!1),[pe,te]=i.useState("");i.useEffect(()=>{if(!e||o!=="orders")return;(async()=>{try{f(!0),x(null);const $=await sr(e,{page:w,pageSize:20,q:R||void 0});d($.orders),p($.meta)}catch($){console.error("Failed to fetch orders:",$),x($ instanceof Error?$.message:"Failed to load orders")}finally{f(!1)}})()},[e,o,w,R]),i.useEffect(()=>{m(1)},[R]),i.useEffect(()=>{if(!e||o!=="products")return;(async()=>{try{P(!0),H(null);const $=await jt(e);U($)}catch($){console.error("Failed to fetch products:",$),H($ instanceof Error?$.message:"Failed to load products")}finally{P(!1)}})()},[e,o]);const ge=A=>A?new Date(A).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",xe=A=>{switch(A.toUpperCase()){case"PENDING":return"bg-yellow-500/20 text-yellow-300 border-yellow-500/30";case"PAID":return"bg-blue-500/20 text-blue-300 border-blue-500/30";case"COMPLETED":case"FULFILLED":return"bg-green-500/20 text-green-300 border-green-500/30";case"CANCELLED":case"REFUNDED":return"bg-gray-500/20 text-gray-400 border-gray-500/30";case"FAILED":return"bg-red-500/20 text-red-300 border-red-500/30";default:return"bg-gray-500/20 text-gray-300 border-gray-500/30"}},Ze=A=>{C(A),j({status:A.status,trackingNumber:A.trackingNumber||"",trackingUrl:A.trackingUrl||"",shippedAt:A.shippedAt||""}),k(null),N(!1)},et=()=>{C(null),k(null),N(!1)},Fe=async A=>
5{if(A.preventDefault(),!(!e||!E))try{b(!0),k(null),N(!1);const $={status:L.status,trackingNumber:L.trackingNumber||null,trackingUrl:L.trackingUrl||null,shippedAt:L.shippedAt||null},de=await or(e,E.id,$);d(c.map(ve=>ve.id===de.id?de:ve)),C(de),N(!0),setTimeout(()=>N(!1),3e3)}catch($){console.error("Failed to update order:",$),k($ instanceof Error?$.message:"Failed to update order")}finally{b(!1)}},ce=()=>{r(`/${t}/merchandise/products/new`)},Re=A=>{r(`/${t}/merchandise/products/${A}`)},Ae=async A=>{ee(A),K(!0)},tt=async()=>{if(!(!e||!Ee)){M(!0),te("");try{await ar(e,Ee);const A=await jt(e);U(A),K(!1),ee(null)}catch(A){console.error("Failed to delete product:",A),te("Failed to delete product. Please try again."),G(!0),K(!1)}finally{M(!1)}}},be=A=>{l(A),a({tab:A})},$e=A=>A==null?"-":`$${(A/100).toFixed(2)}`;return n.jsxs("div",{className:"max-w-6xl mx-auto",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-3xl font-bold text-white mb-3",children:"FanMerch"}),n.jsx("p",{className:"text-gray-400 text-lg",children:"Manage orders, products, and FanPack funnel settings."})]}),n.jsx("div",{className:"mb-8",children:n.jsx("div",{className:"border-b border-white/10",children:n.jsxs("nav",{className:"flex gap-8",children:[n.jsxs("button",{onClick:()=>be("orders"),className:`pb-4 px-2 font-medium text-sm transition-colors relative ${o==="orders"?"text-[#6d60ff]":"text-gray-400 hover:text-gray-300"}`,children:["Orders",o==="orders"&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[#6d60ff]"})]}),n.jsxs("button",{onClick:()=>be("products"),className:`pb-4 px-2 font-medium text-sm transition-colors relative ${o==="products"?"text-[#6d60ff]":"text-gray-400 hover:text-gray-300"}`,children:["Products",o==="products"&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[#6d60ff]"})]}),n.jsxs("button",{onClick:()=>be("fanpack"),className:`pb-4 px-2 font-medium text-sm transition-colors relative ${o==="fanpack"?"text-[#6d60ff]":"text-gray-400 hover:text-gray-300"}`,children:["FanPack",o==="fanpack"&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[#6d60ff]"})]}),n.jsxs("button",{onClick:()=>be("integrations"),className:`pb-4 px-2 font-medium text-sm transition-colors relative ${o==="integrations"?"text-[#6d60ff]":"text-gray-400 hover:text-gray-300"}`,children:["Integrations",o==="integrations"&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[#6d60ff]"})]}),n.jsxs("button",{onClick:()=>be("settings"),className:`pb-4 px-2 font-medium text-sm transition-colors relative ${o==="settings"?"text-[#6d60ff]":"text-gray-400 hover:text-gray-300"}`,children:["Settings",o==="settings"&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[#6d60ff]"})]})]})})}),o==="orders"&&n.jsx(dr,{orders:c,isLoading:u,error:h,searchQuery:R,setSearchQuery:T,onOrderClick:Ze,formatPrice:$e,formatDate:ge,getStatusColor:xe,page:(g==null?void 0:g.page)??w,totalPages:(g==null?void 0:g.totalPages)??1,total:(g==null?void 0:g.total)??c.length,onPrevPage:()=>m(A=>Math.max(1,A-1)),onNextPage:()=>m(A=>Math.min((g==null?void 0:g.totalPages)??A+1,A+1))}),o==="products"&&n.jsx(ao,{products:F,isLoading:S,error:I,onCreateClick:ce,onEditClick:Re,onDeleteClick:Ae,formatPrice:$e,searchQuery:W,setSearchQuery:le,filterType:Pe,setFilterType:V,filterStatus:se,setFilterStatus:he,artistSlug:t,artistId:e}),o==="fanpack"&&n.jsx(io,{artistId:e,artistSlug:t}),o==="integrations"&&n.jsx(ho,{artistId:e}),o==="settings"&&n.jsx(lo,{}),E&&n.jsx(go,{artistId:e,order:E,orderForm:L,setOrderForm:j,onSave:Fe,onClose:et,isSaving:D,error:v,success:y,formatPrice:$e,formatDate:ge,getStatusColor:xe,onOrderUpdate:A=>{C(A),d(c.map($=>$.id===A.id?A:$))}}),n.jsx(lr,{isOpen:De,title:"Deactivate Product",message:"Are you sure you want to deactivate this product? It will no longer be available for purchase.",confirmText:"Deactivate",onConfirm:tt,onCancel:()=>{K(!1),ee(null)},isLoading:oe}),n.jsx(cr,{isOpen:ke,title:"Error",message:pe,variant:"error",onClose:()=>G(!1)})]})}const yo=Object.freeze(Object.defineProperty({__proto__:null,default:xo},Symbol.toStringTag,{value:"Module"}));
5export{cr as A,Ce as C,js as D,fo as I,Ps as a,vo as b,yo as c,Ds as u};

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.