local addonName, ZLAUTO = ...

local ZL = ZLAUTO.mainFrame
local autoBid = ZL.autoBid
local LoadItemDataByID = ZL.LoadItemDataByID
local cGetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
local cGetItemIcon = C_Item and C_Item.GetItemIconByID or GetItemIcon
local DisableAddOn = C_AddOns and C_AddOns.DisableAddOn or DisableAddOn
local MyAddon = ZL.MyAddon

--创建StaticPopup手动添加收支记录文本框
function ZL.CreateStaticPopupAddIncomeEditboxs()
    ZL.AddIncomeEditboxs = CreateFrame("Frame", nil, ZL)
    local AddIncomeEditboxs = ZL.AddIncomeEditboxs
    AddIncomeEditboxs:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    AddIncomeEditboxs:Hide()
    local xSize, ySize = 130, 24
    AddIncomeEditboxs.editBox2 = ZL.CreateEditBox(AddIncomeEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox2")
    AddIncomeEditboxs.editBox2:SetMaxLetters(150)
    AddIncomeEditboxs.editBox2:Disable()
    AddIncomeEditboxs.editBox2.text = AddIncomeEditboxs.editBox2:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox2.text:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox2.text:SetPoint("TOPLEFT", AddIncomeEditboxs, "TOPLEFT", 0, 0)
    AddIncomeEditboxs.editBox2.text:SetText("玩家名：")
    AddIncomeEditboxs.editBox2:SetPoint("LEFT", AddIncomeEditboxs.editBox2.text, "RIGHT", 15, 0)
    AddIncomeEditboxs.editBox2.text2 = AddIncomeEditboxs.editBox2:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox2.text2:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox2.text2:SetPoint("LEFT", AddIncomeEditboxs.editBox2, "RIGHT", 5, 0)
    AddIncomeEditboxs.editBox3 = ZL.CreateEditBox(AddIncomeEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox3")
    AddIncomeEditboxs.editBox3:SetPoint("TOP", AddIncomeEditboxs.editBox2, "BOTTOM", 0, -5)
    AddIncomeEditboxs.editBox3:SetMaxLetters(9)
    AddIncomeEditboxs.editBox3:SetNumeric(true)
    AddIncomeEditboxs.editBox3:SetScript("OnEnter", function (self)
        ZL.GameTooltipShowAnchor(self, "ANCHOR_TOPRIGHT")
        GameTooltip:AddLine("输入大于0的数，最大9个字符！")
        GameTooltip:AddLine("支持鼠标滚轮快速设置", 1, 1, 1)
        GameTooltip:AddLine("右键：|cffffffff设置默认值和鼠标滚动幅度|r")
        GameTooltip:Show()
    end)
    AddIncomeEditboxs.editBox3:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
    AddIncomeEditboxs.editBox3:SetScript("OnMouseWheel", function (self, delta)
        if self:HasFocus() then
            local number = self:GetNumber()
            if delta > 0 then
                number = number + ZL.opt.popupPriceDelta
            else
                number = number - ZL.opt.popupPriceDelta
            end
            if number < ZL.opt.popupPriceDelta then
                number = ZL.opt.popupPriceDelta
            end
            self:SetNumber(number)
        end
    end)
    AddIncomeEditboxs.editBox3:SetScript("OnMouseDown", function (self, button)
        if button == "RightButton" then
            local function tempfunc()
                return {
                    {
                        text = "默认值",
                        hasArrow = 1,
                        menuTable = function ()
                            local numList = {50, 100, 200, 400, 500, 1000, 2000, 4000, 5000, 10000}
                            local menuList = {}
                            for _, value in ipairs(numList) do
                                tinsert(menuList, {
                                    text = value,
                                    checkable = 1,
                                    checked = value == ZL.opt.popupPrice and true or false,
                                    func = function ()
                                        ZL.opt.popupPrice = value
                                        ZL.GUI:CloseMenu()
                                    end
                                })
                            end
                            return menuList
                        end,
                    },
                    {
                        text = "滚轮幅度",
                        hasArrow = 1,
                        menuTable = function ()
                            local numList = {50, 100, 500, 1000, 5000, 10000}
                            local menuList = {}
                            for _, value in ipairs(numList) do
                                tinsert(menuList, {
                                    text = value,
                                    checkable = 1,
                                    checked = value == ZL.opt.popupPriceDelta and true or false,
                                    func = function ()
                                        ZL.opt.popupPriceDelta = value
                                        ZL.GUI:CloseMenu()
                                    end
                                })
                            end
                            return menuList
                        end,
                    },
                }
            end
            ZL.GUI:ToggleMenu(self, tempfunc(), 'TOPLEFT', self, 'BOTTOMRIGHT', 0, 0)
        end
    end)
    AddIncomeEditboxs.editBox3.text = AddIncomeEditboxs.editBox3:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox3.text:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox3.text:SetPoint("RIGHT", AddIncomeEditboxs.editBox3, "LEFT", -15, 0)
    AddIncomeEditboxs.editBox3.text:SetText("单　价：")
    AddIncomeEditboxs.editBox3.text2 = AddIncomeEditboxs.editBox3:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox3.text2:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox3.text2:SetPoint("LEFT", AddIncomeEditboxs.editBox3, "RIGHT", 5, 0)
    AddIncomeEditboxs.editBox3.text2:SetText("(必填)")
    AddIncomeEditboxs.editBox4 = ZL.CreateEditBox(AddIncomeEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox4")
    AddIncomeEditboxs.editBox4:SetPoint("TOP", AddIncomeEditboxs.editBox3, "BOTTOM", 0, -5)
    AddIncomeEditboxs.editBox4:SetMaxLetters(150)
    AddIncomeEditboxs.editBox4:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
    AddIncomeEditboxs.editBox4:SetScript("OnMouseUp", function (self)
        if (select(1, GetCursorInfo())) == "item" then
            self:SetText(select(3, GetCursorInfo()))
            ClearCursor()
        end
    end)
    AddIncomeEditboxs.editBox4.text = AddIncomeEditboxs.editBox4:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox4.text:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox4.text:SetPoint("RIGHT", AddIncomeEditboxs.editBox4, "LEFT", -15, 0)
    AddIncomeEditboxs.editBox4.text:SetText("名　称：")
    AddIncomeEditboxs.editBox4.text2 = AddIncomeEditboxs.editBox4:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox4.text2:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox4.text2:SetPoint("LEFT", AddIncomeEditboxs.editBox4, "RIGHT", 5, 0)
    AddIncomeEditboxs.editBox4.text2:SetText("(必填)")
    AddIncomeEditboxs.editBox7 = ZL.CreateEditBox(AddIncomeEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox7")
    AddIncomeEditboxs.editBox7:SetPoint("TOP", AddIncomeEditboxs.editBox4, "BOTTOM", 0, -5)
    AddIncomeEditboxs.editBox7:SetNumeric(true)
    AddIncomeEditboxs.editBox7:SetNumber(1)
    AddIncomeEditboxs.editBox7:SetScript("OnEnter", function (self)
        GameTooltip:ClearAllPoints()
        GameTooltip:ClearLines()
        GameTooltip:SetOwner(AddIncomeEditboxs, "ANCHOR_NONE")
        GameTooltip:AddLine("输入大于0的数，默认为1")
        GameTooltip:SetPoint("LEFT", self, "RIGHT")
        GameTooltip:Show()
    end)
    AddIncomeEditboxs.editBox7:SetScript("OnLeave", function (self) GameTooltip:Hide() end)
    AddIncomeEditboxs.editBox7.text = AddIncomeEditboxs.editBox7:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox7.text:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox7.text:SetPoint("RIGHT", AddIncomeEditboxs.editBox7, "LEFT", -15, 0)
    AddIncomeEditboxs.editBox7.text:SetText("数　量：")
    AddIncomeEditboxs.editBox7.text2 = AddIncomeEditboxs.editBox7:CreateFontString(nil, "OVERLAY")
    AddIncomeEditboxs.editBox7.text2:SetFontObject(GameFontWhite)
    AddIncomeEditboxs.editBox7.text2:SetPoint("LEFT", AddIncomeEditboxs.editBox7, "RIGHT", 5, 0)
    AddIncomeEditboxs.editBox7.text2:SetText("(必填)")
    do
        local editboxList = {"StaticPopupDialogsEditBox3", "StaticPopupDialogsEditBox4", "StaticPopupDialogsEditBox7"}
        local function OnTabPressed(self)
            EditBox_HandleTabbing(self, editboxList)
        end
        AddIncomeEditboxs.editBox3:SetScript("OnTabPressed", OnTabPressed)
        AddIncomeEditboxs.editBox4:SetScript("OnTabPressed", OnTabPressed)
        AddIncomeEditboxs.editBox7:SetScript("OnTabPressed", OnTabPressed)
    end
    AddIncomeEditboxs:SetSize(20+xSize+AddIncomeEditboxs.editBox3.text:GetWidth()+AddIncomeEditboxs.editBox3.text2:GetWidth(), ySize*4+3*5)
end
--创建StaticPopup创建拍卖记录文本框
function ZL.CreateStaticPopupAddAuctionEditboxs()
    ZL.AddAuctionEditboxs = CreateFrame("Frame", nil, ZL)
    local AddAuctionEditboxs = ZL.AddAuctionEditboxs
    AddAuctionEditboxs:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    AddAuctionEditboxs:Hide()
    local xSize, ySize = 130, 24
    AddAuctionEditboxs.editBox5 = ZL.CreateEditBox(AddAuctionEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox5")
    AddAuctionEditboxs.editBox5:SetNumeric(true)
    AddAuctionEditboxs.editBox5:SetScript("OnMouseUp", function (self)
        if (select(1, GetCursorInfo())) == "item" then
            self:SetText(select(2, GetCursorInfo()))
            ClearCursor()
        end
    end)
    AddAuctionEditboxs.editBox5:SetScript("OnEnter", function (self)
        ZL.GameTooltipShow(self, "LEFT", "RIGHT")
        GameTooltip:AddLine("方法：")
        GameTooltip:AddLine("1、Shift+左键点击背包或物品链接", 1, 1, 1)
        GameTooltip:AddLine("2、鼠标点击物品，移动到这里，\n释放鼠标后可以自动获取到物品ID", 1, 1, 1)
        GameTooltip:Show()
    end)
    AddAuctionEditboxs.editBox5:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    AddAuctionEditboxs.editBox5.text = AddAuctionEditboxs.editBox5:CreateFontString(nil, "OVERLAY")
    AddAuctionEditboxs.editBox5.text:SetFontObject(GameFontWhite)
    AddAuctionEditboxs.editBox5.text:SetPoint("TOPLEFT", AddAuctionEditboxs, "TOPLEFT", 0, 0)
    AddAuctionEditboxs.editBox5.text:SetText("物品ID：")
    AddAuctionEditboxs.editBox5:SetPoint("LEFT", AddAuctionEditboxs.editBox5.text, "RIGHT", 15, 0)
    AddAuctionEditboxs.editBox5.text2 = AddAuctionEditboxs.editBox5:CreateFontString(nil, "OVERLAY")
    AddAuctionEditboxs.editBox5.text2:SetFontObject(GameFontWhite)
    AddAuctionEditboxs.editBox5.text2:SetPoint("LEFT", AddAuctionEditboxs.editBox5, "RIGHT", 5, 0)
    AddAuctionEditboxs.editBox5.text2:SetText("(必填)")
    AddAuctionEditboxs.editBox6 = ZL.CreateEditBox(AddAuctionEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsEditBox6")
    AddAuctionEditboxs.editBox6:SetPoint("TOP", AddAuctionEditboxs.editBox5, "BOTTOM", 0, -5)
    AddAuctionEditboxs.editBox6:SetNumeric(true)
    AddAuctionEditboxs.editBox6.text = AddAuctionEditboxs.editBox6:CreateFontString(nil, "OVERLAY")
    AddAuctionEditboxs.editBox6.text:SetFontObject(GameFontWhite)
    AddAuctionEditboxs.editBox6.text:SetPoint("RIGHT", AddAuctionEditboxs.editBox6, "LEFT", -15, 0)
    AddAuctionEditboxs.editBox6.text:SetText("数　量：")
    AddAuctionEditboxs.editBox6.text2 = AddAuctionEditboxs.editBox6:CreateFontString(nil, "OVERLAY")
    AddAuctionEditboxs.editBox6.text2:SetFontObject(GameFontWhite)
    AddAuctionEditboxs.editBox6.text2:SetPoint("LEFT", AddAuctionEditboxs.editBox6, "RIGHT", 5, 0)
    AddAuctionEditboxs.editBox6.text2:SetText("(必填)")
    do
        local editboxList = {"StaticPopupDialogsEditBox5", "StaticPopupDialogsEditBox6"}
        local function OnTabPressed(self)
            EditBox_HandleTabbing(self, editboxList)
        end
        AddAuctionEditboxs.editBox5:SetScript("OnTabPressed", OnTabPressed)
        AddAuctionEditboxs.editBox6:SetScript("OnTabPressed", OnTabPressed)
    end
    AddAuctionEditboxs:SetSize(20+xSize+AddAuctionEditboxs.editBox5.text:GetWidth()+AddAuctionEditboxs.editBox5.text2:GetWidth(), ySize*2+5)
end
--创建批量修改起拍价和加价幅度
function ZL.CreateStaticPopupModifyStartAmountEditboxs()
    ZL.ModifyStartAmountEditboxs = CreateFrame("Frame", nil, ZL)
    local ModifyStartAmountEditboxs = ZL.ModifyStartAmountEditboxs
    ModifyStartAmountEditboxs:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    ModifyStartAmountEditboxs:Hide()
    local xSize, ySize = 130, 24
    ModifyStartAmountEditboxs.editBox1 = ZL.CreateEditBox(ModifyStartAmountEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsModifyEditBox1")
    ModifyStartAmountEditboxs.editBox1:SetNumeric(true)
    ModifyStartAmountEditboxs.editBox1.text = ModifyStartAmountEditboxs.editBox1:CreateFontString(nil, "OVERLAY")
    ModifyStartAmountEditboxs.editBox1.text:SetFontObject(GameFontWhite)
    ModifyStartAmountEditboxs.editBox1.text:SetPoint("TOPLEFT", ModifyStartAmountEditboxs, "TOPLEFT", 0, 0)
    ModifyStartAmountEditboxs.editBox1.text:SetText("起拍价：")
    ModifyStartAmountEditboxs.editBox1:SetPoint("LEFT", ModifyStartAmountEditboxs.editBox1.text, "RIGHT", 15, 0)
    ModifyStartAmountEditboxs.editBox2 = ZL.CreateEditBox(ModifyStartAmountEditboxs, xSize, ySize, 14, "LEFT", nil, nil, nil, nil, nil, nil, "StaticPopupDialogsModifyEditBox2")
    ModifyStartAmountEditboxs.editBox2:SetPoint("TOP", ModifyStartAmountEditboxs.editBox1, "BOTTOM", 0, -5)
    ModifyStartAmountEditboxs.editBox2:SetNumeric(true)
    ModifyStartAmountEditboxs.editBox2:SetScript("OnEnter", function (self)
        ZL.GameTooltipShow(self, "LEFT", "RIGHT")
        if ZL.opt.intervalBidIncrement then
            GameTooltip:AddLine("注意：")
            GameTooltip:AddLine("已开启按区间自动调整加价幅度，\n无法手动设置", 1, 0, 0)
            GameTooltip:AddLine(" ")
            GameTooltip:AddLine("Shift+左键：|cffffffff关闭自动调整加价幅度|r")
        else
            GameTooltip:AddLine("提示：")
            GameTooltip:AddLine("Shift+左键：|cffffffff开启自动调整加价幅度|r")
        end
        GameTooltip:AddLine("Shift+右键：|cffffffff设置区间加价幅度|r")
        GameTooltip:Show()
    end)
    ModifyStartAmountEditboxs.editBox2:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    ModifyStartAmountEditboxs.editBox2:SetScript("OnMouseDown", function (self, button)
        if IsShiftKeyDown() then
            if button == "LeftButton" then
                if ZL.opt.intervalBidIncrement then
                    ZL.opt.intervalBidIncrement = nil
                    ZL.Print("已|cff4080FF关闭|r按区间自动调整加价幅度。")
                    self:Enable()
                else
                    ZL.opt.intervalBidIncrement = true
                    ZL.Print("已|cff4080FF开启|r按区间自动调整加价幅度。")
                    self:Disable()
                end
                GameTooltip:Hide()
            elseif button == "RightButton" then
                ZL.OpenAceConfigDialog("金团拍卖助手", "behaviour")
            end
        end
    end)
    ModifyStartAmountEditboxs.editBox2.text = ModifyStartAmountEditboxs.editBox2:CreateFontString(nil, "OVERLAY")
    ModifyStartAmountEditboxs.editBox2.text:SetFontObject(GameFontWhite)
    ModifyStartAmountEditboxs.editBox2.text:SetPoint("RIGHT", ModifyStartAmountEditboxs.editBox2, "LEFT", -15, 0)
    ModifyStartAmountEditboxs.editBox2.text:SetText("加　价：")
    do
        local editboxList = {"StaticPopupDialogsModifyEditBox1", "StaticPopupDialogsModifyEditBox2"}
        local function OnTabPressed(self)
            EditBox_HandleTabbing(self, editboxList)
        end
        ModifyStartAmountEditboxs.editBox1:SetScript("OnTabPressed", OnTabPressed)
        ModifyStartAmountEditboxs.editBox2:SetScript("OnTabPressed", OnTabPressed)
    end
    ModifyStartAmountEditboxs:SetSize(20+xSize+ModifyStartAmountEditboxs.editBox1.text:GetWidth(), ySize*2+5)
end

--定义静态弹出对话框
--重置当前拍卖记录
StaticPopupDialogs["ZL_RESETCURRENT"] = {
	text = "%s",
	button1 = "重置|cffffff00并保存|r",
	button2 = "重置|cffff0000不保存|r",
    button3 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
        self:GetEditBox():SetText(ZL_CURRENT.name or GetInstanceInfo())
    end,
	OnAccept = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
        if ZL_CURRENT["auctionlist"] then
            for num, data in ipairs(ZL_CURRENT["auctionlist"]) do
                local f = ZL.AuctionFrame2.entries[num]
                if data.state == "auctioning" then
                    ZL_CURRENT.auctionlist[num].state = "waiting"
                    ZL_CURRENT.auctionlist[num].endTime = nil
                    ZL_CURRENT.auctionlist[num].isPaused = nil
                    ZL_CURRENT.auctionlist[num].bidderlist = {}
                    f:SetValues(num)
                end
                f:Hide()
            end
        end

        local _, _, totalincome = ZL.GetAveWages()
        ZL_CURRENT.totalincome = totalincome
        if (not ZL_CURRENT.name) and (strlen(self:GetEditBox():GetText()) == 0) then
            ZL_CURRENT.name = GetInstanceInfo()
        elseif strlen(self:GetEditBox():GetText()) > 0 then
            ZL_CURRENT.name = self:GetEditBox():GetText()
        end
        if not ZL_CURRENT.auctiondate then ZL_CURRENT.auctiondate = date("%Y-%m-%d %H:%M:%S", GetServerTime()) end
        local index
        local auctionGUID = (ZL_CURRENT.globalConfig and ZL_CURRENT.globalConfig.auctionGUID) and ZL_CURRENT.globalConfig.auctionGUID or ZL_CURRENT.auctionGUID
        if auctionGUID then
            for _index, _data in ipairs(ZL_HISTORY) do
                local _acutionGUID = (_data.globalConfig and _data.globalConfig.auctionGUID) and _data.globalConfig.auctionGUID or _data.auctionGUID
                if auctionGUID == _acutionGUID then
                    index = _index
                    break
                end
            end
        end
        if index then
            ZL_HISTORY[index] = ZL_CURRENT
        else
            table.insert(ZL_HISTORY, ZL_CURRENT)
        end
        ZL_PLAYERLIST = {}
        ZL_CURRENT = {}
        ZL.CreateAuctionInfo()
        ZL.AuctionFrame2:Update()
        ZL.AuctionRecordFrame.historyFrame:Update()
        ZL.AuctionRecordFrame.currentIncomeFrame:Update()
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
        if not ZL.PlayerIsML() and ZL.GetMLname() then
            MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
        end
        local chatType
        if IsInRaid(1) then
            chatType = "RAID"
        elseif IsInGroup(1) then
            chatType = "PARTY"
        elseif IsInGuild() then
            chatType = "GUILD"
        end
        if chatType then
            --获取团队版本号
            local data = {type="request"}
            MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
        end
        ZL.TransmitAddonInfo_Pro()
        local link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "历史记录", "历史记录")
        ZL.Print("已重置当前记录，可到" .. link .. "中恢复", true)
	end,
	OnCancel = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
        if ZL_CURRENT["auctionlist"] then
            for num, data in ipairs(ZL_CURRENT["auctionlist"]) do
                local f = ZL.AuctionFrame2.entries[num]
                if data.state == "auctioning" then
                    ZL_CURRENT.auctionlist[num].state = "waiting"
                    ZL_CURRENT.auctionlist[num].endTime = nil
                    ZL_CURRENT.auctionlist[num].isPaused = nil
                    ZL_CURRENT.auctionlist[num].bidderlist = {}
                    f:SetValues(num)
                end
                f:Hide()
            end
        end
        ZL_PLAYERLIST = {}
        ZL_CURRENT = {}
        ZL.CreateAuctionInfo()
        ZL.AuctionFrame2:Update()
        ZL.AuctionRecordFrame.historyFrame:Update()
        ZL.AuctionRecordFrame.currentIncomeFrame:Update()
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
        if not ZL.PlayerIsML() and ZL.GetMLname() then
            MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
        end
        local chatType
        if IsInRaid(1) then
            chatType = "RAID"
        elseif IsInGroup(1) then
            chatType = "PARTY"
        elseif IsInGuild() then
            chatType = "GUILD"
        end
        if chatType then
            --获取团队版本号
            local data = {type="request"}
            MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
        end
        ZL.TransmitAddonInfo_Pro()
        ZL.Print("拍卖记录已清空", true)
	end,
	OnAlt = function(self, data)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}

--重置有拍卖中物品当前拍卖二次确认
StaticPopupDialogs["ZL_RESETCURRENT2"] = {
	text = "存在拍卖中的物品，确认重置当前拍卖记录？",
    button1 = "确认",
    button2 = "取消",
    whileDead = 1,
    showAlert = 1,
    hideOnEscape = 1,
    OnAccept = function(self)
        ZL.resetAuction()
    end,
    OnCancel = function(self)
    end,
}

--最高竞价二次确认
StaticPopupDialogs["ZL_BIDAMOUNTCONFIRM"] = {
	text = "%s",
    button1 = "竞价",
    button2 = "取消",
    whileDead = 1,
    showAlert = 1,
    hideOnEscape = 1,
    OnAccept = function(self, data)
        local wantBid = data.wantBid
        local newBid = data.newBid
        local bidCount = data.bidCount
        local curAuctionList = ZL_CURRENT.auctionlist[data.index]
        local itemlink = curAuctionList.itemlink
        local msgStr = ""
        if wantBid >= newBid then
            if bidCount == 1 then
                msgStr = tostring(wantBid)
            else
                msgStr = tostring(wantBid) .. "x" .. bidCount
            end
            if ZL_CURRENT.globalConfig.auctionMode == "团队" then
                if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                    SendChatMessage(msgStr, "RAID")
                else
                    SendChatMessage(itemlink .. msgStr, "RAID")
                end
            else
                MyAddon:TransmitAddonInfo2("AUTOAUC BID", itemlink .. msgStr)
            end
        else
            msgStr = "出价过低，当前竞拍数量".. bidCount .. "至少出价：|cffffd100" .. newBid .."|rg"
            ZL.Print(msgStr, true)
        end
    end,
    OnCancel = function(self)
    end,
}

--流拍物品申请重拍确认
StaticPopupDialogs["ZL_RETAKE"] = {
	text = "%s",
	button1 = "重拍",
	button2 = "取消",
    hasEditBox = false,
	OnAccept = function(self, data)
		if ZL.retake and #ZL.retake > 0 then
            local retake = ZL.retake
            local function linshi()
                if #retake > 0 then
                    local AuctioningCount = ZL.GetAuctioningCount()
                    if (not ZL_CURRENT.globalConfig.allowMultipleAuctions) and AuctioningCount > 0 then
                        C_Timer.After(2, linshi)
                    else
                        local fdata = tremove(ZL.retake, 1)
                        local _, _index = ZL.FetchDataFromItemId(fdata.itemlink, fdata.itemindex)
                        if _index then
                            local curAuctionList = ZL_CURRENT.auctionlist[_index]
                            --如果是流拍的物品重新拍卖，检测流拍物品是否在流拍包里，如果在移动到其他包里
                            if curAuctionList.state == "failed" and ZL.opt.liupaiToggle and curAuctionList["spawnUID"] and next(curAuctionList["spawnUID"], nil) then
                                local itemList = {}
                                for _, value in pairs(curAuctionList["spawnUID"]) do
                                    if value["itemGUID"] and next(value["itemGUID"], nil) then
                                        for key, _ in pairs(value["itemGUID"]) do
                                            local bagID, slotIndex = ZL.FindItemInBag(key)
                                            if bagID and (bagID == ZL.opt.liupaiBagId or bagID == ZL.opt.liupaiBagId2) then
                                                --从第一个背包开始查询空闲的格子，如果不是流拍背包，也不是自己拍到的背包，则放进去
                                                local targetBagID, targetslotIndex
                                                local currentInfo
                                                for _bagID = 0, NUM_BAG_SLOTS do
                                                    if _bagID ~= ZL.opt.liupaiBagId and _bagID ~= ZL.opt.liupaiBagId and _bagID ~= ZL.opt.selfBagId then
                                                        for _slotIndex = 1, C_Container.GetContainerNumSlots(_bagID) do
                                                            currentInfo = C_Container.GetContainerItemInfo(_bagID, _slotIndex)
                                                            if not currentInfo then
                                                                targetBagID = _bagID
                                                                targetslotIndex = _slotIndex
                                                                break
                                                            end
                                                        end
                                                    end
                                                end
                                                currentInfo = nil
                                                if targetBagID then
                                                    table.insert(itemList, {
                                                        bagID = bagID, slotIndex = slotIndex,
                                                        targetBagID = targetBagID, targetslotIndex = targetslotIndex,
                                                    })
                                                end
                                            end
                                        end
                                    end
                                end

                                if #itemList > 0 then
                                    local index = 1
                                    local function _linshi()
                                        if index <= #itemList then
                                            if not (InCombatLockdown() or UnitIsDeadOrGhost("player")) then
                                                C_Container.PickupContainerItem(itemList[index]["bagID"], itemList[index]["slotIndex"])
                                                C_Container.PickupContainerItem(itemList[index]["targetBagID"], itemList[index]["targetslotIndex"])
                                                index = index + 1
                                                C_Timer.After(1, _linshi)
                                            else
                                                C_Timer.After(0.2, _linshi)
                                            end
                                        end
                                    end
                                    _linshi()
                                end
                            end
                            curAuctionList.bidderlist = {}
                            table.insert(ZL_CURRENT.auctionlist[_index].bidderlist, {
                                bidder = ZL.GetClassColorName(fdata.fullName),
                                bidamount = curAuctionList.startbidamount,
                                bidCount = 1,
                                time = GetTime()*1000,
                            })
                            local _data = {
                                type = "开始拍卖",
                                isRestart = curAuctionList.state,
                                data2 = curAuctionList,
                                syncIndex = _index,
                                globalConfigData = ZL.globalConfigData(),
                            }
                            MyAddon:TransmitAddonInfo("AUTOAUC SYNC1", _data)
                            local Frame1 = ZL.AuctionFrame2.entries[_index]
                            Frame1.sync = true
                            Frame1.MLframe.functionFrame.CancelBtn:Disable()
                            C_Timer.After(10, function ()
                                Frame1.sync = nil
                                Frame1.MLframe.functionFrame.CancelBtn:Enable()
                            end)
                            C_Timer.After(2, linshi)
                        end
                    end
                end
            end
            linshi()
        end
	end,
	OnCancel = function(self, data)
        SendChatMessage("因暂时不方便拍卖，请稍后重新提交重拍申请", "WHISPER", nil, data)
        ZL.retake = {}
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}

--拾取绑定物品加入到打包拍卖确认提醒
StaticPopupDialogs["ZL_ISPACKAGE"] = {
	text = "%s",
	button1 = "打包拍卖",
	button2 = "取消",
    hasEditBox = false,
	OnAccept = function(self, data)
		ZL.AddToPackage(data)
	end,
	OnCancel = function(self)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}
--更改拍卖模式警告提醒
StaticPopupDialogs["ZL_CHANGEAUCTIONMODE"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
	OnAccept = function(self, data)
        if data.type == "匿名" then
            local fdata = {
                type = "开始投票",
                totalMembers = data.totalMembers,
            }
            MyAddon:TransmitAddonInfo("AUTOAUC VOTE", fdata)
        end
        ZL.AuctionFrame2.auctionModeDropdown:Disable()
	end,
	OnCancel = function(self)
        ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = true,
}

--切换为匿名拍卖模式投票
StaticPopupDialogs["ZL_CHANGEAUCTIONMODEVOTE"] = {
	text = "",  --%s
    timeout = 31,
	button1 = "同意",
	button2 = "反对",
    OnShow = function(self)
        local txtString = self:GetTextFontString() or self.text
        txtString:SetFormattedText(self.data .. "正在进行|cffff0000【匿名】|r拍卖投票，请选择(%d)", 30)
        self.ticker = C_Timer.NewTicker(1, function()
            if self.timeleft > 0 then
                txtString:SetFormattedText(self.data .. "正在进行|cffff0000【匿名】|r拍卖投票，请选择(%d)", self.timeleft)
                if self.timeleft <= 0 then
                    self:Hide()
                end
            end
        end)
        if ZL.voteTimer then
            if not ZL.voteTimer:IsCancelled() then
                ZL.voteTimer:Cancel()
            end
            ZL.voteTimer = nil
        end
        ZL.voteTimer = C_Timer.NewTimer(32, function ()
            local pass = ZL.voteAgree*100/ZL.voteTotalMembers
            local msgStr = "|cff00ff00同意：|r" .. ZL.voteAgree .. " |cffff0000反对：|r" .. ZL.voteRefuse .. " |cff0070dd总人数：|r" .. ZL.voteTotalMembers
            ZL.Print(msgStr, true)
            if pass > 50 then
                if ZL.PlayerIsML() then
                    ZL.opt.auctionMode = ZL.AuctionFrame2.auctionModeDropdown:GetText()
                    ZL.TransmitAddonInfo_Pro()
                    ZL.AuctionFrame2.auctionModeDropdown:Enable()
                    SendChatMessage("通过！通过率：" .. format("%.2f%%", pass) .. "，大于50%，拍卖模式已切换为【匿名】拍卖！", "RAID")
                end
                msgStr = "|cff00ff00通过！|r通过率：" .. format("%.2f%%", pass) .. "，大于50%，拍卖模式已切换为【|cffff0000匿名|r】拍卖！"
                ZL.Print(msgStr, true)
            else
                msgStr = "|cffff0000失败！|r通过率：" .. format("%.2f%%", pass) .. "，没有大于50%，拍卖模式已切换为【团队】模式！"
                ZL.Print(msgStr, true)
                if ZL.PlayerIsML() then
                    ZL.AuctionFrame2.auctionModeDropdown:SetValue(1)
                    ZL.AuctionFrame2.auctionModeDropdown:Enable()
                end
            end
        end)
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
    end,
	OnAccept = function(self, data)
        local fdata = {
            type = "同意",
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC VOTE", fdata)
	end,
    OnCancel = function(self, data)
        local fdata = {
            type = "反对",
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC VOTE", fdata)
    end,
    OnHide = function(self)
        if ( self.timeleft > 0 ) then
            self:Hide();
        end
        if self.ticker then
            self.ticker:Cancel()
            self.ticker = nil
        end
    end,
    whileDead = true,
    hideOnEscape = false,
}
--进入全新副本时提醒是否重置拍卖记录
StaticPopupDialogs["ZL_RESETCURRENTINFO"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
	OnAccept = function(self)
        if ZL.auctionStateCount() > 0 then
            StaticPopup_Show("ZL_RESETCURRENT2")
        else
            ZL.resetAuction()
        end
	end,
    OnCancel = function (self, data)
        if data then
            if data.type == "更新日期" then
                ZL_CURRENT.auctiondate =  date("%Y-%m-%d %H:%M:%S", GetServerTime())
            elseif data.type == "更新副本" then
                ZL_CURRENT.instanceID = data.instanceID
                ZL_CURRENT.maxPlayers = data.maxPlayers
                ZL_CURRENT.name = data.name
            end
        end
    end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}
--手动添加收支记录
StaticPopupDialogs["ZL_ADDINCOME"] = {
    text = "【|cffffd100%s|r】请输入必填项目",
    button1 = "确定",
    button2 = "取消",
    OnShow = function(dialog, data)
		dialog:GetButton1():Disable()
        local relativeTo = select(2, dialog.ButtonContainer:GetPoint())
        ZL.AddIncomeEditboxs:ClearAllPoints()
        ZL.AddIncomeEditboxs:SetPoint("TOP", relativeTo, "BOTTOM", 0, -15)
        ZL.AddIncomeEditboxs:Show()
        dialog.ButtonContainer:ClearAllPoints()
        dialog.ButtonContainer:SetPoint("TOP", ZL.AddIncomeEditboxs, "BOTTOM", 0, -9)
        local editBox2 = ZL.AddIncomeEditboxs.editBox2
        local editBox3 = ZL.AddIncomeEditboxs.editBox3
        local editBox4 = ZL.AddIncomeEditboxs.editBox4
        local editBox7 = ZL.AddIncomeEditboxs.editBox7
        editBox2:SetScript("OnMouseDown", function (self, button)
            if button == "LeftButton" then
                local function tempList()
                    local menuTable = {}
                    local currentRoster = ZL.GetCurrentRoster()
                    if currentRoster then
                        for i = 1, #currentRoster do
                            if #currentRoster[i] > 0 then
                                local group = {
                                    text = "|cffffffff小队" .. tostring(i) .. "|r",
                                    hasArrow = true,
                                    isTitle = true,
                                    menuTable = {},
                                }
                                for _, playerName in ipairs(currentRoster[i]) do
                                    local isCandidate = true
                                    if data.index then
                                        isCandidate = ZL.IsCandidate(data.index, playerName)
                                    end
                                    tinsert(group.menuTable, {
                                        text = function ()
                                            if isCandidate then
                                                return ZL.GetNoRealmName(playerName, true)
                                            else
                                                return ZL.GetNoRealmName(playerName).."(不可交易)"
                                            end
                                        end,
                                        disabled = not isCandidate,
                                        func = function ()
                                            self:SetText(ZL.GetNoRealmName(playerName, true))
                                            data.name = playerName
                                            self:ClearFocus()
                                            ZL.GUI:CloseMenu()
                                        end,
                                    })
                                end
                                tinsert(menuTable, group)
                                group = nil
                            end
                        end
                    end
                    return menuTable
                end
                local menuList = tempList()
                if #menuList > 0 then
                    ZL.GUI:ToggleMenu(self, menuList, "cursor")
                end
            end
        end)
        editBox2:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(editBox2:GetText()) > 0 and editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            elseif data.type == "支出" then
                if editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            end
        end)
        editBox3:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(editBox2:GetText()) > 0 and editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            elseif data.type == "支出" then
                if editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            end
        end)
        editBox4:SetScript("OnTextChanged", function (self)
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                if strlen(editBox2:GetText()) > 0 and editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            elseif data.type == "支出" then
                if editBox3:GetNumber() > 0 and strlen(editBox4:GetText()) > 0 then
                    dialog:GetButton1():Enable()
                else
                    dialog:GetButton1():Disable()
                end
            end
        end)
        editBox4:SetScript("OnEnter", function (self)
            GameTooltip:ClearAllPoints()
            GameTooltip:ClearLines()
            GameTooltip:SetOwner(self, "ANCHOR_NONE")
            if data.type == "收入" or data.type == "指定人员" or data.type == "罚款" then
                GameTooltip:AddLine("如：罚款，垃圾或其他收入")
            elseif data.type == "支出" then
                GameTooltip:AddLine("如：补贴，物资消耗支出等")
            end
            GameTooltip:AddLine("如需输入物品名，|cffffd100Shift+左键|r点击\n背包物品或拍卖图标", 1, 1, 1)
            GameTooltip:SetPoint("LEFT", self, "RIGHT")
            GameTooltip:Show()
        end)
        editBox2:SetText("")
		editBox3:SetText("")
        editBox4:SetText("")
        editBox7:SetNumber(1)
        dialog:SetHeight(dialog:GetHeight()+ZL.AddIncomeEditboxs:GetHeight()+15)
        if data.type == "收入" then
            editBox2.text2:SetText("(必填)")
            editBox7.text2:SetText("(必填)")
        elseif data.type == "支出" then
            editBox2.text2:SetText("(可选)")
            editBox7.text2:SetText("(可选)")
        elseif data.type == "指定人员" then
            local ddate = ZL_CURRENT.auctionlist[data.index]
            editBox2.text2:SetText("(必填)")
            editBox7.text2:SetText("(必填)")
            editBox3:SetNumber(ddate.startbidamount)
            editBox4:SetText(ddate.itemlink)
            editBox7:SetNumber(ddate.itemCount)
        elseif data.type == "罚款" then
            editBox2.text2:SetText("(必填)")
            editBox7.text2:SetText("(必填)")
            editBox2:SetText(ZL.GetNoRealmName(data.name, true))
            editBox3:SetNumber(data.amount)
            editBox4:SetText("罚款")
        end
    end,
    OnAccept = function (dialog, data)
        local itemList
        local editBox2 = ZL.AddIncomeEditboxs.editBox2
        local editBox3 = ZL.AddIncomeEditboxs.editBox3
        local editBox4 = ZL.AddIncomeEditboxs.editBox4
        local editBox7 = ZL.AddIncomeEditboxs.editBox7
        local player = data.name
        local notes = editBox4:GetText()
        local amount = 0
        local itemCount = editBox7:GetNumber()
        if ((not itemCount) or itemCount <= 0) then
            itemCount = 1
        end
        ZL_CURRENT.IncomeList = ZL_CURRENT.IncomeList or {}
        if data.type == "收入" or data.type == "支出" or data.type == "罚款" then
            if data.type == "收入" or data.type == "罚款" then
                amount = editBox3:GetNumber() * itemCount
            elseif data.type == "支出" then
                amount = -editBox3:GetNumber() * itemCount
            end
            table.insert(ZL_CURRENT.IncomeList, {
                player = player,
                amount = amount,
                notes = notes,
                itemCount = itemCount,
                itemList = itemList,
            })
            if ZL.PlayerIsML(player) and amount > 0 then
                --ML自己拍到的物品直接记录到已支付
                if not ZL_CURRENT.playerPayToML then ZL_CURRENT.playerPayToML = {} end
                local oldPayToML = ZL_CURRENT.playerPayToML[player] and ZL_CURRENT.playerPayToML[player] or 0
                ZL_CURRENT.playerPayToML[player] = oldPayToML + amount
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            end
            ZL.AuctionRecordFrame.currentIncomeFrame:Update()
            ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            local fdata = {
                type = "添加收支",
                data = ZL_CURRENT.IncomeList,
                globalConfigData = ZL.globalConfigData(),
            }
            MyAddon:TransmitAddonInfo("AUTOAUC SYNC11", fdata)
        elseif data.type == "指定人员" then
            local ddate = ZL_CURRENT.auctionlist[data.index]
            ddate.bidderlist = {}
            table.insert(ddate.bidderlist, {
                bidder = player,
                bidamount = editBox3:GetNumber(),
                bidCount = itemCount,
                time = GetTime()*1000,
            })
            ZL.startOrCanelAuction(data.index, true)
        end
    end,
    OnHide = function (dialog)
        dialog:Hide()
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--批量修改起拍价和加价幅度
StaticPopupDialogs["ZL_MODIFYSTARTAMOUNT"] = {
    text = "%s",
    button1 = "确定",
    button2 = "取消",
    OnShow = function(dialog, data)
        local relativeTo = select(2, dialog.ButtonContainer:GetPoint())
        ZL.ModifyStartAmountEditboxs:ClearAllPoints()
        ZL.ModifyStartAmountEditboxs:SetPoint("TOP", relativeTo, "BOTTOM", 0, -15)
        dialog.ButtonContainer:ClearAllPoints()
        dialog.ButtonContainer:SetPoint("TOP", ZL.ModifyStartAmountEditboxs, "BOTTOM", 0, -9)
        ZL.ModifyStartAmountEditboxs:Show()
        local editBox1 = ZL.ModifyStartAmountEditboxs.editBox1
        local editBox2 = ZL.ModifyStartAmountEditboxs.editBox2
        editBox1:SetFocus()
        editBox1:SetText("")
        editBox2:SetText("")
        if ZL.opt.intervalBidIncrement then
            editBox2:Disable()
        else
            editBox2:Enable()
        end
        editBox1:SetScript("OnEnterPressed", function (self)
            dialog:GetButton1():Click()
        end)
        editBox2:SetScript("OnEnterPressed", function (self)
            dialog:GetButton1():Click()
        end)
		dialog:SetHeight(dialog:GetHeight()+ZL.ModifyStartAmountEditboxs:GetHeight()+15)
    end,
    OnAccept = function (dialog, _data)
        local editBox1 = ZL.ModifyStartAmountEditboxs.editBox1
        local editBox2 = ZL.ModifyStartAmountEditboxs.editBox2
        local startbidamount = editBox1:GetNumber()
        local increament = editBox2:GetNumber()
        local msgStr = ""
        if not ZL.PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        ZL.AuctionFrame2.iconHeaderBtn.checkBtn:SetChecked(false)
        local type = _data.type
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = ZL.AuctionFrame2.entries[index]
                if (not data.lgnore) and (not data.isPackage) and data.bindType == 1 and data.stackCount == 1
                and ((type == 1 and data.state == "waiting") or (type == 2 and data.state == "failed")
                or (type == 3 and (data.state == "waiting" or data.state == "failed"))
                or (type == 4 and (data.state == "waiting" or data.state == "failed") and f.infoFrame.checkBtn:GetChecked())) then
                    if startbidamount > 0 then
                        data["startbidamount"] = startbidamount
                    end
                    if increament > 0 then
                        data["bidIncrement"] = increament
                    end
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        ZL.AuctionFrame2:Update()
    end,
    OnHide = function (dialog)
        dialog:Hide()
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--清除所有历史记录警告
StaticPopupDialogs["ZL_CLEARHISTORYWARNING"] = {
	text = "警告！警告！将清空所有历史拍卖记录，并且无法恢复！是否确定清空？",
	button1 = "确定",
    button2 = "取消",
	OnAccept = function(self, data)
        for _, f in ipairs(ZL.AuctionRecordFrame.historyFrame.entries) do
            f:Hide()
        end
        ZL_HISTORY = {}
	end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--删除历史拍卖记录警告
StaticPopupDialogs["ZL_DELETEHISTORYWARNING"] = {
	text = "删除后无法恢复，确认删除该拍卖记录？",
	button1 = "确定",
    button2 = "取消",
	OnAccept = function(self, data)
        table.remove(ZL_HISTORY, data)
        ZL.AuctionRecordFrame.historyFrame:Update()
	end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--删除拍卖警告
StaticPopupDialogs["ZL_DELETEAUCTIONWARNING"] = {
	text = "%s",
	button1 = "确定",
    button2 = "取消",
	OnAccept = function(self, data)
        local curAuctionList = ZL_CURRENT.auctionlist[data]
        --将需要删除的拍卖物品发送给其他成员
        local fdata = {
            type = "删除拍卖物品",
            itemindex = curAuctionList.itemindex,
            itemlink = curAuctionList.itemlink,
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC10", fdata)
        ZL.AuctionFrame2.entries[data].sync = true
        C_Timer.After(10, function ()
            ZL.AuctionFrame2.entries[data].sync = nil
        end)
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--自动出价
StaticPopupDialogs["ZL_AUTOBID"] = {
    text = "输入%s的最大心里价位:",
    timeout = 31,
	button1 = "开始自动出价",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
        self:SetHyperlinksEnabled(true)
        self:SetScript("OnHyperlinkEnter", function(self, link, _, button)
            local itemID = GetItemInfoInstant(link)
            if itemID then
                GameTooltip:SetOwner(button, "ANCHOR_RIGHT", 0, 0)
                GameTooltip:ClearLines()
                GameTooltip:SetHyperlink(link)
                GameTooltip:Show()
            end
        end)
        self:SetScript("OnHyperlinkLeave", function(self)
            GameTooltip:Hide()
        end)
        self:GetButton1():Disable()
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
        if self.data.targetAmount then self:GetEditBox():SetText(self.data.targetAmount) end
    end,
	OnAccept = function(self, data)
		data.f.maxAutoBid = self:GetEditBox():GetNumber() or 0
        if data.f.maxAutoBid > 0 then
            data.f.bidFrame.bidEditBox:Disable()
            data.f.bidFrame.bidBtn:SetText("停止")
            data.f.bidFrame.lgnoreBtn:Disable()
            local itemCount = ZL_CURRENT.auctionlist[data.index].itemCount
            local bidCount = data.f.bidFrame.bidCounts:GetNumber()
            bidCount = bidCount > 0 and bidCount or 1
            bidCount = bidCount > itemCount and itemCount or bidCount
            autoBid(data.index, data.f.maxAutoBid, bidCount)
            if data.f.autoBid then
                if (not data.f.autoBid:IsCancelled()) then
                    data.f.autoBid:Cancel()
                end
                data.f.autoBid = nil
            end
            data.f.autoBid = C_Timer.NewTicker(2, function (self)
                autoBid(data.index, data.f.maxAutoBid, bidCount)
            end)
        end
        self:GetEditBox():ClearFocus()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = 1,
    hideOnEscape = 1,
}

--代交欠款名单确认
StaticPopupDialogs["ZL_CONFIRMTRADERNAME"] = {
    text = "【%s】没有欠款记录，如果是代交欠款，请先选择代交人，然后点记录\n如果不是，请选择不记录:",
	button1 = "记录",
	button2 = "不记录",
    OnShow = function(dialog)
        dialog:GetButton1():Disable()
        local relativeTo = select(2, dialog.ButtonContainer:GetPoint())
        ZL.GroupMembersDropdown:ClearAllPoints()
        ZL.GroupMembersDropdown:SetPoint("TOP", relativeTo, "BOTTOM", 0, -15)
        dialog.ButtonContainer:ClearAllPoints()
        dialog.ButtonContainer:SetPoint("TOP", ZL.GroupMembersDropdown, "BOTTOM", 0, -9)
        dialog:SetHeight(dialog:GetHeight()+ZL.GroupMembersDropdown:GetHeight()+15)
        ZL.GroupMembersDropdown:Show()
        ZL.GroupMembersDropdown:SetDefaultText("")
        local menuTable = {}
        if IsInRaid(1) then
            local WagesGroupMembers = ZL.GetCurrentRoster()
            if WagesGroupMembers then
                for i, data in ipairs(WagesGroupMembers) do
                    if #data > 0 then
                        local memberList = {}
                        for _, playerName in ipairs(data) do
                            tinsert(memberList, {text=playerName, func = function ()
                                dialog:GetButton1():Enable()
                            end})
                        end
                        tinsert(menuTable, {
                            text = i .. "队",
                            hasArrow = true,
                            disabled = true,
                            menuTable = memberList,
                        })
                    end
                end
            end
        end
        ZL.GroupMembersDropdown:SetMenuTable(menuTable)
    end,
    OnAccept = function(dialog, data)
        local playerName = ZL.GroupMembersDropdown:GetText()
        if playerName and playerName ~= "" then
            if not ZL_CURRENT.playerPayToML then ZL_CURRENT.playerPayToML = {} end
            ZL_CURRENT.playerPayToML[playerName] = (ZL_CURRENT.playerPayToML[playerName] or 0) + data.tradeMoneyOther
            ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            local msgStr
            if playerName ~= data.tradePartner then
                msgStr = playerName .. "已由" .. data.tradePartner .. "代交欠款：|cffffffff" .. data.tradeMoneyOther .. "|rg"
            else
                msgStr = format("已记录%s消费|cffffffff%d|rg", playerName, data.tradeMoneyOther)
            end
            ZL.Print(msgStr, true)
        end
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}

--增加玩家收入金额
StaticPopupDialogs["ZL_ADDTOPLAYER"] = {
    text = "输入你想|cffffd100增加|r[|cffffd100%s|r]的收入金额：",
	button1 = "确定",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
		self:GetButton1():Disable()
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
    end,
	OnAccept = function(self, data)
		local addamount = self:GetEditBox():GetNumber() or 0
        if (not ZL_CURRENT.playerPayToML) then ZL_CURRENT.playerPayToML = {} end
        ZL_CURRENT.playerPayToML[data]= (ZL_CURRENT.playerPayToML[data] or 0 )+ addamount
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
	end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--扣除玩家收入金额
StaticPopupDialogs["ZL_REMFROMPLAYER"] = {
    text = "输入你想|cffffd100扣除|r[|cffffd100%s|r]的收入金额：",
	button1 = "确定",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
		self:GetButton1():Disable()
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
    end,
	OnAccept = function(self, data)
		local addamount = self:GetEditBox():GetNumber() or 0
        if (not ZL_CURRENT.playerPayToML) then ZL_CURRENT.playerPayToML = {} end
        ZL_CURRENT.playerPayToML[data] = (ZL_CURRENT.playerPayToML[data] or 0) - addamount
        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--手动创建拍卖物品
StaticPopupDialogs["ZL_ADDAUCTIONITEM"] = {
    text = "请填写需要拍卖的物品ID和数量：",
    button1 = "确定",
    button2 = "取消",
    OnShow = function(dialog)
		dialog:GetButton1():Disable()
        local relativeTo = select(2, dialog.ButtonContainer:GetPoint())
        ZL.AddAuctionEditboxs:ClearAllPoints()
        ZL.AddAuctionEditboxs:SetPoint("TOP", relativeTo, "BOTTOM", 0, -15)
        ZL.AddAuctionEditboxs:Show()
        dialog.ButtonContainer:ClearAllPoints()
        dialog.ButtonContainer:SetPoint("TOP", ZL.AddAuctionEditboxs, "BOTTOM", 0, -9)
        local editBox5 = ZL.AddAuctionEditboxs.editBox5
        local editBox6 = ZL.AddAuctionEditboxs.editBox6
        editBox5:SetFocus()
        editBox6:SetNumber(1)
        editBox5:SetScript("OnTextChanged", function (self)
            if editBox5:GetNumber() > 0 and editBox6:GetNumber() > 0 then
                dialog:GetButton1():Enable()
            else
                dialog:GetButton1():Disable()
            end
        end)
        editBox6:SetScript("OnTextChanged", function (self)
            if editBox5:GetNumber() > 0 and editBox6:GetNumber() > 0 then
                dialog:GetButton1():Enable()
            else
                dialog:GetButton1():Disable()
            end
        end)
        editBox5:SetText("")
        if dialog.data then
            editBox5:SetNumber(dialog.data.itemId)
        end
		dialog:SetHeight(dialog:GetHeight()+ZL.AddAuctionEditboxs:GetHeight()+15)
    end,
    OnAccept = function (dialog, data)
        local editBox5 = ZL.AddAuctionEditboxs.editBox5
        local editBox6 = ZL.AddAuctionEditboxs.editBox6
        local itemId = editBox5:GetNumber()
        local itemCount = editBox6:GetNumber()
        local function func(itemlink)
            ZL.ManualCreateAuctionItem(itemlink, itemCount or 1, data and data.itemGuid)
        end
        LoadItemDataByID(itemId, func, editBox5)
    end,
    OnHide = function (dialog, _data)
        dialog:Hide()
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
--[=[
--同步不同战网子账号之间数据弹窗确认
StaticPopupDialogs["ZL_SYNCROLES"] = {
	text = "%s",
	button1 = "同意",
	button2 = "拒绝",
    timeout = 0,
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
        self.timeout = nil
    end,
	OnAccept = function(self, data)
        ZL.SaveRoles(data)
        RolesOverView["syncKeyUnBind"][data.OwnRolesSyncKey] = nil --从新绑定的从这里面移除
        local _data = {
            type = "addnewAgree",
            playerName = ZL.GetClassColorName(),
            rolesData = RolesOverView.owner,
            syncData = RolesOverView.sync,
            OwnRolesSyncKey = select(3, ZL.GetOwnRolesSyncKey()),
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(data.playerName), "BULK")
        local msgStr = "已成功与" .. data.playerName .. "绑定同步角色数据！"
        ZL.Print(msgStr, true)
	end,
	OnCancel = function(self, data)
        local _data = {
            type = "addnewRefuse",
            data = ZL.GetClassColorName(),
        }
        MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(data.playerName), "BULK")
	end,
    OnUpdate = function(self, elapsed)
        -- 每帧更新时触发
        if not self.timeout then self.timeout = self.data.timeout - GetTime() end
        self.timeout = self.timeout - elapsed
        if self.timeout <= 0 then
            self.timeout = 0
            self:Hide()  -- 倒计时结束后关闭对话框
        else
            (self:GetTextFontString() or self.text):SetText(self.data.playerName .. "请求与你共享角色数据，是否同意？倒数：" .. "|cff00ff00" .. ceil(self.timeout) .. "|r")
        end
    end,
    whileDead = true,
    hideOnEscape = false,
}

--修改子账号名字
StaticPopupDialogs["ZL_MODIFYBNCHILD"] = {
	text = "%s",
	button1 = "修改",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if #(self:GetText() or "") > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
        self:GetButton1():Disable()
    end,
	OnAccept = function(self, data)
        local _, _, BNChild = strsplit(":", data)
        local BNChildNewName = self:GetEditBox():GetText()
        BNChildNewName = BNChildNewName:gsub(":", "")
        RolesOverView["BNChildNewName"][BNChild] = self:GetEditBox():GetText()
        if ZL.LgnoreRolesFrame:IsShown() then
            ZL.LgnoreRolesFrame:Update()
        end
        ZL.RolesOverViewFrame.battleTagDropdown:SetMenuTable(ZL.GetBattleTagDropdownList())
        ZL.RolesOverViewFrame.battleTagDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetMenuTable(ZL.GetBNChildDropdownList())
        ZL.RolesOverViewFrame.BNChildDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetValue("全部")
        ZL.RolesOverViewFrame.realmDropdown:SetMenuTable(ZL.GetRealmDropdownList())
        ZL.RolesOverViewFrame.realmDropdown:SetDefaultText(GetRealmName())
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = 1,
    hideOnEscape = 1,
}
--删除角色数据
StaticPopupDialogs["ZL_DELETEROLES"] = {
	text = "%s",
	button1 = "删除",
	button2 = "取消",
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)
    end,
	OnAccept = function(self, data)
        if not ZL.glb.rolesDel then ZL.glb.rolesDel = {} end
        ZL.glb.rolesDel[data] = true
        local playerName, realmName, BNChild, battleTag = strsplit(":", data)
        local parsePlayerName = ZL.ParseClassColorName(playerName)
        local factionGroup = select(2, UnitFactionGroup("player"))
        if RolesOverView["owner"][battleTag] and RolesOverView["owner"][battleTag][BNChild] and RolesOverView["owner"][battleTag][BNChild][realmName]
        and RolesOverView["owner"][battleTag][BNChild][realmName][factionGroup] then
            RolesOverView["owner"][battleTag][BNChild][realmName][factionGroup][parsePlayerName] = nil
        end
        if RolesOverView["sync"][battleTag] and RolesOverView["sync"][battleTag][BNChild] and RolesOverView["sync"][battleTag][BNChild][realmName]
        and RolesOverView["sync"][battleTag][BNChild][realmName][factionGroup] then
            RolesOverView["sync"][battleTag][BNChild][realmName][factionGroup][parsePlayerName] = nil
        end
        RolesOverView["syncKey"][realmName .. ":" .. factionGroup .. ":" .. parsePlayerName] = nil
        ZL.glb["rolesLgnore"][data] = nil
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()
	end,
	OnCancel = function(self, data)
	end,
    whileDead = 1,
    hideOnEscape = 1,
}
--删除绑定子账号
StaticPopupDialogs["ZL_DELETEBNCHILD"] = {
	text = "%s",
	button1 = "解除绑定",
	button2 = "取消",
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,

	OnAccept = function(self, data)
        RolesOverView["syncKeyUnBind"][data] = nil
        local battleTag, BNChild = strsplit(":", data)
        if RolesOverView["sync"] and RolesOverView["sync"][battleTag] then
            RolesOverView["sync"][battleTag][BNChild] = nil
        end
        local accountPlayer = {}
        local myRealm, myFactiongroup = GetRealmName(), select(2, UnitFactionGroup("player"))
        for key, value in pairs(RolesOverView["syncKey"]) do
            if value == data then
                local realm, factiongroup, player = strsplit(":", key)
                if realm == myRealm and factiongroup == myFactiongroup then
                    tinsert(accountPlayer, player)
                end
                RolesOverView["syncKey"][key] = nil
            end
        end
        if ZL.glb["rolesLgnore"] then
            for key in pairs(ZL.glb["rolesLgnore"]) do
                local _, _, _BNChild, _battleTag = strsplit(":", key)
                if BNChild == _BNChild and battleTag == _battleTag then
                    ZL.glb["rolesLgnore"][key] = nil
                end
            end
        end
        if ZL.glb["rolesDel"] then
            for key in pairs(ZL.glb["rolesDel"]) do
                local _, _, _BNChild, _battleTag = strsplit(":", key)
                if BNChild == _BNChild and battleTag == _battleTag then
                    ZL.glb["rolesDel"][key] = nil
                end
            end
        end
        local msgStr = "已解除[|cffffff00" .. battleTag .. ":" .. (RolesOverView["BNChildNewName"][BNChild] or BNChild) .. "|r]绑定！"
        ZL.Print(msgStr, true)
        -- RolesOverView["BNChildNewName"][BNChild] = nil
        ZL.RolesOverViewFrame.battleTagDropdown:SetMenuTable(ZL.GetBattleTagDropdownList())
        ZL.RolesOverViewFrame.battleTagDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetMenuTable(ZL.GetBNChildDropdownList())
        ZL.RolesOverViewFrame.BNChildDropdown:SetDefaultText("全部")
        ZL.RolesOverViewFrame.BNChildDropdown:SetValue("全部")
        ZL.RolesOverViewFrame.realmDropdown:SetMenuTable(ZL.GetRealmDropdownList())
        ZL.RolesOverViewFrame.realmDropdown:SetDefaultText(GetRealmName())
        ZL.RolesOverViewFrame:Update()
        ZL.LgnoreRolesFrame:Update()

        --发送解除消息
        if #accountPlayer > 0 then
            --先判断是否有在线好友
            local isOnline
            for _, player in ipairs(accountPlayer) do
                if ZL.IsOnline(player, nil, nil, true) then
                    --发送解绑信息
                    local _, _, ownSyncKey = ZL.GetOwnRolesSyncKey()
                    local _data = {
                        type = "unBind",
                        playerName = ZL.GetClassColorName(),
                        rolesData = "已解绑",
                        accountSyncKey = ownSyncKey,
                    }
                    MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(player), "BULK")
                    isOnline = true
                    wipe(accountPlayer)
                    accountPlayer = nil
                    break
                end
            end
            --没有在线好友，则先全部添加, 最多添加2次
            if not isOnline then
                ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", ZL.AddFriendFilterFunc)
                for _, player in ipairs(accountPlayer) do
                    local info = C_FriendList.GetFriendInfo(player)
                    if (not info) and C_FriendList.GetNumFriends() < 100 then
                        C_FriendList.AddFriend(player)
                    end
                end
                --1秒后再添加一次
                C_Timer.After(1, function ()
                    for _, player in ipairs(accountPlayer) do
                        local info = C_FriendList.GetFriendInfo(player)
                        if (not info) and C_FriendList.GetNumFriends() < 100 then
                            C_FriendList.AddFriend(player)
                        end
                    end
                    --1秒后判断是否有在线好友
                    C_Timer.After(1, function ()
                        ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", ZL.AddFriendFilterFunc)
                        for _, player in ipairs(accountPlayer) do
                            if ZL.IsOnline(player, nil, nil, true) then
                                --发送解绑信息
                                local _, _, ownSyncKey = ZL.GetOwnRolesSyncKey()
                                local _data = {
                                    type = "unBind",
                                    playerName = ZL.GetClassColorName(),
                                    rolesData = "已解绑",
                                    accountSyncKey = ownSyncKey,
                                }
                                MyAddon:TransmitAddonInfo2("AUTOAUC ROLES", _data, "WHISPER", ZL.ParseClassColorName(player), "BULK")
                                wipe(accountPlayer)
                                accountPlayer = nil
                                break
                            end
                        end
                    end)
                end)
            end
            
        end

	end,
	OnCancel = function(self, data)
	end,
    whileDead = 1,
    hideOnEscape = 1,
}
]=]
--复制当前配置并切换为默认配置（全账号共享配置）
StaticPopupDialogs["ZL_CHANGEANDCOPYTODEFAULTPROFILE"] = {
	text = "%s",
	button1 = "复制当前配置并切换为默认配置",
	button2 = "直接切换为默认配置",
    button3 = "取消",
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,
	OnAccept = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        ZL.db:CopyProfile(data)
        local msgStr = "已复制当前角色配置并切换到默认配置(子账号所有角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
        ZL.db.global.copyToDefalutProfile = true
	end,
    OnCancel = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        local msgStr = "已切换到默认配置(子账号所有角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
    end,
	OnAlt = function()
        ZL.db.profile.askedAboutProfile = true
        local msgStr = "如需子账号所有角色共享配置，可到设置里面修改为默认配置。"
        ZL.Print(msgStr, true)
	end,
    whileDead = 1,
    hideOnEscape = 1,
}
--直接切换为默认配置（全账号共享配置）
StaticPopupDialogs["ZL_CHANGEDEFAULTPROFILE"] = {
	text = "%s",
	button1 = "切换为默认配置",
	button2 = "取消",
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,

	OnAccept = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        ZL.db:SetProfile("Default")
        local msgStr = "已切换到默认配置(子账号所有角色共享)，您也可以到设置里面重新更改。"
        ZL.Print(msgStr, true)
	end,
    OnCancel = function(self, data)
        ZL.db.profile.askedAboutProfile = true
        local msgStr = "如需子账号所有角色共享配置，可到设置里面修改为默认配置。"
        ZL.Print(msgStr, true)
    end,
    whileDead = 1,
    hideOnEscape = 1,
}

--导入关注物品字符串
StaticPopupDialogs["ZL_IMPORTCORCERNSTRING"] = {
	text = "%s",
	button1 = "导入",
	button2 = "取消",
    OnShow = function(self)
		self:GetButton1():SetText(self.data.btnText)
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,

	OnAccept = function(self, data)
        ZL.WaStringFrame:Hide()
        local selectCharKey = data.selectCharKey
        ZL.opt.concernList[selectCharKey] = data.data
        ZL.ConcernFrame:Update()
        if ZL.AuctionFrame2:IsShown() then
            ZL.AuctionFrame2:Update()
        end
        ZL.Print(selectCharKey .. "  关注物品数据导入成功", true)
	end,
    OnCancel = function(self, data)
    end,
    whileDead = 1,
    hideOnEscape = 1,
}

--设置快速出价幅度quickBidIncrement
StaticPopupDialogs["ZL_QUICKBIDINCREMENT"] = {
	text = "请输入快速出价弹窗加价幅度",
	button1 = "确认",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
		self:GetButton1():Disable()
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,

	OnAccept = function(self, data)
        ZL.opt.quickBidIncrement = self:GetEditBox():GetNumber()
	end,
    OnCancel = function(self, data)
    end,
    whileDead = 1,
    hideOnEscape = 1,
}

--角色拥有物品数量大于1时出价确认
StaticPopupDialogs["ZL_CONFIRMBID"] = {
	text = "%s",
	button1 = "继续竞价",
	button2 = "取消",
    OnShow = function(self)
        self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(false)

    end,

	OnAccept = function(self, data)
        ZL_CURRENT.auctionlist[data.index].confirmBid = true
        if ZL_CURRENT.globalConfig.auctionMode == "团队" then
            if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                SendChatMessage(data.msgStr, "RAID")
            else
                SendChatMessage(data.itemlink .. data.msgStr, "RAID")
            end
        else
            MyAddon:TransmitAddonInfo2("AUTOAUC BID", data.itemlink .. data.msgStr)
        end
	end,
    OnCancel = function(self, data)
    end,
    whileDead = 1,
    showAlert = 1,
    hideOnEscape = 1,
}

--不能使用物品竞拍时提醒
StaticPopupDialogs["ZL_CANUSECONFIRMBID"] = {
	text = "%s",
	button1 = "继续竞价",
	button2 = "取消",
	OnAccept = function(self, data)
        local _, index = ZL.FetchDataFromItemId(data.itemlink, data.itemindex)
        if not index then return end
        ZL_CURRENT.auctionlist[index].canUseConfirgBid = true
        if data.btn == "LeftButton" then
            ZL.AuctionFrame2.entries[index].bidFrame.bidBtn:Click()
        elseif data.btn == "RightButton" then
            StaticPopup_Show("ZL_AUTOBID", ZL_CURRENT.auctionlist[index].itemlink, nil, {index=index, f=ZL.AuctionFrame2.entries[index]})
        end
	end,
    OnCancel = function(self, data)
    end,
    whileDead = 1,
    showAlert = 1,
    hideOnEscape = 1,
}

--校正包装备累计分配数量
StaticPopupDialogs["ZL_CORRECTBUYERTOTAL"] = {
    text = "请输入校正后的累计分配数量",
    button1 = "确定",
    button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
        self:GetEditBox():SetNumeric(true)
        self:GetEditBox():SetAutoFocus(true)

    end,
    OnAccept = function(self, index)
        local data = ZL.opt.buyerHistory[index]
        data.total = self:GetEditBox():GetText()
        local item = Item:CreateFromItemID(data.itemId)
        if item:GetItemID() then
            item:ContinueOnItemLoad(function()
                local _, itemLink = cGetItemInfo(data.itemId)
                local buyerName = ZL.GetClassColorName(data.buyerName)
                ZL.Print(itemLink .. " - " .. buyerName .. " - 累计数量已调整为：" .. data.total)
            end)
        end
        self:GetEditBox():ClearFocus()
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}

--设置ROLL计时
StaticPopupDialogs["ZL_ROLLCOUNTDOWN"] = {
    text = "请输入ROLL记录时长(秒)",
    button1 = "确定",
    button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		if self:GetNumber() > 0 then
			self:GetParent():GetButton1():Enable()
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
        self:GetEditBox():SetNumeric(true)
        self:GetEditBox():SetAutoFocus(true)

    end,

    OnAccept = function(self)
        ZL.opt.rollCountDown =( self:GetEditBox():GetNumber() and self:GetEditBox():GetNumber() > 5) and self:GetEditBox():GetNumber() or 5
        ZL.Print("ROLL时长已调整为：" .. ZL.opt.rollCountDown .. "秒", true)
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
}
StaticPopupDialogs["ZL_IMPORTTASKPROFILESTRING1"] = {
    text = "%s",
    button1 = "覆盖导入",
    button2 = "新建导入",
    button3 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent().button2:Click() end,
    EditBoxOnTextChanged = function(self)
        if strlen(self:GetText()) > 0 then
            local isExist
            for _, profileKey in ipairs(ZL.opt.taskList["profileKeys"]) do
                if profileKey == self:GetText() then
                    isExist = true
                end
            end
            if not isExist then
                self:GetParent().button2:Enable()
            else
                self:GetParent().button2:Disable()
                ZL.Print("配置名已存在，请重新输入！", nil, nil, nil, nil, true)
            end
        else
            self:GetParent().button2:Disable()
        end
    end,
    OnShow = function(self)
		self.button2:Disable()
        self:GetEditBox():SetAutoFocus(false)
        self:GetEditBox():SetNumeric(true)

    end,

    OnAccept = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            local valueIndex
            for index, value in ipairs(ZL.opt.taskList["profileKeys"]) do
                if value == profileName then
                    valueIndex = index
                end
            end
            if valueIndex then
                ZL.opt.taskList.task[profileName] = data[profileName]
                ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
                ZL.TaskFrame.historyProfileDropdown:SetValue(valueIndex)
                ZL.Print("【|cffffffff" .. profileName .. "|r】配置已导入！")
            else
                ZL.Print("导入失败！")
            end
        else
            ZL.Print("导入失败！")
        end
    end,

    OnCancel = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            local _profileName = self:GetEditBox():GetText()
            ZL.opt.taskList.task[_profileName] = data[profileName]
            tinsert(ZL.opt.taskList["profileKeys"], _profileName)
            ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
            ZL.TaskFrame.historyProfileDropdown:SetValue(#ZL.opt.taskList["profileKeys"])
            ZL.Print("【|cffffffff" .. profileName .. "|r】已导入新建配置【|cffffffff" .. _profileName .. "|r】中！")
        else
            ZL.Print("导入失败！")
        end
    end,
    whileDead = 1,
    hideOnEscape = 1,
}

StaticPopupDialogs["ZL_IMPORTTASKPROFILESTRING2"] = {
    text = "%s",
    button1 = "导入",
    button2 = "取消",
    hasEditBox = false,
    OnShow = function(self)
        self:GetEditBox():SetNumeric(true)
        self:GetEditBox():SetAutoFocus(true)
    end,
    OnAccept = function(self, data)
        local profileName
        for key in pairs(data) do
            profileName = key
            break
        end
        if profileName then
            ZL.opt.taskList.task[profileName] = data[profileName]
            tinsert(ZL.opt.taskList["profileKeys"], profileName)
            ZL.TaskFrame.historyProfileDropdown:SetMenuTable(ZL.getTaskProfileDropdownList())
            ZL.TaskFrame.historyProfileDropdown:SetValue(#ZL.opt.taskList["profileKeys"])
            ZL.Print("【|cffffffff" .. profileName .. "|r】配置已导入！")
        else
            ZL.Print("导入失败！")
        end
    end,

    OnCancel = function(self)
    end,
    whileDead = 1,
    hideOnEscape = 1,
}
--导入配置提醒
StaticPopupDialogs["ZL_IMPORTPROFILESCONFIRM"] = {
    text = "%s",
    button1 = "备份后导入",
    button2 = "覆盖导入",
    button3 = "取消",
    OnAccept = function(self, data)
        ZL_Profile.profiles = ZL_Profile.profiles or {}
        for key, value in pairs(data) do
            if ZL_Profile.profiles[key] then
                ZL_Profile.profiles[key .. " 备份"] = ZL_Profile.profiles[key]
            end
            ZL_Profile.profiles[key] = value
        end
        ZL.Print("配置导入完成！")
    end,
    OnCancel = function(self, data)
        ZL_Profile.profiles = ZL_Profile.profiles or {}
        for key, value in pairs(data) do
            ZL_Profile.profiles[key] = value
        end
        ZL.Print("配置导入完成！")
    end,
    whileDead = 1,
    hideOnEscape = 1,
}
--新建补贴配置
StaticPopupDialogs["ZL_CREATENEWBUTIEPROFILE"] = {
	text = "请输入补贴名称",
	button1 = "新建",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self)
		local txt = self:GetText() or ""
        if #txt > 0 then
			if ZL.opt.subsidyProfileList.profile[txt] then
                self:GetParent():GetButton1():Disable()
                ZL.Print(txt .. "|cffffffff已存在|r", true)
            else
                self:GetParent():GetButton1():Enable()
            end
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(true)
    end,
	OnAccept = function(self)
        local text = self:GetEditBox():GetText()
        ZL.saveBuTieProfileName(text)
	end,
	OnCancel = function(self)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}
--修改补贴名字
StaticPopupDialogs["ZL_RENAMEBUTIEPROFILE"] = {
	text = "请输入补贴新的名称",
	button1 = "确认",
	button2 = "取消",
    hasEditBox = true,
    EditBoxOnEnterPressed = function(self) self:GetParent():GetButton1():Click() end,
    EditBoxOnTextChanged = function(self, data)
		local txt = self:GetText() or ""
        if #txt > 0 then
			if ZL.opt.subsidyProfileList.profile[txt] then
                self:GetParent():GetButton1():Disable()
                if txt ~= data then
                    ZL.Print(txt .. "|cffffffff已存在|r", true)
                end
            else
                self:GetParent():GetButton1():Enable()
            end
		else
			self:GetParent():GetButton1():Disable()
		end
	end,
    OnShow = function(self, data)
		self:GetEditBox():SetNumeric(false)
        self:GetEditBox():SetAutoFocus(true)
        self:GetEditBox():SetText(data)
        self:GetEditBox():HighlightText()
    end,
	OnAccept = function(self, data)
        local profileName = self:GetEditBox():GetText()
        if ZL.opt.subsidyProfileList.profile[profileName] then
            ZL.Print("配置名称已存在，请重新输入！")
        else
            for i, v in ipairs(ZL.opt.subsidyProfileList.profileKeys) do
                if v == data then
                    ZL.opt.subsidyProfileList.profileKeys[i] = profileName
                    break
                end
            end
            ZL.opt.subsidyProfileList.profile[profileName] = CopyTable(ZL.opt.subsidyProfileList.profile[data])
            ZL.opt.subsidyProfileList.profile[data] = nil
            if ZL.BillOverviewFrame:IsShown() then
                ZL.BillOverviewFrame:Update()
            end
        end
	end,
	OnCancel = function(self)
	end,
    timeout = 0,
    whileDead = true,
    hideOnEscape = false,
}
