import{a as c,D as u}from"./DataFilter-CJCQVhjM.js";import{n,M as m,U as d,m as p,b as o}from"./index-DDNMzpZj.js";import{o as i,g as h}from"./mixins-CpCP8hE3.js";import{S as f}from"./StarsLine-CReD_mDq.js";import{S as _}from"./StatInput-BU1s-zba.js";const g={model:{prop:"show",event:"close"},components:{Modal:m,DataFilter:c},props:{show:{type:Boolean,required:!0},route:{type:String,required:!0},routeParameters:{type:String,default:void 0},categories:{type:Array,required:!0},dataModel:{type:Object,default:void 0},canUnselect:{type:Boolean,default:!0}},data(){return{message:[],previousRoute:"",data_model:{},name_searched:""}},methods:{selectItem(r){this.$emit("item-selected",r),this.close()},close(){this.$emit("close",!1)},getColumn(r){return this.getColumns.map(t=>this.data_model[t.key].expand(r,this.getLang))}},computed:{getData(){return this.message.filter(r=>r.n.toLowerCase().includes(this.name_searched.toLowerCase())&&this.getFilters.every(t=>this.data_model[t.key].show(r[t.key])))},getResultsCount(){return this.getData.length==1?this.getData.length+" result":this.getData.length+" results"},getColumns(){return this.categories.filter(r=>r.isColumn)},getFilters(){return this.categories.filter(r=>r.isFilter)},getLang(){return this.$store.getters.getLang}},watch:{show(){if(this.show){let r=this.route;this.routeParameters!==void 0&&(r+="?"+this.routeParameters),this.previousRoute!==r&&(this.message=[]),this.previousRoute=r,this.message.length===0&&this.axios.get(r).then(s=>this.message=s.data).catch(s=>this.$store.dispatch("addAxiosErrorMessage",s));let t=this;this.$nextTick().then(()=>{t.name_searched="",t.$refs.nameField.focus()})}}},mounted(){if(this.categories.forEach(r=>{this.$set(this.data_model,r.key,d.copy(u[r.key]))}),this.dataModel!==void 0)for(let[r,t]of Object.entries(this.dataModel))this.$set(this.data_model,r,t)}};var y=function(){var t=this,s=t._self._c;return s("modal",{attrs:{show:t.show},on:{close:function(e){return t.close()}},scopedSlots:t._u([{key:"header",fn:function(){return[s("span",{staticClass:"flex flex-row flex-wrap items-center"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.name_searched,expression:"name_searched"}],ref:"nameField",staticClass:"input input-sm",attrs:{placeholder:"Name",type:"text"},domProps:{value:t.name_searched},on:{input:function(e){e.target.composing||(t.name_searched=e.target.value)}}}),s("button",{staticClass:"btn btn-sm btn-red mx-2",on:{click:function(e){t.name_searched=""}}},[t._v("Clear")]),t._l(t.getFilters,function(e,a){return s("data-filter",{key:a,staticClass:"my-2 mr-2",attrs:{category:e.name,data:t.data_model[e.key].data}})})],2)]},proxy:!0},{key:"footer",fn:function(){return[t._v(" "+t._s(t.getResultsCount)+" ")]},proxy:!0}])},[t.message.length<1?s("div",[t._v(" Loading... ")]):s("div",[s("table",{staticClass:"table"},[s("thead",[s("tr",t._l(t.getColumns,function(e,a){return s("th",{key:a,staticClass:"whitespace-nowrap"},[t._v(t._s(e.name))])}),0)]),s("tbody",[t.canUnselect?s("tr",{on:{click:function(e){return t.selectItem(null)}}},t._l(t.getColumns.length,function(e){return s("td",{key:e},[t._v("-")])}),0):t._e(),t._l(t.getData,function(e){return s("tr",{key:e.id,on:{click:function(a){return t.selectItem(e.id)}}},t._l(t.getColumn(e),function(a,l){return s("td",{key:l},[t._v(t._s(a))])}),0)})],2)])])])},v=[],b=n(g,y,v,!1,null,null);const F=b.exports,x={components:{StarsLine:f},mixins:[i],props:{object:{type:Object,required:!0}},methods:{tryToEmit(r,t){this.party_mode!==this.$MODE.ReadOnly&&this.$emit(r,t)}},computed:{...p({party_mode:r=>r.party_builder.party_mode}),getImage(){return this.objectIsEmpty?this.party_mode===this.$MODE.Edit?"/img/empty_summon.jpg":"/img/empty_summon_ro.jpg":"/img/unit/"+this.object.summonid+"000.jpg"}}};var j=function(){var t=this,s=t._self._c;return s("span",{staticClass:"relative tooltip-parent"},[s("img",{staticClass:"w-full",class:t.party_mode!==t.$MODE.ReadOnly?"cursor-pointer":"",staticStyle:{"min-height":"83px","max-height":"83px"},attrs:{draggable:!t.objectIsEmpty,src:t.getImage},on:{click:function(e){return t.tryToEmit("click-portrait")},dragstart:function(e){return t.tryToEmit("drag-portrait",e)},dragover:function(e){e.preventDefault()},drop:function(e){return e.preventDefault(),t.tryToEmit("drop-portrait",e)}}}),t.objectIsEmpty?t._e():s("stars-line",{staticClass:"absolute bottom-0 right-0 w-4/5 bg-black/50",attrs:{base:t.object.starsbase,extra:t.object.starsmax,current:t.object.stars,max:5,transcendance:!0,readOnly:t.party_mode===t.$MODE.ReadOnly},on:{"update:current":function(e){return t.$emit("stars-changed",e)}}}),t.object.current_data!==void 0?s("span",{staticClass:"tooltip"},t._l(t.object.data[t.object.current_data],function(e,a){return s("span",{key:a,staticClass:"font-mono text-xs"},[s("span",{staticClass:"capitalize"},[t._v(t._s(e.aura_type))]),t._v(" "+t._s(e.stat)+" "+t._s(e.percent)+"% "),e.slot?s("span",[t._v("("+t._s(e.slot)+")")]):t._e(),s("br")])}),0):t._e()],1)},C=[],$=n(x,j,C,!1,null,null);const w=$.exports,k={components:{StatInput:_,Portrait:w},mixins:[i,h],props:{object:{type:Object,required:!0},showLevel:{type:Boolean,default:!1}},methods:{drop(r){const t=r.dataTransfer.getData("summon");t.length>0&&this.$emit("swap",JSON.parse(t))},starsChanged(r){this.$set(this.object,"stars",r),(!this.showLevel||this.object.level>this.getLevel)&&this.$set(this.object,"level",this.getLevel),o.setSummonCurrentData(this.object)}},computed:{getTitleColor(){switch(this.object.stars){case 3:return"color: #ffa826;";case 4:return"color: #e3b7ff;";case 5:return"color: #a1e3ff;";default:return""}},getLevel(){return o.getSummonLevel(this.object)}}};var E=function(){var t=this,s=t._self._c;return s("div",{staticClass:"flex flex-col",staticStyle:{"min-width":"110px","max-width":"110px"}},[t.objectIsEmpty?s("span",{staticClass:"text-xs h-5"}):s("a",{staticClass:"text-xs text-primary hover:text-primary rounded-t h-5 px-1 text-center truncate",style:t.getTitleColor,attrs:{target:"_blank",href:"https://gbf.wiki/"+t.object.nameen,title:t.getName}},[t._v(t._s(t.getName))]),s("portrait",{attrs:{object:t.object},on:{"drag-portrait":function(e){return t.$emit("drag-portrait",e)},"drop-portrait":t.drop,"click-portrait":function(e){return t.$emit("click-portrait")},"stars-changed":t.starsChanged}}),!t.objectIsEmpty&&t.showLevel?s("div",{staticClass:"flex flex-row flex-nowrap justify-around text-xs"},[s("stat-input",{attrs:{shortName:"lvl",longName:"Summon level",prop:t.object.level,length:3},on:{"update:prop":function(e){return t.$set(t.object,"level",e)}}}),s("stat-input",{attrs:{shortName:"+",longName:"Plus bonuses",prop:t.object.pluses,length:3},on:{"update:prop":function(e){return t.$set(t.object,"pluses",e)}}})],1):t._e()],1)},D=[],S=n(k,E,D,!1,null,null);const N=S.exports;export{N as B,F as M};