"use strict";const e=require("../../../../common/vendor.js");require("../../../adapter-vue.js");const r=require("../../../utils/documentLink.js"),o=require("../../../utils/env.js"),t=require("../../../../common/assets.js"),i=require("./group-introduction/config.js"),n=require("../../common/Toast/index.js"),u=require("../server.js"),p=require("../../common/Toast/type.js");Math||(f+g+s+a)();const f=()=>"../../common/Icon.js",s=()=>"./group-introduction/index.js",a=()=>"../../common/Dialog/index.js",g=()=>"../../common/Avatar/index.js",l=e.defineComponent({__name:"index",setup(f){const s=u.TUIGroupServer.getInstance(),a=s.constants,g=e.reactive({profile:{groupID:"",name:"",type:i.groupIntroConfig[0].type,avatar:i.groupIntroConfig[0].icon,introduction:"",notification:"",memberList:[],isSupportTopic:!1},groupConfig:{title:"",value:"",key:"",type:"",placeholder:""},isEdit:!1});e.watchEffect((()=>{const e=s.getOnCallParams(a.TUIGroup.SERVICE.METHOD.CREATE_GROUP);g.profile.memberList=e.memberList,g.groupConfig.title=e.title}));const l=e.computed((()=>i.findGroupIntroConfig(g.profile.type))),c=e.computed((()=>{let r="添加群聊";return g.isEdit&&(r=g.groupConfig.title),e.Wt.t(`TUIGroup.${r}`)})),d=e.computed((()=>{const r={name:e.Wt.t("TUIGroup.群名称"),key:"name",placeholder:e.Wt.t("TUIGroup.请输入群名称")},o={name:`${e.Wt.t("TUIGroup.群ID")}(${e.Wt.t("TUIGroup.选填")})`,key:"groupID",placeholder:e.Wt.t("TUIGroup.请输入群ID")};return g.profile.type===e.qt.TYPES.GRP_COMMUNITY?[r]:[r,o]})),C=e.computed((()=>""===g.profile.name&&!g.isEdit)),m=e=>{g.profile.type!==e&&(g.profile.type=e,g.profile.avatar=i.findGroupIntroConfig(e).icon,g.isEdit&&(g.groupConfig.value=e))},I=()=>{const{profile:r}=g;if(g.isEdit)return g.profile[g.groupConfig.key]=g.groupConfig.value,g.isEdit=!g.isEdit;(async r=>{try{r.memberList=r.memberList.map((e=>({userID:e.userID}))),r.type===e.qt.TYPES.GRP_COMMUNITY&&delete r.groupID;const o=await e.es.createGroup(r),{type:t}=o.data.group;t===e.qt.TYPES.GRP_AVCHATROOM&&await e.es.joinGroup({groupID:o.data.group.groupID,applyMessage:""}),E(o.data.group),n.Toast({message:e.Wt.t("TUIGroup.群组创建成功"),type:p.TOAST_TYPE.SUCCESS})}catch(o){n.Toast({message:o.message,type:p.TOAST_TYPE.ERROR})}})(r)},T=()=>{if(g.isEdit)return g.isEdit=!g.isEdit;E(null)},y=e=>{switch(g.isEdit=!g.isEdit,g.groupConfig.key=e,g.groupConfig.value=g.profile[e],e){case"name":g.groupConfig.title="设置群名称",g.groupConfig.placeholder="请输入群名称",g.groupConfig.type="input";break;case"groupID":g.groupConfig.title="设置群ID",g.groupConfig.placeholder="请输入群ID",g.groupConfig.type="input";break;case"type":g.groupConfig.title="选择群类型",g.groupConfig.type="select"}},E=r=>{e.Jt.update(e.o.GRP,"isShowCreateComponent",!1);const o=s.getOnCallCallback(a.TUIGroup.SERVICE.METHOD.CREATE_GROUP);o&&o(r)};return(i,n)=>e.e({a:e.o$1(T),b:e.p({file:e.unref(o.isPC)?e.unref(t.closeIcon$2):e.unref(t.backIcon),size:"16px"}),c:e.t(e.unref(c)),d:!e.unref(g).isEdit},e.unref(g).isEdit?e.e({v:"input"===e.unref(g).groupConfig.type},"input"===e.unref(g).groupConfig.type?{w:e.unref(e.Wt).t(`TUIGroup.${e.unref(g).groupConfig.placeholder}`),x:e.unref(g).groupConfig.value,y:e.o$1((r=>e.unref(g).groupConfig.value=r.detail.value))}:{z:e.o$1(m),A:e.p({groupType:e.unref(g).groupConfig.value})}):e.e({e:e.t(e.unref(e.Wt).t("TUIGroup.群头像")),f:e.p({url:e.unref(g).profile.avatar}),g:e.f(e.unref(d),((r,i,n)=>e.e({a:e.t(r.name)},e.unref(o.isPC)?{b:r.placeholder,c:e.unref(g).profile[r.key],d:e.o$1((o=>e.unref(g).profile[r.key]=o.detail.value),i)}:{e:e.t(e.unref(g).profile[r.key]),f:"c9c12286-3-"+n+",c9c12286-0",g:e.p({file:e.unref(t.rightIcon)}),h:e.o$1((e=>y(r.key)),i)},{i:i}))),h:e.unref(o.isPC),i:e.t(e.unref(e.Wt).t("TUIGroup.群类型")),j:e.unref(o.isPC)},e.unref(o.isPC)?{k:e.o$1(m),l:e.p({groupType:e.unref(g).profile.type})}:{m:e.t(e.unref(l).label),n:e.p({file:e.unref(t.rightIcon)}),o:e.o$1((e=>y("type")))},{p:!e.unref(o.isPC)},e.unref(o.isPC)?{}:{q:e.t(e.unref(l).label),r:e.t(e.unref(l).detail),s:e.t(e.unref(e.Wt).t(`TUIGroup.${e.unref(l).src}`)),t:e.unref(r.Link).product.url}),{B:e.unref(o.isPC)&&!e.unref(g).isEdit},e.unref(o.isPC)&&!e.unref(g).isEdit?{C:e.t(e.unref(e.Wt).t("TUIGroup.取消")),D:e.o$1(T)}:{},{E:e.t(e.unref(e.Wt).t("TUIGroup.确认")),F:e.unref(C),G:e.o$1(I),H:e.n(e.unref(o.isPC)?"":"group-h5"),I:e.o$1(T),J:e.p({show:!0,isH5:!e.unref(o.isPC),isHeaderShow:!1,isFooterShow:!1,background:!1})})}}),c=e._export_sfc(l,[["__scopeId","data-v-c9c12286"]]);wx.createComponent(c);
