8 lines
32 KiB
JavaScript
8 lines
32 KiB
JavaScript
import{d as j,a$ as Je,s as se,e as Qe,C as w,k as G,aJ as x,bv as et,aY as Y,aZ as tt,aL as Re,r as L,K as _e,bi as nt,b1 as ot,bX as $e,bV as st,af as oe,bu as ze,aQ as ye,aR as le,cu as U,aX as it,aW as at,b5 as rt,bd as Le,cA as lt,aM as ut,a1 as Ae,bS as dt,b_ as ct,u as be,G as X,o as ce,al as pe,y as b,z as h,A as r,H as c,D as K,a2 as J,a3 as ue,F as ie,am as ae,a7 as re,ak as Ce,B as P,U as pt,J as Q,S as q,E as Pe,I as Ie,cH as He,aA as Ve,az as ke,N as mt,a5 as ft,a4 as ve,a9 as ge,a8 as vt,Q as gt}from"./G_17LgpR.js";import{e as ne}from"./DWEdiVkG.js";import{f as ht,a as De}from"./C3gkR5pj.js";import{S as wt,a as xt}from"./DiiZMebn.js";/* empty css *//* empty css */import{P as yt}from"./5EiETixP.js";import{i as Oe}from"./B9nbzEx0.js";import{B as de}from"./DUAMdf4s.js";import{_ as _t}from"./DlAUqK2U.js";import{_ as Se}from"./CNxSHjm0.js";import{C as Ue}from"./CgJkSVJR.js";import{B as bt}from"./C_gIYN7y.js";import{U as Ct}from"./wt3vyHO9.js";import"./DFUQTW3o.js";import{B as kt}from"./C1vz2RTh.js";import{T as St}from"./CKbLd5ES.js";import{M as $t,_ as he,u as Lt}from"./CL-FXKZS.js";import{S as We}from"./aNyYT5DR.js";import{B as Pt}from"./ToDZsT2k.js";import{u as It,b as Ot}from"./DYXDK3m5.js";import{g as Mt,a as Me}from"./ycclw7qJ.js";import{i as Tt,g as Bt,c as Ft,d as Et,a as Nt,e as jt}from"./C7wQ3vfD.js";function Rt(e){const{selectionStart:s}=e;return e.value.slice(0,s)}function zt(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return(Array.isArray(s)?s:[s]).reduce((t,o)=>{const u=e.lastIndexOf(o);return u>t.location?{location:u,prefix:o}:t},{location:-1,prefix:""})}function Te(e){return(e||"").toLowerCase()}function At(e,s,n){const t=e[0];if(!t||t===n)return e;let o=e;const u=s.length;for(let i=0;i<u;i+=1)if(Te(o[i])!==Te(s[i])){o=o.slice(i);break}else i===u-1&&(o=o.slice(u));return o}function Ht(e,s){const{measureLocation:n,prefix:t,targetText:o,selectionStart:u,split:i}=s;let l=e.slice(0,n);l[l.length-i.length]===i&&(l=l.slice(0,l.length-i.length)),l&&(l=`${l}${i}`);let p=At(e.slice(u),o.slice(u-n-t.length),i);p.slice(0,i.length)===i&&(p=p.slice(i.length));const d=`${l}${t}${o}${i}`;return{text:`${d}${p}`,selectionLocation:d.length}}function Vt(e,s){e.setSelectionRange(s,s),e.blur(),e.focus()}function Dt(e,s){const{split:n}=s;return!n||e.indexOf(n)===-1}function Ut(e,s){let{value:n=""}=s;const t=e.toLowerCase();return n.toLowerCase().indexOf(t)!==-1}const Ke=Symbol("MentionsContextKey");function Wt(){}const Kt=j({compatConfig:{MODE:3},name:"DropdownMenu",props:{prefixCls:String,options:{type:Array,default:()=>[]}},setup(e,s){let{slots:n}=s;const{activeIndex:t,setActiveIndex:o,selectOption:u,onFocus:i=Wt,loading:l}=Je(Ke,{activeIndex:se(),loading:se(!1)});let p;const d=y=>{clearTimeout(p),p=setTimeout(()=>{i(y)})};return Qe(()=>{clearTimeout(p)}),()=>{var y;const{prefixCls:C,options:M}=e,a=M[t.value]||{};return w($t,{prefixCls:`${C}-menu`,activeKey:a.value,onSelect:g=>{let{key:I}=g;const _=M.find(T=>{let{value:F}=T;return F===I});u(_)},onMousedown:d},{default:()=>[!l.value&&M.map((g,I)=>{var _,T;const{value:F,disabled:R,label:A=g.value,class:H,style:W}=g;return w(he,{key:F,disabled:R,onMouseenter:()=>{o(I)},class:H,style:W},{default:()=>[(T=(_=n.option)===null||_===void 0?void 0:_.call(n,g))!==null&&T!==void 0?T:typeof A=="function"?A(g):A]})}),!l.value&&M.length===0?w(he,{key:"notFoundContent",disabled:!0},{default:()=>[(y=n.notFoundContent)===null||y===void 0?void 0:y.call(n)]}):null,l.value&&w(he,{key:"loading",disabled:!0},{default:()=>[w(We,{size:"small"},null)]})]})}}}),qt={bottomRight:{points:["tl","br"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},bottomLeft:{points:["tr","bl"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},topRight:{points:["bl","tr"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topLeft:{points:["br","tl"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}},Xt=j({compatConfig:{MODE:3},name:"KeywordTrigger",props:{loading:{type:Boolean,default:void 0},options:{type:Array,default:()=>[]},prefixCls:String,placement:String,visible:{type:Boolean,default:void 0},transitionName:String,getPopupContainer:Function,direction:String,dropdownClassName:String},setup(e,s){let{slots:n}=s;const t=()=>`${e.prefixCls}-dropdown`,o=()=>{const{options:i}=e;return w(Kt,{prefixCls:t(),options:i},{notFoundContent:n.notFoundContent,option:n.option})},u=G(()=>{const{placement:i,direction:l}=e;let p="topRight";return l==="rtl"?p=i==="top"?"topLeft":"bottomLeft":p=i==="top"?"topRight":"bottomRight",p});return()=>{const{visible:i,transitionName:l,getPopupContainer:p}=e;return w(St,{prefixCls:t(),popupVisible:i,popup:o(),popupClassName:e.dropdownClassName,popupPlacement:u.value,popupTransitionName:l,builtinPlacements:qt,getPopupContainer:p},{default:n.default})}}}),Zt=tt("top","bottom"),qe={autofocus:{type:Boolean,default:void 0},prefix:Y.oneOfType([Y.string,Y.arrayOf(Y.string)]),prefixCls:String,value:String,disabled:{type:Boolean,default:void 0},split:String,transitionName:String,placement:Y.oneOf(Zt),character:Y.any,characterRender:Function,filterOption:{type:[Boolean,Function]},validateSearch:Function,getPopupContainer:{type:Function},options:et(),loading:{type:Boolean,default:void 0},rows:[Number,String],direction:{type:String}},Xe=x(x({},qe),{dropdownClassName:String}),Ze={prefix:"@",split:" ",rows:1,validateSearch:Dt,filterOption:()=>Ut};Re(Xe,Ze);var Be=function(e,s){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&s.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++)s.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(n[t[o]]=e[t[o]]);return n};function Fe(){}const Yt=j({compatConfig:{MODE:3},name:"Mentions",inheritAttrs:!1,props:Re(Xe,Ze),emits:["change","select","search","focus","blur","pressenter"],setup(e,s){let{emit:n,attrs:t,expose:o,slots:u}=s;const i=L(null),l=L(null),p=L(),d=_e({value:e.value||"",measuring:!1,measureLocation:0,measureText:null,measurePrefix:"",activeIndex:0,isFocus:!1});nt(()=>{d.value=e.value});const y=f=>{n("change",f)},C=f=>{let{target:{value:m}}=f;y(m)},M=(f,m,k)=>{x(d,{measuring:!0,measureText:f,measurePrefix:m,measureLocation:k,activeIndex:0})},a=f=>{x(d,{measuring:!1,measureLocation:0,measureText:null}),f?.()},g=f=>{const{which:m}=f;if(d.measuring){if(m===U.UP||m===U.DOWN){const k=V.value.length,S=m===U.UP?-1:1,v=(d.activeIndex+S+k)%k;d.activeIndex=v,f.preventDefault()}else if(m===U.ESC)a();else if(m===U.ENTER){if(f.preventDefault(),!V.value.length){a();return}const k=V.value[d.activeIndex];H(k)}}},I=f=>{const{key:m,which:k}=f,{measureText:S,measuring:v}=d,{prefix:$,validateSearch:z}=e,O=f.target;if(O.composing)return;const N=Rt(O),{location:E,prefix:B}=zt(N,$);if([U.ESC,U.UP,U.DOWN,U.ENTER].indexOf(k)===-1)if(E!==-1){const D=N.slice(E+B.length),ee=z(D,e),te=!!Z(D).length;ee?(m===B||m==="Shift"||v||D!==S&&te)&&M(D,B,E):v&&a(),ee&&n("search",D,B)}else v&&a()},_=f=>{d.measuring||n("pressenter",f)},T=f=>{R(f)},F=f=>{A(f)},R=f=>{clearTimeout(p.value);const{isFocus:m}=d;!m&&f&&n("focus",f),d.isFocus=!0},A=f=>{p.value=setTimeout(()=>{d.isFocus=!1,a(),n("blur",f)},100)},H=f=>{const{split:m}=e,{value:k=""}=f,{text:S,selectionLocation:v}=Ht(d.value,{measureLocation:d.measureLocation,targetText:k,prefix:d.measurePrefix,selectionStart:l.value.getSelectionStart(),split:m});y(S),a(()=>{Vt(l.value.input,v)}),n("select",f,d.measurePrefix)},W=f=>{d.activeIndex=f},Z=f=>{const m=f||d.measureText||"",{filterOption:k}=e;return e.options.filter(v=>k?k(m,v):!0)},V=G(()=>Z());return o({blur:()=>{l.value.blur()},focus:()=>{l.value.focus()}}),ot(Ke,{activeIndex:$e(d,"activeIndex"),setActiveIndex:W,selectOption:H,onFocus:R,onBlur:A,loading:$e(e,"loading")}),st(()=>{oe(()=>{d.measuring&&(i.value.scrollTop=l.value.getScrollTop())})}),()=>{const{measureLocation:f,measurePrefix:m,measuring:k}=d,{prefixCls:S,placement:v,transitionName:$,getPopupContainer:z,direction:O}=e,N=Be(e,["prefixCls","placement","transitionName","getPopupContainer","direction"]),{class:E,style:B}=t,D=Be(t,["class","style"]),ee=ze(N,["value","prefix","split","validateSearch","filterOption","options","loading"]),te=x(x(x({},ee),D),{onChange:Fe,onSelect:Fe,value:d.value,onInput:C,onBlur:F,onKeydown:g,onKeyup:I,onFocus:T,onPressenter:_});return w("div",{class:ye(S,E),style:B},[w(Pt,le(le({},te),{},{ref:l,tag:"textarea"}),null),k&&w("div",{ref:i,class:`${S}-measure`},[d.value.slice(0,f),w(Xt,{prefixCls:S,transitionName:$,dropdownClassName:e.dropdownClassName,placement:v,options:k?V.value:[],visible:!0,direction:O,getPopupContainer:z},{default:()=>[w("span",null,[m])],notFoundContent:u.notFoundContent,option:u.option}),d.value.slice(f+m.length)])])}}}),Gt={value:String,disabled:Boolean,payload:it()},Ye=x(x({},Gt),{label:at([])}),Ge={name:"Option",props:Ye,render(e,s){let{slots:n}=s;var t;return(t=n.default)===null||t===void 0?void 0:t.call(n)}};j(x({compatConfig:{MODE:3}},Ge));const Jt=e=>{const{componentCls:s,colorTextDisabled:n,controlItemBgHover:t,controlPaddingHorizontal:o,colorText:u,motionDurationSlow:i,lineHeight:l,controlHeight:p,inputPaddingHorizontal:d,inputPaddingVertical:y,fontSize:C,colorBgElevated:M,borderRadiusLG:a,boxShadowSecondary:g}=e,I=Math.round((e.controlHeight-e.fontSize*e.lineHeight)/2);return{[s]:x(x(x(x(x({},Le(e)),Bt(e)),{position:"relative",display:"inline-block",height:"auto",padding:0,overflow:"hidden",lineHeight:l,whiteSpace:"pre-wrap",verticalAlign:"bottom"}),Ft(e,s)),{"&-disabled":{"> textarea":x({},jt(e))},"&-focused":x({},Nt(e)),[`&-affix-wrapper ${s}-suffix`]:{position:"absolute",top:0,insetInlineEnd:d,bottom:0,zIndex:1,display:"inline-flex",alignItems:"center",margin:"auto"},[`> textarea, ${s}-measure`]:{color:u,boxSizing:"border-box",minHeight:p-2,margin:0,padding:`${y}px ${d}px`,overflow:"inherit",overflowX:"hidden",overflowY:"auto",fontWeight:"inherit",fontSize:"inherit",fontFamily:"inherit",fontStyle:"inherit",fontVariant:"inherit",fontSizeAdjust:"inherit",fontStretch:"inherit",lineHeight:"inherit",direction:"inherit",letterSpacing:"inherit",whiteSpace:"inherit",textAlign:"inherit",verticalAlign:"top",wordWrap:"break-word",wordBreak:"inherit",tabSize:"inherit"},"> textarea":x({width:"100%",border:"none",outline:"none",resize:"none",backgroundColor:"inherit"},Et(e.colorTextPlaceholder)),[`${s}-measure`]:{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,zIndex:-1,color:"transparent",pointerEvents:"none","> span":{display:"inline-block",minHeight:"1em"}},"&-dropdown":x(x({},Le(e)),{position:"absolute",top:-9999,insetInlineStart:-9999,zIndex:e.zIndexPopup,boxSizing:"border-box",fontSize:C,fontVariant:"initial",backgroundColor:M,borderRadius:a,outline:"none",boxShadow:g,"&-hidden":{display:"none"},[`${s}-dropdown-menu`]:{maxHeight:e.dropdownHeight,marginBottom:0,paddingInlineStart:0,overflow:"auto",listStyle:"none",outline:"none","&-item":x(x({},lt),{position:"relative",display:"block",minWidth:e.controlItemWidth,padding:`${I}px ${o}px`,color:u,fontWeight:"normal",lineHeight:l,cursor:"pointer",transition:`background ${i} ease`,"&:hover":{backgroundColor:t},"&:first-child":{borderStartStartRadius:a,borderStartEndRadius:a,borderEndStartRadius:0,borderEndEndRadius:0},"&:last-child":{borderStartStartRadius:0,borderStartEndRadius:0,borderEndStartRadius:a,borderEndEndRadius:a},"&-disabled":{color:n,cursor:"not-allowed","&:hover":{color:n,backgroundColor:t,cursor:"not-allowed"}},"&-selected":{color:u,fontWeight:e.fontWeightStrong,backgroundColor:t},"&-active":{backgroundColor:t}})}})})}},Qt=rt("Mentions",e=>{const s=Tt(e);return[Jt(s)]},e=>({dropdownHeight:250,controlItemWidth:100,zIndexPopup:e.zIndexPopupBase+50}));var Ee=function(e,s){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&s.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++)s.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(n[t[o]]=e[t[o]]);return n};function en(){return!0}const tn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{prefix:n="@",split:t=" "}=s,o=Array.isArray(n)?n:[n];return e.split(t).map(function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i=null;return o.some(l=>u.slice(0,l.length)===l?(i=l,!0):!1),i!==null?{prefix:i,value:u.slice(i.length)}:null}).filter(u=>!!u&&!!u.value)},nn=()=>x(x({},qe),{loading:{type:Boolean,default:void 0},onFocus:{type:Function},onBlur:{type:Function},onSelect:{type:Function},onChange:{type:Function},onPressenter:{type:Function},"onUpdate:value":{type:Function},notFoundContent:Y.any,defaultValue:String,id:String,status:String}),we=j({compatConfig:{MODE:3},name:"AMentions",inheritAttrs:!1,props:nn(),slots:Object,setup(e,s){let{slots:n,emit:t,attrs:o,expose:u}=s;var i,l;const{prefixCls:p,renderEmpty:d,direction:y}=ut("mentions",e),[C,M]=Qt(p),a=se(!1),g=se(null),I=se((l=(i=e.value)!==null&&i!==void 0?i:e.defaultValue)!==null&&l!==void 0?l:""),_=It(),T=Ot.useInject(),F=G(()=>Mt(T.status,e.status));Lt({prefixCls:G(()=>`${p.value}-menu`),mode:G(()=>"vertical"),selectable:G(()=>!1),onClick:()=>{},validator:m=>{let{mode:k}=m}}),Ae(()=>e.value,m=>{I.value=m});const R=m=>{a.value=!0,t("focus",m)},A=m=>{a.value=!1,t("blur",m),_.onFieldBlur()},H=function(){for(var m=arguments.length,k=new Array(m),S=0;S<m;S++)k[S]=arguments[S];t("select",...k),a.value=!0},W=m=>{e.value===void 0&&(I.value=m),t("update:value",m),t("change",m),_.onFieldChange()},Z=()=>{const m=e.notFoundContent;return m!==void 0?m:n.notFoundContent?n.notFoundContent():d("Select")},V=()=>{var m;return dt(((m=n.default)===null||m===void 0?void 0:m.call(n))||[]).map(k=>{var S,v;return x(x({},ct(k)),{label:(v=(S=k.children)===null||S===void 0?void 0:S.default)===null||v===void 0?void 0:v.call(S)})})};u({focus:()=>{g.value.focus()},blur:()=>{g.value.blur()}});const f=G(()=>e.loading?en:e.filterOption);return()=>{const{disabled:m,getPopupContainer:k,rows:S=1,id:v=_.id.value}=e,$=Ee(e,["disabled","getPopupContainer","rows","id"]),{hasFeedback:z,feedbackIcon:O}=T,{class:N}=o,E=Ee(o,["class"]),B=ze($,["defaultValue","onUpdate:value","prefixCls"]),D=ye({[`${p.value}-disabled`]:m,[`${p.value}-focused`]:a.value,[`${p.value}-rtl`]:y.value==="rtl"},Me(p.value,F.value),!z&&N,M.value),ee=x(x(x(x({prefixCls:p.value},B),{disabled:m,direction:y.value,filterOption:f.value,getPopupContainer:k,options:e.loading?[{value:"ANTDV_SEARCHING",disabled:!0,label:w(We,{size:"small"},null)}]:e.options||V(),class:D}),E),{rows:S,onChange:W,onSelect:H,onFocus:R,onBlur:A,ref:g,value:I.value,id:v}),te=w(Yt,le(le({},ee),{},{dropdownClassName:M.value}),{notFoundContent:Z,option:n.option});return C(z?w("div",{class:ye(`${p.value}-affix-wrapper`,Me(`${p.value}-affix-wrapper`,F.value,z),N,M.value)},[te,w("span",{class:`${p.value}-suffix`},[O])]):te)}}}),xe=j(x(x({compatConfig:{MODE:3}},Ge),{name:"AMentionsOption",props:Ye})),on=x(we,{Option:xe,getMentions:tn,install:e=>(e.component(we.name,we),e.component(xe.name,xe),e)}),sn={class:"mt-.5rem"},an={key:0,class:"video-container"},rn=["src"],ln={key:1,class:"w-full aspect-square flex items-center"},un=["alt"],dn={class:"font-semibold font-azar text-xs"},cn={class:"flex items-center"},pn={class:"text-xs"},mn=j({__name:"Content",props:{media:{},name:{},id:{},scrollSave:{}},setup(e){const s=be(),n=X(),t=e,o=L([]);function u(l){const p=document.querySelector(".scrollHome");p&&(sessionStorage.setItem(t.scrollSave,p.scrollTop.toString()),console.log("content",p.scrollTop.toString(),t.scrollSave)),s.push({name:"product_detail-id",params:{id:l}})}ce(()=>{const l={root:null,rootMargin:"0px",threshold:.5},p=y=>{y.forEach(C=>{const M=C.target;C.isIntersecting?M.play():M.pause()})},d=new IntersectionObserver(p,l);o.value.forEach(y=>{d.observe(y)})});const i=[yt];return(l,p)=>{const d=pe("lazy");return h(),b("div",sn,[w(c(wt),{pagination:!0,modules:i,class:"postConfig !h-unset !aspect-square !m-unset"},{default:K(()=>[(h(!0),b(J,null,ue(l.media,y=>(h(),ie(c(xt),{class:"!w-full !h-unset !aspect-square"},{default:K(()=>[y.type==="video"?(h(),b("div",an,[r("video",{ref_for:!0,ref_key:"videos",ref:o,src:c(ae)(y.url),playsinline:"",muted:"",loop:"",class:"video"},null,8,rn)])):(h(),b("div",ln,[re(r("img",{alt:c(Ce),class:"w-full"},null,8,un),[[d,{src:c(ae)(y.url),loading:c(Oe),error:c(Oe)}]])]))]),_:2},1024))),256))]),_:1}),r("div",{class:"flex bg-[#0195f7] text-white px-3 py-3 items-center justify-between",onClick:p[0]||(p[0]=y=>u(l.id))},[r("div",dn,P(l.name),1),r("div",cn,[r("div",pn,P(c(n).useString("viewProduct")),1),w(de,{icon:c(n).isRTL?"vuesax-linear:arrow-left-1":"vuesax-linear:arrow-right-1",size:"16"},null,8,["icon"])])])])}}}),fn=_t(mn,[["__scopeId","data-v-8c70fb9e"]]),vn="data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",gn="data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",hn={key:0,src:vn,alt:"comment","cursor-pointer":""},wn={key:1,src:gn,alt:"comment","cursor-pointer":""},xn=j({__name:"comment",setup(e){const s=X();return(n,t)=>c(s).isNightStore?(h(),b("img",hn)):(h(),b("img",wn))}}),yn="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",_n="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",bn="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='white'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Cn="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='black'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",kn={key:0,src:yn,alt:"comment","cursor-pointer":""},Sn={key:1,src:_n,alt:"comment","cursor-pointer":""},$n={key:0,src:bn,alt:"comment","cursor-pointer":""},Ln={key:1,src:Cn,alt:"comment","cursor-pointer":""},Pn=j({__name:"save",props:{isSaved:{type:Boolean}},setup(e){const s=X();return(n,t)=>(h(),ie(pt,{name:"fade-nav",mode:"out-in"},{default:K(()=>[n.isSaved?(h(),b(J,{key:1},[c(s).isNightStore?(h(),b("img",$n)):(h(),b("img",Ln))],64)):(h(),b(J,{key:0},[c(s).isNightStore?(h(),b("img",kn)):(h(),b("img",Sn))],64))]),_:1}))}}),In="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",On="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Mn={key:0,src:In,alt:"comment","cursor-pointer":""},Tn={key:1,class:"rtl:-scale-x-100",src:On,alt:"comment","cursor-pointer":""},Bn=j({__name:"share",setup(e){const s=X();return(n,t)=>c(s).isNightStore?(h(),b("img",Mn)):(h(),b("img",Tn))}}),Fn=["id"],En={class:"flex px-3 items-center justify-between"},Nn={alt:"instagram",class:"w-2rem h-2rem rounded-full"},jn={class:"ms-2"},Rn={class:"text-sm font-semibold"},zn={key:0},An={class:"p-4"},Hn={class:"flex gap-4 items-center justify-between"},Vn={class:"flex items-center gap-4"},Dn=["aria-disabled"],Un={class:"mt-2 text-sm"},Wn={class:"font-semibold ms1"},Kn={class:"ms-2 font-azar text-xs whitespace-pre-line"},qn={class:"text-xs mt-1 text-gray-500"},Ne=100,Xn=j({__name:"Post",props:{post:{},index:{},scrollSave:{},addLikeLoading:{type:Boolean}},emits:["openOption","openComment","handleLike","handleSave"],setup(e,{emit:s}){const n=be(),t=s,o=X(),u=L({}),i=Q(),l=a=>a?.length>Ne;function p(a){t("openOption",a)}function d(a){t("openComment",a)}async function y(a,g,I){if(navigator.share)try{await navigator.share({title:`${o.lang==="fa"?`${Ie.fa} | ${g}`:`${Ie.en} | ${g}`}`,text:`${I}`,url:`${window.location.origin}/product_detail/${a}`})}catch(_){console.error("Sharing failed",_)}else alert("Web Share API not supported in this browser.")}const C=a=>{u.value={...u.value,[a]:!u.value[a]}},M=a=>l(a)?a?.slice(0,Ne)+"...":a;return(a,g)=>{const I=pe("lazy");return h(),b("div",{class:"w-full mb-2",id:"post-"+a.post.id},[r("div",En,[r("div",{class:"flex items-center",onClick:g[0]||(g[0]=_=>c(n).push({name:"user_detail-id",params:{id:a.post?.users?.id}}))},[re(r("img",Nn,null,512),[[I,{src:c(ae)(a.post?.users?.avatar),loading:c(ne),error:c(ne)}]]),r("div",jn,[r("div",Rn,P(a.post?.users?.username),1)])]),a.post?.users?.id===c(i).user?.id?(h(),b("div",zn,[w(de,{icon:"vuesax-linear:more",class:"rotate-90",size:"18",onClick:g[1]||(g[1]=_=>p(a.post.id))})])):q("",!0)]),w(fn,{media:a.post?.files,name:a.post.title_fa,id:a.post.id,scrollSave:a.scrollSave},null,8,["media","name","id","scrollSave"]),r("div",An,[r("div",Hn,[r("div",Vn,[r("div",{class:"flex items-center gap-1","aria-disabled":a.addLikeLoading,onClick:g[2]||(g[2]=_=>t("handleLike",a.post.likes?.some(T=>T.user_id===c(i).user?.id),a.post?.id))},[w(Se,{"is-liked":a.post.likes?.some(_=>_.user_id===c(i).user?.id)},null,8,["is-liked"]),Pe(" "+P(a.post?.likes?.length??0),1)],8,Dn),r("div",{class:"flex items-center gap-1",onClick:g[3]||(g[3]=_=>d(a.post.id))},[w(xn),Pe(" "+P(a.post?.comments?.length??0),1)]),r("div",{class:"flex items-center gap-1",onClick:g[4]||(g[4]=_=>y(a.post?.id,a.post?.title_fa,a.post?.description))},[w(Bn)])]),r("div",{onClick:g[5]||(g[5]=_=>t("handleSave",a.post.saved?.some(T=>T.user_id===c(i).user?.id),a.post?.id))},[w(Pn,{"is-saved":a.post.saved?.some(_=>_.user_id===c(i).user?.id)},null,8,["is-saved"])])]),r("div",Un,[r("span",Wn,P(a.post?.users?.username),1),r("span",Kn,P(u.value[a.index]?a.post?.description:M(a.post?.description)),1),l(a.post?.description)?(h(),b("span",{key:0,class:"text-gray cursor-pointer ms-1 whitespace-pre-line",onClick:g[6]||(g[6]=_=>C(a.index))},P(u.value[a.index]?c(o).useString("less"):c(o).useString("more")),1)):q("",!0),r("div",qn,P(c(ht)(a.post?.created_at)),1)])])],8,Fn)}}}),Yo=Object.assign(Xn,{__name:"Post"}),Zn=["width","height"],Yn=["y"],Gn=["y"],Go=j({__name:"PostCardSkeleton",setup(e){const s=L(!1),n=L(null),t=_e(He(n,{width:0,height:0},{box:"border-box"}));return ce(async()=>{s.value=!0}),(o,u)=>s.value?(h(),b("div",{key:0,ref_key:"skeletonRatio",ref:n,class:"h-fit"},[w(c(Ue),{width:t.width,height:"800"},{default:K(()=>[u[0]||(u[0]=r("circle",{cx:30,cy:"30",r:"20"},null,-1)),u[1]||(u[1]=r("rect",{x:"60",y:"25",rx:"3",ry:"3",width:"100",height:"10"},null,-1)),r("rect",{x:"0",y:"60",rx:"0",ry:"0",width:Math.max(100,t.width),height:Math.max(0,t.width-100)},null,8,Zn),r("rect",{x:"20",y:Math.max(0,t.width-10),rx:"0",ry:"0",width:300,height:10},null,8,Yn),r("rect",{x:"20",y:Math.max(0,t.width+10),rx:"0",ry:"0",width:300,height:8},null,8,Gn)]),_:1,__:[0,1]},8,["width"])],512)):q("",!0)}}),Jo=async e=>await ke.post("/media/create-like",{product_id:e}),Qo=async e=>Ve.fetch("likes","delete",{field:["user_id","product_id"],value:[Q().user.id,e]}),Jn=async e=>await ke.post("/media/create-comment-like",{comment_id:e}),Qn=async e=>Ve.fetch("likes","delete",{field:["user_id","comment_id"],value:[Q().user.id,e]}),eo={class:"mt-4"},to={class:"flex text-xs gap-2"},no=["alt"],oo={class:"flex-1"},so={class:"flex gap-2 items-center"},io={class:"text-xs text-gray-500"},ao=["aria-disabled"],ro=j({__name:"SubCommentCard",props:{item:{},addLikeLoading:{type:Boolean}},emits:["likeComment","reply"],setup(e,{emit:s}){const n=Q();X();const t=s;return(o,u)=>{const i=pe("lazy");return h(),b("div",eo,[r("div",to,[r("div",null,[re(r("img",{alt:c(Ce),width:"40",class:"rounded-full aspect-square"},null,8,no),[[i,{src:c(ae)(o.item?.user?.avatar),loading:c(ne),error:c(ne)}]])]),r("div",oo,[r("div",so,[r("div",null,P(o.item.user.name),1),r("div",io,P(c(De)(o.item.created_at)),1)]),r("div",null,P(o.item.message),1)]),r("div",{class:"flex flex-col items-center gap-1 w-14px",onClick:u[0]||(u[0]=l=>t("likeComment",o.item.like?.some(p=>p.user_id===c(n).user?.id),o.item.id)),"aria-disabled":o.addLikeLoading},[w(Se,{"is-gray":"","is-liked":o.item.like?.some(l=>l.user_id===c(n).user?.id)},null,8,["is-liked"]),r("div",null,P(o.item.like?.length),1)],8,ao)])])}}}),lo={class:"mb-5"},uo={class:"flex text-xs gap-2"},co=["alt"],po={class:"flex-1"},mo={class:"flex gap-2 items-center"},fo={class:"text-xs text-gray-500"},vo=["aria-disabled"],go={key:1,class:"ms11"},ho=j({__name:"CommentCard",props:{item:{},addLikeLoading:{type:Boolean}},emits:["likeComment","reply"],setup(e,{emit:s}){const n=Q(),t=X(),o=s,u=L(!1);return(i,l)=>{const p=pe("lazy");return h(),b("div",lo,[r("div",uo,[r("div",null,[re(r("img",{alt:c(Ce),width:"40",class:"rounded-full aspect-square"},null,8,co),[[p,{src:c(ae)(i.item.user.avatar),loading:c(ne),error:c(ne)}]])]),r("div",po,[r("div",mo,[r("div",null,P(i.item.user.name),1),r("div",fo,P(c(De)(i.item.created_at)),1)]),r("div",null,P(i.item.message),1),r("div",{class:"text-gray-5",onClick:l[0]||(l[0]=d=>o("reply"))},P(c(t).useString("reply")),1)]),r("div",{class:"flex flex-col items-center gap-1 w-14px","aria-disabled":i.addLikeLoading,onClick:l[1]||(l[1]=d=>o("likeComment",i.item.like?.some(y=>y.user_id===c(n).user?.id),i.item.id,!1,i.item.id))},[w(Se,{"is-gray":"","is-liked":i.item.like?.some(d=>d.user_id===c(n).user?.id)},null,8,["is-liked"]),r("div",null,P(i.item.like?.length),1)],8,vo)]),i.item?.replies?.length>0?(h(),b(J,{key:0},[u.value?(h(),b("div",go,[(h(!0),b(J,null,ue(i.item?.replies,d=>(h(),ie(ro,{item:d,onLikeComment:y=>o("likeComment",d.like?.some(C=>C.user_id===c(n).user?.id),d.id,!0,i.item.id),addLikeLoading:i.addLikeLoading},null,8,["item","onLikeComment","addLikeLoading"]))),256))])):(h(),b("div",{key:0,onClick:l[2]||(l[2]=d=>u.value=!u.value),class:"text-zinc-5 text-xs mt-2 ms-20"},P(c(t).useString("viewMoreReplies",i.item?.replies?.length)),1))],64)):q("",!0)])}}}),wo=["width"],xo=j({__name:"CommentCardSkeleton",setup(e){const s=L(!1),n=L(null),t=_e(He(n,{width:0,height:0},{box:"border-box"}));return ce(async()=>{s.value=!0}),(o,u)=>s.value?(h(),b("div",{key:0,ref_key:"skeletonRatio",ref:n,class:"h-fit"},[w(c(Ue),{width:t.width,height:"60"},{default:K(()=>[u[0]||(u[0]=r("circle",{cx:15,cy:"30",r:"15"},null,-1)),u[1]||(u[1]=r("rect",{x:"45",y:"15",rx:"3",ry:"3",width:"100",height:"12"},null,-1)),r("rect",{x:"45",y:"35",rx:"5",ry:"5",width:t.width-100,height:"10"},null,8,wo)]),_:1,__:[0,1]},8,["width"])],512)):q("",!0)}}),yo=async(e,s=1,n=10)=>{const t=(s-1)*n,o=t+n-1;return(await mt.from("comments").select(`*,
|
|
user:users(name, avatar),
|
|
like:likes(user_id),
|
|
replies:comments(*,
|
|
user:users(name, avatar),
|
|
like:likes(user_id)
|
|
)`).eq("product_id",e).is("parent_id",null).range(t,o).order("created_at",{ascending:!1}))?.data},je=async(e,s,n=void 0)=>await ke.post("/media/add-comment",{message:e,product_id:s,parent_id:n}),_o={flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},bo={"mt-1":"","font-semibold":""},Co={class:"flex items-center"},ko={class:"me-1"},So={class:"flex items-center p1"},$o=j({__name:"CommentAddEdit",props:{open:{type:Boolean},id:{}},emits:["update:open","addCommentId"],setup(e,{emit:s}){const n=be(),t=X(),o=Q(),u=L(null),i=L(!0),l=L(null),p=L(!1),d=L(!1),y=L(!1);Q();const C=L(void 0),M=()=>{i.value=l.value.scrollTop<=5};function a(){C.value=void 0}function g(){setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:"smooth",block:"center"}),p.value=!0},300)}ce(()=>{oe(()=>{l.value&&M()})});const I=e,_=s,T=L(!1),F=L([]),R=L(""),A=L(null),H=L(!1),W=L(0),Z=L(20),V=async()=>{try{if(!H.value){T.value=!0;const v=await yo(I.id,++W.value,Z.value);v?.length<Z.value&&(H.value=!0),F.value.push(...v)}}catch(v){console.log("e ===>",v)}finally{T.value=!1}};async function me(){await V(),await oe(),await u.value?.setOpen(),await A.value?.focus()}async function fe(){await oe(),await u.value?.setClose(),f(),a()}function f(){F.value=[],W.value=0,H.value=!1}const m=async()=>{try{if(R.value?.length>0){if(d.value=!0,C.value){const v=await je(R.value,I.id,C.value.id);C.value?.replies||(C.value.replies=[]),C.value?.replies.push({message:R.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],...v}),_("addCommentId",v.id)}else{const v=await je(R.value,I.id);F.value?.unshift({message:R.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],replies:[],...v}),_("addCommentId",v.id)}await oe(()=>{R.value="",C.value=void 0})}}catch(v){console.log(v)}finally{d.value=!1}};function k(v,$,z,O){try{if(y.value=!0,ge())if(v)if(Qn($),z){const E=F.value.find(B=>B.id===O)?.replies.find(B=>B.id===$);E?.like.splice(E.like?.findIndex(B=>B.user_id===o.user?.id))}else{const N=F.value.find(E=>E.id===O);N?.like.splice(N?.like?.findIndex(E=>E.user_id===o.user?.id))}else Jn($),z?F.value.find(B=>B.id===O)?.replies.find(B=>B.id===$)?.like.push({product_id:$,user_id:o.user.id}):F.value.find(E=>E.id===O)?.like?.push({product_id:$,user_id:o.user.id});else n.push({name:"auth-login"}),gt.warn(t.useString("pleaseLoginOrRegister"))}catch(N){console.log(N)}finally{y.value=!1}}const S=L();return ft(S,([{isIntersecting:v}])=>{v&&I.open&&setTimeout(()=>{V()},100)}),Ae(I,v=>{v.open?me():fe()}),(v,$)=>{const z=on;return h(),ie(bt,{title:"",ref_key:"sheetRef",ref:u,headerCls:"",allowCloseScrollup:i.value,closeOnClickOutside:"",onOnClickOutside:$[3]||($[3]=O=>_("update:open",!1)),onOnClose:$[4]||($[4]=O=>_("update:open",!1))},{header:K(()=>[r("div",_o,[$[5]||($[5]=r("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""},null,-1)),r("div",bo,P(c(t).useString("comments")),1)])]),default:K(()=>[r("div",{class:ve(["h-70vh w-full relative relative",c(ge)()?"pb-4rem":""])},[r("div",{class:"h-full px-4 overflow-auto",ref_key:"scrollArea",ref:l,onScroll:M},[(h(!0),b(J,null,ue(F.value,O=>(h(),ie(ho,{item:O,onLikeComment:k,onReply:N=>C.value=O,addLikeLoading:y.value},null,8,["item","onReply","addLikeLoading"]))),256)),T.value?(h(),b(J,{key:0},ue(5,O=>w(xo)),64)):q("",!0),re(r("div",{ref_key:"observer",ref:S,class:"w-full opacity-0 relative"}," load ",512),[[vt,!T.value]])],544),c(ge)()?(h(),b("div",{key:0,class:"flex w-inherit fixed gap-2 items-end my-2 px4 py-1 bottom-1",onFocusin:g,onFocusout:$[2]||($[2]=O=>p.value=!1)},[w(Ct,{width:"40",src:c(o).user?.avatar,"just-show-profile":""},null,8,["src"]),r("div",{class:ve(["border-solid w-full border-1 comment_input",C.value?"rounded-3xl":"rounded-full"])},[C.value?(h(),b("div",{key:0,class:ve(["rounded-t-3xl text-xs p3 mb1 flex justify-between",c(t).isNightStore?"bg-zinc-7 text-gray-2":"bg-gray-50 text-gray-4"])},[r("div",Co,[r("span",null,[r("span",ko,P(c(t).useString("replyingTo")),1),r("span",null,P(C.value?.user?.name),1)])]),w(de,{icon:"vuesax-linear:add",class:"rotate-45",color:c(t).isNightStore?"bg-zinc-7":"text-gray-4",onClick:$[0]||($[0]=O=>C.value=void 0)},null,8,["color"])],2)):q("",!0),r("div",So,[w(z,{value:R.value,"onUpdate:value":$[1]||($[1]=O=>R.value=O),placeholder:c(t).useString("yourComment"),class:"comment_input"},null,8,["value","placeholder"]),w(kt,{onClick:m,class:"rounded-full w-3.5rem",type:"primary",loading:d.value},{default:K(()=>[w(de,{icon:"vuesax-linear:arrow-up"})]),_:1},8,["loading"])])],2)],32)):q("",!0)],2)]),_:1},8,["allowCloseScrollup"])}}}),es=Object.assign($o,{__name:"CommentAddEdit"});export{es as C,Yo as P,Go as _,Bn as a,Jo as c,Qo as d};
|