2 lines
8.7 KiB
JavaScript
2 lines
8.7 KiB
JavaScript
import{U as we}from"./KYGZybbC.js";import{d as ne,u as Se,r as t,H as re,cZ as ke,l as be,I as ue,o as ce,ag as de,bc as Ie,a0 as se,af as ae,aj as Ce,z as l,A as f,a1 as M,B as u,D as k,U as ve,E as A,a2 as V,bT as B,a6 as ie,K as o,T as S,C as R,G as X,c_ as Ee,d0 as De,d1 as Le}from"./CE4SaZgW.js";import{B as j}from"./DAaUah2x.js";import{d as Te}from"./DEFgvqDI.js";import{_ as He,C as Re,i as oe}from"./CzGVe8d-.js";import{S as $e,a as Pe}from"./CUkMw_9s.js";/* empty css */import{u as Ue}from"./BMvqCgID.js";import{e as le}from"./DPkf2bcV.js";import{r as ze}from"./CkPaWjHN.js";import{s as Be}from"./BiK9i_Zy.js";import{_ as Me}from"./DlAUqK2U.js";const Ae={class:"flex full_story z-400 justify-center"},Xe={key:0,class:"absolute w-full top-0 right-0 left-0 z-1000"},je={class:"flex items-center gap-2"},qe={class:"relative"},Ye={class:"w-2.5rem h-2.5rem rounded-full",alt:""},Ne={key:0,src:He,alt:"",class:"w-15px absolute right-0 bottom-0 bg-white rounded-full"},Oe={class:"text-gray-200 text-shadow text-xs"},We={class:"w-full"},Ve={key:0,class:"absolute w-full bottom-0 right-0 left-0 z-1000 flex items-center gap8 px5 functions_area"},Fe={class:"flex flex-col items-center gap-2 text-white functions-area basic-icon-old"},Ge={class:"text-xs text-red-6"},Ke={class:"flex flex-col items-center gap-2 text-white functions-area basic-icon-old"},Ze={class:"text-xs"},Je=ne({__name:"HighlightStories",props:{id:{},specifyId:{type:Boolean,default:!1},stories:{},highlightId:{},cover:{},title:{}},emits:["update:id","refresh"],setup(q,{emit:$}){const D=Se();t();const h=t(null),i=t(0),n=t(0),b=t(0);t("");const c=re(),v=q,p=$,m=t([]),s=t(null),{direction:Y,isSwiping:P}=ke(s);t(!1),t(!1),t(!1);const U=be(()=>{if(v.stories?.length)return v.stories[i.value]});let L;const N=Ue();ue();const _=t(!1),y=t(!1);t(!1);let I,T=!1,z=0,a=!1;function w(e){c.isSeller?D.push({name:"add-story"}):D.push({name:"user_detail-id",params:{id:U.value?.id}})}function C(e){F=e.touches[0].clientY,z=e.touches[0].clientX,a=!1,T=!1,I=setTimeout(()=>{T=!0,a||fe(e)},300)}function g(e){a||setTimeout(()=>{a=!0,clearTimeout(I)},50)}function H(e){clearTimeout(I);const r=s.value?.querySelector(".account-detail-area"),d=s.value?.querySelector(".functions_area");r&&r.contains(e.target)||d&&d.contains(e.target)||(e.preventDefault(),!T&&!a?Q(e):me(e))}function fe(e){const r=s.value?.querySelector(".account-detail-area"),d=s.value?.querySelector(".functions_area");r&&r.contains(e.target)||d&&d.contains(e.target)||(e.preventDefault(),e.stopPropagation(),_.value=!0,O())}function me(e){e.preventDefault(),e.stopPropagation(),_.value&&Z(),_.value=!1}let F=0;function G(e){(e.touches[0]?.clientY??0)-F>0&&e.preventDefault()}ce(()=>{i.value=v.stories?.findIndex(e=>e?.media?.id===v.id),h.value.activeIndex=i.value,i.value===0&&K(),s.value?.addEventListener("touchstart",C),s.value?.addEventListener("touchend",H),s.value?.addEventListener("touchmove",g),s.value?.addEventListener("touchcancel",H),s.value?.addEventListener("touchmove",G,{passive:!1})}),de(()=>{s.value?.removeEventListener("touchstart",C),s.value?.removeEventListener("touchend",H),s.value?.addEventListener("touchmove",g),s.value?.removeEventListener("touchcancel",H),s.value?.removeEventListener("touchmove",G)}),Ie(()=>{P.value&&Y.value==="down"&&p("update:id",void 0)}),se(i,async e=>{await K()});async function K(){b.value=v.stories?.length,m.value=[],await ae(),h.value&&(h.value.activeIndex=i.value);for(let e=0;e<b.value;e++)m.value.push(0);O(),Z()}const he=e=>{h.value=e,y.value=!0},ge=e=>{if(!y.value)return;const r=e?.activeIndex;n.value!==r&&(n.value=r)};function Z(){L=Be(()=>{n.value<m.value.length&&(m.value[n.value]+=10,m.value[n.value]>100&&J())},1e3)}function O(){clearInterval(L),L=void 0}function J(){b.value>n.value+1?n.value++:(O(),n.value=0,_e())}function pe(){n.value!==0?n.value--:ye()}function _e(){v.specifyId?p("update:id",void 0):N.users.length>i.value+1?i.value++:p("update:id",void 0)}function Q(e){if(e.target.closest(".basic-icon-old"))return;const d=s.value?.querySelector(".account-detail-area"),x=s.value?.querySelector(".functions_area");if(d&&d.contains(e.target)||x&&x.contains(e.target))return;const E=e.currentTarget?.clientWidth;let W=0;"touches"in e?W=z:e instanceof MouseEvent&&(W=e.offsetX),W>E/2?c.isRtl?ee():te():c.isRtl?te():ee()}function ee(){m.value[n.value]=100,J()}function te(){m.value[n.value]=0,m.value[n.value-1]=0,pe()}function ye(){i.value!==0&&!v.specifyId&&i.value--}async function xe(){await Ee(c.useString("areYouSureToDeleteThisHighlight"),v.highlightId??"",ze,()=>p("refresh"))}return se([n,y],([e,r])=>{if(!r||!h.value||!v.stories?.length)return;const d=Math.max(0,Math.min(e,v.stories.length-1));h.value.activeIndex!==d&&setTimeout(()=>{try{h.value?.slideTo(d)}catch{y.value=!1,ae(()=>y.value=!0)}},50)},{immediate:!0}),(e,r)=>{const d=Ce("lazy");return l(),f(M,null,[u("div",Ae,[u("div",{ref_key:"target",ref:s,class:"relative w-full md:w-426px bg-black flex items-center",onClick:Q},[k(ve,{name:"fade"},{default:A(()=>[_.value?S("",!0):(l(),f("div",Xe,[(l(),f("div",{class:"flex gap-2px shadow-xl",key:i.value},[(l(!0),f(M,null,V(e.stories,(x,E)=>(l(),X(Re,{key:E,rtl:o(c).isRTL,percent:m.value[E]},null,8,["rtl","percent"]))),128))])),u("div",{class:"p-2 flex items-center gap-2 account-detail-area justify-between",onClick:B(w,["prevent"])},[u("div",je,[u("div",qe,[ie(u("img",Ye,null,512),[[d,{src:o(c).useDataStorage(e.cover),loading:o(le),error:o(le)}]]),o(c).isSeller?(l(),f("img",Ne)):S("",!0)]),u("div",Oe,R(e.title),1)]),k(j,{icon:"vuesax-linear:add",class:"text-white rotate-45",size:"32",onClick:r[0]||(r[0]=B(x=>p("update:id",void 0),["stop","prevent"]))})])]))]),_:1}),u("div",We,[(l(),X(o($e),{key:i.value,ref_key:"swiperRef",ref:h,onSwiper:he,onSlideChange:ge,initialSlide:i.value,grabCursor:!0,modules:[],speed:0,noSwiping:!0,class:"mySwiper6"},{default:A(()=>[(l(!0),f(M,null,V(e.stories,(x,E)=>(l(),X(o(Pe),{key:E,class:"self-center"},{default:A(()=>[ie((l(),f("img",{alt:"instagram",class:"w-full bg-black pointer-events-none",key:i.value})),[[d,{src:o(c).useDataStorage(x?.media?.media_url),loading:o(oe),error:o(oe)}]])]),_:2},1024))),128))]),_:1},8,["initialSlide"]))])],512)]),_.value?S("",!0):(l(),f("div",Ve,[o(c).isSeller?(l(),f("div",{key:0,class:"flex gap-5 items-center",dir:"rtl",onClick:B(xe,["stop"])},[u("div",Fe,[k(j,{icon:"vuesax-linear:trash",color:"red",size:"22",class:"h7"}),u("div",Ge,R(o(c).useString("delete")),1)])])):S("",!0),o(c).isSeller?(l(),f("div",{key:1,class:"flex gap-5 items-center",dir:"rtl",onClick:r[1]||(r[1]=B(x=>o(D).push({name:"highlight-edit-id",params:{id:e.highlightId}}),["stop"]))},[u("div",Ke,[k(j,{icon:"vuesax-linear:edit-2",size:"22",class:"h6"}),u("div",Ze,R(o(c).useString("edit")),1)])])):S("",!0)]))],64)}}}),Qe=Object.assign(Je,{__name:"HighlightStories"}),et={class:"stories-container -ms4"},tt={class:"border-gray-600 border-1 border-solid w-70px h-70px rounded-full flex items-center justify-center"},st={class:"text-center text-xs mt-7px"},at=["onClick"],it={class:"text-center"},ot={class:"w-full text-center text-xs truncate"},lt=ne({__name:"Highlights",props:{currentUser:{}},setup(q){const $=t([]),D=De(),h=Le(),i=t(null),n=t(null),b=t(null),c=t(null),v=t(null),p=t([]),m=t(!1),s=re(),{user:Y}=ue();let P,U;const L=q,N=a=>{window.innerWidth<426||(m.value=!0,P=a.clientX,U=v.value.scrollLeft)},_=()=>{m.value=!1},y=a=>{if(!m.value)return;const C=(a.clientX-P)*2;v.value.scrollLeft=U-C},I=async()=>{try{const a=await Te(h?.params?.id||s?.sellerConfig?.store.id,{page:1,limit:40});$.value=a}catch(a){console.log(a)}},T=a=>{console.log(a),i.value=a?.cover_media_url,n.value=a?.id,c.value=a?.cover_media_url,b.value=a?.title,p.value=a?.stories};function z(){I(),i.value=null}return ce(async()=>{document.addEventListener("mouseup",_),document.addEventListener("mousemove",y),await I()}),de(()=>{document.removeEventListener("mouseup",_),document.removeEventListener("mousemove",y)}),(a,w)=>{const C=we;return l(),f("div",et,[u("div",{ref_key:"scrollContainer",ref:v,class:"scroll-wrapper ps-3 sm:min-w-16vw",onMousedown:N},[o(Y)?.id===L.currentUser?.id?(l(),f("div",{key:0,class:"me-2",onClick:w[0]||(w[0]=()=>o(D).push({name:"highlight-create"}))},[u("div",tt,[k(j,{icon:"vuesax-linear:add"})]),u("div",st,R(o(s).useString("new")),1)])):S("",!0),(l(!0),f(M,null,V($.value,g=>(l(),f("div",{key:g?.id,onClick:H=>T(g),class:"story"},[u("div",it,[k(C,{src:g?.cover_media_url,"seen-story":!0,width:"75"},null,8,["src"])]),u("div",ot,R(g?.title),1)],8,at))),128))],544),k(ve,{name:"slide-up",mode:"out-in"},{default:A(()=>[i.value?(l(),X(Qe,{key:0,id:i.value,"onUpdate:id":w[1]||(w[1]=g=>i.value=g),highlightId:n.value,title:b.value,cover:c.value,stories:p.value,onRefresh:z},null,8,["id","highlightId","title","cover","stories"])):S("",!0)]),_:1})])}}}),yt=Object.assign(Me(lt,[["__scopeId","data-v-ef0e0d45"]]),{__name:"Highlights"});export{yt as H};
|