import{At as e,Cn as t,Ct as n,Dt as r,E as i,Et as a,Jt as o,Kt as s,Mt as c,N as l,Nt as u,On as d,Ot as ee,P as f,T as p,Tn as m,gt as te,hn as h,in as g,jt as _,kt as ne}from"./game-logic-CfBcTF_c.js";import"./vendor-pinia-DP9x75p8.js";import"./vendor-vue-router-CWDMmE-U.js";import"./vendor-crypto-DGvz1MHk.js";import"./game-i18n-DEf7ySVe.js";import"./vendor-others-CUjrprN5.js";import"./vendor-reka-ui-CZQh7FLl.js";import"./vendor-utils-Dg-HLkEU.js";import"./vendor-vueuse-C7EbLx--.js";import"./vendor-icons-W6Ny__75.js";import{t as re}from"./CardDescription-BjAei3DC.js";import{h as v,u as y}from"./game-config-D-D7cMgJ.js";import{A as ie,I as ae,M as oe,P as se,_ as ce,c as le,l as b,o as x,r as S,s as C,u as w,w as T}from"./index-DRmrr36X.js";import{t as E}from"./useGameConfig-CVlwnWOp.js";import{t as D}from"./AlertDialog-Bf_xgpJz.js";import{t as O}from"./CardUnlockOverlay-CVKjkS94.js";import{t as k}from"./UnlockRequirement-p2W4t6RX.js";var A={key:0,class:`container mx-auto p-4 sm:p-6`},j={class:`text-2xl sm:text-3xl font-bold mb-4 sm:mb-6`},M={class:`grid grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4`},N={class:`flex justify-between items-start gap-2`},P={class:`min-w-0 flex-1`},F={class:`space-y-2.5 sm:space-y-3`},I={class:`text-xs sm:text-sm space-y-1.5 sm:space-y-2`},L={class:`text-muted-foreground mb-1 sm:mb-2`},R={class:`space-y-1 sm:space-y-1.5`},z={class:`flex items-center gap-1.5 sm:gap-2`},ue={class:`text-xs`},B={class:`flex items-center gap-1.5 sm:gap-2`},V={class:`text-xs`},H={class:`flex items-center gap-1.5 sm:gap-2`},U={class:`text-xs`},W=u({__name:`ResearchView`,setup(u){let W=ae(),de=ce(),{t:G}=se(),{TECHNOLOGIES:K,BUILDINGS:fe}=E(),q=a(()=>W.currentPlanet),J=a(()=>W.player),Y=h(null),X=e=>{if(!W.currentPlanet||!i(W.currentPlanet,e,W.player.technologies,W.player.researchQueue).valid)return!1;let t=W.player.technologies[e]||0,{queueItem:n}=p(W.currentPlanet,e,t,W.player.officers);return W.player.researchQueue.push(n),!0},Z=e=>{if(!q.value)return!1;let t=K.value[e],n=f(t,Q(e)+1);return!n||Object.keys(n).length===0?!0:l(q.value,W.player.technologies,n)},pe=e=>{if(!q.value)return G(`researchView.research`);let t=K.value[e],n=Q(e);return t.maxLevel!==void 0&&n>=t.maxLevel?G(`researchView.maxLevelReached`):J.value.researchQueue.length>0||Z(e)?G(`researchView.research`):G(`buildingsView.requirementsNotMet`)},me=e=>{let t=K.value[e],n=f(t,Q(e)+1);if(!n||!q.value)return``;let r=[];for(let[e,t]of Object.entries(n))if(Object.values(y).includes(e)){let n=e,i=q.value.buildings[n]||0,a=fe.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${G(`common.current`)}: Lv ${i})`)}else if(Object.values(v).includes(e)){let n=e,i=W.player.technologies[n]||0,a=K.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${G(`common.current`)}: Lv ${i})`)}return r.join(`
`)},he=e=>{if(!Z(e)){Y.value?.show({title:G(`common.requirementsNotMet`),message:me(e)});return}X(e)||Y.value?.show({title:G(`researchView.researchFailed`),message:G(`researchView.researchFailedMessage`)})},Q=e=>J.value.technologies[e]||0,ge=e=>{if(!q.value)return!1;let t=K.value[e],n=Q(e);if(t.maxLevel!==void 0&&n>=t.maxLevel||J.value.researchQueue.length>0)return!1;let r=$(e,n+1);return l(q.value,W.player.technologies,t.requirements)&&q.value.resources.metal>=r.metal&&q.value.resources.crystal>=r.crystal&&q.value.resources.deuterium>=r.deuterium},$=(e,t)=>te(e,t);return(i,a)=>q.value?(s(),e(`div`,A,[c(k,{"required-building":t(y).ResearchLab,"required-level":1},null,8,[`required-building`]),r(`h1`,j,d(t(G)(`researchView.title`)),1),r(`div`,M,[(s(!0),e(n,null,o(Object.values(t(v)),e=>(s(),ee(t(w),{key:e,class:`relative`},{default:g(()=>[c(O,{requirements:t(K)[e].requirements,currentLevel:Q(e)},null,8,[`requirements`,`currentLevel`]),c(t(le),null,{default:g(()=>[r(`div`,N,[r(`div`,P,[c(t(C),{class:`text-base sm:text-lg cursor-pointer hover:text-primary transition-colors`,onClick:n=>t(de).openTechnology(e,Q(e))},{default:g(()=>[_(d(t(K)[e].name),1)]),_:2},1032,[`onClick`]),c(t(re),{class:`text-xs sm:text-sm`},{default:g(()=>[_(d(t(K)[e].description),1)]),_:2},1024)]),c(t(ie),{variant:`secondary`,class:`text-xs whitespace-nowrap flex-shrink-0`},{default:g(()=>[_(`Lv `+d(Q(e)),1)]),_:2},1024)])]),_:2},1024),c(t(b),null,{default:g(()=>[r(`div`,F,[r(`div`,I,[r(`p`,L,d(t(G)(`researchView.researchCost`))+`:`,1),r(`div`,R,[r(`div`,z,[c(T,{type:`metal`,size:`sm`}),r(`span`,ue,d(t(G)(`resources.metal`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(x)(q.value.resources.metal,$(e,Q(e)+1).metal)])},d(t(S)($(e,Q(e)+1).metal)),3)]),r(`div`,B,[c(T,{type:`crystal`,size:`sm`}),r(`span`,V,d(t(G)(`resources.crystal`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(x)(q.value.resources.crystal,$(e,Q(e)+1).crystal)])},d(t(S)($(e,Q(e)+1).crystal)),3)]),r(`div`,H,[c(T,{type:`deuterium`,size:`sm`}),r(`span`,U,d(t(G)(`resources.deuterium`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(x)(q.value.resources.deuterium,$(e,Q(e)+1).deuterium)])},d(t(S)($(e,Q(e)+1).deuterium)),3)])])]),c(t(oe),{onClick:t=>he(e),disabled:!ge(e),class:`w-full`},{default:g(()=>[_(d(pe(e)),1)]),_:2},1032,[`onClick`,`disabled`])])]),_:2},1024)]),_:2},1024))),128))]),c(D,{ref_key:`alertDialog`,ref:Y},null,512)])):ne(``,!0)}});export{W as default};