1import{d as N,r as d,j as e,B as P,D as le,f as ne,g as ie,h as ce,t as M}from"./index-Ba4BgsO5.js";import{S as V,a as _,b as z,c as G}from"./select-DGHYmM0b.js";import{p as D}from"./tradeValue-Rp5qGxcU.js";import{u as oe}from"./useTeamDraftPicks-Cido698F.js";import{A as J}from"./arrow-left-right-DHtjZ6Bb.js";import"./index-BdQq_4o_.js";import"./index-7i6O1qb3.js";import"./chevron-up-Do4Z_DWR.js";const de={"AFC East":["Bills","Dolphins","Patriots","Jets"],"AFC North":["Browns","Ravens","Bengals","Steelers"],"AFC South":["Texans","Titans","Colts","Jaguars"],"AFC West":["Chiefs","Raiders","Chargers","Broncos"],"NFC East":["Cowboys","Eagles","Giants","Commanders"],"NFC North":["Bears","Lions","Packers","Vikings"],"NFC South":["Falcons","Panthers","Saints","Buccaneers"],"NFC West":["49ers","Rams","Seahawks","Cardinals"]},W=Object.values(de).flat(),j=({team:u,className:f="w-6 h-6"})=>{const t=u.toLowerCase();let r=t.replace(/\s+/g,"");return t==="raiders"?r="lv":t==="browns"?r="cle":t==="texans"?r="hou":t==="titans"?r="ten":t==="giants"?r="nyg":t==="jets"?r="nyj":t==="eagles"?r="phi":t==="commanders"?r="wsh":t==="cowboys"?r="dal":t==="packers"?r="gb":t==="lions"?r="det":t==="vikings"?r="min":t==="bears"?r="chi":t==="saints"?r="no":t==="buccaneers"?r="tb":t==="falcons"?r="atl":t==="panthers"?r="car":t==="49ers"?r="sf":t==="seahawks"?r="sea":t==="rams"?r="lar":t==="cardinals"?r="ari":t==="bills"?r="buf":t==="dolphins"?r="mia":t==="patriots"?r="ne":t==="chiefs"?r="kc":t==="chargers"?r="lac":t==="broncos"?r="den":t==="ravens"?r="bal":t==="bengals"?r="cin":t==="steelers"?r="pit":t==="colts"?r="ind":t==="jaguars"&&(r="jax"),e.jsx("img",{src:`https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/${r}.png`,alt:`${u} logo`,className:`${f} object-contain flex-shrink-0`,onError:c=>{c.target.style.display="none"}})};function ve({onClose:u}){var L,I;const f=N(s=>s.preselectedTradeTeam),[t,r]=d.useState(f||""),[c,H]=d.useState(""),[U,v]=d.useState(()=>!f),[q,k]=d.useState(()=>!!f),[m,y]=d.useState([]),[x,w]=d.useState([]);d.useEffect(()=>{y([])},[t]),d.useEffect(()=>{w([])},[c]);const[me,K]=d.useState(null),[xe,E]=d.useState(!1),[Q,X]=d.useState(!1),[Y,F]=d.useState(!1),[p,O]=d.useState(null),Z=N(s=>s.addCompletedTrade),ee=N(s=>s.setCurrentTab),se=N(s=>s.draftPicks);d.useEffect(()=>{f&&(r(f),v(!1),k(!0),N.setState({preselectedTradeTeam:null}))},[f]);const{data:R,isLoading:C}=oe();d.useEffect(()=>{!C&&!t&&!f&&(v(!0),k(!1))},[C,f,t]);const te=N(s=>s.getCurrentOwner),T=s=>{if(!R)return[];const a=[];
1return Object.entries(R.picks).forEach(([l,i])=>{i.forEach(h=>{const g=h.match(/round\s+(\d+)/i),n=h.match(/pick\s+(\d+)/i);if(g&&n){const o=parseInt(g[1]),b=parseInt(n[1]);te(o,b,l)===s&&a.push({round:o,pick:b,team:s})}})}),a.sort((l,i)=>l.pick-i.pick).filter(l=>!se.find(h=>h.round===l.round&&h.pick===l.pick&&h.playerId!==null))},S=t?T(t):[],$=c?T(c):[],B=()=>{const s=n=>{const o=n.map(b=>b.round===1?"1st":b.round===2?"2nd":b.round===3?"3rd":`${b.round}th`);return o.length===1?`${o[0]} round pick`:o.length===2?`${o[0]} and ${o[1]} round picks`:`${o.slice(0,-1).join(", ")}, and ${o[o.length-1]} round picks`},a={fromTeam:t,toTeam:c,fromPicks:s(m),toPicks:s(x)};K(a),E(!0),X(!0),Z({fromTeam:t,toTeam:c,fromPicks:m.map(n=>({round:n.round,pick:n.pick})),toPicks:x.map(n=>({round:n.round,pick:n.pick}))});const l=x.map(n=>({round:n.round,pick:n.pick})),i=m.map(n=>({round:n.round,pick:n.pick})),h=l.length>0?Math.min(...l.map(n=>n.pick)):1/0,g=i.length>0?Math.min(...i.map(n=>n.pick)):1/0;h<=g?O({leftTeam:t,leftPicks:l,rightTeam:c,rightPicks:i}):O({leftTeam:c,leftPicks:i,rightTeam:t,rightPicks:l}),document.dispatchEvent(new CustomEvent("stopAutoDraft")),F(!0)},ae=()=>{F(!1),E(!1);const a=N.getState().draftPicks.find(i=>i.playerId===null),l=a?a.round:1;ee(`Round${l}`),u==null||u()},re=(s,a)=>{a?m.find(l=>l.pick===s.pick)?y(m.filter(l=>l.pick!==s.pick)):y([...m,s]):x.find(l=>l.pick===s.pick)?w(x.filter(l=>l.pick!==s.pick)):w([...x,s])},A=(s,a)=>{const l=a?m.find(i=>i.pick===s.pick):x.find(i=>i.pick===s.pick);return e.jsxs("div",{className:`px-3 py-1 cursor-pointer transition-all duration-200 flex items-center justify-between text-sm ${l?"bg-gray-100 shadow-sm":"bg-white hover:bg-gray-100"}`,onClick:()=>re(s,a),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-gray-900 font-normal text-sm",children:["Round ",s.round,", Pick ",s.pick]}),l&&e.jsx("span",{className:"text-green-600 font-bold ml-1",children:"â"})]}),e.jsx("span",{className:"font-mono text-sm text-gray-900 font-medium",children:D[s.pick]||0})]},`${s.round}-${s.pick}`)};return C?e.jsx("div",{className:"w-full min-h-[calc(80vh-4rem)] bg-white text-gray-900 flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-lg font-semibold text-gray-700 mb-2",children:"Loading draft picks data..."})})}):e.jsxs("div",{className:`w-full bg-white text-gray-900 ${u?"min-h-0":"min-h-[calc(80vh-4rem)]"}`,children:[e.jsxs("div",{className:`${u?"w-full px-5 pt-6 pb-5":"max-w-5xl mx-auto px-3 pt-4"}`,children:[e.jsxs("div",{className:`flex justify-center items-start gap-1 mx-auto ${u?"w-full":"max-w-[70%]"}`,children:[e.jsxs("div",{className:"w-full mb-4",children:[e.jsxs(V,{value:t,open:U,onOpenChange:v,onValueChange:s=>{r(s),v(!1),setTimeout(()=>k(!0),0)},children:[e.jsx(_,{className:"w-full text-lg h-10 border-2",style:{backgroundColor:"#E5E7EB",color:"#000000",borderColor:"#D1D5DB"},children:e.jsx("div",{className:"flex items-center gap-2 w-full",children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:t}),e.jsx(j,{team:t,className:"w-6 h-6"})]}):e.jsx("span",{children:"Select Team 1"})})}),e.jsxs(z,{position:"popper",showScrollButtons:!1,viewportClassName:"!h-auto",className:"bg-white border-gray-400 p-0 w-full max-h-[400px] overflow-y-auto",children:[e.jsx("div",{className:"bg-gray-100 border-b border-gray-300 px-3 py-2",children:e.jsx("div",{className:"text-xs font-semibold text-gray-600",children:"Ordered by next pick"})}),e.jsx("div",{className:"space-y-0",children:W.filter(s=>s!==c).map(s=>{const a=T(s),l=a.length>0?a[0].pick:null;return{team:s,nextPick:l}}).sort((s,a)=>s.nextPick===null?1:a.nextPick===null?-1:s.nextPick-a.nextPick).map(({team:s,nextPick:a})=>e.jsx(G,{value:s,hideCheck:!0,className:"!p-0 !bg-transparent hover:!bg-gray-100 focus:!bg-gray-100 cursor-pointer group",children:e.jsx("div",{className:"w-full px-3 py-2 flex items-center gap-3 text-gray-900",children:a?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-sm w-8 text-black",children:a}),e.jsx("span",{className:"font-medium text-sm flex-1",children:s}),e.jsx(j,{team:s})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"â"})})},`${s}-${a}
1`))})]})]}),t&&S.length>0&&e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"border border-gray-400 rounded-lg overflow-hidden bg-white max-h-[300px] flex flex-col",children:e.jsx("div",{className:"overflow-y-auto pt-0",children:S.map((s,a)=>e.jsxs("div",{children:[A(s,!0),a<S.length-1&&e.jsx("div",{className:"border-b border-gray-200"})]},`${s.round}-${s.pick}`))})})})]}),e.jsxs("div",{className:"w-full mb-4",children:[e.jsxs(V,{value:c,open:q,onOpenChange:k,onValueChange:s=>{H(s),k(!1)},children:[e.jsx(_,{className:"w-full text-lg h-10 border-2",style:{backgroundColor:"#E5E7EB",color:"#000000",borderColor:"#D1D5DB"},children:e.jsx("div",{className:"flex items-center gap-2 w-full",children:c?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:c}),e.jsx(j,{team:c,className:"w-6 h-6"})]}):e.jsx("span",{children:"Select Team 2"})})}),e.jsxs(z,{position:"popper",showScrollButtons:!1,viewportClassName:"!h-auto",className:"bg-white border-gray-400 p-0 w-full max-h-[400px] overflow-y-auto",children:[e.jsx("div",{className:"bg-gray-100 border-b border-gray-300 px-3 py-2",children:e.jsx("div",{className:"text-xs font-semibold text-gray-600",children:"Ordered by next pick"})}),e.jsx("div",{className:"space-y-0",children:W.filter(s=>s!==t).map(s=>{const a=T(s),l=a.length>0?a[0].pick:null;return{team:s,nextPick:l}}).sort((s,a)=>s.nextPick===null?1:a.nextPick===null?-1:s.nextPick-a.nextPick).map(({team:s,nextPick:a})=>e.jsx(G,{value:s,hideCheck:!0,className:"!p-0 !bg-transparent hover:!bg-gray-100 focus:!bg-gray-100 cursor-pointer group",children:e.jsx("div",{className:"w-full px-3 py-2 flex items-center gap-3 text-gray-900",children:a?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-sm w-8 text-black",children:a}),e.jsx("span",{className:"font-medium text-sm flex-1",children:s}),e.jsx(j,{team:s})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"â"})})},`${s}-${a}`))})]})]}),c&&$.length>0&&e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"border border-gray-400 rounded-lg overflow-hidden bg-white max-h-[300px] flex flex-col",children:e.jsx("div",{className:"overflow-y-auto pt-0",children:$.map((s,a)=>e.jsxs("div",{children:[A(s,!1),a<$.length-1&&e.jsx("div",{className:"border-b border-gray-200"})]},`${s.round}-${s.pick}`))})})})]})]}),(m.length>0||x.length>0)&&(()=>{const s=m.reduce((n,o)=>n+(D[o.pick]||0),0),a=x.reduce((n,o)=>n+(D[o.pick]||0),0),l=m.length>=2||x.length>=2,i=l&&m.length>0&&x.length>0,h=i?Math.min(s,a)/Math.max(s,a)*100:0,g=i&&h>=95;return e.jsxs("div",{className:"mt-4 bg-gray-50 border border-gray-200 rounded-lg p-3 mx-auto w-full max-w-[80%]",children:[e.jsx("div",{className:"flex flex-col items-center gap-2",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(j,{team:t||"",className:"w-10 h-10"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-gray-900 leading-tight truncate max-w-[100px]",children:t}),e.jsxs("div",{className:"text-xs text-gray-600 font-bold",children:[s," pts"]})]})]}),e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:i&&e.jsxs("div",{className:"w-full px-2",children:[e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mb-1",children:e.jsx("div",{className:"h-2 rounded-full transition-all duration-300",style:{width:`${h}%`,backgroundColor:g?"#16a34a":"#dc2626"}})}),e.jsx("div",{className:"text-center",children:e.jsx("span",{className:`text-xs font-bold ${g?"text-green-600":"text-red-600"}`,children:g?"Accept Trade":`${h.toFixed(0)}% Fair`})})]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 justify-end text-right",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-gray-900 leading-tight truncate max-w-[100px]",children:c}),e.jsxs("div",{className:"text-xs text-gray-600 font-bold",children:[a," pts"]})]}),e.jsx(j,{team:c||"",className:"w-10 h-10"})]})]})}),l&&m.length>0&&x.length>0&&!Q&&e.jsxs("div",{className:"flex justify-center gap-2 mt-3 pt-2 border-t border-gray-100",children:[e.jsx(P,{variant:"ghost",size:"sm",className:"h-7 text-[10px] text-gray-500 hover:text-red-600 px-2",onClick:()=>{y([]),w([])},children:"Cancel"}),g?e.jsx(P,{variant:"default",size:"sm",className:"h-7 bg-green-600 hover:bg-green-700 text-white font-bold px-4 text-[10px]",onClick:B,children:"Accept Trade"}):e.jsx(P,{variant:"default",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-white font-bold px-4 text-[10px]",onClick:B,children:"Force Trade"})]})]})})()]}),e.jsx(le,{open:Y,onOpenChange:()=>{},children:e.jsxs(ne,{className:"max-w-lg bg-white p-0 overflow-hidden [&>button]:hidden",children:[e.jsx(ie,{className:"px-6 py-2 border-b",children:e.jsxs(ce,{className:"text-xl font-bold text-gray-900 text-center flex items-center justify-center gap-2",children:[e.jsx(J,{className:"w-5 h-5 text-green-600"}),"Trade Successful",e.jsx(J,{className:"w-5 h-5 text-green-600"})]})}),p&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[e.jsx(j,{team:p.leftTeam,className:"w-12 h-12"}),e.jsx("span",{className:"text-xl font-bold",style:{color:((L=M(p.leftTeam))==null?void 0:L.bg)||"#000"},children:p.leftTeam})]}),e.jsx("div",{className:"text-sm text-gray-600 mb-2 font-medium",children:"Receive:"}),e.jsx("div",{className:"space-y-1",children:p.leftPicks.sort((s,a)=>s.pick-a.pick).map((s,a)=>e.jsxs("div",{className:"bg-gray-100 rounded px-3 py-1 text-sm font-medium",children:["Round ",s.round,", Pick ",s.pick]},a))})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[e.jsx(j,{team:p.rightTeam,className:"w-12 h-12"}),e.jsx("span",{className:"text-xl font-bold",style:{color:((I=M(p.rightTeam))==null?void 0:I.bg)||"#000"},children:p.rightTeam})]}),e.jsx("div",{className:"text-sm text-gray-600 mb-2 font-medium",children:"Receive:"}),e.jsx("div",{className:"space-y-1",children:p.rightPicks.sort((s,a)=>s.pick-a.pick).map((s,a)=>e.jsxs("div",{className:"bg-gray-100 rounded px-3 py-1 text-sm font-medium",children:["Round ",s.round,", Pick ",s.pick]},a))})]})]}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(P,{onClick:ae,className:"bg-blue-600 hover:bg-blue-700 text-white font-bold px-8 py-2 text-lg shadow-[0_4px_0_rgb(30,58,138)] active:shadow-none active:translate-y-[2px] transition-all border-b-4 border-blue-800",children:"Return to Draft"})})]})]})})]})}export{ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.