import{D as xo}from"./deleteDialog-BYsrA0c0.js";import{d as go,a as ko,s as yo,r,f as c,g as I,i as s,w as a,I as Co,h,l as J,k as K,j as f,A as z,t as A,G as w,D as y,E as _o,L as P,x as S,m as G,F as W,C as bo,W as So,X as Vo,y as Do,_ as Io}from"./index-N7CMQwFv.js";import{U as Go,g as Fo,f as No,a as Ao,b as X,c as q,d as Uo,e as Eo,h as $o,i as Lo,j as zo,k as Bo,l as Mo,m as To}from"./uploadFont-CJSn7IiG.js";import jo from"./createdFontsGroup-CdwR-mfu.js";import{V as Ho}from"./VSelect-CAAOHY78.js";import{V as Ro,e as Oo,a as Jo}from"./VList-BYq4u0VJ.js";import{V as C}from"./VTooltip-Ap2rzsdn.js";import"./VRow-CGgRlzLk.js";/* empty css */import"./VCol-xRADuXqd.js";import"./alioss-D7aFrPDM.js";import"./file-C2qrOrfI.js";import"./VFileInput-kaJey9cy.js";import"./VChip-iaVLrPY0.js";import"./VSlideGroup-BGEgBoXK.js";import"./VRadioGroup-Bk91gCKJ.js";import"./VMenu-Dbaxs5uG.js";const Ko={class:"d-flex align-center justify-end mb-5"},Po={style:{width:"500px"}},Wo={class:"choose-info"},Xo={class:"choose-info"},qo={key:0,class:"d-flex align-center justify-space-between",style:{width:"460px"}},Qo={class:"font-outside-title"},Yo={key:1,class:"d-flex align-center justify-space-between pt-2",style:{width:"460px"}},Zo={key:0,class:"d-flex align-center choose-info2"},mo={class:"mr-2"},oe={key:1,class:"d-flex align-center change-group-name-box"},ee={class:"d-flex align-center"},ne=go({__name:"index",setup(le){const Q=ko(),B=yo(),t=r([]),b=r({}),Y=()=>{t.value.sort((n,e)=>{if(!(n.type===1||e.type===1))return e.sortNum-n.sortNum})},M=()=>{Fo().then(n=>{p.value=[],t.value=n.data.records,Y(),t.value.forEach(e=>{b.value[e.id]="";const l=r(0);e.fonts.forEach(o=>{o.show&&(l.value+=1)}),l.value===e.fonts.length?e.showAll=!0:e.showAll=!1,p.value.push({name:e.name,id:e.id,chooseNum:l.value})})})};M();const p=r([]),Z=async(n,e)=>{n.show=!n.show,n.show?await No({id:n.id}):await Ao({id:n.id}),t.value.forEach(l=>{const o=r(0),u=r(0);l.type===1&&(l.fonts.forEach(d=>{d.show?o.value+=1:u.value+=1}),u.value===l.fonts.length&&(X({id:l.id}),l.showAll=!1),o.value===l.fonts.length&&(q({id:l.id}),l.showAll=!0),p.value.forEach(d=>{e.id===d.id&&(l.chooseNum=o.value)}))})},m=async n=>{n.showAll?await X({id:n.id}):await q({id:n.id});const e=r(0);t.value.forEach(l=>{if(l.type===1){l.showAll=!l.showAll;const o=r(!1);l.showAll?o.value=!0:o.value=!1,l.fonts.forEach(u=>{u.show=o.value,u.show&&(e.value+=1)})}}),p.value.forEach(l=>{n.id===l.id&&(l.chooseNum=e.value)})},T=r({}),oo=r(null),eo=n=>{oo.value=n,b.value[n.id]=n.name,T.value[n.id]=!0},no=n=>{Uo({id:n.id,name:b.value[n.id]}).then(e=>{n.name=b.value[n.id],T.value[n.id]=!1,p.value.forEach(l=>{n.id===l.id&&(l.name=b.value[n.id])})})},F=r(!1),U=r(""),j=r(""),H=r(null),V=r(null),lo=(n,e)=>{U.value="Delete Font",j.value="Are you sure you want to delete this font?",F.value=!0,H.value=e.id,V.value=n.id},so=n=>{U.value="Delete Font Group",j.value="Are you sure you want to delete the entire font group?",F.value=!0,V.value=n.id},to=()=>{U.value==="Delete Font"?Eo({id:H.value}).then(n=>{t.value.forEach(e=>{const l=e.fonts.findIndex(o=>o.id===H.value);l!==-1&&e.fonts.splice(l,1)}),p.value.forEach(e=>{V.value===e.id&&(e.chooseNum-=1)}),B.changeSnackbar({color:"#7367f0",location:"top",variant:"elevated",text:"Delete Successfully !",visible:!0})}):$o({id:V.value}).then(n=>{const e=t.value.findIndex(o=>o.id===V.value);e!==-1&&t.value.splice(e,1);const l=p.value.findIndex(o=>o.id===V.value);l!==-1&&p.value.splice(l,1),B.changeSnackbar({color:"#7367f0",location:"top",variant:"elevated",text:"Delete Successfully !",visible:!0})})},R=(n,e,l)=>{const o=n.findIndex(_=>_.id===e),u=n.findIndex(_=>_.id===l);if(o===-1||u===-1)return;const[d]=n.splice(o,1);n.splice(u,0,d)},ao=n=>{const e=t.value.find(l=>l.fonts.some(o=>o.id===n));if(e){const l=e.fonts.findIndex(o=>o.id===n);l>0&&R(e.fonts,n,e.fonts[l-1].id)}},ro=n=>{const e=t.value.find(l=>l.fonts.some(o=>o.id===n));if(e){const l=e.fonts.findIndex(o=>o.id===n);l<e.fonts.length-1&&R(e.fonts,n,e.fonts[l+1].id)}},uo=n=>{Lo({id:n.id}).then(e=>{ao(n.id)})},io=n=>{zo({id:n.id}).then(e=>{ro(n.id)})},O=(n,e)=>{const l=t.value.findIndex(d=>d.id===n),o=t.value.findIndex(d=>d.id===e);if(l===-1||o===-1)return;const[u]=t.value.splice(l,1);t.value.splice(o,0,u)},co=n=>{const e=t.value.findIndex(l=>l.id===n);e>0&&O(n,t.value[e-1].id)},fo=n=>{const e=t.value.findIndex(l=>l.id===n);e<t.value.length-1&&O(n,t.value[e+1].id)},po=n=>{Bo({id:n.id}).then(e=>{co(n.id)})},vo=n=>{Mo({id:n.id}).then(e=>{fo(n.id)})},E=r(!1),$=r(!1),ho=n=>{To({name:n}).then(e=>{B.changeSnackbar({color:"#7367f0",location:"top",variant:"elevated",text:"Add Font Group Successfully !",visible:!0}),M()})},wo=()=>{M();const n=document.getElementById("fontsLink");n&&n.remove();const e=document.createElement("link");e.id="fontsLink",e.rel="stylesheet",e.href=`https://www.artshiney.com/shopapi/common/fonts.css?merchantId=${Q.getUserBaseInfo.id}`,document.head.appendChild(e)};return(n,e)=>{const l=xo;return c(),I(W,null,[s(Do,null,{default:a(()=>[s(Co,null,{default:a(()=>[e[11]||(e[11]=h("div",{class:"font-title"},"Custome Jewelry Font",-1)),h("div",Ko,[s(J,{variant:"outlined",onClick:e[0]||(e[0]=o=>E.value=!0)},{default:a(()=>e[9]||(e[9]=[K("Add Other Font")])),_:1,__:[9]}),s(J,{class:"ml-5",variant:"outlined",onClick:e[1]||(e[1]=o=>$.value=!0)},{default:a(()=>e[10]||(e[10]=[K("Create New Font Group")])),_:1,__:[10]})]),h("div",Po,[s(Ho,{label:"Font Library",modelValue:f(p),"onUpdate:modelValue":e[4]||(e[4]=o=>z(p)?p.value=o:null),items:f(t)},{selection:a(({item:o,index:u})=>{var d,_;return[h("div",null,[h("span",Wo,'" '+A((d=o==null?void 0:o.raw)==null?void 0:d.name)+' " Selected',1),h("span",Xo," "+A((_=o==null?void 0:o.raw)==null?void 0:_.chooseNum)+" ,",1)])]}),item:a(({item:o,index:u,props:d})=>[s(Ro,null,{default:a(()=>{var _;return[s(Oo,null,{default:a(()=>{var v,D,N,x,g,L;return[((v=o==null?void 0:o.raw)==null?void 0:v.type)===1?(c(),I("div",qo,[h("div",Qo,A((D=o==null?void 0:o.raw)==null?void 0:D.name),1),s(C,{text:(N=o==null?void 0:o.raw)!=null&&N.showAll?"Hide":"Show"},{activator:a(({props:i})=>{var k;return[s(w,y(i,{icon:(k=o==null?void 0:o.raw)!=null&&k.showAll?"custom-eye-line":"custom-eye-off-line",size:"large",color:"#000000",onClick:se=>m(o==null?void 0:o.raw)}),null,16,["icon","onClick"])]}),_:2},1032,["text"])])):(c(),I("div",Yo,[f(T)[(x=o==null?void 0:o.raw)==null?void 0:x.id]?(c(),I("div",oe,[s(_o,{class:"change-group-name-input",modelValue:f(b)[(L=o==null?void 0:o.raw)==null?void 0:L.id],"onUpdate:modelValue":i=>{var k;return f(b)[(k=o==null?void 0:o.raw)==null?void 0:k.id]=i},label:"Font Group Name",onKeydown:e[2]||(e[2]=P(()=>{},["stop"])),variant:"outlined",onMousedown:e[3]||(e[3]=P(()=>{},["stop"]))},null,8,["modelValue","onUpdate:modelValue"]),s(C,{text:"Confirm Group Name Change"},{activator:a(({props:i})=>[s(w,y(i,{icon:"custom-check-double-line ml-2",onClick:k=>no(o==null?void 0:o.raw),size:"large"}),null,16,["onClick"])]),_:2},1024)])):(c(),I("div",Zo,[h("div",mo,A((g=o==null?void 0:o.raw)==null?void 0:g.name),1),s(C,{text:"Change Group Name"},{activator:a(({props:i})=>[s(w,y(i,{icon:"custom-edit-line",onClick:k=>eo(o==null?void 0:o.raw)}),null,16,["onClick"])]),_:2},1024)])),h("div",null,[u!==0&&u!==1?(c(),S(C,{key:0,text:"Move up"},{activator:a(({props:i})=>[s(w,y(i,{class:"cursor-pointer",icon:"custom-corner-left-up-line",size:"large",color:"#000000",onClick:k=>po(o==null?void 0:o.raw)}),null,16,["onClick"])]),_:2},1024)):G("",!0),u!==f(t).length-1?(c(),S(C,{key:1,text:"Move down"},{activator:a(({props:i})=>[s(w,y(i,{class:"cursor-pointer",icon:"custom-corner-right-down-line",size:"large",color:"#000000",onClick:k=>vo(o==null?void 0:o.raw)}),null,16,["onClick"])]),_:2},1024)):G("",!0),s(C,{text:"Delete"},{activator:a(({props:i})=>[s(w,y(i,{icon:"custom-delete-bin-line",onClick:k=>so(o==null?void 0:o.raw),size:"large",color:"#000000"}),null,16,["onClick"])]),_:2},1024)])]))]}),_:2},1024),(c(!0),I(W,null,bo((_=o==null?void 0:o.raw)==null?void 0:_.fonts,(v,D)=>(c(),S(Jo,{key:D,class:"mr-1"},{title:a(()=>[h("div",ee,[s(w,{icon:"custom-checkbox-blank-circle-line mr-2",size:"12"}),h("div",{style:So({"font-family":v.uid})},A(v.name),5)])]),append:a(()=>{var N;return[D!==0?(c(),S(C,{key:0,text:"Move up"},{activator:a(({props:x})=>[s(w,y({ref_for:!0},x,{class:"cursor-pointer",icon:"custom-corner-left-up-line",size:"large",color:"#000000",onClick:g=>uo(v)}),null,16,["onClick"])]),_:2},1024)):G("",!0),D!==((N=o==null?void 0:o.raw)==null?void 0:N.fonts.length)-1?(c(),S(C,{key:1,text:"Move down"},{activator:a(({props:x})=>[s(w,y({ref_for:!0},x,{class:"cursor-pointer",icon:"custom-corner-right-down-line",size:"large",color:"#000000",onClick:g=>io(v)}),null,16,["onClick"])]),_:2},1024)):G("",!0),s(C,{text:v.show?"Hide":"Show"},{activator:a(({props:x})=>{var g;return[((g=o==null?void 0:o.raw)==null?void 0:g.type)===1?(c(),S(w,y({key:0,ref_for:!0},x,{icon:v.show?"custom-eye-line":"custom-eye-off-line",color:"#000000",onClick:L=>Z(v,o==null?void 0:o.raw)}),null,16,["icon","onClick"])):G("",!0)]}),_:2},1032,["text"]),s(C,{text:"Delete"},{activator:a(({props:x})=>{var g;return[((g=o==null?void 0:o.raw)==null?void 0:g.type)===2?(c(),S(w,y({key:0,ref_for:!0},x,{icon:"custom-delete-bin-line",color:"#000000",onClick:L=>lo(o==null?void 0:o.raw,v)}),null,16,["onClick"])):G("",!0)]}),_:2},1024)]}),_:2},1024))),128))]}),_:2},1024),s(Vo)]),_:1},8,["modelValue","items"])])]),_:1,__:[11]})]),_:1}),s(Go,{"upload-font-visible":f(E),"onUpdate:uploadFontVisible":e[5]||(e[5]=o=>z(E)?E.value=o:null),"fonts-data":f(t),"onChange:addSuccess":e[6]||(e[6]=o=>wo())},null,8,["upload-font-visible","fonts-data"]),s(jo,{"created-font-visible":f($),"onUpdate:createdFontVisible":e[7]||(e[7]=o=>z($)?$.value=o:null),"onChange:groupName":ho},null,8,["created-font-visible"]),s(l,{"open-or-close-delete-dialog-visible":f(F),"onUpdate:openOrCloseDeleteDialogVisible":e[8]||(e[8]=o=>z(F)?F.value=o:null),"delete-title":f(U),"delete-text":f(j),"onChange:confirmDelete":to},null,8,["open-or-close-delete-dialog-visible","delete-title","delete-text"])],64)}}}),_e=Io(ne,[["__scopeId","data-v-ab38e192"]]);export{_e as default};