import popup from "$utils/tool/popup";
import {PopupExportComponent} from "$popup/popup-export/const";
import unit from "$utils/unit/unit";
import type from '../data/type';
import {RoomGiftType} from "@/pages/talking/const/roomGiftType";

export default <LibMixins>{

    data(){
        return {
            giftSelect:0,
            useOffsetWidth: unit.unitPx(30)
        }
    },

    computed:{
      useGiftType(){
          return type[this.giftType] || type[RoomGiftType.default] || {};
      }
    },

    watch:{
      giftSelect(){
          if (this.lastTrigger !== undefined && this.pressNumber>0 && this.requestUnique === this.lastTrigger.unique) {
              this.giveTriggerChangeNumber(this.lastTrigger.resultConfig,this.lastTrigger.unique);
              this.lastTrigger = undefined;
          }
      }
    },

    methods:{

        changeGiftSelect(index:number){

            if (this.giftSelect !== index) {
                this.giftSelect = index;
            }

        },

        openIntroduce(item,event){
            return popup.$popup.open(PopupExportComponent.giftIntroduce,{
                value:true,
                x: event.clientX - event.offsetX + this.useOffsetWidth,
                y: event.clientY - event.offsetY,
                item
            });
        },

        closeIntroduce(event){
            return popup.$popup.open(PopupExportComponent.giftIntroduce,{
                value:false
            });
        },

    }

}
