PageSourceSearch

https://mtgmaster.app/assets/Wishboard-C610JVBS.js

js mtgmaster.app collected 2026-10-09 22:55:53 UTC 41,940 bytes, 1 lines download raw bytes

1import{r as t,e as Ke,j as l,M as Ia,a3 as Aa}from"./index-Di8FtgDo.js";import{v as xt,m as Pa,w as ja,n as La}from"./cardsApi-BdZDs8Ne.js";import{E as Ue,F as Fa,G as Ra,H as Ta,I as ze,J as wt,K as Va,L as Ea,a as Da,M as $a,N as Wa,j as qa}from"./collectionApi-BSZP5E9g.js";import{C as ht}from"./ConfirmDialog-BvkewGAe.js";import{C as Oa}from"./CardDetailModal-CljXmOj4.js";import{u as Ba,b as Qa,c as Ha}from"./CollectionGridView-DCh74kf-.js";import{m as Ka,c as Ua,C as za,a as Ga,b as Ya}from"./collectionFilters-Y5oekhZI.js";import{C as Ja}from"./CollectionAddCardModal-jkCjxXIq.js";import{C as Xa}from"./CardsTableView-DelZY1wQ.js";import{d as Za,g as er}from"./deckExportFormats-DFYpgzQ7.js";import"./SetIcon-CLiRABcj.js";import"./collectionPrintMatch-Bku2maA5.js";import"./loader-circle-CDEnj3Fi.js";import"./shield-BzeErTwb.js";import"./AffiliateButton-BSStq6jf.js";import"./chart-line-wwrKjqU9.js";import"./search-CHpvdPcG.js";import"./chevron-up-CaGlue98.js";import"./clsx-B-dksMZM.js";import"./cardImageHelpers-DDWmO_m3.js";import"./ManaCost-DeVtsgD6.js";import"./ellipsis-vertical-Cgkqadfb.js";import"./heart-BgEG9nuU.js";import"./folder-Dl3TpcFk.js";import"./plus-7PJo7nOr.js";import"./pencil-XhWeM8PR.js";import"./trash-2-CqsSnwhG.js";const pt="wishboard_prefs";function tr(){const e=t.useMemo(()=>{try{if(typeof window>"u")return{};const d=localStorage.getItem(pt);if(!d)return{};const x=JSON.parse(d);return!x||typeof x!="object"?{}:(x.filters&&typeof x.filters=="object"&&(x.filters.color_identity&&!Array.isArray(x.filters.color_identity)&&(x.filters.color_identity=String(x.filters.color_identity||"").split(/[,\s]+/g).map(k=>k.trim()).filter(Boolean)),x.filters.keywords&&!Array.isArray(x.filters.keywords)&&(x.filters.keywords=String(x.filters.keywords||"").split(",").map(k=>k.trim()).filter(Boolean))),x)}catch{return{}}},[]),[n,y]=t.useState(e.viewMode||"text"),[u,p]=t.useState(e.pageSize&&[15,25,50,100,200].includes(Number(e.pageSize))?Number(e.pageSize):15),[c,i]=t.useState({set:"any",rarity:"any",language:"any",foil:"any",condition:"any",type:"any",color_identity:[],keywords:[],price_min:"",price_max:"",...e.filters||{}}),[g,b]=t.useState(e.sortBy||"name"),[N,v]=t.useState(e.sortDir||"asc"),[M,S]=t.useState(1),[T,s]=t.useState(""),[J,O]=t.useState(""),[H,F]=t.useState(""),[G,P]=t.useState(""),V=t.useCallback((d,x)=>{const k={...x,...d||{}};return k.color_identity&&!Array.isArray(k.color_identity)&&(k.color_identity=String(k.color_identity||"").split(/[,\s]+/g).map(L=>L.trim()).filter(Boolean)),k.keywords&&!Array.isArray(k.keywords)&&(k.keywords=String(k.keywords||"").split(",").map(L=>L.trim()).filter(Boolean)),k},[]),E=t.useCallback(d=>{i(x=>V(typeof d=="function"?d(x):d,x)),S(1)},[V]),X=t.useCallback(d=>{b(d),S(1)},[]),B=t.useCallback(d=>{v(d),S(1)},[]),Q=t.useCallback(d=>{p(d),S(1)},[]),C=t.useCallback(d=>{O(d),S(1)},[]),A=t.useCallback(d=>{P(d),S(1)},[]);return t.useEffect(()=>{const d={viewMode:n,pageSize:u,filters:c,sortBy:g,sortDir:N};try{localStorage.setItem(pt,JSON.stringify(d))}catch{}},[n,u,c,g,N]),{viewMode:n,setViewMode:y,pageSize:u,setPageSize:Q,filters:c,setFilters:E,sortBy:g,sortDir:N,setSortBy:X,setSortDir:B,page:M,setPage:S,searchInput:T,setSearchInput:s,q:J,setQ:C,naturalSearchInput:H,setNaturalSearchInput:F,naturalQ:G,setNaturalQ:A}}const ar=360*60*1e3,rr=120*1e3,nr=120*1e3,Fe={sets:[],languages:[],conditions:[],rarities:[],keywords:[]};let de=null,qe=0,be=null;const Oe=new Map,$e=new Map,Be=new Map;function Qe({filters:e,sortBy:n,sortDir:y,page:u,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b}){const N=Array.isArray(e?.color_identity)?[...e.color_identity].sort().join(","):"",v=Array.isArray(e?.keywords)?[...e.keywords].sort().join(","):"";return[`page=${u}`,`pageSize=${p}`,`sortBy=${n||""}`,`sortDir=${y||""}`,`set=${e?.set||""}`,`rarity=${e?.rarity||""}`,`language=${e?.language||""}`,`foil=${e?.foil||""}`,`condition=${e?.condition||""}`,`type=${e?.type||""}`,`colors=${N}`,`keywords=${v}`,`priceMin=${e?.price_min||""}`,`priceMax=${e?.price_max||""}`,`q=${c||""}`,`naturalQ=${i||""}`,`currency=${g||""}`,`provider=${b||""}`].join("|")}function or({filters:e,q:n,naturalQ:y,currency:u,priceProvider:p}){const c=Array.isArray(e?.color_identity)?[...e.color_identity].sort().join(","):"",i=Array.isArray(e?.keywords)?[...e.keywords].sort().join(","):"";return[`set=${e?.set||""}`,`rarity=${e?.rarity||""}`,`language=${e?.language||""}`,`foil=${e?.foil||""}`,`condition=${e?.condition||""}`,`type=${e?.type||""}`,`colors=${c}`,`keywords=${i}`,`priceMin=${e?.price_min||""}`,`priceMax=${e?.price_max||""}`,`q=${n||""}`,`naturalQ=${y||""}`,`currency=${u||""}`,`provider=${p||""}`].join("|")}function sr({filters:e,sortBy:n,sortDir:y,pageSize:u,q:p,naturalQ:c,currency:i,priceProvider:g}){const b=Array.isArray(e?.color_identity)?[...e.color_identity].sort().join(","):"",N=Array.isArray(e?.keywords)?[...e.keywords].sort().join(","):"";return[`pageSize=${u}`,`sortBy=${n||""}`,`sortDir=${y||""}`,`set=${e?.set||""}`,`rarity=${e?.rarity||""}`,`language=${e?.language||""}`,`foil=${e?.foil||""}`,`condition=${e?.condition||""}`,`type=${e?.type||""}`,`colors=${b}`,`keywords=${N}`,`priceMin=${e?.price_min||""}`,`priceMax=${e?.price_max||""}`,`q=${p||""}`,`naturalQ=${c||""}`,`currency=${i||""}`,`provider=${g||""}`].join("|")}function gt(e,n,y,u){const p={...e||{},[n]:y?.items||[]},c=Number(y?.total_rows??y?.total??0)||0,i=c>0?Math.ceil(c/Math.max(1,Number(u||1))):1;
1return Object.keys(p).forEach(g=>{Number(g)>i&&delete p[g]}),p}function St(e){const n=Oe.get(e);return n?Date.now()-n.at>rr?(Oe.delete(e),null):n.payload:null}function He(e,n){Oe.set(e,{payload:n,at:Date.now()})}function lr(e){const n=Be.get(e);return n?Date.now()-n.at>nr?(Be.delete(e),null):n.payload:null}function ir(e,n){Be.set(e,{payload:n,at:Date.now()})}function cr(e){const n=Qe(e);if(St(n)||$e.has(n))return;const y=Ue({set:e.filters.set!=="any"?e.filters.set:void 0,rarity:e.filters.rarity!=="any"?e.filters.rarity:void 0,language:e.filters.language!=="any"?e.filters.language:void 0,foil:e.filters.foil!=="any"?e.filters.foil==="foil"?"true":"false":void 0,condition:e.filters.condition!=="any"?e.filters.condition:void 0,type:e.filters.type!=="any"?e.filters.type:void 0,color_identity:Array.isArray(e.filters.color_identity)&&e.filters.color_identity.length?e.filters.color_identity.join(","):void 0,keywords:Array.isArray(e.filters.keywords)&&e.filters.keywords.length?e.filters.keywords.join(","):void 0,price_min:e.filters.price_min!==""?e.filters.price_min:void 0,price_max:e.filters.price_max!==""?e.filters.price_max:void 0,q:e.q,natural_q:e.naturalQ,page:e.page,page_size:e.pageSize,sort_by:e.sortBy,sort_dir:e.sortDir,currency:e.currency,price_provider:e.priceProvider}).then(u=>{u&&He(n,u)}).catch(()=>{}).finally(()=>{$e.delete(n)});$e.set(n,y)}async function bt(){const e=Date.now();return de&&e-qe<ar?de:be||(be=Ra().then(n=>{const y=n||Fe;return de=y,qe=Date.now(),y}).finally(()=>{be=null}),be)}function ur(){de=null,qe=0,be=null}function dr({filters:e,sortBy:n,sortDir:y,page:u,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b,deferSummary:N=!1,accumulatePages:v=!1}){const[M,S]=t.useState([]),[T,s]=t.useState({}),[J,O]=t.useState({sets:[],languages:[],conditions:[],rarities:[],keywords:[]}),[H,F]=t.useState(0),[G,P]=t.useState(0),[V,E]=t.useState(null),[X,B]=t.useState(!0),[Q,C]=t.useState({}),[A,d]=t.useState(!0),x=t.useRef(0),k=t.useRef(0),L=t.useRef(null),se=t.useMemo(()=>sr({filters:e,sortBy:n,sortDir:y,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b}),[e,n,y,p,c,i,g,b]),K=t.useRef(se),ae=t.useRef(v),le=t.useMemo(()=>v?Object.keys(T).map(w=>Number(w)).sort((w,W)=>w-W).filter(w=>w<=u).flatMap(w=>T[w]||[]):M,[v,T,u,M]),re=t.useCallback(async w=>Ue({set:e.set!=="any"?e.set:void 0,rarity:e.rarity!=="any"?e.rarity:void 0,language:e.language!=="any"?e.language:void 0,foil:e.foil!=="any"?e.foil==="foil"?"true":"false":void 0,condition:e.condition!=="any"?e.condition:void 0,type:e.type!=="any"?e.type:void 0,color_identity:Array.isArray(e.color_identity)&&e.color_identity.length?e.color_identity.join(","):void 0,keywords:Array.isArray(e.keywords)&&e.keywords.length?e.keywords.join(","):void 0,price_min:e.price_min!==""?e.price_min:void 0,price_max:e.price_max!==""?e.price_max:void 0,q:c,natural_q:i,page:w,page_size:p,sort_by:n,sort_dir:y,currency:g,price_provider:b}),[g,e,i,p,b,c,n,y]),D=t.useCallback(async()=>{const w=++k.current,W=or({filters:e,q:c,naturalQ:i,currency:g,priceProvider:b}),Y=lr(W);E(Y?Y?.total_value??null:null);try{const a=await Fa({set:e.set!=="any"?e.set:void 0,rarity:e.rarity!=="any"?e.rarity:void 0,language:e.language!=="any"?e.language:void 0,foil:e.foil!=="any"?e.foil==="foil"?"true":"false":void 0,condition:e.condition!=="any"?e.condition:void 0,type:e.type!=="any"?e.type:void 0,color_identity:Array.isArray(e.color_identity)&&e.color_identity.length?e.color_identity.join(","):void 0,keywords:Array.isArray(e.keywords)&&e.keywords.length?e.keywords.join(","):void 0,price_min:e.price_min!==""?e.price_min:void 0,price_max:e.price_max!==""?e.price_max:void 0,q:c,natural_q:i,currency:g,price_provider:b});if(w!==k.current)return;E(a?.total_value??null),ir(W,a||{})}catch{if(w!==k.current)return;E(a=>a??null)}},[e,c,i,g,b]),ne=t.useCallback(()=>{N&&(L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{D()},300))},[N,D]),U=t.useCallback(async(w={})=>{const W=!!w.suppressSummary;B(!0);const Y=++x.current,a=u,m=Qe({filters:e,sortBy:n,sortDir:y,page:a,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b}),h=St(m);h&&(v?s(_=>gt(_,a,h,p)):S(h?.items||[]),F(h?.total_rows??h?.total??0),P(h?.total_cards??h?.total??0),E(_=>h?.total_value!=null?h.total_value:_??null),d(!1));try{const _=await re(a);if(Y!==x.current)return;v?s(ie=>gt(ie,a,_,p)):S(_?.items||[]),F(_?.total_rows??_?.total??0),P(_?.total_cards??_?.total??0),E(ie=>_?.total_value!=null?_.total_value:ie??null),He(m,_||{});const I=_?.total_rows??_?.total??0;Number.isFinite(I)&&I>a*p&&cr({filters:e,sortBy:n,sortDir:y,page:a+1,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b})}catch{if(Y!==x.current)return;v?a<=1&&(s({}),F(0),P(0),E(_=>_??null)):(S([]),F(0),P(0),E(_=>_??null))}finally{Y===x.current&&(B(!1),d(!1),N&&!W&&ne())}},[v,g,N,e,re,i,u,p,b,c,ne,n,y]),me=t.useCallback(async(w={})=>{const W=!!w.suppressSummary;B(!0);const Y=++x.current,a={};try{for(let m=1;m<=u;m+=1){const h=await re(m);if(Y!==x.current)return;a[m]=h?.items||[],s({...a}),F(h?.total_rows??h?.total??0),P(h?.total_cards??h?.total??0),E(_=>h?.total_value!=null?h.total_value:_??null),He(Qe({filters:e,sortBy:n,sortDir:y,page:m,pageSize:p,q:c,naturalQ:i,currency:g,priceProvider:b}),h||{})}}catch{if(Y!==x.current)return;Object.keys(a).length||(s({}),F(0),P(0),E(m=>m??null))}finally{Y===x.current&&(B(!1),d(!1),N&&!W&&ne())}},[g,N,e,re,i,u,p,b,c,ne,n,y]),pe=t.useCallback(async(w={})=>{const W=w.refreshList!==!1,Y=w.refreshSummary!==!1;if(w.refreshMeta){ur();try{const m=await bt();O(m||Fe)}catch{O(Fe)}}const a=[];W&&(v&&u>1?a.push(me({suppressSummary:N})):a.push(U({suppressSummary:N}))),Y&&a.push(D()),await Promise.all(a)},[v,N,U,D,u,me]);return t.useEffect(()=>{let w=!0;return de&&O(de),(async()=>{try{const W=await bt();if(!w)return;O(W||Fe)}catch{if(!w)return;de&&O(de)}})(),()=>{w=!1}},[]),t.useEffect(()=>{U()},[U]),t.useEffect(()=>{const w=K.current!==se,W=ae.current!==v;if(K.current=se,ae.current=v,!v){s({});return}!w&&!W||(s({}),S([]),F(0),P(0),E(null),d(!0))},[v,se]),t.useEffect(()=>(N||D(),()=>{L.current&&clearTimeout(L.current)}),[D,N]),{items:le,meta:J,totalRows:H,totalCards:G,totalValue:V,itemsLoading:X,initialLoading:A,faceById:Q,setFaceById:C,refresh:pe}}function mr({refresh:e,notify:n,onActionComplete:y}){const[u,p]=t.useState({open:!1,id:null,name:"",quantity:1}),[c,i]=t.useState(1),g=t.useCallback((M,S,T=1)=>{const s=Number(T)>0?Number(T):1;p({open:!0,id:M,name:S,quantity:s}),i(Math.min(s,Math.max(1,s)))},[]),b=t.useCallback((M,S)=>{p({open:!0,id:`revert:${M}`,name:S,quantity:1}),i(1)},[]),N=t.useCallback(()=>{p({open:!1,id:null,name:"",quantity:1}),i(1)},[]),v=t.useCallback(async()=>
1{if(!u.id){N();return}try{let M,S;if(String(u.id).startsWith("revert:")){const T=String(u.id).slice(7);M=await Ta(T),S={type:"revert",importId:T},n&&n("Import reverted")}else{const T=Number(u.quantity||0),s=Math.max(1,Math.min(c||1,T||1));if(T>1&&s<T){const J=T-s;M=await ze(u.id,{quantity:J}),n&&n("Quantity updated")}else M=await wt(u.id),n&&n("Item deleted");S={type:"delete",itemId:u.id}}await y?.(M,S),await e({refreshMeta:!!M?.meta_changed})}catch(M){n&&n(M?.message||"Action failed","error")}finally{N()}},[u.id,u.quantity,c,N,n,y,e]);return{confirmDelete:u,deleteQuantity:c,setDeleteQuantity:i,openDeleteConfirm:g,openRevertConfirm:b,handleConfirm:v,handleClose:N}}const We={total:0,processed:0,imported:0,active:!1};function fr({refresh:e,notify:n}){const{t:y}=Ke(["wishboard","collection","common"]),[u,p]=t.useState(!1),[c,i]=t.useState(""),[g,b]=t.useState("mtg-master"),[N,v]=t.useState(!1),[M,S]=t.useState(null),[T,s]=t.useState(""),[J,O]=t.useState(""),[H,F]=t.useState(null),[G,P]=t.useState(We),V=t.useCallback(()=>{S(null),F(null),s(""),P({...We}),p(!0)},[]),E=t.useCallback(()=>{p(!1),F(null)},[]),X=t.useCallback(async C=>{const A=C.target?.files?.[0];if(!A)return;const d=await A.text();i(d),O(A.name||"")},[]),B=t.useCallback(async()=>{if(c.trim()){v(!0),s(""),S(null);try{const C=await Va(c,{delimiter:",",has_header:!0,format:g});return S(C),F(null),n?.(y("wishboard:previewLoaded",{defaultValue:"Preview loaded ({{n}} rows)",n:C.parsed||0})),C}catch(C){const A=C?.message||"Import failed";throw s(A),n?.(A,"error"),C}finally{v(!1)}}},[c,g,n,y]),Q=t.useCallback(async()=>{if(c.trim()){v(!0),s(""),S(null),F(null),P({...We,active:!0});try{await Ea(c,{delimiter:",",has_header:!0,format:g},async C=>{if(C?.type==="start")P(A=>({...A,total:C.parsed||0}));else if(C?.type==="progress")P({total:C.total||0,processed:C.processed||0,imported:C.imported||0,active:!0});else if(C?.type==="done"){P(d=>({...d,active:!1}));const A={ok:!0,imported:C.imported||0,missing:C.missing||[],parsed:C.total||0};F(A),n?.(y("wishboard:appliedToast",{defaultValue:"Import applied: {{imported}} updated • {{missing}} unresolved",imported:A.imported||0,missing:(A.missing||[]).length||0}));try{await e({refreshMeta:!!C?.meta_changed})}catch{}}else C?.type==="error"&&(P(A=>({...A,active:!1})),s(C.message||"Apply failed"),n?.(C.message||"Apply failed","error"))})}catch(C){P(d=>({...d,active:!1}));const A=C?.message||"Apply failed";throw s(A),n?.(A,"error"),C}finally{v(!1)}}},[c,g,n,e,y]);return{importOpen:u,openImport:V,closeImport:E,csvText:c,setCsvText:i,format:g,setFormat:b,busy:N,result:M,error:T,fileName:J,applyRes:H,progress:G,handleFileChange:X,handlePreview:B,handleImport:Q}}const te={quantity:1,condition:"NM",language:"en",foil:!1,altered:!1,purchase_price:"",currency:"usd",set:""},yr=(e,n)=>{if(!n||!Array.isArray(e)||!e.length)return null;const y=n.scryfall_id,u=n.set?String(n.set).toLowerCase():"",p=n.collector_number?String(n.collector_number).toLowerCase():"",c=n.language||n.lang?String(n.language||n.lang).toLowerCase():"";for(const i of e){if(y&&i.scryfall_id===y)return i;const g=i.set?String(i.set).toLowerCase():"",b=i.collector_number?String(i.collector_number).toLowerCase():"";if(u&&p&&u===g&&p===b&&(!c||(i.language||i.lang?String(i.language||i.lang).toLowerCase():"")===c))return i}return null};function hr({refresh:e,notify:n,priceProvider:y,currency:u}){const{t:p}=Ke(["wishboard","collection","common"]),[c,i]=t.useState(!1),[g,b]=t.useState(""),[N,v]=t.useState([]),[M,S]=t.useState(null),[T,s]=t.useState(!1),[J,O]=t.useState(!1),[H,F]=t.useState(te),G=t.useRef(0),P=t.useRef(null),[V,E]=t.useState(null),[X,B]=t.useState([]),[Q,C]=t.useState(null),[A,d]=t.useState(null),[x,k]=t.useState(!1),L=t.useRef(0),se=t.useCallback(async(a,{foil:m}={})=>{if(!a){d(null);return}const h=++L.current;k(!0);try{const _=await xt(a,{provider:y,currency:u,foil:m});if(h!==L.current)return;const I=_?.price||null;I&&Number.isFinite(Number(I.value))?d({value:Number(I.value),currency:I.currency||_?.currency||u||null,provider:I.provider||_?.provider||y||null,finish:I.finish||null}):d(null)}catch{h===L.current&&d(null)}finally{h===L.current&&k(!1)}},[u,y]),K=t.useCallback(()=>{G.current+=1,P.current&&clearTimeout(P.current),S(null),F(te),v([]),O(!1),E(null),B([]),C(null)},[]),ae=t.useCallback(()=>{K(),b(""),i(!0)},[K]),le=t.useCallback(()=>{i(!1),b(""),K(),d(null),k(!1)},[K]),re=t.useCallback(async a=>{b(a),S(null),P.current&&clearTimeout(P.current);const m=++G.current;O(!1);const h=a.trim();if(h.length<3){v([]);return}P.current=setTimeout(async()=>{O(!0);try{const _=await Pa(h,{limit:40});m===G.current&&v(_?.items||[])}catch{m===G.current&&v([])}finally{m===G.current&&O(!1)}},500)},[]),D=t.useCallback(a=>{a&&(E(a),F(m=>({...m,set:a.set||a.set_code||m.set,language:a.language||a.lang||m.language})))},[]),ne=t.useCallback(a=>[...a].sort((m,h)=>{const _=new Date(m?.released_at||0).getTime();return new Date(h?.released_at||0).getTime()-_}),[]),U=t.useCallback(async(a,m=null)=>{try{const h=await ja(a),_=Array.isArray(h?.prints)?h.prints:[],I=ne(_);B(I);const ie=I.length?yr(I,m)||I[0]:null;return D(ie||{set:m?.set||"",set_name:m?.set_name,collector_number:m?.collector_number,language:m?.language||m?.lang||"en"}),I}catch{return B([]),[]}},[D,ne]),me=t.useCallback(a=>
1{if(!a)return;K(),C(a),S(a),b(a.name||""),F({quantity:Math.max(1,Number(a.quantity||1)),condition:a.condition||te.condition,language:a.language||te.language,foil:!!a.foil,altered:!!a.altered,purchase_price:a.purchase_price!=null&&!Number.isNaN(Number(a.purchase_price))?String(a.purchase_price):"",currency:a.currency||te.currency,set:a.set||te.set}),i(!0);const m=a.display_scryfall_id||a.scryfall_id,h={scryfall_id:a.variant_scryfall_id||m,set:a.set,set_name:a.set_name,collector_number:a.collector_number,language:a.language};m&&U(m,h)},[U,K]),pe=t.useCallback(a=>{if(!a)return;K();const m=a.language||a.lang||te.language,h=a.display_scryfall_id||a.scryfall_id||a.preferred_scryfall_id||a.variant_scryfall_id,_=a.preferred_scryfall_id||a.variant_scryfall_id||a.scryfall_id||h;S(a),b(a.name||""),F({...te,quantity:Math.max(1,Number(a.quantity||1)),condition:a.condition||te.condition,language:m,foil:!!a.foil,altered:!!a.altered,purchase_price:"",currency:te.currency,set:a.set||a.set_code||te.set}),i(!0);const I={scryfall_id:_,set:a.set||a.set_code,set_name:a.set_name,collector_number:a.collector_number,language:m};h&&U(h,I)},[U,K]),w=t.useCallback(a=>{S(a),v([]),b(a.name),G.current+=1,P.current&&clearTimeout(P.current),O(!1),U(a.scryfall_id,a)},[U]),W=t.useCallback(a=>{D(a)},[D]);t.useEffect(()=>{if(!c)return;const a=V?.scryfall_id||M?.scryfall_id;if(!a){d(null);return}se(a,{foil:!!H.foil})},[c,H.foil,M?.scryfall_id,se,V?.scryfall_id]);const Y=t.useCallback(async()=>{if(!M)return;s(!0);const a=V?.scryfall_id||M.scryfall_id;if(!a){s(!1);return}const m={scryfall_id:a,set:H.set||M.set||V?.set||V?.set_code,collector_number:V?.collector_number||M.collector_number,foil:!!H.foil,language:H.language,condition:H.condition,altered:!1,quantity:H.quantity,purchase_price:null,currency:null};try{let h;Q?(h=await ze(Q.id,m),n?.(p("wishboard:updated",{defaultValue:"Card updated"}))):(h=await Da(m),n?.(p("wishboard:added",{defaultValue:"Card added"}))),await e({refreshMeta:!!h?.meta_changed}).catch(()=>{}),Q?le():(G.current+=1,b(""),K(),d(null),k(!1))}catch(h){n?.(h?.message||(Q?"Update failed":"Add failed"),"error")}finally{s(!1)}},[M,H,le,Q,n,e,K,V,p]);return{addOpen:c,openAdd:ae,closeAdd:le,openEdit:me,openAddWithCard:pe,addQuery:g,addResults:N,addSel:M,editItem:Q,addBusy:T,addSearching:J,addForm:H,setAddForm:F,handleQueryChange:re,handleSelectResult:w,handleSubmit:Y,selectedPrint:V,printOptions:X,handleSelectPrint:W,cardPrice:A,cardPriceLoading:x}}function pr({open:e,onClose:n,onCopyCardmarket:y,onExportFile:u,title:p,subtitle:c,copyLabel:i,exportLabel:g,busy:b=!1}){return l.jsxs(Ia,{open:e,onClose:n,title:p,maxWidthClass:"max-w-md",children:[l.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:c}),l.jsxs("div",{className:"mt-5 grid gap-2",children:[l.jsx("button",{type:"button",className:"inline-flex h-11 w-full items-center justify-center rounded-md border border-slate-900 bg-slate-900 px-4 text-sm font-semibold text-white transition hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-60",onClick:y,disabled:b,children:i}),l.jsx("button",{type:"button",className:"inline-flex h-11 w-full items-center justify-center rounded-md border bg-background px-4 text-sm font-semibold text-foreground transition hover:bg-muted disabled:cursor-not-allowed disabled:opacity-60",onClick:u,disabled:b,children:g})]})]})}async function gr(e){await Za(er(e))}const br={set:"any",rarity:"any",language:"any",foil:"any",condition:"any",type:"any",color_identity:[],keywords:[],price_min:"",price_max:""},_t="usd";function we(e,n=_t){return String(e||"").trim().toLowerCase()||n}function Ct(e){return e?.display_scryfall_id||e?.variant_scryfall_id||e?.scryfall_id||null}function Kr(){const{t:e}=Ke(["wishboard","collection","common"]),[n,y]=t.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 767px)").matches),[u,p]=t.useState(!1),[c,i]=t.useState(!1),[g,b]=t.useState([]),N=t.useCallback((r,o)=>{if(o?.type!=="revert")return;const f=r?.reverted_at||r?.import?.reverted_at||new Date().toISOString();b($=>Ka($,o.importId,f))},[]),{viewMode:v,setViewMode:M,pageSize:S,setPageSize:T,filters:s,setFilters:J,sortBy:O,sortDir:H,setSortBy:F,setSortDir:G,page:P,setPage:V,searchInput:E,setSearchInput:X,q:B,setQ:Q,naturalSearchInput:C,setNaturalSearchInput:A,naturalQ:d,setNaturalQ:x}=tr(),{priceProvider:k,currency:L}=Ba({sortBy:O,setSortBy:F});t.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia("(max-width: 767px)"),o=f=>{y(!!(f?.matches??r.matches))};return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[]),t.useEffect(()=>{n&&V(1)},[n,V]);
1const se=L==="eur"?"price_eur":L==="tix"?"price_tix":"price_usd",K=n?"images":v,ae=n&&K==="images",le=n?se:O,re=n?"desc":H,{items:D,meta:ne,totalRows:U,totalCards:me,totalValue:pe,itemsLoading:w,initialLoading:W,faceById:Y,setFaceById:a,refresh:m}=dr({filters:s,sortBy:le,sortDir:re,page:P,pageSize:S,q:B,naturalQ:d,currency:L,priceProvider:k,deferSummary:!0,accumulatePages:ae}),{toastMsg:h,toastType:_,notify:I}=Aa(),ie=t.useCallback(r=>J(r),[J]),kt=t.useCallback(r=>X(r),[X]),vt=t.useCallback(()=>Q(E.trim()),[E,Q]),Nt=t.useCallback(()=>{X(""),Q("")},[X,Q]),Mt=t.useCallback(r=>A(r),[A]),It=t.useCallback(()=>{const r=String(C||"").trim();x(r),M("images")},[C,x,M]),At=t.useCallback(()=>{A(""),x("")},[A,x]),Pt=t.useCallback((r,o=2)=>{a(f=>{const $=f&&f[r]||0,j=Math.max(1,o||2),R=($+1)%j;return{...f||{},[r]:R}})},[a]),{importOpen:jt,openImport:Ge,closeImport:Lt,csvText:Ft,setCsvText:Ye,format:ge,setFormat:Je,busy:Rt,result:Tt,error:Vt,fileName:Et,applyRes:Dt,progress:$t,handleFileChange:Wt,handleImport:qt}=fr({refresh:m,notify:I}),{addOpen:Ot,openAdd:Bt,closeAdd:Qt,addQuery:Ht,addResults:Kt,addSel:Ut,addBusy:zt,addSearching:Gt,addForm:Yt,setAddForm:Jt,handleQueryChange:Xt,handleSelectResult:Zt,handleSubmit:ea,selectedPrint:ta,printOptions:aa,handleSelectPrint:ra,openEdit:Xe,editItem:Ze,cardPrice:na,cardPriceLoading:oa}=hr({refresh:m,notify:I,priceProvider:k,currency:L}),sa=t.useCallback(r=>Ye(r.target.value),[Ye]),la=t.useCallback(r=>Je(r.target.value),[Je]),{confirmDelete:Z,deleteQuantity:ia,setDeleteQuantity:ca,openDeleteConfirm:et,openRevertConfirm:ua,handleConfirm:da,handleClose:ma}=mr({refresh:m,notify:I,onActionComplete:N}),[fe,Se]=t.useState({open:!1,scope:"full"}),[Re,_e]=t.useState(!1),[fa,tt]=t.useState(null),[ya,Te]=t.useState(!1),[ha,at]=t.useState(!1),[ke,Ve]=t.useState({}),[ve,rt]=t.useState({}),[q,nt]=t.useState({open:!1,item:null}),[Ne,Ee]=t.useState(1),ee=we(L,_t),[ye,Ce]=t.useState(()=>({purchasePrice:"",currency:ee,loading:!1})),ue=t.useRef(!1),xe=t.useRef(0),Me=t.useCallback(r=>r?.display_scryfall_id||r?.variant_scryfall_id||r?.scryfall_id||"",[]),he=t.useCallback(r=>{Ce(o=>{const f=typeof r=="function"?r(o):r;return!f||typeof f!="object"||o.purchasePrice===f.purchasePrice&&o.currency===f.currency&&o.loading===f.loading?o:f})},[]),Ie=t.useCallback((r,{foil:o,playableOnly:f=!0}={})=>{const $=String(r||"").trim().toLowerCase();return $?`${$}|${o===!0?"foil":o===!1?"nonfoil":"any"}|${f===!1?"all":"playable"}`:""},[]),Ae=t.useCallback(r=>{const o=Me(r);return Ie(o,{foil:r?.foil===!0,playableOnly:!0})},[Ie,Me]),ot=t.useCallback(r=>r?.collection_status||null,[]),st=t.useCallback(r=>{const o=Ae(r);return o&&ke[o]||null},[ke,Ae]),lt=t.useCallback(r=>{const o=Ae(r);return o?!!ve[o]:!1},[ve,Ae]),it=t.useCallback(async(r,{force:o=!1}={})=>{const f=Me(r);if(!f)return;const $=r?.foil===!0,j=!0,R=Ie(f,{foil:$,playableOnly:j});if(!R)return;const oe=ke[R];if(!(!o&&oe&&!oe.error)&&!ve[R]){o&&Ve(z=>{if(!z||!Object.prototype.hasOwnProperty.call(z,R))return z;const ce={...z};return delete ce[R],ce}),rt(z=>({...z,[R]:!0}));try{const z=await La(f,{foil:$,playableOnly:j});Ve(ce=>({...ce,[R]:z||{}}))}catch(z){const ce=z?.message||e("collection:summaryError",{defaultValue:"Unable to load collection details."});Ve(Ma=>({...Ma,[R]:{error:ce}}))}finally{rt(z=>{const ce={...z};return delete ce[R],ce})}}},[Ie,ke,ve,Me,e]),ct=t.useCallback(r=>{tt(r),Te(!0)},[tt,Te]),ut=t.useCallback(r=>{Xe(r)},[Xe]),pa=t.useCallback(()=>at(!0),[]),ga=t.useCallback(async()=>{p(!0),i(!0);try{const r=await $a({limit:50});b(r?.items||[])}catch{b([])}finally{i(!1)}},[]),Pe=t.useCallback(r=>{if(r!=="filtered")return{};const o={};return s.set&&s.set!=="any"&&(o.set=s.set),s.language&&s.language!=="any"&&(o.language=s.language),s.rarity&&s.rarity!=="any"&&(o.rarity=s.rarity),s.foil&&s.foil!=="any"&&(o.foil=s.foil==="foil"?"true":"false"),s.condition&&s.condition!=="any"&&(o.condition=s.condition),s.type&&s.type!=="any"&&(o.type=s.type),Array.isArray(s.color_identity)&&s.color_identity.length&&(o.color_identity=s.color_identity.join(",")),Array.isArray(s.keywords)&&s.keywords.length&&(o.keywords=s.keywords.join(",")),s.price_min!==""&&(o.price_min=s.price_min),s.price_max!==""&&(o.price_max=s.price_max),o.price_provider=k,o.currency=L,B&&(o.q=B),d&&(o.natural_q=d),o},[L,s,d,k,B]),je=t.useCallback(r=>{Se({open:!0,scope:r==="filtered"?"filtered":"full"})},[]),ba=t.useCallback(()=>{Re||Se(r=>({...r,open:!1}))},[Re]),dt=t.useCallback(async r=>{const o=Pe(r),f=200;let $=1,j=0;const R=[];do{const oe=await Ue({...o,sort_by:le,sort_dir:re,page:$,page_size:f,price_provider:k,currency:L}),z=Array.isArray(oe?.items)?oe.items:[];if(!z.length)break;R.push(...z),j=Number(oe?.total_rows||oe?.total||0)||R.length,$+=1}while(R.length<j);return R},[Pe,L,le,re,k]),Ca=t.useCallback(async()=>{je("full")},[je]),xa=t.useCallback(async()=>{je("filtered")},[je]),wa=t.useCallback(async()=>{try{_e(!0);const r=await Wa(Pe(fe.scope)),o=URL.createObjectURL(r),f=document.createElement("a");f.href=o,f.download=fe.scope==="filtered"?"mtg_master_wishboard_filtered.csv":"mtg_master_wishboard.csv",document.body.appendChild(f),f.click(),f.remove(),URL.revokeObjectURL(o),Se($=>({...$,open:!1}))}catch(r){I(r?.message||"Export failed","error")}finally{_e(!1)}},[Pe,fe.scope,I]),Sa=t.useCallback(async()=>{try{_e(!0);const r=await dt(fe.scope);if(!r.length){I(e("wishboard:exportEmpty",{defaultValue:"No cards to export."}),"error");return}await gr(r),I(e("wishboard:exportCopiedCardmarket",{defaultValue:"Copied in Cardmarket Wants format."})),Se(o=>({...o,open:!1}))}catch(r){I(r?.message||e("wishboard:exportCopyError",{defaultValue:"Unable to copy export text."}),"error")}finally{_e(!1)}},[fe.scope,dt,I,e]),mt=t.useCallback(()=>{J({...br}),X(""),Q(""),A(""),x("")},[J,A,x,X,Q]),ft=t.useMemo(()=>Ua(s,B,{includeFolder:!1})+(String(d||"").trim()?1:0),[s,d,B]),De=ft>0,_a=t.useCallback((r,o)=>{F(r),G(o)},[F,G]),ka=t.useCallback(()=>{!ae||w||(D?.length||0)>=(U||0)||V(r=>Number(r||1)+1)},[D?.length,w,ae,V,U]),va=t.useMemo(()=>ge==="manabox"?"Name,Set code,Set name,Collector number,Foil,Rarity,Quantity,ManaBox ID,Scryfall ID,Purchase price,Misprint,Altered,Condition,Language,Purchase price currency\\nDoc Ock's Tentacles,SPM,Marvel's Spider-Man,277,foil,rare,1,108592,eab4f4f1-3e4e-403e-8264-b3e73ee8259a,1.06,false,false,near_mint,en,EUR":ge==="dragonshield"?"Folder Name,Quantity,Trade Quantity,Card Name,Set Code,Set Name,Card Number,Condition,Printing,Language,Price Bought,Date Bought,AVG,LOW,TREND\\nvaris 2025,1,0,Ambush Viper,INR,Innistrad Remastered,186,NearMint,Normal,Spanish,0.00,2025-05-13,0.02,0.02,0.09":ge==="moxfield"?'"Count","Tradelist Count","Name","Edition","Condition","Language","Foil","Tags","Last Modified","Collector Number","Alter","Proxy","Purchase Price"\\n"4","4","Abiding Grace","mh2","Near Mint","English","","","2024-06-24 12:04:42.543000","1","False","False",""':ge==="archidekt"?'Quantity,Name,Finish,Condition,Date Added,Language,Purchase Price,Tags,Edition Name,Edition Code,Multiverse Id,Scryfall ID,Collector Number\\n1,"Sol, Advocate Eternal",Normal,NM,2025-11-05,EN,,,2018 Heroes of the Realm,ph18,0,711ccbf2-1cd6-4881-b020-a71bedb8f664,3':"name,set,collector_number,quantity,foil,language,condition,altered,purchase_price,currency\\nLightning Bolt,2ED,150,1,false,en,NM,false,1.50,USD",[ge]),Le=t.useCallback(()=>{nt({open:!1,item:null}),Ee(1),Ce({purchasePrice:"",currency:ee,loading:!1}),ue.current=!1,xe.current+=1},[ee]),yt=t.useCallback(r=>
1{if(!r?.id)return;const o=r.purchase_price!=null&&!Number.isNaN(Number(r.purchase_price));ue.current=o,Ce({purchasePrice:o?Number(r.purchase_price).toFixed(2):"",currency:we(r.currency,ee),loading:!1}),nt({open:!0,item:r}),Ee(1)},[ee]);t.useEffect(()=>{if(!q.open)return;const r=q.item,o=r?.purchase_price!=null&&!Number.isNaN(Number(r.purchase_price));if(!r||o){he(j=>j.loading?{...j,loading:!1}:j);return}const f=Ct(r);if(!f){he(j=>{const R=ue.current?j.currency:ee;return{purchasePrice:ue.current?j.purchasePrice:"",currency:R,loading:!1}});return}const $=++xe.current;he(j=>({...j,loading:!0})),xt(f,{provider:k,currency:ee,foil:!!r.foil}).then(j=>{if($!==xe.current||ue.current)return;const R=j?.price||null,oe=we(R?.currency||j?.currency,ee),z=R&&Number.isFinite(Number(R.value))?Number(R.value).toFixed(2):"";he({purchasePrice:z,currency:oe,loading:!1})}).catch(()=>{$!==xe.current||ue.current||he({purchasePrice:"",currency:ee,loading:!1})}).finally(()=>{$===xe.current&&he(j=>j.loading?{...j,loading:!1}:j)})},[q.item,q.open,ee,k,he]);const Na=t.useCallback(async()=>{if(!q.item?.id){Le();return}const r=Math.max(1,Number(q.item.quantity||1)),o=Math.max(1,Math.min(Number(Ne||1),r));try{const f=Ct(q.item);await qa({scryfall_id:f,set:q.item.set||q.item.set_code,collector_number:q.item.collector_number,foil:!!q.item.foil,language:q.item.language||q.item.lang||"en",condition:q.item.condition||null,altered:!!q.item.altered,quantity:o,purchase_price:ye.purchasePrice===""?null:Number(ye.purchasePrice),currency:we(ye.currency,ee)});const $=r-o;let j;$<=0?j=await wt(q.item.id):j=await ze(q.item.id,{quantity:$}),I(e("wishboard:addedToCollection",{defaultValue:"Added to collection"})),await m({refreshMeta:!!j?.meta_changed})}catch(f){I(f?.message||e("wishboard:addToCollectionError",{defaultValue:"Failed to add to collection"}),"error")}finally{Le()}},[q.item,Ne,ye,Le,ee,I,m,e]);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:e("wishboard:title",{defaultValue:"My Wishboard"})}),l.jsx("p",{className:"text-sm text-muted-foreground",children:e("wishboard:subtitle",{defaultValue:"Save cards you want to acquire, track upgrade targets, and plan future deck improvements."})})]}),l.jsx(za,{t:e,viewMode:K,onChangeViewMode:M,filters:s,onChangeFilters:ie,meta:ne,isMobileViewport:n,searchInput:E,onChangeSearchInput:kt,onSearch:vt,onClearSearch:Nt,naturalSearchInput:C,onChangeNaturalSearchInput:Mt,onNaturalSearch:It,onClearNaturalSearch:At,naturalSearchActive:!!String(d||"").trim(),naturalSearchLabel:e("wishboard:naturalSearch",{defaultValue:"Natural search your Wishboard"}),naturalSearchPlaceholder:e("wishboard:naturalSearchPlaceholder",{defaultValue:"white spells that exile creatures"}),onOpenMoreFilters:pa,onOpenAdd:Bt,onResetFilters:mt,resetFiltersDisabled:!De,activeFilterCount:ft,onOpenImport:Ge,onOpenHistory:ga,onExportFull:Ca,onExportFiltered:xa,loading:w&&!W,actionsLabel:e("wishboard:actions",{defaultValue:"Wishboard Actions"}),importLabel:e("wishboard:actionImport",{defaultValue:"Import Cards to Wishboard"}),exportFullLabel:e("wishboard:actionExportFull",{defaultValue:"Export all cards from Wishboard"}),exportFilteredLabel:e("wishboard:actionExportCurrent",{defaultValue:"Export with Current Filters"}),historyLabel:e("wishboard:actionHistory",{defaultValue:"Import History (My Wishboard)"}),searchPlaceholder:e("wishboard:search",{defaultValue:"Search your wishboard…"})}),l.jsx(pr,{open:fe.open,onClose:ba,onCopyCardmarket:Sa,onExportFile:wa,busy:Re,title:e("wishboard:exportModalTitle",{defaultValue:"Export Wishboard"}),subtitle:fe.scope==="filtered"?e("wishboard:exportModalSubtitleFiltered",{defaultValue:"Choose a format to copy or download for the cards matching your current filters."}):e("wishboard:exportModalSubtitleFull",{defaultValue:"Choose a format to copy or download for all cards in your wishboard."}),copyLabel:e("wishboard:exportCopyCardmarket",{defaultValue:"Copy for Cardmarket Wants"}),exportLabel:e("wishboard:exportFile",{defaultValue:"Export to File"})}),w&&W&&l.jsx("div",{className:"mb-4",children:l.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[l.jsx("div",{className:"text-sm text-muted-foreground",children:e("wishboard:loading",{defaultValue:"Loading your wishboard…"})}),l.jsx("div",{className:"h-2 rounded bg-muted overflow-hidden",children:l.jsx("div",{className:"h-2 bg-primary animate-pulse w-1/3"})})]})}),!w&&!D?.length&&De?l.jsxs("div",{className:"rounded-lg border p-6 text-center space-y-3",children:[l.jsx("div",{className:"text-sm text-muted-foreground",children:e("wishboard:noMatches",{defaultValue:"No cards match your current filters."})}),l.jsx("button",{type:"button",onClick:mt,className:"inline-flex items-center justify-center h-9 rounded-md border bg-background px-4 text-sm",children:e("collection:resetFiltersBtn",{defaultValue:"Reset filters"})})]}):null,!w&&!D?.length&&!De?l.jsxs("div",{className:"rounded-lg border p-6 text-center space-y-3",children:[l.jsx("div",{className:"text-sm text-muted-foreground",children:e("wishboard:empty",{defaultValue:"Your wishboard is empty. Import a list or add cards from the catalog."})}),l.jsx("button",{type:"button",onClick:Ge,className:"inline-flex items-center justify-center h-9 rounded-md border bg-primary text-primary-foreground px-4",children:e("wishboard:actionImport",{defaultValue:"Import Cards to Wishboard"})})]}):null,h?l.jsx("div",{className:`fixed top-16 right-4 z-20 rounded-md px-3 py-2 text-sm text-white shadow ${_==="error"?"bg-red-600":"bg-green-600"}`,children:h}):null,D?.length?K==="text"?l.jsx(Xa,{items:D,totalCards:me,totalRows:U,totalValue:pe,page:P,pageSize:S,onPageChange:V,onPageSizeChange:T,sortBy:O,sortDir:H,onChangeSort:_a,currency:L,priceProvider:k,onCardClick:ct,showQuantity:!0,showImagePreview:!0,showTotalValue:!0,showFinish:!0,hideTypeColumn:!0,rarityBeforeFinish:!0,affiliateButtonStyle:"icon-sm",onEdit:ut,onDelete:(r,o,f)=>et(r,o,f),soldActionLabel:e("wishboard:addToCollection",{defaultValue:"Add to Collection"}),onMarkSold:yt,showCollectionShield:!0,getCollectionStatus:ot,getCollectionSummary:st,getCollectionSummaryLoading:lt,onRequestCollectionSummary:it}):l.jsx(Qa,{t:e,items:D,totalCards:me,totalRows:U,totalValue:pe,compactMobile:n,faceById:Y,onToggleFace:Pt,onCardClick:ct,page:P,pageSize:S,onPageChange:V,onPageSizeChange:T,currency:L,priceProvider:k,onDelete:(r,o,f)=>et(r,o,f),onEdit:ut,showAffiliate:!0,showSoldAction:!0,soldActionLabel:e("wishboard:addToCollection",{defaultValue:"Add to Collection"}),onMarkSold:yt,showCollectionShield:!0,getCollectionStatus:ot,getCollectionSummary:st,getCollectionSummaryLoading:lt,onRequestCollectionSummary:it,enableInfiniteScroll:ae,hasMore:(D?.length||0)<(U||0),loadingMore:ae&&w&&!W,onLoadMore:ka}
1):null,l.jsx(ht,{open:Z.open,title:Z.id&&String(Z.id).startsWith("revert:")?e("collection:revert",{defaultValue:"Revert"}):e("wishboard:confirmDeleteTitle",{defaultValue:"Delete from Wishboard"}),message:Z.id&&String(Z.id).startsWith("revert:")?e("collection:confirmRevertMsg",{defaultValue:"Revert import “{{name}}”? This will subtract added quantities and restore prices/currency when possible.",name:Z.name}):l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{children:e("wishboard:confirmDeleteMsg",{defaultValue:"Delete “{{name}}” from your wishboard?",name:Z.name})}),Number(Z.quantity||0)>1?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("label",{htmlFor:"wishboard-delete-quantity",className:"text-xs text-muted-foreground",children:e("wishboard:deleteQuantityLabel",{defaultValue:"Units to delete"})}),l.jsx("input",{id:"wishboard-delete-quantity",type:"number","aria-label":e("wishboard:deleteQuantityLabel",{defaultValue:"Units to delete"}),min:1,max:Math.max(1,Number(Z.quantity||1)),value:ia,onChange:r=>{const o=Number(r.target.value)||1,f=Math.max(1,Number(Z.quantity||1));ca(Math.min(Math.max(1,o),f))},className:"h-9 w-24 rounded-md border px-2 text-sm"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:e("wishboard:deleteQuantityHint",{defaultValue:"Current: {{qty}}",qty:Z.quantity||1})})]}):null]}),confirmText:Z.id&&String(Z.id).startsWith("revert:")?e("collection:revert",{defaultValue:"Revert"}):e("wishboard:delete",{defaultValue:"Delete"}),cancelText:e("common:cancel",{defaultValue:"Cancel"}),variant:"danger",onClose:ma,onConfirm:da}),l.jsx(ht,{open:q.open,title:e("wishboard:addToCollectionTitle",{defaultValue:"Add to Collection"}),dialogClassName:"sm:max-w-[760px]",bodyClassName:"sm:px-8 sm:py-6",footerClassName:"sm:px-8",message:(()=>{const r=Math.max(1,Number(q.item?.quantity||1));return l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{children:e("wishboard:addToCollectionMessage",{defaultValue:"How many copies do you want to add to your collection?"})}),l.jsxs("div",{className:"grid gap-4 md:grid-cols-[220px_minmax(0,1fr)] md:items-end",children:[l.jsxs("label",{className:"grid gap-1",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:e("wishboard:addToCollectionQtyLabel",{defaultValue:"Quantity"})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:1,max:r,value:Ne,onChange:o=>{const f=Number(o.target.value)||1;Ee(Math.min(Math.max(1,f),r))},className:"h-10 w-28 rounded-md border bg-background px-3 text-sm text-foreground shadow-inner focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:border-primary/60"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:e("wishboard:addToCollectionQtyHint",{defaultValue:"Max: {{qty}}",qty:r})})]})]}),l.jsxs("label",{className:"grid gap-1",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:e("collection:purchasePrice",{defaultValue:"Purchase Price"})}),l.jsxs("div",{className:"grid gap-2 sm:grid-cols-[120px_minmax(0,1fr)]",children:[l.jsxs("select",{className:"h-10 rounded-md border bg-background px-3 text-sm",value:ye.currency,onChange:o=>{ue.current=!0,Ce(f=>({...f,currency:we(o.target.value,ee)}))},children:[l.jsx("option",{value:"usd",children:"USD"}),l.jsx("option",{value:"eur",children:"EUR"})]}),l.jsx("input",{type:"number",step:"0.01",value:ye.purchasePrice,onChange:o=>{ue.current=!0,Ce(f=>({...f,purchasePrice:o.target.value}))},className:"h-10 min-w-0 rounded-md border bg-background px-3 text-sm text-foreground shadow-inner focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:border-primary/60"})]}),ye.loading?l.jsx("span",{className:"text-xs text-muted-foreground",children:e("common:loading",{defaultValue:"Loading…"})}):null]})]})]})})(),confirmText:e("wishboard:addToCollectionConfirm",{defaultValue:"Add to Collection"}),cancelText:e("common:cancel",{defaultValue:"Cancel"}),variant:"default",confirmDisabled:Ne<1,onClose:Le,onConfirm:Na}),l.jsx(Ga,{open:jt,onClose:Lt,title:e("wishboard:actionImport",{defaultValue:"Import Cards to Wishboard"}),csvText:Ft,onChangeCsvText:sa,format:ge,onChangeFormat:la,busy:Rt,error:Vt,result:Tt,applyRes:Dt,progress:$t,fileName:Et,onFileChange:Wt,onImport:qt,placeholder:va}
1),l.jsx(Ya,{open:u,onClose:()=>p(!1),loading:c,items:g,onRevert:ua,title:e("wishboard:actionHistory",{defaultValue:"Import History (My Wishboard)"}),subtitle:e("wishboard:historySubtitle",{defaultValue:"Review past wishboard imports and revert them if needed."})}),l.jsx(Oa,{open:ya,card:fa,onClose:()=>Te(!1),priceProvider:k}),l.jsx(Ja,{open:Ot,onClose:Qt,title:Ze?e("wishboard:editTitle",{defaultValue:"Edit card"}):e("wishboard:addTitle",{defaultValue:"Add to Wishboard"}),query:Ht,results:Kt,selected:Ut,selectedPrint:ta,printOptions:aa,busy:zt,searching:Gt,form:Yt,setForm:Jt,onQueryChange:Xt,onSelect:Zt,onSelectPrint:ra,onSubmit:ea,submitLabel:Ze?e("collection:saveClose",{defaultValue:"Save & Close"}):e("wishboard:saveNext",{defaultValue:"Save & Next"}),showPurchasePrice:!1,showAltered:!1,showCardPrice:!0,cardPrice:na,cardPriceLoading:oa}),l.jsx(Ha,{open:ha,onClose:()=>at(!1),filters:s,onChangeFilters:ie,meta:ne,showPrimaryFilters:n,currency:L})]})}export{Kr 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.