import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./_plugin-vue2_normalizer-BHc2Ljhs.js";import{t as n}from"./delay-DkB8DMH7.js";import{t as r}from"./p-map-DPdBLmfu.js";import{n as i}from"./chat-Br3Z53i5.js";import{i as a,n as o,r as s}from"./rating-i-Ij2UGy.js";var c=e(n()),l=e(r()),u=t({name:`ShopeeAutoReplyReview`,data(){return{formData:{},queryRating:{star:[5],limit:20},replyRating:{text:this.$t(`SHOPEE_AUTO_REPLY_RATING_PARAM_TEXT`)},replyChat:{text:``},replyHandler:{loading:!1,log:[],sent:0,total:0,sleepPerList:5e3,sleepPerRating:500},matchText:{BUYER_NAME:this.$t(`SHOPEE_AUTO_REPLY_RATING_PARAM_BUYER_NAME`),ORDER_ID:this.$t(`SHOPEE_AUTO_REPLY_RATING_PARAM_ORDER_ID`),RATING_STAR:this.$t(`SHOPEE_AUTO_REPLY_RATING_PARAM_RATING_STAR`)}}},methods:{async getchMetaRating(){let e=await s(this.queryRating.star);this.replyHandler.total=e.to_reply_count},async handleReplyRating(){this.replyHandler.loading=!0,this.replyHandler.sent=0;let e=!0;for(;e;){let t=await o(this.queryRating.star,this.queryRating.limit);if(!(t&&t.length)||(await(0,l.default)(t,async t=>{if(!e)return!1;let{user_id:n,order_id:r,comment_id:o,rating_star:s,user_name:l,reply:u}=t;if(!(!u&&this.queryRating.star.includes(s)))return!1;let d=this.replyRating.text.replace(/BUYER_NAME/g,l).replace(/ORDER_ID/g,r).replace(/RATING_STAR/g,s),f={buyer:l,order_id:r,star:s,text:d,process_current:this.replyHandler.sent,process_total:this.replyHandler.total};if(await a(r,o,d).then(e=>{e.message===`success`?this.replyHandler.log.push(`✅ ${this.$t(`SHOPEE_AUTO_REPLY_RATING_SENT_SUCCESS`,f)}`):this.replyHandler.log.push(`❌ ${this.$t(`SHOPEE_AUTO_REPLY_RATING_SENT_ERROR`,f)}`)}).catch(()=>{this.replyHandler.log.push(`❌ ${this.$t(`SHOPEE_AUTO_REPLY_RATING_SENT_ERROR`,f)}`)}),this.replyChat.text){let e=n,t=n,a=this.replyChat.text.replace(/BUYER_NAME/g,l).replace(/ORDER_ID/g,r).replace(/RATING_STAR/g,s),o={buyer:l,text:a};i(e,t,a).then(()=>{this.replyHandler.log.push(`✅ ${this.$t(`SHOPEE_AUTO_CHAT_RATING_SENT_SUCCESS`,o)}`)}).catch(()=>{this.replyHandler.log.push(`❌ ${this.$t(`SHOPEE_AUTO_CHAT_RATING_SENT_ERROR`,o)}`)})}this.replyHandler.log.push(`-------------`),this.getIsVipPlus||(this.$Message.warning(this.$t(`FEAUTRE_STOP_VIP_PLUS`)),this.replyHandler.log.push(this.$t(`FEAUTRE_STOP_VIP_PLUS`)),e=!1),this.replyHandler.sent+=1,await(0,c.default)(this.replyHandler.sleepPerRating)},{concurrency:1}),!e))break;await(0,c.default)(this.replyHandler.sleepPerList)}e&&(this.replyHandler.loading=!1)}},created(){this.getchMetaRating()},computed:{logText(){return this.replyHandler.log.join(`
`)}}},function(){var e=this,t=e._self._c;return t(`div`,{staticClass:`reply-container`},[t(`Row`,{attrs:{gutter:24}},[t(`Col`,{attrs:{span:16,offset:4}},[t(`Card`,{staticClass:`variables-card`,attrs:{bordered:!1}},[t(`div`,{staticClass:`card-title`,attrs:{slot:`title`},slot:`title`},[t(`Icon`,{attrs:{type:`ios-code`,size:`18`}}),t(`span`,{staticClass:`ml-2`},[e._v(e._s(e.$t(`SHOPEE_AUTO_REPLY_RATING_VARIABLES`)))])],1),t(`div`,{staticClass:`variables-grid`},e._l(e.matchText,function(n,r){return t(`div`,{key:r,staticClass:`variable-item`},[t(`Tag`,{staticClass:`variable-tag`,attrs:{color:`blue`}},[e._v(` `+e._s(r)+` `)]),t(`span`,{staticClass:`variable-description`},[e._v(e._s(n))])],1)}),0)]),t(`Card`,{staticClass:`config-card mt-4`,attrs:{bordered:!1}},[t(`div`,{staticClass:`card-title`,attrs:{slot:`title`},slot:`title`},[t(`Icon`,{attrs:{type:`ios-settings`,size:`18`}}),t(`span`,{staticClass:`ml-2`},[e._v(e._s(e.$t(`SHOPEE_AUTO_REPLY_RATING_CONFIG`)))])],1),t(`Form`,{attrs:{model:e.formData,"label-width":120}},[t(`Row`,{attrs:{gutter:16}},[t(`Col`,{attrs:{span:12}},[t(`FormItem`,{attrs:{label:e.$t(`SHOPEE_AUTO_REPLY_RATING_INPUT_CONTENT`)}},[t(`Input`,{staticClass:`form-textarea`,attrs:{type:`textarea`,rows:4,placeholder:e.$t(`SHOPEE_AUTO_REPLY_RATING_INPUT_CONTENT`)},model:{value:e.replyRating.text,callback:function(t){e.$set(e.replyRating,`text`,t)},expression:`replyRating.text`}})],1)],1),t(`Col`,{attrs:{span:12}},[t(`FormItem`,{attrs:{label:e.$t(`SHOPEE_AUTO_REPLY_RATING_INPUT_CHAT`)}},[t(`Input`,{staticClass:`form-textarea`,attrs:{type:`textarea`,rows:4,placeholder:e.$t(`INPUT_PLACEHOLDER_EMPTY_WITHOUT_USE`)},model:{value:e.replyChat.text,callback:function(t){e.$set(e.replyChat,`text`,t)},expression:`replyChat.text`}})],1)],1)],1),t(`Row`,{attrs:{gutter:16}},[t(`Col`,{attrs:{span:12}},[t(`FormItem`,{attrs:{label:e.$t(`SHOPEE_AUTO_REPLY_RATING_STAR_FILTER`)}},[t(`Select`,{staticStyle:{width:`100%`},attrs:{multiple:``,placeholder:e.$t(`SHOPEE_AUTO_REPLY_RATING_STAR_FILTER`)},on:{"on-change":e.getchMetaRating},model:{value:e.queryRating.star,callback:function(t){e.$set(e.queryRating,`star`,t)},expression:`queryRating.star`}},e._l([1,2,3,4,5],function(n){return t(`Option`,{key:n,attrs:{value:n}},[e._v(` `+e._s(e.$t(`RATING_STAR`,{star:n}))+` `)])}),1),t(`div`,{staticClass:`form-help-text`},[e._v(` `+e._s(e.$t(`SHOPEE_AUTO_REPLY_RATING_STAR_HELP`))+` `)])],1)],1),t(`Col`,{attrs:{span:12}},[t(`FormItem`,{attrs:{label:` `}},[t(`Button`,{staticClass:`action-button`,attrs:{type:`primary`,size:`large`,loading:e.replyHandler.loading,disabled:!(e.replyRating.text&&e.queryRating.star.length)},on:{click:e.handleReplyRating}},[t(`Icon`,{attrs:{type:`ios-play`,size:`16`}}),t(`span`,{staticClass:`ml-1`},[e._v(e._s(e.$t(`SHOPEE_AUTO_REPLY_RATING_BTN`)))])],1)],1)],1)],1)],1)],1),t(`Card`,{staticClass:`log-card mt-4`,attrs:{bordered:!1}},[t(`div`,{staticClass:`card-title`,attrs:{slot:`title`},slot:`title`},[t(`Icon`,{attrs:{type:`ios-list`,size:`18`}}),t(`span`,{staticClass:`ml-2`},[e._v(e._s(e.$t(`SHOPEE_AUTO_REPLY_RATING_LOG`)))]),t(`Badge`,{staticClass:`ml-2`,attrs:{count:e.replyHandler.sent,type:`primary`}}),t(`span`,{staticClass:`ml-2 text-muted`},[e._v(` / `+e._s(e._f(`addCommas`)(e.replyHandler.total))+` `)])],1),t(`div`,{staticClass:`log-container`},[t(`Input`,{staticClass:`log-textarea`,attrs:{value:e.logText,type:`textarea`,rows:15,readonly:``}})],1)])],1)],1)],1)},[],!1,null,`91e36b2e`,null,null).exports;export{u as default};