From f3f65fa99ec20afdd642763d9751c5fa7ff3a170 Mon Sep 17 00:00:00 2001
From: kuaifan
")}}),t("div",{class:"department-tag-num"},` +${e.length}`)]))),t("div",{class:"team-table-department-warp"},a)}}},{title:this.$L("\u6700\u540E\u5728\u7EBF"),key:"line_at",width:168},{title:this.$L("\u64CD\u4F5C"),align:"center",width:100,render:(t,s)=>{const e=s.row.identity,a=[];e.includes("admin")?a.push(t("EDropdownItem",{props:{command:"clearadmin"}},[t("div",this.$L("\u53D6\u6D88\u7BA1\u7406\u5458"))])):a.push(t("EDropdownItem",{props:{command:"setadmin"}},[t("div",this.$L("\u8BBE\u4E3A\u7BA1\u7406\u5458"))])),e.includes("temp")?a.push(t("EDropdownItem",{props:{command:"cleartemp"}},[t("div",this.$L("\u53D6\u6D88\u4E34\u65F6\u8EAB\u4EFD"))])):a.push(t("EDropdownItem",{props:{command:"settemp"}},[t("div",this.$L("\u8BBE\u4E3A\u4E34\u65F6\u5E10\u53F7"))])),a.push(t("EDropdownItem",{props:{command:"email"}},[t("div",this.$L("\u4FEE\u6539\u90AE\u7BB1"))])),a.push(t("EDropdownItem",{props:{command:"password"}},[t("div",this.$L("\u4FEE\u6539\u5BC6\u7801"))])),this.checkinMac&&a.push(t("EDropdownItem",{props:{command:"checkin_mac"}},[t("div",this.$L("\u4FEE\u6539MAC"))])),a.push(t("EDropdownItem",{props:{command:"department"}},[t("div",this.$L("\u4FEE\u6539\u90E8\u95E8"))])),e.includes("disable")?a.push(t("EDropdownItem",{props:{command:"cleardisable"},style:{color:"#f90"}},[t("div",this.$L("\u6062\u590D\u5E10\u53F7\uFF08\u5DF2\u79BB\u804C\uFF09"))])):a.push(t("EDropdownItem",{props:{command:"setdisable"},style:{color:"#f90"}},[t("div",this.$L("\u64CD\u4F5C\u79BB\u804C"))])),a.push(t("EDropdownItem",{props:{command:"delete"},style:{color:"red"}},[t("div",this.$L("\u5220\u9664"))]));const i=t("EDropdown",{props:{size:"small",trigger:"click"},on:{command:n=>{this.dropUser(n,s.row)}}},[t("Button",{props:{type:"primary",size:"small"},style:{fontSize:"12px"}},this.$L("\u64CD\u4F5C")),t("EDropdownMenu",{slot:"dropdown"},[a])]);return t("TableAction",{props:{column:s.column}},[i])}}],list:[],page:1,pageSize:20,total:0,noText:"",checkinMacEditShow:!1,checkinMacEditLoading:0,checkinMacEditData:{},departmentEditShow:!1,departmentEditLoading:0,departmentEditData:{},disableShow:!1,disableLoading:0,disableData:{},disableOptions:{shortcuts:[{text:"12:00",value(){return $A.Date($A.formatDate("Y-m-d 12:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"17:00",value(){return $A.Date($A.formatDate("Y-m-d 17:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"18:00",value(){return $A.Date($A.formatDate("Y-m-d 18:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"19:00",value(){return $A.Date($A.formatDate("Y-m-d 19:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:this.$L("\u73B0\u5728"),value(){return new Date},onClick:t=>{t.handlePickSuccess()}}]},departmentShow:!1,departmentLoading:0,departmentSelect:-1,departmentData:{id:0,name:"",parent_id:0,owner_userid:[],dialog_group:"new",dialog_useid:0},departmentList:[],dialogLoad:!1,dialogList:[],nullCheckinDatum:{mac:"",remark:""}}},created(){this.checkinMac&&this.columns.splice(5,0,{title:this.$L("MAC\u5730\u5740"),key:"checkin_mac",minWidth:80,render:(t,{row:s})=>{let e=$A.cloneJSON(s.checkin_macs||[]);if(e.length===0)return t("div","-");{const a=n=>n.remark?`${n.mac} (${n.remark})`:n.mac,i=[];return i.push(t("AutoTip",a(e[0]))),e.length>1&&(e=e.splice(1),i.push(t("ETooltip",[t("div",{slot:"content",domProps:{innerHTML:e.map(n=>a(n)).join("
")}}),t("div",{class:"department-tag-num"},` +${e.length}`)]))),t("div",{class:"team-table-department-warp"},i)}}})},mounted(){this.getLists(),this.getDepartmentLists()},watch:{keyIs(t){t||(this.keys={},this.setPage(1))},departmentSelect(){this.setPage(1)},windowPortrait:{handler(t){this.minBox=t},immediate:!0},minBox:{handler(){this.$nextTick(t=>{this.$el&&this.$el.clientWidth>0&&(this.minWidth=this.$el.clientWidth)})},immediate:!0}},computed:{departmentParentDisabled(){return!!(this.departmentData.id>0&&this.departmentList.find(({parent_id:t})=>t==this.departmentData.id))},userStyle({minWidth:t,windowPortrait:s}){const e={};return t>0&&s&&(e.minWidth=t-40+"px"),e}},methods:{onSearch(){this.page=1,this.getLists()},getLists(){this.loadIng++,this.keyIs=$A.objImplode(this.keys)!="";let t=$A.cloneJSON(this.keys);this.departmentSelect>-1&&(t=Object.assign(t,{department:this.departmentSelect})),this.$store.dispatch("call",{url:"users/lists",data:{keys:t,get_checkin_mac:this.checkinMac?1:0,page:Math.max(this.page,1),pagesize:Math.max($A.runNum(this.pageSize),10)}}).then(({data:s})=>{this.page=s.current_page,this.total=s.total,this.list=s.data,this.noText="\u6CA1\u6709\u76F8\u5173\u7684\u6210\u5458"}).catch(()=>{this.noText="\u6570\u636E\u52A0\u8F7D\u5931\u8D25"}).finally(s=>{this.loadIng--})},setPage(t){this.page=t,this.getLists()},setPageSize(t){this.page=1,this.pageSize=t,this.getLists()},dropUser(t,s){switch(t){case"settemp":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u5C06\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u8BBE\u4E3A\u4E34\u65F6\u5E10\u53F7\u5417\uFF1F\uFF08\u6CE8\uFF1A\u4E34\u65F6\u5E10\u53F7\u9650\u5236\u8BF7\u67E5\u770B\u7CFB\u7EDF\u8BBE\u7F6E\uFF09`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"cleartemp":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u53D6\u6D88\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u4E34\u65F6\u8EAB\u4EFD\u5417\uFF1F`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"email":$A.modalInput({title:"\u4FEE\u6539\u90AE\u7BB1",placeholder:`\u8BF7\u8F93\u5165\u65B0\u7684\u90AE\u7BB1\uFF08${s.email}\uFF09`,onOk:a=>a?this.operationUser({userid:s.userid,email:a}):"\u8BF7\u8F93\u5165\u65B0\u7684\u90AE\u7BB1\u5730\u5740"});break;case"password":$A.modalInput({title:"\u4FEE\u6539\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u65B0\u7684\u5BC6\u7801",onOk:a=>a?this.operationUser({userid:s.userid,password:a}):"\u8BF7\u8F93\u5165\u65B0\u7684\u5BC6\u7801"});break;case"checkin_mac":this.checkinMacEditData={type:"checkin_macs",userid:s.userid,nickname:s.nickname,checkin_macs:s.checkin_macs},this.checkinMacEditData.checkin_macs.length===0&&this.addCheckinDatum(),this.checkinMacEditShow=!0;break;case"department":let e=[];s.department.some(a=>{const i=this.departmentList.find(n=>n.id==a);i&&e.push(i.owner_userid===s.userid?`${i.name} (${this.$L("\u8D1F\u8D23\u4EBA")})`:i.name)}),this.departmentEditData={type:"department",userid:s.userid,nickname:s.nickname,department:s.department.map(a=>parseInt(a))},this.departmentEditShow=!0;break;case"setdisable":this.disableData={type:"setdisable",userid:s.userid,nickname:s.nickname},this.disableShow=!0;break;case"cleardisable":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u6062\u590D\u5DF2\u79BB\u804C\u5E10\u53F7\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u5417\uFF1F\uFF08\u6CE8\uFF1A\u6B64\u64CD\u4F5C\u4EC5\u6062\u590D\u5E10\u53F7\u72B6\u6001\uFF0C\u65E0\u6CD5\u6062\u590D\u64CD\u4F5C\u79BB\u804C\u65F6\u79FB\u4EA4\u7684\u6570\u636E\uFF09`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"delete":$A.modalInput({title:`\u5220\u9664\u5E10\u53F7\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011`,placeholder:"\u8BF7\u8F93\u5165\u5220\u9664\u539F\u56E0",okText:"\u786E\u5B9A\u5220\u9664",onOk:a=>a?this.operationUser({userid:s.userid,type:t,delete_reason:a}):"\u5220\u9664\u539F\u56E0\u4E0D\u80FD\u4E3A\u7A7A"});break;default:this.operationUser({userid:s.userid,type:t},!0);break}},operationUser(t,s){return new Promise((e,a)=>{t.type=="checkin_macs"?this.checkinMacEditLoading++:t.type=="department"?this.departmentEditLoading++:t.type=="setdisable"?this.disableLoading++:this.loadIng++,this.$store.dispatch("call",{url:"users/operation",data:t}).then(({msg:i})=>{$A.messageSuccess(i),this.getLists(),e(),t.type=="checkin_macs"?this.checkinMacEditShow=!1:t.type=="department"?this.departmentEditShow=!1:t.type=="setdisable"&&(this.disableShow=!1)}).catch(({msg:i})=>{s===!0&&$A.modalError(i),this.getLists(),a(i)}).finally(i=>{t.type=="checkin_macs"?this.checkinMacEditLoading--:t.type=="department"?this.departmentEditLoading--:t.type=="setdisable"?this.disableLoading--:this.loadIng--})})},getDepartmentLists(){this.departmentLoading++,this.$store.dispatch("call",{url:"users/department/list"}).then(({data:t})=>{this.departmentList=[],this.generateDepartmentList(t,0,1)}).finally(t=>{this.departmentLoading--})},generateDepartmentList(t,s,e){t.some(a=>{a.parent_id==s&&(this.departmentList.push(Object.assign(a,{level:e+1})),this.generateDepartmentList(t,a.id,e+1))})},onShowDepartment(t){this.departmentData=Object.assign({id:0,name:"",parent_id:0,owner_userid:[],dialog_group:"new"},t||{}),this.departmentShow=!0},onSaveDepartment(){this.departmentLoading++,this.$store.dispatch("call",{url:"users/department/add",data:Object.assign(this.departmentData,{owner_userid:this.departmentData.owner_userid[0]})}).then(({msg:t})=>{$A.messageSuccess(t),this.getDepartmentLists(),this.getLists(),this.departmentShow=!1}).catch(({msg:t})=>{$A.modalError(t)}).finally(t=>{this.departmentLoading--})},onSelectDepartment(t){if(this.windowPortrait&&(this.minBox=!0),this.departmentSelect===t){this.departmentSelect=-1;return}this.departmentSelect=t},onOpDepartment(t){if($A.leftExists(t,"add_"))this.onShowDepartment({parent_id:parseInt(t.substr(4))});else if($A.leftExists(t,"edit_")){const s=this.departmentList.find(({id:e})=>e===parseInt(t.substr(5)));s&&this.onShowDepartment(s)}else if($A.leftExists(t,"del_")){const s=this.departmentList.find(({id:e})=>e===parseInt(t.substr(4)));s&&$A.modalConfirm({title:this.$L("\u5220\u9664\u90E8\u95E8"),content:`
")}}),t("div",{class:"department-tag-num"},` +${e.length}`)]))),t("div",{class:"team-table-department-warp"},a)}}},{title:this.$L("\u6700\u540E\u5728\u7EBF"),key:"line_at",width:168},{title:this.$L("\u64CD\u4F5C"),align:"center",width:100,render:(t,s)=>{const e=s.row.identity,a=[];e.includes("admin")?a.push(t("EDropdownItem",{props:{command:"clearadmin"}},[t("div",this.$L("\u53D6\u6D88\u7BA1\u7406\u5458"))])):a.push(t("EDropdownItem",{props:{command:"setadmin"}},[t("div",this.$L("\u8BBE\u4E3A\u7BA1\u7406\u5458"))])),e.includes("temp")?a.push(t("EDropdownItem",{props:{command:"cleartemp"}},[t("div",this.$L("\u53D6\u6D88\u4E34\u65F6\u8EAB\u4EFD"))])):a.push(t("EDropdownItem",{props:{command:"settemp"}},[t("div",this.$L("\u8BBE\u4E3A\u4E34\u65F6\u5E10\u53F7"))])),a.push(t("EDropdownItem",{props:{command:"email"}},[t("div",this.$L("\u4FEE\u6539\u90AE\u7BB1"))])),a.push(t("EDropdownItem",{props:{command:"password"}},[t("div",this.$L("\u4FEE\u6539\u5BC6\u7801"))])),this.checkinMac&&a.push(t("EDropdownItem",{props:{command:"checkin_mac"}},[t("div",this.$L("\u4FEE\u6539MAC"))])),a.push(t("EDropdownItem",{props:{command:"department"}},[t("div",this.$L("\u4FEE\u6539\u90E8\u95E8"))])),e.includes("disable")?a.push(t("EDropdownItem",{props:{command:"cleardisable"},style:{color:"#f90"}},[t("div",this.$L("\u6062\u590D\u5E10\u53F7\uFF08\u5DF2\u79BB\u804C\uFF09"))])):a.push(t("EDropdownItem",{props:{command:"setdisable"},style:{color:"#f90"}},[t("div",this.$L("\u64CD\u4F5C\u79BB\u804C"))])),a.push(t("EDropdownItem",{props:{command:"delete"},style:{color:"red"}},[t("div",this.$L("\u5220\u9664"))]));const i=t("EDropdown",{props:{size:"small",trigger:"click"},on:{command:n=>{this.dropUser(n,s.row)}}},[t("Button",{props:{type:"primary",size:"small"},style:{fontSize:"12px"}},this.$L("\u64CD\u4F5C")),t("EDropdownMenu",{slot:"dropdown"},[a])]);return t("TableAction",{props:{column:s.column}},[i])}}],list:[],page:1,pageSize:20,total:0,noText:"",checkinMacEditShow:!1,checkinMacEditLoading:0,checkinMacEditData:{},departmentEditShow:!1,departmentEditLoading:0,departmentEditData:{},disableShow:!1,disableLoading:0,disableData:{},disableOptions:{shortcuts:[{text:"12:00",value(){return $A.Date($A.formatDate("Y-m-d 12:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"17:00",value(){return $A.Date($A.formatDate("Y-m-d 17:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"18:00",value(){return $A.Date($A.formatDate("Y-m-d 18:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:"19:00",value(){return $A.Date($A.formatDate("Y-m-d 19:00:00"))},onClick:t=>{t.handlePickSuccess()}},{text:this.$L("\u73B0\u5728"),value(){return new Date},onClick:t=>{t.handlePickSuccess()}}]},departmentShow:!1,departmentLoading:0,departmentSelect:-1,departmentData:{id:0,name:"",parent_id:0,owner_userid:[],dialog_group:"new",dialog_useid:0},departmentList:[],dialogLoad:!1,dialogList:[],nullCheckinDatum:{mac:"",remark:""}}},created(){this.checkinMac&&this.columns.splice(5,0,{title:this.$L("MAC\u5730\u5740"),key:"checkin_mac",minWidth:80,render:(t,{row:s})=>{let e=$A.cloneJSON(s.checkin_macs||[]);if(e.length===0)return t("div","-");{const a=n=>n.remark?`${n.mac} (${n.remark})`:n.mac,i=[];return i.push(t("AutoTip",a(e[0]))),e.length>1&&(e=e.splice(1),i.push(t("ETooltip",[t("div",{slot:"content",domProps:{innerHTML:e.map(n=>a(n)).join("
")}}),t("div",{class:"department-tag-num"},` +${e.length}`)]))),t("div",{class:"team-table-department-warp"},i)}}})},mounted(){this.getLists(),this.getDepartmentLists()},watch:{keyIs(t){t||(this.keys={},this.setPage(1))},departmentSelect(){this.setPage(1)},windowPortrait:{handler(t){this.minBox=t},immediate:!0},minBox:{handler(){this.$nextTick(t=>{this.$el&&this.$el.clientWidth>0&&(this.minWidth=this.$el.clientWidth)})},immediate:!0}},computed:{departmentParentDisabled(){return!!(this.departmentData.id>0&&this.departmentList.find(({parent_id:t})=>t==this.departmentData.id))},userStyle({minWidth:t,windowPortrait:s}){const e={};return t>0&&s&&(e.minWidth=t-40+"px"),e}},methods:{onSearch(){this.page=1,this.getLists()},getLists(){this.loadIng++,this.keyIs=$A.objImplode(this.keys)!="";let t=$A.cloneJSON(this.keys);this.departmentSelect>-1&&(t=Object.assign(t,{department:this.departmentSelect})),this.$store.dispatch("call",{url:"users/lists",data:{keys:t,get_checkin_mac:this.checkinMac?1:0,page:Math.max(this.page,1),pagesize:Math.max($A.runNum(this.pageSize),10)}}).then(({data:s})=>{this.page=s.current_page,this.total=s.total,this.list=s.data,this.noText="\u6CA1\u6709\u76F8\u5173\u7684\u6210\u5458"}).catch(()=>{this.noText="\u6570\u636E\u52A0\u8F7D\u5931\u8D25"}).finally(s=>{this.loadIng--})},setPage(t){this.page=t,this.getLists()},setPageSize(t){this.page=1,this.pageSize=t,this.getLists()},dropUser(t,s){switch(t){case"settemp":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u5C06\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u8BBE\u4E3A\u4E34\u65F6\u5E10\u53F7\u5417\uFF1F\uFF08\u6CE8\uFF1A\u4E34\u65F6\u5E10\u53F7\u9650\u5236\u8BF7\u67E5\u770B\u7CFB\u7EDF\u8BBE\u7F6E\uFF09`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"cleartemp":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u53D6\u6D88\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u4E34\u65F6\u8EAB\u4EFD\u5417\uFF1F`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"email":$A.modalInput({title:"\u4FEE\u6539\u90AE\u7BB1",placeholder:`\u8BF7\u8F93\u5165\u65B0\u7684\u90AE\u7BB1\uFF08${s.email}\uFF09`,onOk:a=>a?this.operationUser({userid:s.userid,email:a}):"\u8BF7\u8F93\u5165\u65B0\u7684\u90AE\u7BB1\u5730\u5740"});break;case"password":$A.modalInput({title:"\u4FEE\u6539\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u65B0\u7684\u5BC6\u7801",onOk:a=>a?this.operationUser({userid:s.userid,password:a}):"\u8BF7\u8F93\u5165\u65B0\u7684\u5BC6\u7801"});break;case"checkin_mac":this.checkinMacEditData={type:"checkin_macs",userid:s.userid,nickname:s.nickname,checkin_macs:s.checkin_macs},this.checkinMacEditData.checkin_macs.length===0&&this.addCheckinDatum(),this.checkinMacEditShow=!0;break;case"department":let e=[];s.department.some(a=>{const i=this.departmentList.find(n=>n.id==a);i&&e.push(i.owner_userid===s.userid?`${i.name} (${this.$L("\u8D1F\u8D23\u4EBA")})`:i.name)}),this.departmentEditData={type:"department",userid:s.userid,nickname:s.nickname,department:s.department.map(a=>parseInt(a))},this.departmentEditShow=!0;break;case"setdisable":this.disableData={type:"setdisable",userid:s.userid,nickname:s.nickname},this.disableShow=!0;break;case"cleardisable":$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u6062\u590D\u5DF2\u79BB\u804C\u5E10\u53F7\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011\u5417\uFF1F\uFF08\u6CE8\uFF1A\u6B64\u64CD\u4F5C\u4EC5\u6062\u590D\u5E10\u53F7\u72B6\u6001\uFF0C\u65E0\u6CD5\u6062\u590D\u64CD\u4F5C\u79BB\u804C\u65F6\u79FB\u4EA4\u7684\u6570\u636E\uFF09`,loading:!0,onOk:()=>this.operationUser({userid:s.userid,type:t})});break;case"delete":$A.modalInput({title:`\u5220\u9664\u5E10\u53F7\u3010ID:${s.userid}\uFF0C${s.nickname}\u3011`,placeholder:"\u8BF7\u8F93\u5165\u5220\u9664\u539F\u56E0",okText:"\u786E\u5B9A\u5220\u9664",onOk:a=>a?this.operationUser({userid:s.userid,type:t,delete_reason:a}):"\u5220\u9664\u539F\u56E0\u4E0D\u80FD\u4E3A\u7A7A"});break;default:this.operationUser({userid:s.userid,type:t},!0);break}},operationUser(t,s){return new Promise((e,a)=>{t.type=="checkin_macs"?this.checkinMacEditLoading++:t.type=="department"?this.departmentEditLoading++:t.type=="setdisable"?this.disableLoading++:this.loadIng++,this.$store.dispatch("call",{url:"users/operation",data:t}).then(({msg:i})=>{$A.messageSuccess(i),this.getLists(),e(),t.type=="checkin_macs"?this.checkinMacEditShow=!1:t.type=="department"?this.departmentEditShow=!1:t.type=="setdisable"&&(this.disableShow=!1)}).catch(({msg:i})=>{s===!0&&$A.modalError(i),this.getLists(),a(i)}).finally(i=>{t.type=="checkin_macs"?this.checkinMacEditLoading--:t.type=="department"?this.departmentEditLoading--:t.type=="setdisable"?this.disableLoading--:this.loadIng--})})},getDepartmentLists(){this.departmentLoading++,this.$store.dispatch("call",{url:"users/department/list"}).then(({data:t})=>{this.departmentList=[],this.generateDepartmentList(t,0,1)}).finally(t=>{this.departmentLoading--})},generateDepartmentList(t,s,e){t.some(a=>{a.parent_id==s&&(this.departmentList.push(Object.assign(a,{level:e+1})),this.generateDepartmentList(t,a.id,e+1))})},onShowDepartment(t){this.departmentData=Object.assign({id:0,name:"",parent_id:0,owner_userid:[],dialog_group:"new"},t||{}),this.departmentShow=!0},onSaveDepartment(){this.departmentLoading++,this.$store.dispatch("call",{url:"users/department/add",data:Object.assign(this.departmentData,{owner_userid:this.departmentData.owner_userid[0]})}).then(({msg:t})=>{$A.messageSuccess(t),this.getDepartmentLists(),this.getLists(),this.departmentShow=!1}).catch(({msg:t})=>{$A.modalError(t)}).finally(t=>{this.departmentLoading--})},onSelectDepartment(t){if(this.windowPortrait&&(this.minBox=!0),this.departmentSelect===t){this.departmentSelect=-1;return}this.departmentSelect=t},onOpDepartment(t){if($A.leftExists(t,"add_"))this.onShowDepartment({parent_id:parseInt(t.substr(4))});else if($A.leftExists(t,"edit_")){const s=this.departmentList.find(({id:e})=>e===parseInt(t.substr(5)));s&&this.onShowDepartment(s)}else if($A.leftExists(t,"del_")){const s=this.departmentList.find(({id:e})=>e===parseInt(t.substr(4)));s&&$A.modalConfirm({title:this.$L("\u5220\u9664\u90E8\u95E8"),content:`
`};Qt.fence=function(e,t,n,r,a){var l=e[t],u=l.info?zG(l.info).trim():"",c="",d="",f,g,h,p,m;return u&&(h=u.split(/(\s+)/g),c=h[0],d=h.slice(2).join("")),n.highlight?f=n.highlight(l.content,c,d)||Cn(l.content):f=Cn(l.content),f.indexOf(""+Cn(e[t].content)+`w.length)&&(M=w.length);for(var x=0,Y=new Array(M);x
${e.label}
`)},onMsgChange(e){const t=this.allMsgs.find(({type:n,id:r})=>n=="text"&&r==e.id);if(t){const{tail:n}=this.scrollInfo();e.type==="append"?t.msg.text+=e.text:e.type==="replace"&&(t.msg.text=e.text),this.$nextTick(r=>{const{tail:a}=this.scrollInfo();n<=10&&a!=n&&(this.operatePreventScroll++,this.$refs.scroller.scrollToBottom(),setTimeout(l=>{this.operatePreventScroll--},50))})}},getTempId(){return this.tempId++},getMsgs(e){return new Promise((t,n)=>{setTimeout(r=>this.msgLoadIng++,2e3),this.$store.dispatch("getDialogMsgs",e).then(t).catch(n).finally(r=>{this.msgLoadIng--})})},msgFilter(e){if(this.msgType){if(this.msgType==="tag"){if(!e.tag)return!1}else if(this.msgType==="link"){if(!e.link)return!1}else if(this.msgType!==e.mtype)return!1}return!(this.msgId&&e.reply_id!=this.msgId)},onSearchMsgId(){this.dialogSearchMsgId>0&&this.openId===this.dialogId&&(this.onPositionId(this.dialogSearchMsgId),this.$store.state.dialogSearchMsgId=0)},onPositionId(e,t=0,n=0){return new Promise((r,a)=>{if(e===0){$A.modalError("\u67E5\u770B\u5931\u8D25\uFF1A\u53C2\u6570\u9519\u8BEF"),a();return}if(this.loadMsg||this.msgType!==""){if(this.msgType="",n===0)this.$store.dispatch("showSpinner",600);else if(n>20){this.$store.dispatch("hiddenSpinner"),$A.modalError("\u67E5\u770B\u5931\u8D25\uFF1A\u8BF7\u6C42\u8D85\u65F6"),a();return}n++,setTimeout(c=>{this.onPositionId(e,t,n).then(r).catch(a)},Math.min(800,200*n));return}n>0&&this.$store.dispatch("hiddenSpinner");const l=this.allMsgs.findIndex(c=>c.id===e),u=this.prevId>0?0:-1;l>u?setTimeout(c=>{this.onToIndex(l),r()},200):(t>0&&this.$store.dispatch("setLoad",{key:`msg-${t}`,delay:600}),this.preventToBottom=!0,this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,position_id:e,spinner:2e3}).finally(c=>{const d=this.allMsgs.findIndex(f=>f.id===e);d>-1&&(this.onToIndex(d),r()),t>0&&this.$store.dispatch("cancelLoad",`msg-${t}`),this.preventToBottom=!1}))})},onViewTodo(e){if(this.operateVisible)return;this.todoViewId=e.id,this.todoViewMid=e.msg_id,this.todoViewShow=!0,this.allMsgs.findIndex(n=>n.id===this.todoViewMid)===-1&&this.$store.dispatch("call",{url:"dialog/msg/one",data:{msg_id:this.todoViewMid}}).then(({data:n})=>{this.todoViewData=n})},onCloseTodo(){this.todoViewLoad=!1,this.todoViewShow=!1,this.todoViewData={},this.todoViewMid=0,this.todoViewId=0},onPosTodo(){!this.todoViewMid||(this.todoViewPosLoad=!0,this.onPositionId(this.todoViewMid).then(this.onCloseTodo).finally(e=>{this.todoViewPosLoad=!1}))},onDoneTodo(){!this.todoViewId||this.todoViewLoad||(this.todoViewLoad=!0,this.$store.dispatch("call",{url:"dialog/msg/done",data:{id:this.todoViewId}}).then(({data:e})=>{this.$store.dispatch("saveDialogTodo",{id:this.todoViewId,done_at:$A.formatDate("Y-m-d H:i:s")}),this.$store.dispatch("saveDialog",{id:this.dialogId,todo_num:this.todoList.length}),e.add&&this.sendSuccess(e.add),this.todoList.length===0&&this.$store.dispatch("getDialogTodo",this.dialogId),this.onCloseTodo()}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.todoViewLoad=!1}))},itemClassAdd(e){return e===this.msgActiveIndex?"common-shake":""},inputFocus(){this.$nextTick(e=>{this.$refs.input&&this.$refs.input.focus()})},onRecordState(e){this.recordState=e},chatPasteDrag(e,t){if(this.dialogDrag=!1,$A.dataHasFolder(t==="drag"?e.dataTransfer:e.clipboardData)){e.preventDefault(),$A.modalWarning(`\u6682\u4E0D\u652F\u6301${t==="drag"?"\u62D6\u62FD":"\u7C98\u8D34"}\u6587\u4EF6\u5939\u3002`);return}const n=t==="drag"?e.dataTransfer.files:e.clipboardData.files,r=Array.prototype.slice.call(n);r.length>0&&(e.preventDefault(),this.sendFileMsg(r))},chatDragOver(e,t){let n=this.__dialogDrag=$A.randomString(8);if(!e)setTimeout(()=>{n===this.__dialogDrag&&(this.dialogDrag=e)},150);else{if(t.dataTransfer.effectAllowed==="move"||Array.prototype.slice.call(t.dataTransfer.files).length===0)return;this.dialogDrag=!0}},onTouchStart(e){if(this.wrapperStart=null,this.$refs.scroller.$el.contains(e.target))this.wrapperStart=Object.assign(this.scrollInfo(),{clientY:e.touches[0].clientY});else if(this.$refs.input.$refs.editor.contains(e.target)){const t=this.$refs.input.$refs.editor.querySelector(".ql-editor");if(t){const n=t.clientHeight,r=t.scrollTop,a=t.scrollHeight;this.wrapperStart={offset:r,scale:r/(a-n),tail:a-n-r,clientY:e.touches[0].clientY}}}},onTouchMove(e){if(this.footerPaddingBottom>0||this.windowPortrait&&this.windowScrollY>0){if(this.wrapperStart===null){e.preventDefault();return}this.wrapperStart.clientY>e.touches[0].clientY?this.wrapperStart.tail===0&&e.preventDefault():this.wrapperStart.offset===0&&e.preventDefault()}},pasteSend(){this.pasteFile.some(e=>{this.$refs.chatUpload.upload(e)})},chatFile(e,t){switch(e){case"progress":const n={id:t.tempId,dialog_id:this.dialogData.id,reply_id:this.quoteId,type:"loading",userid:this.userId,msg:{}};this.tempMsgs.push(n),this.msgType="",this.cancelQuote(),this.onActive(),this.$nextTick(this.onToBottom);break;case"error":this.tempMsgs=this.tempMsgs.filter(({id:r})=>r!=t.tempId);break;case"success":this.tempMsgs=this.tempMsgs.filter(({id:r})=>r!=t.tempId),this.sendSuccess(t.data);break}},sendSuccess(e){if($A.isArray(e)){e.some(this.sendSuccess);return}this.$store.dispatch("saveDialogMsg",e),this.quoteUpdate||(this.$store.dispatch("increaseTaskMsgNum",e),this.$store.dispatch("increaseMsgReplyNum",e),this.$store.dispatch("updateDialogLastMsg",e)),this.cancelQuote(),this.onActive()},setQuote(e,t){var n;(n=this.$refs.input)==null||n.setQuote(e,t)},cancelQuote(){var e;(e=this.$refs.input)==null||e.cancelQuote()},onEventFocus(){this.$emit("on-focus")},onEventBlur(){this.$emit("on-blur")},onEventMore(e){switch(e){case"image":case"file":this.$refs.chatUpload.handleClick();break;case"call":this.onCallTel();break;case"anon":this.onAnon();break}},onCallTel(){this.$store.dispatch("call",{url:"dialog/tel",data:{dialog_id:this.dialogId},spinner:600}).then(({data:e})=>{e.tel&&$A.eeuiAppSendMessage({action:"callTel",tel:e.tel}),e.add&&(this.$store.dispatch("saveDialogMsg",e.add),this.$store.dispatch("updateDialogLastMsg",e.add),this.onActive())}).catch(({msg:e})=>{$A.modalError(e)})},onAnon(){if(this.dialogData.type!=="user"||this.dialogData.bot){$A.modalWarning("\u533F\u540D\u6D88\u606F\u4EC5\u5141\u8BB8\u53D1\u9001\u7ED9\u4E2A\u4EBA");return}$A.modalInput({title:"\u53D1\u9001\u533F\u540D\u6D88\u606F",placeholder:"\u533F\u540D\u6D88\u606F\u5C06\u901A\u8FC7\u533F\u540D\u6D88\u606F\uFF08\u673A\u5668\u4EBA\uFF09\u53D1\u9001\u7ED9\u5BF9\u65B9\uFF0C\u4E0D\u4F1A\u8BB0\u5F55\u4F60\u7684\u4EFB\u4F55\u8EAB\u4EFD\u4FE1\u606F",inputProps:{type:"textarea",rows:3,autosize:{minRows:3,maxRows:6},maxlength:2e3},okText:"\u533F\u540D\u53D1\u9001",onOk:e=>e?new Promise((t,n)=>{this.$store.dispatch("call",{url:"dialog/msg/sendanon",data:{userid:this.dialogData.dialog_user.userid,text:e},method:"post"}).then(({msg:r})=>{t(r)}).catch(({msg:r})=>{n(r)})}):"\u8BF7\u8F93\u5165\u6D88\u606F\u5185\u5BB9"})},onEventEmojiVisibleChange(e){e&&this.windowPortrait&&this.onToBottom()},onHeightChange({newVal:e,oldVal:t}){const n=e-t;if(n!==0){const{offset:r,tail:a}=this.scrollInfo();a>0&&this.onToOffset(r+n)}},onActive(){this.$emit("on-active")},onToBottom(){this.msgNew=0;const e=this.$refs.scroller;e&&(e.scrollToBottom(),requestAnimationFrame(t=>e.scrollToBottom()))},onToIndex(e){const t=this.$refs.scroller;t&&(t.stopToBottom(),t.scrollToIndex(e,-100),requestAnimationFrame(n=>t.scrollToIndex(e,-100))),requestAnimationFrame(n=>this.msgActiveIndex=e)},onToOffset(e){const t=this.$refs.scroller;t&&(t.stopToBottom(),t.scrollToOffset(e),setTimeout(n=>t.scrollToOffset(e),10))},scrollInfo(){const e=this.$refs.scroller;return e?e.scrollInfo():{offset:0,scale:0,tail:0}},openProject(){!this.dialogData.group_info||(this.windowPortrait&&this.$store.dispatch("openDialog",0),this.goForward({name:"manage-project",params:{projectId:this.dialogData.group_info.id}}))},openTask(){!this.dialogData.group_info||(this.taskId>0&&this.$store.dispatch("openDialog",0),this.$store.dispatch("openTask",{id:this.dialogData.group_info.id,deleted_at:this.dialogData.group_info.deleted_at,archived_at:this.dialogData.group_info.archived_at}))},onPrevPage(){this.prevId!==0&&this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,prev_id:this.prevId,save_before:e=>this.scrollDisabled=!0,save_after:e=>this.scrollDisabled=!1}).then(({data:e})=>{const t=e.list.map(n=>n.id);this.$nextTick(()=>{const n=this.$refs.scroller,r=t.reduce((l,u)=>({size:(typeof l=="object"?l.size:n.getSize(l))+n.getSize(u)}));let a=n.getOffset()+r.size;this.prevId===0&&(a-=36),this.onToOffset(a),setTimeout(l=>n.virtual.handleFront(),10)})}).catch(()=>{})},onDialogMenu(e){var t;switch(e){case"searchMsg":this.searchShow=!0,this.$nextTick(r=>{this.$refs.searchInput.focus()});break;case"openCreate":const n=[this.userId];this.dialogData.dialog_user&&this.userId!=this.dialogData.dialog_user.userid&&n.push(this.dialogData.dialog_user.userid),this.createGroupData={userids:n,uncancelable:[this.userId]},this.createGroupShow=!0;break;case"modifyNormal":this.modifyData={dialog_id:this.dialogData.id,avatar:this.dialogData.avatar,name:this.dialogData.name},this.dialogData.type==="user"&&(this.modifyData=Object.assign(this.modifyData,{userid:this.dialogData.dialog_user.userid,avatar:(t=this.cacheUserBasic.find(r=>r.userid===this.dialogData.dialog_user.userid))==null?void 0:t.userimg,clear_day:0,webhook_url:"",system_name:""}),this.modifyLoad++,this.$store.dispatch("call",{url:"users/bot/info",data:{id:this.dialogData.dialog_user.userid}}).then(({data:r})=>{this.modifyData.clear_day=r.clear_day,this.modifyData.webhook_url=r.webhook_url,this.modifyData.system_name=r.system_name}).finally(()=>{this.modifyLoad--})),this.modifyShow=!0;break;case"modifyAdmin":this.modifyData={dialog_id:this.dialogData.id,avatar:this.dialogData.avatar,admin:1},this.modifyShow=!0;break;case"groupInfo":this.groupInfoShow=!0;break;case"transfer":this.groupTransferData={dialog_id:this.dialogId,userid:[],disabledChoice:[this.userId]},this.groupTransferShow=!0;break;case"transferConfirm":this.onTransferGroup();break;case"disband":this.onDisbandGroup();break;case"exit":this.onExitGroup();break}},onTransferGroup(){if(this.groupTransferData.userid.length===0){$A.messageError("\u8BF7\u9009\u62E9\u65B0\u7684\u7FA4\u4E3B");return}this.groupTransferLoad++,this.$store.dispatch("call",{url:"dialog/group/transfer",data:{dialog_id:this.dialogId,userid:this.groupTransferData.userid[0]}}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveDialog",e)}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.groupTransferLoad--,this.groupTransferShow=!1})},onDisbandGroup(){$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u8981\u89E3\u6563\u3010${this.dialogData.name}\u3011\u7FA4\u7EC4\u5417\uFF1F`,loading:!0,okText:"\u89E3\u6563",onOk:()=>new Promise((e,t)=>{this.$store.dispatch("call",{url:"dialog/group/disband",data:{dialog_id:this.dialogId}}).then(({msg:n})=>{e(n),this.$store.dispatch("forgetDialog",this.dialogId),this.goForward({name:"manage-messenger"})}).catch(({msg:n})=>{t(n)})})})},onExitGroup(){$A.modalConfirm({content:"\u4F60\u786E\u5B9A\u8981\u9000\u51FA\u7FA4\u7EC4\u5417\uFF1F",loading:!0,onOk:()=>new Promise((e,t)=>{this.$store.dispatch("call",{url:"dialog/group/deluser",data:{dialog_id:this.dialogId}}).then(({msg:n})=>{e(n),this.$store.dispatch("forgetDialog",this.dialogId),this.goForward({name:"manage-messenger"})}).catch(({msg:n})=>{t(n)})})})},onCreateGroup(){this.createGroupLoad++,this.$store.dispatch("call",{url:"dialog/group/add",data:this.createGroupData}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.createGroupShow=!1,this.createGroupData={},this.$store.dispatch("saveDialog",e),this.$store.dispatch("openDialog",e.id)}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.createGroupLoad--})},onModify(){this.modifyData.userid?(this.modifyLoad++,this.$store.dispatch("call",{url:"users/bot/edit",data:{id:this.modifyData.userid,avatar:this.modifyData.avatar,name:this.modifyData.name,clear_day:this.modifyData.clear_day,webhook_url:this.modifyData.webhook_url},method:"post"}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveUserBasic",{userid:this.modifyData.userid,nickname:e.name,userimg:e.avatar}),this.$store.dispatch("saveDialog",{id:this.modifyData.dialog_id,name:e.name}),this.modifyShow=!1,this.modifyData={}}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.modifyLoad--})):(this.modifyLoad++,this.$store.dispatch("call",{url:"dialog/group/edit",data:this.modifyData}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveDialog",e),this.modifyShow=!1,this.modifyData={}}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.modifyLoad--}))},onForward(){return new Promise((e,t)=>{if(this.forwardData.length===0){$A.messageError("\u8BF7\u9009\u62E9\u8F6C\u53D1\u5BF9\u8BDD\u6216\u6210\u5458"),t();return}const n=this.forwardData.filter(a=>$A.leftExists(a,"d:")).map(a=>a.replace("d:","")),r=this.forwardData.filter(a=>!$A.leftExists(a,"d:"));this.$store.dispatch("call",{url:"dialog/msg/forward",data:{dialogids:n,userids:r,msg_id:this.operateItem.id}}).then(({data:a,msg:l})=>{this.$store.dispatch("saveDialogMsg",a.msgs),this.$store.dispatch("updateDialogLastMsg",a.msgs),$A.messageSuccess(l),e()}).catch(({msg:a})=>{$A.modalError(a),t()})})},onScroll(e){this.operatePreventScroll===0&&(this.operateVisible=!1);const{offset:t,tail:n}=this.scrollInfo();this.scrollOffset=t,this.scrollTail=n,this.scrollTail<=55&&(this.msgNew=0),this.scrollAction=e.target.scrollTop,this.scrollDirection=this.scrollTmp<=this.scrollAction?"down":"up",setTimeout(r=>this.scrollTmp=this.scrollAction,0)},onRange(e){if(this.preventMoreLoad)return;const t=this.scrollDirection==="down"?"next_id":"prev_id";for(let n=e.start;n<=e.end;n++){const r=this.allMsgs[n][t];if(r){const a=this.allMsgs[n+(t==="next_id"?1:-1)];a&&a.id!=r&&(this.preventMoreLoad=!0,this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,[t]:r}).finally(l=>{this.preventMoreLoad=!1}))}}},onBack(){if(!this.beforeBack)return this.handleBack();const e=this.beforeBack();e&&e.then?e.then(()=>{this.handleBack()}):this.handleBack()},handleBack(){const{name:e,params:t}=this.$store.state.routeHistoryLast;e===this.$route.name&&/^\d+$/.test(t.dialogId)?this.goForward({name:this.$route.name}):this.goBack()},onMsgType(e){switch(e){case"project":this.openProject();break;case"task":this.openTask();break;default:this.loadMsg?$A.messageWarning("\u6B63\u5728\u52A0\u8F7D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5..."):this.msgType=e;break}},onMention(e){const t=this.cacheUserBasic.find(({userid:n})=>n==e.userid);t&&this.$refs.input.addMention({denotationChar:"@",id:t.userid,value:t.nickname})},onLongpress({event:e,el:t,msgData:n}){if(this.operateVisible=this.operateItem.id===n.id,this.operateItem=$A.isJson(n)?n:{},this.operateCopys=[],e.target.nodeName==="IMG"&&this.$Electron?this.operateCopys.push({type:"image",icon:"",label:"\u590D\u5236\u56FE\u7247",value:$A.thumbRestore(e.target.currentSrc)}):e.target.nodeName==="A"&&(e.target.classList.contains("mention")&&e.target.classList.contains("file")&&this.findOperateFile(this.operateItem.id,e.target.href),this.operateCopys.push({type:"link",icon:"",label:"\u590D\u5236\u94FE\u63A5",value:e.target.href})),n.type==="text"){e.target.nodeName==="IMG"&&this.operateCopys.push({type:"imagedown",icon:"",label:"\u4E0B\u8F7D\u56FE\u7247",value:$A.thumbRestore(e.target.currentSrc)});const r=this.getSelectedTextInElement(t);if(r.length>0&&this.operateCopys.push({type:"selected",icon:"",label:"\u590D\u5236\u9009\u62E9",value:r}),n.msg.text.replace(/<[^>]+>/g,"").length>0){let a=this.operateCopys.length>0?"\u590D\u5236\u6587\u672C":"\u590D\u5236";r.length>0&&(a="\u590D\u5236\u5168\u90E8"),this.operateCopys.push({type:"text",icon:"",label:a,value:""})}}this.$nextTick(()=>{const r=t.getBoundingClientRect(),a=this.$el.getBoundingClientRect();this.operateStyles={left:`${e.clientX-a.left}px`,top:`${r.top+this.windowScrollY}px`,height:r.height+"px"},this.operateVisible=!0})},onOperate(e,t=null){this.operateVisible=!1,this.$nextTick(n=>{switch(e){case"reply":this.onReply();break;case"update":this.onUpdate();break;case"copy":this.onCopy(t);break;case"forward":this.forwardData=[],this.$refs.forwardSelect.onSelection();break;case"withdraw":this.onWithdraw();break;case"view":this.onViewFile();break;case"down":this.onDownFile();break;case"tag":this.onTag();break;case"newTask":let r=$A.formatMsgBasic(this.operateItem.msg.text);r=r.replace(/${e.label}
`)},onMsgChange(e){const t=this.allMsgs.find(({type:n,id:r})=>n=="text"&&r==e.id);if(t){const{tail:n}=this.scrollInfo();e.type==="append"?t.msg.text+=e.text:e.type==="replace"&&(t.msg.text=e.text),this.$nextTick(r=>{const{tail:a}=this.scrollInfo();n<=10&&a!=n&&(this.operatePreventScroll++,this.$refs.scroller.scrollToBottom(),setTimeout(l=>{this.operatePreventScroll--},50))})}},getTempId(){return this.tempId++},getMsgs(e){return new Promise((t,n)=>{setTimeout(r=>this.msgLoadIng++,2e3),this.$store.dispatch("getDialogMsgs",e).then(t).catch(n).finally(r=>{this.msgLoadIng--})})},msgFilter(e){if(this.msgType){if(this.msgType==="tag"){if(!e.tag)return!1}else if(this.msgType==="link"){if(!e.link)return!1}else if(this.msgType!==e.mtype)return!1}return!(this.msgId&&e.reply_id!=this.msgId)},onSearchMsgId(){this.dialogSearchMsgId>0&&this.openId===this.dialogId&&(this.onPositionId(this.dialogSearchMsgId),this.$store.state.dialogSearchMsgId=0)},onPositionId(e,t=0,n=0){return new Promise((r,a)=>{if(e===0){$A.modalError("\u67E5\u770B\u5931\u8D25\uFF1A\u53C2\u6570\u9519\u8BEF"),a();return}if(this.loadMsg||this.msgType!==""){if(this.msgType="",n===0)this.$store.dispatch("showSpinner",600);else if(n>20){this.$store.dispatch("hiddenSpinner"),$A.modalError("\u67E5\u770B\u5931\u8D25\uFF1A\u8BF7\u6C42\u8D85\u65F6"),a();return}n++,setTimeout(c=>{this.onPositionId(e,t,n).then(r).catch(a)},Math.min(800,200*n));return}n>0&&this.$store.dispatch("hiddenSpinner");const l=this.allMsgs.findIndex(c=>c.id===e),u=this.prevId>0?0:-1;l>u?setTimeout(c=>{this.onToIndex(l),r()},200):(t>0&&this.$store.dispatch("setLoad",{key:`msg-${t}`,delay:600}),this.preventToBottom=!0,this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,position_id:e,spinner:2e3}).finally(c=>{const d=this.allMsgs.findIndex(f=>f.id===e);d>-1&&(this.onToIndex(d),r()),t>0&&this.$store.dispatch("cancelLoad",`msg-${t}`),this.preventToBottom=!1}))})},onViewTodo(e){if(this.operateVisible)return;this.todoViewId=e.id,this.todoViewMid=e.msg_id,this.todoViewShow=!0,this.allMsgs.findIndex(n=>n.id===this.todoViewMid)===-1&&this.$store.dispatch("call",{url:"dialog/msg/one",data:{msg_id:this.todoViewMid}}).then(({data:n})=>{this.todoViewData=n})},onCloseTodo(){this.todoViewLoad=!1,this.todoViewShow=!1,this.todoViewData={},this.todoViewMid=0,this.todoViewId=0},onPosTodo(){!this.todoViewMid||(this.todoViewPosLoad=!0,this.onPositionId(this.todoViewMid).then(this.onCloseTodo).finally(e=>{this.todoViewPosLoad=!1}))},onDoneTodo(){!this.todoViewId||this.todoViewLoad||(this.todoViewLoad=!0,this.$store.dispatch("call",{url:"dialog/msg/done",data:{id:this.todoViewId}}).then(({data:e})=>{this.$store.dispatch("saveDialogTodo",{id:this.todoViewId,done_at:$A.formatDate("Y-m-d H:i:s")}),this.$store.dispatch("saveDialog",{id:this.dialogId,todo_num:this.todoList.length}),e.add&&this.sendSuccess(e.add),this.todoList.length===0&&this.$store.dispatch("getDialogTodo",this.dialogId),this.onCloseTodo()}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.todoViewLoad=!1}))},itemClassAdd(e){return e===this.msgActiveIndex?"common-shake":""},inputFocus(){this.$nextTick(e=>{this.$refs.input&&this.$refs.input.focus()})},onRecordState(e){this.recordState=e},chatPasteDrag(e,t){if(this.dialogDrag=!1,$A.dataHasFolder(t==="drag"?e.dataTransfer:e.clipboardData)){e.preventDefault(),$A.modalWarning(`\u6682\u4E0D\u652F\u6301${t==="drag"?"\u62D6\u62FD":"\u7C98\u8D34"}\u6587\u4EF6\u5939\u3002`);return}const n=t==="drag"?e.dataTransfer.files:e.clipboardData.files,r=Array.prototype.slice.call(n);r.length>0&&(e.preventDefault(),this.sendFileMsg(r))},chatDragOver(e,t){let n=this.__dialogDrag=$A.randomString(8);if(!e)setTimeout(()=>{n===this.__dialogDrag&&(this.dialogDrag=e)},150);else{if(t.dataTransfer.effectAllowed==="move"||Array.prototype.slice.call(t.dataTransfer.files).length===0)return;this.dialogDrag=!0}},onTouchStart(e){if(this.wrapperStart=null,this.$refs.scroller.$el.contains(e.target))this.wrapperStart=Object.assign(this.scrollInfo(),{clientY:e.touches[0].clientY});else if(this.$refs.input.$refs.editor.contains(e.target)){const t=this.$refs.input.$refs.editor.querySelector(".ql-editor");if(t){const n=t.clientHeight,r=t.scrollTop,a=t.scrollHeight;this.wrapperStart={offset:r,scale:r/(a-n),tail:a-n-r,clientY:e.touches[0].clientY}}}},onTouchMove(e){if(this.footerPaddingBottom>0||this.windowPortrait&&this.windowScrollY>0){if(this.wrapperStart===null){e.preventDefault();return}this.wrapperStart.clientY>e.touches[0].clientY?this.wrapperStart.tail===0&&e.preventDefault():this.wrapperStart.offset===0&&e.preventDefault()}},pasteSend(){this.pasteFile.some(e=>{this.$refs.chatUpload.upload(e)})},chatFile(e,t){switch(e){case"progress":const n={id:t.tempId,dialog_id:this.dialogData.id,reply_id:this.quoteId,type:"loading",userid:this.userId,msg:{}};this.tempMsgs.push(n),this.msgType="",this.cancelQuote(),this.onActive(),this.$nextTick(this.onToBottom);break;case"error":this.tempMsgs=this.tempMsgs.filter(({id:r})=>r!=t.tempId);break;case"success":this.tempMsgs=this.tempMsgs.filter(({id:r})=>r!=t.tempId),this.sendSuccess(t.data);break}},sendSuccess(e){if($A.isArray(e)){e.some(this.sendSuccess);return}this.$store.dispatch("saveDialogMsg",e),this.quoteUpdate||(this.$store.dispatch("increaseTaskMsgNum",e),this.$store.dispatch("increaseMsgReplyNum",e),this.$store.dispatch("updateDialogLastMsg",e)),this.cancelQuote(),this.onActive()},setQuote(e,t){var n;(n=this.$refs.input)==null||n.setQuote(e,t)},cancelQuote(){var e;(e=this.$refs.input)==null||e.cancelQuote()},onEventFocus(){this.$emit("on-focus")},onEventBlur(){this.$emit("on-blur")},onEventMore(e){switch(e){case"image":case"file":this.$refs.chatUpload.handleClick();break;case"call":this.onCallTel();break;case"anon":this.onAnon();break}},onCallTel(){this.$store.dispatch("call",{url:"dialog/tel",data:{dialog_id:this.dialogId},spinner:600}).then(({data:e})=>{e.tel&&$A.eeuiAppSendMessage({action:"callTel",tel:e.tel}),e.add&&(this.$store.dispatch("saveDialogMsg",e.add),this.$store.dispatch("updateDialogLastMsg",e.add),this.onActive())}).catch(({msg:e})=>{$A.modalError(e)})},onAnon(){if(this.dialogData.type!=="user"||this.dialogData.bot){$A.modalWarning("\u533F\u540D\u6D88\u606F\u4EC5\u5141\u8BB8\u53D1\u9001\u7ED9\u4E2A\u4EBA");return}$A.modalInput({title:"\u53D1\u9001\u533F\u540D\u6D88\u606F",placeholder:"\u533F\u540D\u6D88\u606F\u5C06\u901A\u8FC7\u533F\u540D\u6D88\u606F\uFF08\u673A\u5668\u4EBA\uFF09\u53D1\u9001\u7ED9\u5BF9\u65B9\uFF0C\u4E0D\u4F1A\u8BB0\u5F55\u4F60\u7684\u4EFB\u4F55\u8EAB\u4EFD\u4FE1\u606F",inputProps:{type:"textarea",rows:3,autosize:{minRows:3,maxRows:6},maxlength:2e3},okText:"\u533F\u540D\u53D1\u9001",onOk:e=>e?new Promise((t,n)=>{this.$store.dispatch("call",{url:"dialog/msg/sendanon",data:{userid:this.dialogData.dialog_user.userid,text:e},method:"post"}).then(({msg:r})=>{t(r)}).catch(({msg:r})=>{n(r)})}):"\u8BF7\u8F93\u5165\u6D88\u606F\u5185\u5BB9"})},onEventEmojiVisibleChange(e){e&&this.windowPortrait&&this.onToBottom()},onHeightChange({newVal:e,oldVal:t}){const n=e-t;if(n!==0){const{offset:r,tail:a}=this.scrollInfo();a>0&&this.onToOffset(r+n)}},onActive(){this.$emit("on-active")},onToBottom(){this.msgNew=0;const e=this.$refs.scroller;e&&(e.scrollToBottom(),requestAnimationFrame(t=>e.scrollToBottom()))},onToIndex(e){const t=this.$refs.scroller;t&&(t.stopToBottom(),t.scrollToIndex(e,-100),requestAnimationFrame(n=>t.scrollToIndex(e,-100))),requestAnimationFrame(n=>this.msgActiveIndex=e)},onToOffset(e){const t=this.$refs.scroller;t&&(t.stopToBottom(),t.scrollToOffset(e),setTimeout(n=>t.scrollToOffset(e),10))},scrollInfo(){const e=this.$refs.scroller;return e?e.scrollInfo():{offset:0,scale:0,tail:0}},openProject(){!this.dialogData.group_info||(this.windowPortrait&&this.$store.dispatch("openDialog",0),this.goForward({name:"manage-project",params:{projectId:this.dialogData.group_info.id}}))},openTask(){!this.dialogData.group_info||(this.taskId>0&&this.$store.dispatch("openDialog",0),this.$store.dispatch("openTask",{id:this.dialogData.group_info.id,deleted_at:this.dialogData.group_info.deleted_at,archived_at:this.dialogData.group_info.archived_at}))},onPrevPage(){this.prevId!==0&&this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,prev_id:this.prevId,save_before:e=>this.scrollDisabled=!0,save_after:e=>this.scrollDisabled=!1}).then(({data:e})=>{const t=e.list.map(n=>n.id);this.$nextTick(()=>{const n=this.$refs.scroller,r=t.reduce((l,u)=>({size:(typeof l=="object"?l.size:n.getSize(l))+n.getSize(u)}));let a=n.getOffset()+r.size;this.prevId===0&&(a-=36),this.onToOffset(a),setTimeout(l=>n.virtual.handleFront(),10)})}).catch(()=>{})},onDialogMenu(e){var t;switch(e){case"searchMsg":this.searchShow=!0,this.$nextTick(r=>{this.$refs.searchInput.focus()});break;case"openCreate":const n=[this.userId];this.dialogData.dialog_user&&this.userId!=this.dialogData.dialog_user.userid&&n.push(this.dialogData.dialog_user.userid),this.createGroupData={userids:n,uncancelable:[this.userId]},this.createGroupShow=!0;break;case"modifyNormal":this.modifyData={dialog_id:this.dialogData.id,avatar:this.dialogData.avatar,name:this.dialogData.name},this.dialogData.type==="user"&&(this.modifyData=Object.assign(this.modifyData,{userid:this.dialogData.dialog_user.userid,avatar:(t=this.cacheUserBasic.find(r=>r.userid===this.dialogData.dialog_user.userid))==null?void 0:t.userimg,clear_day:0,webhook_url:"",system_name:""}),this.modifyLoad++,this.$store.dispatch("call",{url:"users/bot/info",data:{id:this.dialogData.dialog_user.userid}}).then(({data:r})=>{this.modifyData.clear_day=r.clear_day,this.modifyData.webhook_url=r.webhook_url,this.modifyData.system_name=r.system_name}).finally(()=>{this.modifyLoad--})),this.modifyShow=!0;break;case"modifyAdmin":this.modifyData={dialog_id:this.dialogData.id,avatar:this.dialogData.avatar,admin:1},this.modifyShow=!0;break;case"groupInfo":this.groupInfoShow=!0;break;case"transfer":this.groupTransferData={dialog_id:this.dialogId,userid:[],disabledChoice:[this.userId]},this.groupTransferShow=!0;break;case"transferConfirm":this.onTransferGroup();break;case"disband":this.onDisbandGroup();break;case"exit":this.onExitGroup();break}},onTransferGroup(){if(this.groupTransferData.userid.length===0){$A.messageError("\u8BF7\u9009\u62E9\u65B0\u7684\u7FA4\u4E3B");return}this.groupTransferLoad++,this.$store.dispatch("call",{url:"dialog/group/transfer",data:{dialog_id:this.dialogId,userid:this.groupTransferData.userid[0]}}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveDialog",e)}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.groupTransferLoad--,this.groupTransferShow=!1})},onDisbandGroup(){$A.modalConfirm({content:`\u4F60\u786E\u5B9A\u8981\u89E3\u6563\u3010${this.dialogData.name}\u3011\u7FA4\u7EC4\u5417\uFF1F`,loading:!0,okText:"\u89E3\u6563",onOk:()=>new Promise((e,t)=>{this.$store.dispatch("call",{url:"dialog/group/disband",data:{dialog_id:this.dialogId}}).then(({msg:n})=>{e(n),this.$store.dispatch("forgetDialog",this.dialogId),this.goForward({name:"manage-messenger"})}).catch(({msg:n})=>{t(n)})})})},onExitGroup(){$A.modalConfirm({content:"\u4F60\u786E\u5B9A\u8981\u9000\u51FA\u7FA4\u7EC4\u5417\uFF1F",loading:!0,onOk:()=>new Promise((e,t)=>{this.$store.dispatch("call",{url:"dialog/group/deluser",data:{dialog_id:this.dialogId}}).then(({msg:n})=>{e(n),this.$store.dispatch("forgetDialog",this.dialogId),this.goForward({name:"manage-messenger"})}).catch(({msg:n})=>{t(n)})})})},onCreateGroup(){this.createGroupLoad++,this.$store.dispatch("call",{url:"dialog/group/add",data:this.createGroupData}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.createGroupShow=!1,this.createGroupData={},this.$store.dispatch("saveDialog",e),this.$store.dispatch("openDialog",e.id)}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.createGroupLoad--})},onModify(){this.modifyData.userid?(this.modifyLoad++,this.$store.dispatch("call",{url:"users/bot/edit",data:{id:this.modifyData.userid,avatar:this.modifyData.avatar,name:this.modifyData.name,clear_day:this.modifyData.clear_day,webhook_url:this.modifyData.webhook_url},method:"post"}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveUserBasic",{userid:this.modifyData.userid,nickname:e.name,userimg:e.avatar}),this.$store.dispatch("saveDialog",{id:this.modifyData.dialog_id,name:e.name}),this.modifyShow=!1,this.modifyData={}}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.modifyLoad--})):(this.modifyLoad++,this.$store.dispatch("call",{url:"dialog/group/edit",data:this.modifyData}).then(({data:e,msg:t})=>{$A.messageSuccess(t),this.$store.dispatch("saveDialog",e),this.modifyShow=!1,this.modifyData={}}).catch(({msg:e})=>{$A.modalError(e)}).finally(e=>{this.modifyLoad--}))},onForward(){return new Promise((e,t)=>{if(this.forwardData.length===0){$A.messageError("\u8BF7\u9009\u62E9\u8F6C\u53D1\u5BF9\u8BDD\u6216\u6210\u5458"),t();return}const n=this.forwardData.filter(a=>$A.leftExists(a,"d:")).map(a=>a.replace("d:","")),r=this.forwardData.filter(a=>!$A.leftExists(a,"d:"));this.$store.dispatch("call",{url:"dialog/msg/forward",data:{dialogids:n,userids:r,msg_id:this.operateItem.id}}).then(({data:a,msg:l})=>{this.$store.dispatch("saveDialogMsg",a.msgs),this.$store.dispatch("updateDialogLastMsg",a.msgs),$A.messageSuccess(l),e()}).catch(({msg:a})=>{$A.modalError(a),t()})})},onScroll(e){this.operatePreventScroll===0&&(this.operateVisible=!1);const{offset:t,tail:n}=this.scrollInfo();this.scrollOffset=t,this.scrollTail=n,this.scrollTail<=55&&(this.msgNew=0),this.scrollAction=e.target.scrollTop,this.scrollDirection=this.scrollTmp<=this.scrollAction?"down":"up",setTimeout(r=>this.scrollTmp=this.scrollAction,0)},onRange(e){if(this.preventMoreLoad)return;const t=this.scrollDirection==="down"?"next_id":"prev_id";for(let n=e.start;n<=e.end;n++){const r=this.allMsgs[n][t];if(r){const a=this.allMsgs[n+(t==="next_id"?1:-1)];a&&a.id!=r&&(this.preventMoreLoad=!0,this.getMsgs({dialog_id:this.dialogId,msg_id:this.msgId,msg_type:this.msgType,[t]:r}).finally(l=>{this.preventMoreLoad=!1}))}}},onBack(){if(!this.beforeBack)return this.handleBack();const e=this.beforeBack();e&&e.then?e.then(()=>{this.handleBack()}):this.handleBack()},handleBack(){const{name:e,params:t}=this.$store.state.routeHistoryLast;e===this.$route.name&&/^\d+$/.test(t.dialogId)?this.goForward({name:this.$route.name}):this.goBack()},onMsgType(e){switch(e){case"project":this.openProject();break;case"task":this.openTask();break;default:this.loadMsg?$A.messageWarning("\u6B63\u5728\u52A0\u8F7D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5..."):this.msgType=e;break}},onMention(e){const t=this.cacheUserBasic.find(({userid:n})=>n==e.userid);t&&this.$refs.input.addMention({denotationChar:"@",id:t.userid,value:t.nickname})},onLongpress({event:e,el:t,msgData:n}){if(this.operateVisible=this.operateItem.id===n.id,this.operateItem=$A.isJson(n)?n:{},this.operateCopys=[],e.target.nodeName==="IMG"&&this.$Electron?this.operateCopys.push({type:"image",icon:"",label:"\u590D\u5236\u56FE\u7247",value:$A.thumbRestore(e.target.currentSrc)}):e.target.nodeName==="A"&&(e.target.classList.contains("mention")&&e.target.classList.contains("file")&&this.findOperateFile(this.operateItem.id,e.target.href),this.operateCopys.push({type:"link",icon:"",label:"\u590D\u5236\u94FE\u63A5",value:e.target.href})),n.type==="text"){e.target.nodeName==="IMG"&&this.operateCopys.push({type:"imagedown",icon:"",label:"\u4E0B\u8F7D\u56FE\u7247",value:$A.thumbRestore(e.target.currentSrc)});const r=this.getSelectedTextInElement(t);if(r.length>0&&this.operateCopys.push({type:"selected",icon:"",label:"\u590D\u5236\u9009\u62E9",value:r}),n.msg.text.replace(/<[^>]+>/g,"").length>0){let a=this.operateCopys.length>0?"\u590D\u5236\u6587\u672C":"\u590D\u5236";r.length>0&&(a="\u590D\u5236\u5168\u90E8"),this.operateCopys.push({type:"text",icon:"",label:a,value:""})}}this.$nextTick(()=>{const r=t.getBoundingClientRect(),a=this.$el.getBoundingClientRect();this.operateStyles={left:`${e.clientX-a.left}px`,top:`${r.top+this.windowScrollY}px`,height:r.height+"px"},this.operateClient={x:e.clientX,y:e.clientY},this.operateVisible=!0})},onOperate(e,t=null){this.operateVisible=!1,this.$nextTick(n=>{switch(e){case"reply":this.onReply();break;case"update":this.onUpdate();break;case"copy":this.onCopy(t);break;case"forward":this.forwardData=[],this.$refs.forwardSelect.onSelection();break;case"withdraw":this.onWithdraw();break;case"view":this.onViewFile();break;case"down":this.onDownFile();break;case"tag":this.onTag();break;case"newTask":let r=$A.formatMsgBasic(this.operateItem.msg.text);r=r.replace(/"+e+""};_r.prototype.br=function(){return this.options.xhtml?""+Xn(h.message+"",!0)+"";throw h}}er.options=er.setOptions=function(e){return Ja(er.defaults,e),er};er.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new _r,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}};er.defaults=er.getDefaults();er.Parser=Xa;er.parser=Xa.parse;er.Renderer=_r;er.TextRenderer=ws;er.Lexer=oo;er.lexer=oo.lex;er.InlineLexer=Li;er.inlineLexer=Li.output;er.Slugger=u1;er.parse=er;on.initHighlightingOnLoad();const Dj=new er.Renderer;var Oj=er.setOptions({renderer:Dj,gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!0,highlight:function(e){return on.highlightAuto(e).value}}),Tj=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"preview",staticClass:"markdown-preview-warp"},[n("div",{class:`markdown-preview ${"markdown-theme-"+e.theme}`,domProps:{innerHTML:e._s(e.html)}}),n("div",{class:["preview-img",e.previewImgModal?"active":""]},[n("span",{staticClass:"close icon-close iconfont",on:{click:function(r){e.previewImgModal=!1}}}),n("img",{class:[e.previewImgMode],attrs:{src:e.previewImgSrc,alt:""}})])])},Pj=[];const Aj={name:"markdown-preview",props:{initialValue:{type:String,default:""},markedOptions:{type:Object,default:()=>({})},theme:{type:String,default:"light"},copyCode:{type:Boolean,default:!0},copyBtnText:{type:String,default:"\u590D\u5236\u4EE3\u7801"}},data(){return{html:"",previewImgModal:!1,previewImgSrc:"",previewImgMode:""}},mounted(){this.translateMarkdown()},methods:{tocLevel(e,t){let n=9999;return t.forEach(({level:r})=>{n=Math.min(n,r)}),n===9999?e:e-(n-1)},translateMarkdown(){let e=Oj(this.initialValue,{sanitize:!1,...this.markedOptions}).replace(/href="/gi,'target="_blank" href="');if(this.copyCode&&(e=e.replace(/
/g,''+this.copyBtnText+"")),/\[\[TOC\]\]/.test(e)){let t="";S0.tocItems.forEach(n=>{t+=`").replace(/<\/pre>/g,"
>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,t===0?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(vf[n]+Lf+1)]++,e.dyn_dtree[2*OO(t)]++),e.last_lit===e.lit_bufsize-1}function gf(e,t,n,r){let a=65535&e|0,s=e>>>16&65535|0,l=0;for(;n!==0;){l=n>2e3?2e3:n,n-=l;do a=a+t[r++]|0,s=s+a|0;while(--l);a%=65521,s%=65521}return a|s<<16|0}const FH=function(){let e;const t=[];for(let n=0;n<256;n++){e=n;for(let r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();function Hr(e,t,n,r){const a=FH,s=r+n;e^=-1;for(let l=r;l >>8&255,H[2]=i>>>16&255,H[3]=i>>>24&255,n.check=Hr(n.check,H,4,0)),i=0,p=0,n.mode=D4;case D4:for(;p<16;){if(c===0)break e;c--,i+=r[s++]< >8),512&n.flags&&(H[0]=255&i,H[1]=i>>>8&255,n.check=Hr(n.check,H,2,0)),i=0,p=0,n.mode=O4;case O4:if(1024&n.flags){for(;p<16;){if(c===0)break e;c--,i+=r[s++]< >>8&255,n.check=Hr(n.check,H,2,0)),i=0,p=0}else n.head&&(n.head.extra=null);n.mode=T4;case T4:if(1024&n.flags&&(m=n.length,m>c&&(m=c),m&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),$s(n.head.extra,r,s,m,w)),512&n.flags&&(n.check=Hr(n.check,r,m,s)),c-=m,s+=m,n.length-=m),n.length))break e;n.length=0,n.mode=P4;case P4:if(2048&n.flags){if(c===0)break e;m=0;do w=r[s+m++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w));while(w&&m >>=7&p,p-=7&p,n.mode=wy;break}for(;p<3;){if(c===0)break e;c--,i+=r[s++]< >>=1,p-=1,3&i){case 0:n.mode=$4;break;case 1:if(aK(n),n.mode=tv,t===Qp){i>>>=2,p-=2;break e}break;case 2:n.mode=L4;break;case 3:e.msg="invalid block type",n.mode=mr}i>>>=2,p-=2;break;case $4:for(i>>>=7&p,p-=7&p;p<32;){if(c===0)break e;c--,i+=r[s++]< >>16^65535)){e.msg="invalid stored block lengths",n.mode=mr;break}if(n.length=65535&i,i=0,p=0,n.mode=by,t===Qp)break e;case by:n.mode=R4;case R4:if(m=n.length,m){if(m>c&&(m=c),m>h&&(m=h),m===0)break e;$s(a,r,s,m,l),c-=m,s+=m,h-=m,l+=m,n.length-=m;break}n.mode=Gs;break;case L4:for(;p<14;){if(c===0)break e;c--,i+=r[s++]< >>=5,p-=5,n.ndist=1+(31&i),i>>>=5,p-=5,n.ncode=4+(15&i),i>>>=4,p-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=mr;break}n.have=0,n.mode=N4;case N4:for(;n.have >>=b,p-=b,n.lens[n.have++]=D;else{if(D===16){for(A=b+2;p>>=b,p-=b,n.have===0){e.msg="invalid bit length repeat",n.mode=mr;break}w=n.lens[n.have-1],m=3+(3&i),i>>>=2,p-=2}else if(D===17){for(A=b+3;p>>=b,p-=b,w=0,m=3+(7&i),i>>>=3,p-=3}else{for(A=b+7;p>>=b,p-=b,w=0,m=11+(127&i),i>>>=7,p-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=mr;break}for(;m--;)n.lens[n.have++]=w}}if(n.mode===mr)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=mr;break}if(n.lenbits=9,M={bits:n.lenbits},T=Qd(LO,n.lens,0,n.nlen,n.lencode,0,n.work,M),n.lenbits=M.bits,T){e.msg="invalid literal/lengths set",n.mode=mr;break}if(n.distbits=6,n.distcode=n.distdyn,M={bits:n.distbits},T=Qd(NO,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,M),n.distbits=M.bits,T){e.msg="invalid distances set",n.mode=mr;break}if(n.mode=tv,t===Qp)break e;case tv:n.mode=nv;case nv:if(c>=6&&h>=258){e.next_out=l,e.avail_out=h,e.next_in=s,e.avail_in=c,n.hold=i,n.bits=p,YH(e,v),l=e.next_out,a=e.output,h=e.avail_out,s=e.next_in,r=e.input,c=e.avail_in,i=n.hold,p=n.bits,n.mode===Gs&&(n.back=-1);break}for(n.back=0;R=n.lencode[i&(1< >x)],b=R>>>24,E=R>>>16&255,D=65535&R,!(x+b<=p);){if(c===0)break e;c--,i+=r[s++]< >>=x,p-=x,n.back+=x}if(i>>>=b,p-=b,n.back+=b,n.length=D,E===0){n.mode=V4;break}if(32&E){n.back=-1,n.mode=Gs;break}if(64&E){e.msg="invalid literal/length code",n.mode=mr;break}n.extra=15&E,n.mode=F4;case F4:if(n.extra){for(A=n.extra;p>>=n.extra,p-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=j4;case j4:for(;R=n.distcode[i&(1< >x)],b=R>>>24,E=R>>>16&255,D=65535&R,!(x+b<=p);){if(c===0)break e;c--,i+=r[s++]< >>=x,p-=x,n.back+=x}if(i>>>=b,p-=b,n.back+=b,64&E){e.msg="invalid distance code",n.mode=mr;break}n.offset=D,n.extra=15&E,n.mode=z4;case z4:if(n.extra){for(A=n.extra;p>>=n.extra,p-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=mr;break}n.mode=U4;case U4:if(h===0)break e;if(m=v-h,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=mr;break}m>n.wnext?(m-=n.wnext,_=n.wsize-m):_=n.wnext-m,m>n.length&&(m=n.length),y=n.window}else y=a,_=l-n.offset,m=n.length;m>h&&(m=h),h-=m,n.length-=m;do a[l++]=y[_++];while(--m);n.length===0&&(n.mode=nv);break;case V4:if(h===0)break e;a[l++]=n.length,h--,n.mode=nv;break;case wy:if(n.wrap){for(;p<32;){if(c===0)break e;c--,i|=r[s++]< =0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),!(n.windowBits>=0&&n.windowBits<16)||t&&t.windowBits||(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(15&n.windowBits)==0&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new RO,this.strm.avail_out=0;let r=iK(this.strm,n.windowBits);if(r!==Jn||(this.header=new oK,function(a,s){let l;a&&a.state&&(l=a.state,(2&l.wrap)==0||(l.head=s,s.done=!1))}(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=Y0(n.dictionary):n.dictionary instanceof ArrayBuffer&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(r=Y4(this.strm,n.dictionary),r!==Jn))))throw Error(_f[r])}push(t,n){const{strm:r,options:{chunkSize:a,dictionary:s}}=this;let l,c,h=!1;if(this.ended)return!1;c=n===~~n?n:n===!0?Yr:Rs,typeof t=="string"?r.input=function(i){const p=new Os(i.length);for(let d=0,v=p.length;d =p&&ti(gr.DATA_ERROR);m[e]=Z4(v,t)}var _,y=h+2,b=[];for(t=0;t 20)&&ti(gr.DATA_ERROR),r.read(1);)r.read(1)?l--:l++;x[e]=l}for(E=D=x[0],e=1;e>>8^a[255&(e^t[l])];return-1^e}var _f={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};const jH=9,Fn=3,Bo=258,Ka=Bo+Fn+1,zH=32,Pm=42,K0=69,Nv=73,Bv=91,Fv=103,Nl=113,Rd=666,Kr=1,Zd=2,Bl=3,rc=4,UH=3;function Fo(e,t){return e.msg=_f[t],t}function b4(e){return(e<<1)-(e>4?9:0)}function Io(e){let t=e.length;for(;--t>=0;)e[t]=0}function To(e){const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&($s(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function ai(e,t){BH(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,To(e.strm)}function Vn(e,t){e.pending_buf[e.pending++]=t}function md(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function VH(e,t,n,r){let a=e.avail_in;return a>r&&(a=r),a===0?0:(e.avail_in-=a,$s(t,e.input,e.next_in,a,n),e.state.wrap===1?e.adler=gf(e.adler,t,a,n):e.state.wrap===2&&(e.adler=Hr(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)}function $O(e,t){let n,r,a=e.max_chain_length,s=e.strstart,l=e.prev_length,c=e.nice_match;const h=e.strstart>e.w_size-Ka?e.strstart-(e.w_size-Ka):0,i=e.window,p=e.w_mask,d=e.prev,v=e.strstart+Bo;let m=i[s+l-1],_=i[s+l];e.prev_length>=e.good_match&&(a>>=2),c>e.lookahead&&(c=e.lookahead);do if(n=t,i[n+l]===_&&i[n+l-1]===m&&i[n]===i[s]&&i[++n]===i[s+1]){s+=2,n++;do;while(i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&i[++s]===i[++n]&&s>>24,a>>>=c,s-=c,c=l>>>16&255,!(16&c)){if((64&c)==0){l=M[(65535&l)+(a&(1<=1&&R[E]===0;E--);if(D>E&&(D=E),E===0)return a[s++]=20971520,a[s++]=20971520,c.bits=1,0;for(b=1;b>>0)>>0)=8&!r;if(t)return Ae.selectUint8Array(l,s,t);if(l)return s;throw Error("Decryption error")}async function U0(e,t,n){let r;if(t.length!==cc.getHashByteLength(e))throw Error("Invalid hash length");const a=new Uint8Array(vs[e].length);for(r=0;r