1import{S as $,a as tt}from"./SorterTestDialog.nS0jzl.js";import{B as H}from"./BCard.nS0jzl.js";import{B as et}from"./BBtnPrimary.nS0jzl.js";import{B as st}from"./BBtnSecondaryOutlined.nS0jzl.js";import{_ as C,ad as j,f as ot,j as f,d as e,a as c,bk as N,t as h,F as S,k as D,o as u,x as R,a4 as lt,bQ as I,bP as O,bR as V,bT as rt,c as z,w as k,V as q,r as y,n as F,l as B,u as it,Y as nt,g as v,bO as at,bS as ct,bM as dt,b_ as ut,bZ as L,eH as ht,bV as mt,a2 as bt,I as ft,aq as gt,ar as pt,L as yt,h as kt}from"./index.nS0jzl.js";import{I as St}from"./InfoTooltip.nS0jzl.js";import{p as Y}from"./stringUtils.nS0jzl.js";import{b as J,g as _t,a as vt,f as K}from"./srUtils.nS0jzl.js";import{g as Tt}from"./scUtils.nS0jzl.js";import{c as It}from"./clipboardUtils.nS0jzl.js";import{A as W}from"./AbsoluteLoader.nS0jzl.js";import{N as xt}from"./NoItemsFound.nS0jzl.js";import{B as U}from"./constants.nS0jzl.js";import"./LoadingIndicator.nS0jzl.js";const Pt="/sorter-start-scanning.nS0jzl.png";class x{constructor(t="-",r="-",a="-",s=null,o=null,i=null,m=null,b=null,n=null,g=null,_={}){this.asin=t,this.asr=i,this.soldDays=m,this.title=r,this.binding=a,this.publicationDate=s,this.thumbnailLink=o,this.usedBbPrice=b,this.newBbPrice=n,this.amazonPrice=g,this.offerGroupMap=_}static fromBookStat(t){const r=t?.bookDetail,a=t?.offerDetails,s=a?.buyBoxOfferList||[],o=a?.offers||[],i=s.find(g=>g.condition==="Used")?.price||null,m=s.find(g=>g.condition==="New")?.price||null,b=t?.amazonOffer?.price||null,n=r?.thumbnailLink||null;return new x(r?.asin,r?.title,r?.binding,r?.publicationDate,n,J(t),Tt(t),i,m,b,wt(o))}}function wt(l){let t={};if(t[p.MU]=[],t[p.FU]=[],t[p.FN]=[],t[p.MN]=[],!l||!l?.length)return t;const r=l.find(i=>i.channel==="Merchant"&&i.condition==="Used")?.offers||[],a=l.find(i=>i.channel==="Merchant"&&i.condition==="New")?.offers||[],s=l.find(i=>i.channel==="FBA"&&i.condition==="Used")?.offers||[],o=l.find(i=>i.channel==="FBA"&&i.condition==="New")?.offers||[];return t[p.MU]=t[p.MU].concat(r),t[p.FU]=t[p.FU].concat(s),t[p.FN]=t[p.FN].concat(o),t[p.MN]=t[p.MN].concat(a),t}const p={MU:"MU",FU:"FU",FN:"FN",MN:"MN"};class E{constructor(t=null,r=null,a=[],s=null,o=null,i=null,m=null,b=null,n=null,g=null,_=null,T=new x){this.selectedGate=t,this.currentType=r,this.logs=a,this.idTriggerMap=s,this.idSectionMap=o,this.payout=i,this.color=m,this.sound=b,this.tag=n,this.targetType=g,this.sbybPrice=_,this.bookzy=T}}const zt={name:"SorterScanBookzy",props:{book:{type:Object,default:new x}},methods:{formatEpocDate:ot,formatPrice:j,copyToClipboardFromInputAndNotify:It}},Bt={class:"sorter-bookzy-wrapper"},Dt={class:"sorter-bookzy-book-detail-wrapper"},Mt={class:"sorter-bookzy-thumbnail bg-surface_subtle"},At=["href"],Et={class:"flex-grow-1 d-flex flex-column"},Ft={class:"sorter-bookzy-book-detail--asin py-3"},Ct=["value"],Nt={class:"sorter-bookzy-book-detail--text"},Rt={class:"sorter-bookzy-book-detail--text text-capitalize"},Ot={class:"sorter-bookzy-offers-wrapper"},Vt={class:"sorter-bookzy-offers-container"},Lt={class:"sorter-bookzy-offers--offer-columns pt-2"},Ut={class:"sorter-bookzy-special-offers-wrapper"},Gt={class:"bb-highlight"},Ht={class:"bb-highlight"};function jt(l,t,r,a,s,o){return u(),f("div",Bt,[e("div",Dt,[e("div",Mt,[e("a",{href:r.book.asin!=="-"?`https://www.amazon.com/dp/${r.book.asin}`:null,target:"_blank"},[c(N,{src:r.book.thumbnailLink,width:"110",height:"152",cover:""},null,8,["src"])],8,At)]),e("div",Et,[e("div",Ft,[e("input",{id:"sorter-bookzy-asin",class:"ghost-input",readonly:"",value:r.book.asin,onClick:t[0]||(t[0]=i=>o.copyToClipboardFromInputAndNotify("sorter-bookzy-asin",i))},null,8,Ct)]),e("div",Nt,h(r.book.title),1),t[1]||(t[1]=e("div",{class:"mb-3"},null,-1)),e("div",Rt,h(r.book.binding),1)])]),t[6]||(t[6]=e("div",{class:"mb-6"},null,-1)),e("div",Ot,[e("div",Vt,[t[2]||(t[2]=e("div",{class:"sorter-bookzy-offers--header bg-text_primary"},[e("div",null,"MU"),e("div",null,"FU"),e("div",null,"FN"),e("div",null,"MN")],-1)),e("div",Lt,[(u(!0),f(S,null,D(Object.keys(r.book.offerGroupMap),(i,m)=>(u(),f("div",{key:`offer-group-${m+1}`},[(u(!0),f(S,null,D(r.book.offerGroupMap[i],(b,n)=>(u(),f("div",{key:`group-${m+1}-offer-${n+1}`,class:R(["sorter-bookzy-offer",{"amazon-highlight":b.amazon,"bb-highlight":b.isBuyBoxWinner}])},[e("div",null,h(o.formatPrice(b.price)),1)],2))),128))]))),128))])])]),t[7]||
1(t[7]=e("div",{class:"mb-6"},null,-1)),e("div",Ut,[e("div",null,[t[3]||(t[3]=e("div",null,"Used BB",-1)),e("div",Gt,h(o.formatPrice(r.book.usedBbPrice,"-")),1)]),e("div",null,[t[4]||(t[4]=e("div",null,"New BB",-1)),e("div",Ht,h(o.formatPrice(r.book.newBbPrice,"-")),1)]),e("div",null,[t[5]||(t[5]=e("div",null,"Amazon",-1)),e("div",null,h(o.formatPrice(r.book.amazonPrice,"-")),1)])])])}const qt=C(zt,[["render",jt],["__scopeId","data-v-2119b58b"]]),Yt={ITEM_ID:"itemId",TITLE:"title"},Jt={name:"SorterBookzySearchDialog",components:{AbsoluteLoader:W,BCard:H,NoItemsFound:xt},props:{search:{type:String,default:""},searchType:{type:String,default:""}},emits:["close-sorter-bookzy-search-dialog","on-item-select"],data(){return{dialog:!0,loading:!1,SearchFields:Yt,otherProducts:[],selectedItem:{},isFetchingMoreProduct:!1,titleSearchPage:1,book:null}},computed:{items(){return this.book?[this.book]:Array.isArray(this.otherProducts)?this.otherProducts:[]}},watch:{dialog(l){l||this.$emit("close-sorter-bookzy-search-dialog")}},mounted(){this.searchBook()},methods:{async searchBook(){this.loading=!0;let l={queryType:U.CACHE,applyPreFilters:!0,groupType:null};this.searchType===this.SearchFields.TITLE?l.title=this.search:l.itemId=this.search;const t=await rt(l),r=t?.data?.data;if(t?.data?.success)if(!!r?.otherProducts?.length){I(O.MULTIPLE_RESULTS);const s=r.otherProducts;s.splice(0,0,t?.data?.data),this.searchType===this.SearchFields.TITLE?s.forEach(o=>o.scannedId=null):s.forEach(o=>o.scannedId=this.search),this.otherProducts=s}else this.book=JSON.parse(JSON.stringify(t?.data?.data));else I(V.ERROR);this.loading=!1},onItemSelect(l){this.selectedItem=l,setTimeout(()=>{this.$emit("on-item-select",this.selectedItem),this.dialog=!1},200)},formatProductGroup(l){const t=l?.bookDetail?.productGroup;if(!t)return"";const r=t.replaceAll("_DISPLAY_ON_WEBSITE","").replaceAll("_display_on_website","");return Y(r)},formatAvgSrValue(l){const t=J(l);return K(t,"N/A")},formatSrValue(l){const t=_t(l);return vt(t,"N/A")},checkScroll(l){const t=l.target,r=20,a=120,s=t.scrollHeight-(t.scrollTop+t.clientHeight),o=s<=r;o&&!this.endLatch&&(this.endLatch=!0,this.fetchMoreProduct()),!o&&this.endLatch&&s>a&&(this.endLatch=!1)},async fetchMoreProduct(){if(!this.isFetchingMoreProduct&&!(this.otherProducts.length>100)){this.isFetchingMoreProduct=!0;try{let l={queryType:U.CACHE,applyPreFilters:!0,groupType:null,titleSearchPage:this.titleSearchPage},t=this.search;this.searchType===this.SearchFields.TITLE?l.title=this.search:l.itemId=this.search;const r=await lt.get("book/stats/v3",{params:l});if(r?.data?.success){let a=r.data?.data;const s=!!a?.otherProducts?.length,o=a?.otherProducts;let i=JSON.parse(JSON.stringify(r?.data?.data));i.searchValue=t,s&&(I(O.MULTIPLE_RESULTS),this.otherProducts.push(...o),this.otherProducts.splice(0,0,r?.data?.data))}else I(V.ERROR);this.titleSearchPage+=1}finally{this.isFetchingMoreProduct=!1}}}}},Kt={key:0,class:"d-flex flex-column h-100 w-100 overflow-y-auto",style:{"min-height":"650px"}},Wt=["onClick"],Qt={class:"flex-grow-1 d-flex"},Zt={class:"pr-2 cursor-pointer"},Xt={class:"text-success text-uppercase text-ellipsis",style:{"max-width":"80px"}},$t={class:"text-capitalize"},te={class:"title-clamp-2"},ee={style:{width:"80px","min-height":"80px"},class:"flex-shrink-0"},se={key:0,class:"w-100 h-100 align-center justify-center text-center align-content-center"};function oe(l,t,r,a,s,o){const i=y("absolute-loader"),m=y("no-items-found"),b=y("b-card");return u(),z(q,{modelValue:s.dialog,"onUpdate:modelValue":t[2]||(t[2]=n=>s.dialog=n),width:"600",height:"800",class:"h-100"},{default:k(()=>[c(b,{title:"Select Item",class:"h-100 w-100 dialog-card",onOnCloseClick:t[1]||(t[1]=n=>s.dialog=!1)},{default:k(()=>[c(i,{value:s.loading},null,8,["value"]),o.items&&o.items.length?(u(),f("div",Kt,[e("div",{ref:"scrollArea",class:"flex-grow-1 overflow-y-auto",style:{height:"620px"},onScroll:t[0]||(t[0]=(...n)=>o.checkScroll&&o.checkScroll(...n))},[(u(!0),f(S,null,D(o.items,(n,g)=>(u(),f("div",{key:g,class:R(["multiple-result-item",s.selectedItem.bookDetail?.asin===n.bookDetail?.asin?"active":""]),onClick:()=>o.onItemSelect(n)},[e("div",Qt,[e("div",Zt,[c(F,{icon:s.selectedItem.bookDetail?.asin===n.bookDetail?.asin?"mdi-radiobox-marked":"mdi-radiobox-blank",color:s.selectedItem.bookDetail?.asin===n.bookDetail?.asin?"primary":"secondary",size:"20"},null,8,["icon","color"])]),e("table",null,[e("tbody",null,[e("tr",null,[e("td",Xt,h(o.formatProductGroup(n)),1),e("td",$t,h(n.bookDetail.binding),1)]),t[7]||
1(t[7]=e("tr",null,[e("td",{colspan:"2",class:"py-1"})],-1)),e("tr",null,[t[3]||(t[3]=e("td",{class:"text-brand text-right"}," ASIN ",-1)),e("td",null,h(n.bookDetail.asin),1)]),e("tr",null,[t[4]||(t[4]=e("td",{class:"text-brand text-right"}," ASR ",-1)),e("td",null,h(o.formatAvgSrValue(n)),1)]),e("tr",null,[t[5]||(t[5]=e("td",{class:"text-brand text-right"}," SR ",-1)),e("td",null,h(o.formatSrValue(n)),1)]),e("tr",null,[t[6]||(t[6]=e("td",{class:"text-brand text-right"}," Title ",-1)),e("td",te,h(n.bookDetail.title),1)])])])]),e("div",ee,[c(N,{src:n.bookDetail.thumbnailLink,width:"80"},null,8,["src"])])],10,Wt))),128))],544)])):(u(),f(S,{key:1},[s.loading?B("",!0):(u(),f("div",se,[c(m,{"item-type":"product"})]))],64))]),_:1})]),_:1},8,["modelValue"])}const le=C(Jt,[["render",oe],["__scopeId","data-v-20eb5d10"]]),G="sorterScanInput",w={ITEM_ID:"itemId",TITLE:"title"},re={name:"SorterScanView",components:{SorterBookzySearchDialog:le,AbsoluteLoader:W,SorterLogs:tt,InfoTooltip:St,BBtnSecondaryOutlined:st,BBtnPrimary:et,BCard:H,SorterTestDialog:$,SorterScanBookzy:qt},data(){return{testDialog:!1,ruleChecksDialog:!1,inputHasFocus:!1,startScanning:!1,startScanningImage:Pt,gateMetaMap:{},isbn:"",sinkResults:!0,loading:!1,rules:[l=>!!l||"This field cannot be empty"],result:new E,SORTER_SCAN_INPUT_ID:G,SearchFields:w,searchActionModel:w.ITEM_ID,actions:[{title:"Barcode",value:w.ITEM_ID},{title:"Title",value:w.TITLE}],bookzySearchDialog:{model:!1,isbn:""}}},computed:{...it(["sorterGateMetadata"])},watch:{sorterGateMetadata:{handler:function(l){const t=l||[];let r={};t.forEach(function(a){let s=a.gate;r[s]={},Object.keys(a).forEach(function(o){o!=="gate"&&(r[s][o]=a[o])})}),this.gateMetaMap=r},immediate:!0,deep:!0}},mounted(){this.sinkResults=mt(L.SORTER_ACT_AS_A_DEVICE)??!0},methods:{formatSr:K,formatPrice:j,parseEnum:Y,async scan(l=null){const t=l&&typeof l=="object"&&l.bookDetail?l:null;if(this.searchActionModel===this.SearchFields.TITLE&&!t){this.bookzySearchDialog.model=!0,this.bookzySearchDialog.isbn=(this.isbn||"").trim();return}const{valid:r}=await this.$refs.sorterScanForm.validate();if(!r)return;this.loading=!0,this.resetResult();const s={id:t?t.bookDetail.asin:this.isbn.trim(),sinkResults:this.sinkResults},o=await ht(s);if(o?.data?.success){const i=o.data?.data?.bookStat??null,m=o.data?.data?.testResult?.gate,b=o.data?.data?.testResult?.type,n=o.data.data?.testResult?.logs||[],g=o.data.data?.testResult?.payout??null,_=o.data?.data?.idTriggerMap,T=o.data?.data?.idSectionMap,M=o.data?.data?.testResult?.sbybPrice??null,A=this.gateMetaMap[m],{color:d,sound:P,tag:Q,targetType:Z}=A,X=x.fromBookStat(i);this.playSound(P),this.result=new E(m,b,n,_,T,g,d,P,Q,Z,M,X)}else this.resetResult(),this.isbn="";this.getFocusToSearchInput(),this.loading=!1},scanSelectedItem(l){l&&this.scan(l)},resetResult(){this.result=new E},typeStyle(l){return l==="SUCCESS"?"text-success":"text-error"},getFocusToSearchInput(){const l=document.getElementById(G);l.focus(),l.select()},onSinResultsChange(l){ut(L.SORTER_ACT_AS_A_DEVICE,l.target.checked)},navigateToKeepa(){const l=dt.KEEPA,t=this.result.bookzy.asin;window.open(`${l}${t}`,"_blank")},playSound(l){l&&(at(this.audio),this.audio=ct(l),I(this.audio))}}},ie={class:"d-flex"},ne={class:"sorter-scan-input-wrapper flex-grow-1"},ae=["id"],ce={class:"search-bar-actions-wrapper"},de=["onClick"],ue={class:"d-inline-flex flex-shrink-0 checkbox-text"},he={class:"sorter-scan-grid"},me={class:"sorter-scan-grid-left"},be={class:"sorter-scan-selected-gate"},fe={class:"sorter-scan-selected-gate-tag text-capitalize"},ge={class:"sorter-scan-grid-row"},pe={class:"sorter-scan-card label-value-card"},ye={class:"label-value-card--value purple-text"},ke={class:"sorter-scan-card label-value-card"},Se={class:"label-value-card--value purple-text"},_e={class:"sorter-scan-grid-row"},ve={class:"sorter-scan-card label-value-card"},Te={class:"label-value-card--value yellow-text"},Ie={class:"sorter-scan-card label-value-card"},xe={class:"label-value-card--value yellow-text"},Pe={class:"d-flex"},we={class:"sorter-scan-grid-right"},ze={class:"sorter-scan-card pa-0 h-100"};function Be(l,t,r,a,s,o){const i=y("b-btn-primary"),m=y("b-card"),b=y("info-tooltip"),n=y("absolute-loader"),g=y("b-btn-secondary-outlined"),_=y("SorterScanBookzy"),T=y("sorter-logs"),M=y("sorter-test-dialog"),A=y("sorter-bookzy-search-dialog");return u(),f(S,null,[s.startScanning?(u(),f(S,{key:1},[c(m,{class:"mb-6",padding:"0"},{default:k(()=>[e("div",ie,[e("div",ne,[c(F,{class:"sorter-scan-input-icon",color:s.inputHasFocus?"brand":"text_primary",icon:"mdi-magnify",size:"24"},null,8,["color"]),c(bt,{ref:"sorterScanForm",onSubmit:ft(o.scan,["prevent"])},{default:k(()=>[gt(e("input",{id:s.SORTER_SCAN_INPUT_ID,"onUpdate:modelValue":t[1]||(t[1]=d=>s.isbn=d),class:"sorter-scan-input",placeholder:"EAN / ISBN / ASIN",onFocus:t[2]||(t[2]=d=>d.target.select()),onFocusin:t[3]||(t[3]=d=>s.inputHasFocus=!0),onFocusout:t[4]||(t[4]=d=>s.inputHasFocus=!1)},null,40,ae),[[pt,s.isbn]])]),_:1},8,["onSubmit"])]),e("div",ce,[(u(!0),f(S,null,D(s.actions,(d,P)=>(u(),f("span",{key:P,class:R([{"font-weight-medium text-brand":d.value===s.searchActionModel},"clickable"]),onClick:()=>{s.searchActionModel=d.value}},h(d.title),11,de))),128))]),e("div",ue,[c(yt,{modelValue:s.sinkResults,"onUpdate:modelValue":t[5]||(t[5]=d=>s.sinkResults=d),style:{"margin-top":"4px"},label:"Act as a sorter device",density:"compact","hide-details":"",onInput:o.onSinResultsChange},null,8,["modelValue","onInput"]),c(b,{"class-prop":"align-self-center mx-2"},{default:k(()=>t[17]||(t[17]=[v(" Will relay the effects of the test as if itâs coming from a sorter device. Such as adding an item to SBYB shipment if the gate is SBYB gate. ")])),_:1})])])]),_:1}),e("div",he,[c(n,{value:s.loading,"border-radius":10},null,8,["value"]),e("div",me,[e("div",{class:"sorter-scan-card sorter-scan-gate-info-card",style:nt(s.result.color&&s.result.color!=="NONE"?`background-color: ${s.result.color}; color: rgb(var(--v-theme-text_inverse))!important;`:null)},[e("h1",be,h(o.parseEnum(s.result.selectedGate,"-")),1),e("h2",fe,[s.result.tag?(u(),f(S,{key:0},[v(" ("+h(s.result.tag)+") ",1)],64)):B("",!0)])],4),t[24]||(t[24]=e("div",null,null,-1)),e("div",ge,[e("div",pe,[t[18]||(t[18]=e("span",{class:"label-value-card--label"},"payout",-1)),e("div",ye,h(o.formatPrice(s.result.payout,"-")),1)]),e("div",ke,[t[19]||(t[19]=e("span",{class:"label-value-card--label"},"sbyb",-1)),e("div",Se,h(o.formatPrice(s.result.sbybPrice,"-")),1)])]),t[25]||(t[25]=e("div",null,null,-1)),e("div",_e,[e("div",ve,[t[20]||(t[20]=e("span",{class:"label-value-card--label"},"asr",-1)),e("div",Te,h(s.result.bookzy.asr?o.formatSr(s.result.bookzy.asr,"N/A"):"-"),1)]),e("div",Ie,[t[21]||(t[21]=e("span",{class:"label-value-card--label"},"sold days",-1)),e("div",xe,h(s.result.bookzy.soldDays??"-"),1)])]),t[26]||(t[26]=e("div",null,null,-1)),e("div",Pe,[c(kt),c(g,{height:"44",disabled:!s.result.bookzy.asin||s.result.bookzy.asin==="-",onClick:o.navigateToKeepa},{default:k(()=>t[22]||(t[22]=[v(" keepa ")])),_:1},8,["disabled","onClick"]),c(g,{class:"ml-3",height:"44",disabled:!s.result.logs?.length,onClick:t[6]||(t[6]=d=>s.ruleChecksDialog=!0)},{default:k(()=>t[23]||(t[23]=[v(" see rule checks ")])),_:1},8,["disabled"])])]),e("div",we,[e("div",ze,[c(_,{book:s.result.bookzy},null,8,["book"])])])])],64)):(u(),z(m,{key:0,class:"sorter-scan-greeting",padding:"30"},{default:k(()=>[t[12]||(t[12]=v(" Before scanning, ensure: ")),t[13]||(t[13]=e("ul",null,[e("li",null,"Triggers are set up correctly."),e("li",null,'All "Fallback Scenarios" have designated gates in the "Sorter Settings" page.')],-1)),t[14]||(t[14]=v(" For any questions, please reach out to the support team for further assistance. ")),t[15]||(t[15]=e("div",{class:"mb-7"},null,-1)),c(N,{src:s.startScanningImage,width:"190",height:"187"},null,8,["src"]),t[16]||(t[16]=e("div",{class:"mb-7"},null,-1)),c(i,{height:"44",onClick:t[0]||(t[0]=d=>s.startScanning=!0)},{default:k(()=>[c(F,{style:{"margin-right":"10px"},icon:"mdi-send-outline",size:"18"}),t[11]||(t[11]=v(" start scanning "))]),_:1})]),_:1})),c(q,{modelValue:s.ruleChecksDialog,"onUpdate:modelValue":t[8]||(t[8]=d=>s.ruleChecksDialog=d),width:"700"},{default:k(()=>[c(m,{title:"Rule Checks",onOnCloseClick:t[7]||(t[7]=d=>s.ruleChecksDialog=!1)},{default:k(()=>[c(T,{logs:s.result.logs,"id-trigger-map-prop":s.result.idTriggerMap,"id-section-map-prop":s.result.idSectionMap,"no-header":!0,isbn:s.isbn},null,8,["logs","id-trigger-map-prop","id-section-map-prop","isbn"])]),_:1})]),_:1},8,["modelValue"]),s.testDialog?(u(),z(M,{key:2,onSorterTestDialog:t[9]||(t[9]=d=>s.testDialog=!1)})):B("",!0),s.bookzySearchDialog.model?(u(),z(A,{key:3,search:s.bookzySearchDialog.isbn,"search-type":s.searchActionModel,onOnItemSelect:o.scanSelectedItem,onCloseSorterBookzySearchDialog:t[10]||(t[10]=d=>{s.bookzySearchDialog.model=!1})},null,8,["search","search-type","onOnItemSelect"])):B("",!0)],64)}const je=C(re,[["render",Be],["__scopeId","data-v-d50d9e44"]]);export{je as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.