1(self.webpackChunkperpetua_web=self.webpackChunkperpetua_web||[]).push([[5103],{45103:(e,t,a)=>{a.r(t),a.d(t,{default:()=>_e});var s=a(74848),r=a(96540),o=a(2896),l=a(84976),n=a(71789),i=a(97665),c=a(34832),d=a(52013),p=a(99468);const u=e=>{const{t}=(0,p.c)(),{selectedRowInclusionCheckboxes:a,setSelectedRowInclusionCheckboxes:o}=e,l=(0,r.useCallback)((e=>{o((0,c.I)(a,[e]))}),[o,a]);return(0,s.jsxs)("div",{className:"flex flex-col space-y-2","data-cy":"row-inclusion-container",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,children:t("bulk_operations.row_inclusions.section_title")}),(0,s.jsx)(d.SB,{title:t("bulk_operations.row_inclusions.tooltip.title"),description:t("bulk_operations.row_inclusions.tooltip.description"),children:(0,s.jsx)(d.Sd,{iconType:d.iz.info,iconColor:d.yP.grayLight2,className:"hover:text-gray-1"})})]}),(0,s.jsxs)("div",{className:"flex space-x-3",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(d.cY,{checked:a.includes(n.R9.GoalsAndAdGroups),onChange:()=>l(n.R9.GoalsAndAdGroups),disabled:1===a.length&&a.includes(n.R9.GoalsAndAdGroups),dataCy:"goals-and-ad-groups-checkbox"}),(0,s.jsx)(d.gL,{typography:d.c0.body,color:a.includes(n.R9.GoalsAndAdGroups)?d.yP.grayDark3:d.yP.gray1,children:t("bulk_operations.row_inclusions.goals_ad_groups.label")})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(d.cY,{checked:a.includes(n.R9.ProductAsins),onChange:()=>l(n.R9.ProductAsins),disabled:1===a.length&&a.includes(n.R9.ProductAsins),dataCy:"products-checkbox"}),(0,s.jsx)(d.gL,{typography:d.c0.body,color:a.includes(n.R9.ProductAsins)?d.yP.grayDark3:d.yP.gray1,children:t("bulk_operations.row_inclusions.product_asins.label")})]})]})]})};var y=a(34609);const g=()=>{const{t:e}=(0,p.c)(),{CAMPAIGNS_BULK_OPS_TYPES:t,GOALS_AND_SEGMENTS_BULK_OPS_TYPES:a,NON_PERPETUA_MANAGED_BULK_OPERATION_TYPE_MAP:s,PERPETUA_MANAGED_BULK_OPERATION_TYPE_MAP:r,SPBulkOpsTypes:o}=(0,n.o_)();return{determineBulkOperationType:(e,t,a)=>{switch(e){case n.Wl.CostOfGoodsPerUnit:return y.x.costOfGoodsPerUnit;case n.Wl.NonPerpetuaManaged:return s[t];case n.Wl.PerpetuaManaged:return a===n.tt.ProductTags?y.x.productTags:r[t][a]}},getAdType:t=>o.includes(t)?e("sponsored_products"):"",getGranularityLevel:s=>a.includes(s)?e("goals_and_segments"):t.includes(s)?e("campaigns"):s===y.x.productTags?e("product_tags"):s===y.x.spMAGGoalList?e("bulk_operations.multi_ad_group.summary_cell.title"):"",getBulkOperationSelectionLabel:t=>{switch(t){case y.x.spCombinedGoalsList:return e("goals_and_segments");case y.x.spMAGGoalList:return e("bulk_operations.dropdown.mag.title");case y.x.spCampaignList:return e("campaigns");case y.x.productTags:return e("product_tags");case y.x.spCampaignBulkTakeover:return e("bulk_ops_campaign_takeover_title");case y.x.costOfGoodsPerUnit:return e("bulk_ops_cogs_title");default:return""}}}};var _=a(1373),m=a(55915),h=a(51379),x=a(71750),b=a(57879),j=a(46851),f=a(51754),k=a(44479),v=a(89044),w=a(16900),T=a(35961),P=a(98655),N=a(42140),O=a(12040),C=a(5972),S=a(57539);const L=({number:e,title:t})=>(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-indigo-3-light",children:(0,s.jsx)(d.gL,{color:d.yP.indigoDark2,typography:d.c0.label2,children:e})}),(0,s.jsx)(d.gL,{color:d.yP.grayDark3,typography:d.c0.label3,children:t})]});var A=a(4213),G=a(38470),B=a(907);const D=({selectedRadioButton:e,setSelectedRadioButton:t,selectedAdType:a,setSelectedAdType:l,selectedGranularityLevel:c,setSelectedGranularityLevel:D,setSelectedTabId:R,selectedRowInclusionCheckboxes:M,setSelectedRowInclusionCheckboxes:E,historyTableRef:W})=>{const{t:U}=(0,p.c)(),I=(0,O.GQ)(),z=(0,i.jE)(),F=(0,f.c)(),H=(0,j.D)(),V=(0,o.d4)((e=>e.user.preferences.userPreferences.language_preference)),[Y,q]=(0,r.useState)(!1),{startDate:J,endDate:Q,setCalendarDateRanges:K,setMaxNumberOfDays:X}=(0,_.UH)(),{magGoalsBulkOperations:Z,magctBulkOpsRelease2:$}=(0,m.E0)(),ee=(0,v.A)();(0,k.JY)({title:U("bulk_operations"),datePickerState:h.n.HIDDEN}),(0,r.useEffect)((()=>(K(w.wj.filter((e=>e.code===b.ad.SevenDays||e.code===b.ad.ThirtyDays))),X(30),()=>{K(null),X(null)})),[X,K]),(0,r.useEffect)((()=>{Q&&J&&7!==Q.diff(J,"days")&&I(N.yL.BulkOpsDateRangeConfigured,{start_date:J,end_date:Q,geo_company_id:F.id,company_id:H.id,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"Performance Date Range Selected",object:"Bulk Operations"})}),[J,Q,H.id,F.id,ee]);const te=e=>{t(e),I(N.yL.BulkOpsTypeChanged,{change_type:e===n.Wl.PerpetuaManaged?y.x.spCombinedGoalsList:y.x.spCampaignBulkTakeover,geo_company_id:F.id,company_id:H.id,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"Type Selected",object:"Bulk Operations"})},ae=(0,r.useCallback)((e=>{D(e),I(N.yL.BulkOpsGranularitySelected,{change_type:e,geo_company_id:F.id,company_id:H.id,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"Granularity Selected",object:"Bulk Operations"})}),[H.id,F.id,D]),se=(0,s.jsx)(d.W2,{children:(0,s.jsx)(d.MV,{text:U("coming_soon"),variant:d.FU.gray,size:d.t.micro})}),re=[{title:U("goals_and_segments"),description:U("bulk_operations.dropdown.gs.description"),value:n.tt.GoalsAndSegments},...Z?[{title:U("bulk_operations.dropdown.mag.title"),description:U("bulk_operations.dropdown.mag.description"),value:n.tt.MAGGoals}]:[],{title:U("campaigns"),value:n.tt.Campaigns},{title:U("product_tags"),value:n.tt.ProductTags,pill:(0,s.jsx)(d.MV,{text:U("badges.new"),variant:d.FU.indigo1,size:d.t.micro,className:"ml-auto"})}],{determineBulkOperationType:oe}=g(),le=((e,t,a,s,r,l,i,c)=>{const{t:d}=(0,p.c)(),u=(0,O.GQ)(),{startDate:y,endDate:g}=(0,_.UH)(),m=(0,o.d4)((e=>e.companies.activeGeoCompany.id)),h=(0,o.d4)((e=>e.companies.activeCompany.id));return async()=>{let t=null;q(!0);try{const t=await(0,G.v7)(m,r===n.Wl.NonPerpetuaManaged?null:y,r===n.Wl.NonPerpetuaManaged?null:g,e,c);if(!t.ok)throw new Error(d("csv_template_download_error"));if(t.data.perpetua_execution_id)return s?.();const{file:a,fileName:o}=await(0,B.g)(t.data.gcs_path,m);(0,A.saveAs)(a,o)}catch(e){(0,P.ZT)(d("csv_template_download_error"),e),t=JSON.stringify(e)}finally{R(n.js.Download),z.invalidateQueries({queryKey:[T.B.bulkOpsHistoryTable,F.id]}),q(!1),u(N.yL.BulkOpsTemplateDownloaded,{start_date:y,end_date:g,ad_type:l,granularity:i,...i===n.tt.MAGGoals&&{selected_row_inclusions:{goals_ad_groups:c?.includes(n.R9.GoalsAndAdGroups),product_asins:c?.includes(n.R9.ProductAsins)}},error:t,geo_company_id:m,company_id:h,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:`${e} Bulk Template Downloaded`,object:"Bulk Operations"})}}})(oe(e,a,c),0,0,(()=>(0,P.X6)({title:U("downloading_file"),buttonText:U("view_downloads"),buttonOnClick:()=>W.current?.scrollIntoView({behavior:"smooth"})})),e,a,c,M),ne=(0,r.useMemo)((()=>{switch(e){case n.Wl.PerpetuaManaged:return U("create_and_download_spreadsheet.custom");case n.Wl.NonPerpetuaManaged:return U("create_and_download_spreadsheet.takeover");case n.Wl.CostOfGoodsPerUnit:return U("create_and_download_spreadsheet.cogs")}}),[e,U]),ie=(0,r.useMemo)((()=>{switch(e){case n.Wl.PerpetuaManaged:return U("download_spreadsheet.custom");case n.Wl.NonPerpetuaManaged:return U("download_spreadsheet.takeover");case n.Wl.CostOfGoodsPerUnit:return U("download_spreadsheet.cogs")}}),[e,U]);return(0,s.jsxs)(d.Wt,{className:"space-y-6 p-6",shadow:!0,border:!0,rounded:!0,children:[(0,s.jsx)(L,{number:1,title:ne}),(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsxs)(d.sN,{onClick:()=>te(n.Wl.PerpetuaManaged),selected:e===n.Wl.PerpetuaManaged,inRow:!0,children:[(0,s.jsx)(d.sN.RadioButton,{}),(0,s.jsxs)(d.sN.Content,{children:[(0,s.jsx)(d.sN.Title,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_combined_goals_title")})}),(0,s.jsx)(d.sN.Description,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_combined_goals_description")})})]})]}),(0,s.jsxs)(d.sN,{onClick:()=>te(n.Wl.NonPerpetuaManaged),selected:e===n.Wl.NonPerpetuaManaged,inRow:!0,children:[(0,s.jsx)(d.sN.RadioButton,{}),(0,s.jsxs)(d.sN.Content,{children:[(0,s.jsx)(d.sN.Title,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_campaign_takeover_title")})}),(0,s.jsx)(d.sN.Description,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_campaign_takeover_description")})})]})]}),!H.is_vendor&&(0,s.jsxs)(d.sN,{onClick:()=>te(n.Wl.CostOfGoodsPerUnit),selected:e===n.Wl.CostOfGoodsPerUnit,inRow:!0,children:[(0,s.jsx)(d.sN.RadioButton,{}),(0,s.jsxs)(d.sN.Content,{children:[(0,s.jsx)(d.sN.Title,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_cogs_title")})}),(0,s.jsx)(d.sN.Description,{children:(0,s.jsx)(d.l0,{children:U("bulk_ops_cogs_description")})})]})]})]}),(0,s.jsx)("hr",{className:"w-full border-gray-4-light"}),(0,s.jsxs)("div",{className:"space-y-6",children:[e===n.Wl.NonPerpetuaManaged&&(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:U("bulk_ops_combined_goals_description.disclaimer")}),e===n.Wl.CostOfGoodsPerUnit&&(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:U("traffic_reporting.cogs.sections.download.description",{country:new Intl.DisplayNames([V],{type:"region"}).of(F.country_code),marketplace:C.PA[F.country_code]})}),e===n.Wl.PerpetuaManaged&&(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(d.gL,{typography:d.c0.label2,children:U("granularity_level")}),(0,s.jsxs)(d.yv,{value:c,onValueChange:e=>ae(e),children:[(0,s.jsx)(d.eJ,{className:"w-full text-ellipsis whitespace-nowrap"}),(0,s.jsx)(d.Bz,{children:(0,s.jsx)(d.RM,{children:re.map(((e,t)=>(0,s.jsxs)(r.Fragment,{children:[0!==t&&(0,s.jsx)(d.nR,{}),(0,s.jsxs)(d.Md,{value:e.value,children:[(0,s.jsxs)(d.I0,{children:[(0,s.jsx)(d.Dl,{children:e.title}),e.description&&(0,s.jsx)(d.fl,{children:e.description})]}),e.pill&&(0,s.jsx)(d.W2,{children:e.pill})]})]},e.value)))})})]})]}),[n.tt.Campaigns,n.tt.GoalsAndSegments,n.tt.MAGGoals].includes(c)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(d.gL,{typography:d.c0.label2,children:U("ad_type")}),(0,s.jsxs)(d.yv,{value:a,onValueChange:e=>l(e),disabled:!0,children:[(0,s.jsx)(d.eJ,{className:"w-full",dataCy:"ad-type-dropdown-trigger"}),(0,s.jsxs)(d.Bz,{children:[(0,s.jsx)(d.Md,{value:n.eQ.SponsoredProducts,children:U("sponsored_products")}),(0,s.jsxs)(d.Md,{value:n.eQ.SponsoredBrands,disabled:!0,children:[(0,s.jsx)(d.I0,{children:(0,s.jsx)(d.Dl,{children:U("sponsored_brands")})}),se]}),(0,s.jsxs)(d.Md,{value:n.eQ.SponsoredDisplay,disabled:!0,children:[(0,s.jsx)(d.I0,{children:(0,s.jsx)(d.Dl,{children:U("sponsored_display")})}),se]})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(d.gL,{typography:d.c0.label2,children:U("performance_date_range")}),(0,s.jsx)(x.A,{})]})]})]}),c===n.tt.MAGGoals&&e===n.Wl.PerpetuaManaged&&$&&(0,s.jsx)(u,{selectedRowInclusionCheckboxes:M,setSelectedRowInclusionCheckboxes:E}),c===n.tt.GoalsAndSegments&&e===n.Wl.PerpetuaManaged&&(0,s.jsx)(d.nV,{bannerSize:d.Mz.small,variant:d.ZJ.greenLight3,bannerVariant:d.m1.warning,title:(0,s.jsx)(d.He,{typography:d.c0.body,color:d.yP.orangeDark3,children:(0,S.R)(U("goals_segments_granularity_warning_text"))})}),(0,s.jsx)(d.lD,{text:ie,variant:d.Yx.primary,iconType:d.iz.download,size:d.gO.large,onClick:le,loading:Y,dataCy:"bulk-ops-download-csv-button",block:!0})]})]})},R=()=>{const{t:e}=(0,p.c)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:2,title:e("edit_custom_spreadsheet")}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,children:e("to_ensure_errors_are_reduced.disclaimer")}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:(0,S.R)(e("traffic_reporting.product_tags.sections.edit.instructions"))})]})]})};var M=a(46942),E=a.n(M),W=a(90888);const U=({error:e,getBulkOperationSelectionLabel:t,onClose:a})=>{const{t:r}=(0,p.c)(),{title:o,description:l}="mismatch"===e.kind?{title:r("bulk_operations.upload.granularity_mismatch.title"),description:r("bulk_operations.upload.granularity_mismatch.description",{detected:t(e.detectedType),selected:t(e.selectedType)})}:{title:r("bulk_operations.upload.read_failed.title"),description:r("bulk_operations.upload.read_failed.description")};return(0,s.jsx)(d.Ub,{open:!0,onClose:a,headerText:o,width:520,contentClassName:"p-6",footerButtons:[{text:r("cancellation.okay"),onClick:a,variant:d.Yx.primary}],children:(0,s.jsx)(d.gL,{color:d.yP.gray1,children:l})})},I={[y.x.spCampaignList]:{required:["Campaign ID"],forbidden:[]},[y.x.spMAGGoalList]:{required:["Ad Group Title"],forbidden:[]},[y.x.spCombinedGoalsList]:{required:["Company Name"],forbidden:["Ad Group Title","Campaign ID"]}},z=e=>{const t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/""/g,'"'):t},F=({bulkOperationType:e,onUploadFinish:t})=>{const{t:a}=(0,p.c)(),l=(0,O.GQ)(),{getBulkOperationSelectionLabel:n}=g(),c=(0,i.jE)(),{toasts:u}=(0,W.Nk)(),y=(0,r.useRef)(null),_=(0,o.d4)((e=>e.companies.activeGeoCompany?.id)),m=(0,o.d4)((e=>e.companies.activeCompany?.id)),[h,x]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[f,k]=(0,r.useState)(null),v=e=>{e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?x(!0):"dragleave"===e.type&&x(!1)},w=async s=>{if(!s)return;let r;try{r=await(async e=>{const t=e.stream().getReader(),a=new TextDecoder;let s="";try{for(;;){const{done:e,value:r}=await t.read();if(r){s+=a.decode(r,{stream:!0});const e=s.search(/\r?\n/);if(-1!==e)return s.slice(0,e)}if(e)return s}}finally{await t.cancel()}})(s)}catch{return void k({kind:"readFailed"})}const o=(e=>{const t=(e=>new Set(e.replace(/^\uFEFF/,"").split(",").map(z)))(e),a=Object.entries(I).filter((([,e])=>e.required.every((e=>t.has(e)))&&e.forbidden.every((e=>!t.has(e)))));return 1===a.length?a[0][0]:null})(r),n=(({selectedType:e,detectedType:t})=>t&&t!==e?{kind:"mismatch",selectedType:e,detectedType:t}:{kind:"ok",type:e})({selectedType:e,detectedType:o});if("mismatch"===n.kind)return void k({kind:"mismatch",selectedType:n.selectedType,detectedType:n.detectedType});const i=n.type;j(!0);let d=null;(0,G.eD)(_,s,i).then((e=>{if(e.ok)(0,P.$U)(a("bulk_operation_uploaded_successfully"));else if(e.data.gcs_path){const t=e.data.gcs_path;u.forEach((e=>{(0,P.UW)(e.id)}
1)),(0,P.X6)({title:a("error_uploading_csv"),description:a("fix_csv_errors_and_reupload"),buttonOnClick:async()=>{try{const{file:e,fileName:a}=await(0,B.g)(t,_);(0,A.saveAs)(e,a)}catch(e){(0,P.ZT)(a("csv_template_download_error"),e),d=JSON.stringify(e)}},buttonText:a("download_csv_with_errors_here_or_from_upload_history"),toastType:P.Ck.error,options:{duration:1/0}})}else(0,P.ZT)(a("bulk_operation_failed_upload"),new Error(JSON.stringify(e.data))),d=e.data})).catch((e=>{(0,P.ZT)(a("bulk_operation_failed_upload"),e),d=JSON.stringify(e)})).finally((()=>{t(),j(!1),c.invalidateQueries({queryKey:[T.B.bulkOpsHistoryTable,_]}),l(N.yL.BulkOpsSpreadsheetUploaded,{bulk_operation_type:i,error:d,geo_company_id:_,company_id:m,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"Spreadsheet Uploaded",object:"Bulk Operations"})}))};return(0,s.jsxs)(s.Fragment,{children:[f&&(0,s.jsx)(U,{error:f,getBulkOperationSelectionLabel:n,onClose:()=>k(null)}),(0,s.jsxs)("div",{className:E()("group flex h-36 w-full cursor-pointer flex-col items-center justify-center space-y-1 rounded-lg border-2 border-dashed border-indigo-1 hover:border-gray-3-dark",{"!border-gray-3-dark":h}),onClick:()=>{y.current?.click()},onDragEnter:v,onDragLeave:v,onDragOver:v,onDrop:e=>{e.preventDefault(),e.stopPropagation(),x(!1);const t=e.dataTransfer.files[0];w(t)},children:[b?(0,s.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,s.jsx)(d.mb,{iconColor:d.yP.indigo1,iconSize:"w-8 h-8"}),(0,s.jsxs)(d.gL,{typography:d.c0.label2,color:d.yP.gray1,children:[a("uploading"),"..."]})]}):(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(d.Sd,{iconType:d.iz.upload,className:E()("text-indigo-1 group-hover:!text-indigo-2-dark",{"!text-indigo-2-dark":h})}),(0,s.jsx)(d.gL,{typography:d.c0.label2,className:E()("text-indigo-1 group-hover:!text-indigo-2-dark",{"!text-indigo-2-dark":h}),children:a("select_or_drag_and_drop_to_upload")})]}),(0,s.jsx)(d.gL,{typography:d.c0.caption,className:E()("!text-gray-2-light group-hover:!text-indigo-2-dark",{"!text-indigo-2-dark":h}),children:a("supports_csv_only")}),(0,s.jsx)("input",{type:"file",accept:".csv",ref:y,onClick:e=>{e.currentTarget.value=""},onChange:e=>{e.target.files?.[0]&&w(e.target.files[0])},style:{display:"none"},max:"1"})]})]})},H=({bulkOperationType:e})=>{const{t}=(0,p.c)();return(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:(a=(()=>{switch(e){case y.x.spCampaignBulkTakeover:return t("campaign_bulk_takeover_instructions");case y.x.spCampaignList:return t("bulk_sp_campaign_edit_instructions");case y.x.spCombinedGoalsList:return t("bulk_sp_goals_edit_instructions");case y.x.spMAGGoalList:return t("bulk_mag_goals_edit_instructions");case y.x.productTags:default:return""}})(),(0,S.R)(a,{rehypeReactOptions:{components:{strong:e=>(0,s.jsx)("span",{className:"font-semibold",...e})}}}))});var a},V=()=>{const{t:e}=(0,p.c)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:2,title:e("traffic_reporting.cogs.sections.edit.title")}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,children:e("to_ensure_errors_are_reduced.disclaimer")}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:(0,S.R)(e("traffic_reporting.cogs.sections.edit_spreadsheet.instructions"))})]})]})},Y=({instructions:e})=>{const{t}=(0,p.c)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:2,title:t("edit_takeover_spreadsheet")}),(0,s.jsx)(d.gL,{typography:d.c0.label,children:t("to_ensure_errors_are_reduced.disclaimer")}),e]})},q=({instructions:e})=>{const{t}=(0,p.c)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:2,title:t("edit_takeover_spreadsheet")}),(0,s.jsx)(d.gL,{typography:d.c0.label,children:t("edit_custom_spreadsheet")}),e]})},J=({uploadBox:e})=>{const{t}=(0,p.c)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:3,title:t("upload_spreadsheet_with_edits")}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,children:t("traffic_reporting.cogs.sections.upload.description")}),e]})]})},Q=({uploadBox:e,selectedAdType:t})=>{const{t:a}=(0,p.c)(),{AD_TYPE_TO_TEXT:r}=(0,n.o_)();return(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:3,title:a("upload_spreadsheet_with_edits")}),(0,s.jsx)(d.gL,{color:d.yP.grayDark3,typography:d.c0.label,children:a("the_edited_spreadsheet_must_match_parameters")}),(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)(d.MV,{text:a("non_perpetua_managed_campaigns"),variant:d.FU.indigo2,size:d.t.micro}),(0,s.jsx)(d.MV,{text:r[t],variant:d.FU.indigo2,size:d.t.micro})]}),e]})},K=({uploadBox:e,selectedAdType:t,selectedGranularityLevel:a})=>{const{t:r}=(0,p.c)(),{AD_TYPE_TO_TEXT:o,GRANULARITY_LEVEL_TO_TEXT:l}=(0,n.o_)();return a===n.tt.ProductTags?(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:3,title:r("upload_spreadsheet_with_edits")}),(0,s.jsx)(d.gL,{typography:d.c0.label,children:r("product_tags.upload_description")}),e]}):(0,s.jsxs)("div",{className:"w-full space-y-4",children:[(0,s.jsx)(L,{number:3,title:r("upload_spreadsheet_with_edits")}),(0,s.jsx)(d.gL,{typography:d.c0.label,children:r("the_spreadsheet_uploaded_needs_to_match_granularity_level")}),(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)(d.MV,{text:r("perpetua_managed_campaigns"),variant:d.FU.indigo2,size:d.t.micro}),(0,s.jsx)(d.MV,{text:o[t],variant:d.FU.indigo2,size:d.t.micro}),(0,s.jsx)(d.MV,{text:l[a],variant:d.FU.indigo2,size:d.t.micro})]}),e]})},X=({selectedRadioButton:e,selectedAdType:t,selectedGranularityLevel:a,setSelectedTabId:r})=>{const{determineBulkOperationType:o}=g(),l=o(e,t,a),i=(0,s.jsx)(F,{bulkOperationType:l,onUploadFinish:()=>r(n.js.Upload)}),c=(0,s.jsx)(H,{bulkOperationType:l});return(0,s.jsxs)(d.Wt,{className:"flex space-x-6 p-6",shadow:!0,border:!0,rounded:!0,children:[e===n.Wl.NonPerpetuaManaged&&(0,s.jsx)(Y,{instructions:c}),e===n.Wl.PerpetuaManaged&&l===y.x.productTags&&(0,s.jsx)(R,{}),e===n.Wl.PerpetuaManaged&&l!==y.x.productTags&&(0,s.jsx)(q,{instructions:c}),e===n.Wl.CostOfGoodsPerUnit&&(0,s.jsx)(V,{}),(0,s.jsx)("div",{className:"min-h-full w-0.5 bg-gray-4-light"}),e===n.Wl.NonPerpetuaManaged&&(0,s.jsx)(Q,{uploadBox:i,selectedAdType:t}),e===n.Wl.PerpetuaManaged&&(0,s.jsx)(K,{uploadBox:i,selectedAdType:t,selectedGranularityLevel:a}),e===n.Wl.CostOfGoodsPerUnit&&(0,s.jsx)(J,{uploadBox:i})]})};var Z=a(97286),$=a(68827),ee=a(35860);const te=({row:{key:e,data:{workflowProgress:t,workflowResult:a,resultURI:l,status:i,bulkOperationType:c,transferType:u}}})=>{const{t:g}=(0,p.c)(),_=(0,O.GQ)(),m=(0,$.B)(),h=(0,o.d4)((e=>e.companies?.activeGeoCompany?.id)),x=(0,o.d4)((e=>e.companies.activeCompany?.id)),[b,j]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),v=(0,r.useMemo)((()=>{const t={[n.mm.Success]:g("completed"),[n.mm.Failed]:g("failed"),[n.mm.SuccessWithWarnings]:g("completed_with_warnings"),[n.mm.PartialSuccess]:g("completed_with_
1some_failures"),[n.mm.NoAction]:g("no_changes_applied"),[n.mm.InternalError]:g("unexpected_error")};return i===n.mm.InternalError?(0,s.jsxs)("div",{className:"flex w-full items-center justify-between",children:[i===n.mm.InternalError&&(0,s.jsxs)("div",{children:[(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.gray1,"data-cy":"status-cell-internal-error-label",children:t[i]}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray2,"data-cy":"status-cell-internal-error-description",children:g("contact_support")})]}),i===n.mm.InternalError&&(0,s.jsx)(d.SB,{side:d.pD.top,title:g("contact_support"),children:(0,s.jsx)(d.lD,{iconType:d.iz.support,variant:d.Yx.quaternary,color:d.yP.gray1,onClick:()=>m.showNewMessage("Iâm having issues with initiating a Bulk Operation, can you help me?")})},`${e}-open`)]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.gray1,"data-cy":"status-cell-completed-progress-label",children:t[i]}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray2,"data-cy":"status-cell-completed-description-label",children:i===n.mm.NoAction&&u===n.De.UPLOAD?g("bulk_ops_status_bar_upload_no_action_warning"):c===y.x.spCampaignBulkTakeover&&u===n.De.UPLOAD&&a?g("open_to_view_details"):g(l?"download_to_view_details":"unable_to_view_details")})]}),c===y.x.spCampaignBulkTakeover&&u===n.De.UPLOAD&&a?(0,s.jsx)(d.SB,{side:d.pD.top,title:g("view"),children:(0,s.jsx)(d.lD,{iconType:d.iz.view,variant:d.Yx.quaternary,color:d.yP.gray1,onClick:()=>{j(!0),_(N.yL.BulkOpsHistoryViewed,{history_type:u,error:null,geo_company_id:h,company_id:x,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"History Viewed",object:"Bulk Operations"})},dataCy:"campaign-takeover-details-open-button"})},`${e}-open`):l?(0,s.jsx)(d.SB,{side:d.pD.top,title:g("download"),"data-cy":"csv-download-button-tooltip",children:f?(0,s.jsx)(d.mb,{iconColor:d.yP.gray1}):(0,s.jsx)(d.lD,{iconType:d.iz.download,variant:d.Yx.quaternary,color:d.yP.gray1,onClick:async()=>{let e=null;k(!0);try{const{file:e,fileName:t}=await(0,B.g)(l,h);(0,A.saveAs)(e,t)}catch(t){(0,P.ZT)(g("error"),t),e=JSON.stringify(t)}finally{k(!1),_(N.yL.BulkOpsHistoryDownloaded,{history_type:u,error:e,geo_company_id:h,company_id:x,marketplace:N.O8.Amazon,page_name:"Bulk Operations",action:"Downloaded",object:"History"})}},dataCy:"csv-download-button"})},`${e}-download`):null]})}),[x,h,c,f,l,e,i,u,a,m]);return(0,s.jsxs)(s.Fragment,{children:[(e=>{switch(e){case n.mm.Success:return(0,s.jsx)(d.Sd,{iconType:d.iz.approve,iconColor:d.yP.green1});case n.mm.Failed:return(0,s.jsx)(d.Sd,{iconType:d.iz.warning,iconColor:d.yP.orange1});case n.mm.SuccessWithWarnings:case n.mm.NoAction:case n.mm.PartialSuccess:return(0,s.jsx)(d.Sd,{iconType:d.iz.approve,iconColor:d.yP.orange1});default:return null}})(i),i!==n.mm.InProgress?v:(0,s.jsx)("div",{className:"w-full","data-cy":"status-cell-in-progress",children:(0,s.jsxs)("div",{className:"w-[148px] space-y-1",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.grayLight2,children:g("percent_completed",{percentage:Math.floor(t?.finished/t?.total*100||0)})}),(0,s.jsx)(d.hk,{progress:t?t?.finished/t?.total:0})]})}),b&&(0,s.jsx)(ee.A,{campaignTakeoverResults:a,modalVisible:b,setModalVisible:j})]})};var ae=a(74353),se=a.n(ae);const re=({row:{data:{actionDate:e,email:t}}})=>(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.gray1,children:se()(e).calendar(null,{lastWeek:"llll",lastDay:"llll",sameDay:"llll",sameElse:"llll"})}),(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.gray1,children:t})]});var oe=a(60404);const le=({row:{data:{bulkOperationType:e,fileName:t,adType:a,granularity:o}}})=>{const{t:l}=(0,p.c)(),n=!!t||!!a||!!o,[i,c]=r.useState(!1),u=(0,oe.zh)({position:"relative",opacity:i?"100%":"0%",height:i?(()=>{let e=20,s=0;return t&&(s+=1),a&&(s+=1),o&&(s+=1),e*=s,t&&(e+=20*Math.floor(t?.length/40)),e})():20,delay:150});return(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)(d.gL,{typography:d.c0.label,color:d.yP.gray1,children:(()=>{switch(e){case y.x.spCampaignBulkTakeover:return l("sp_campaign_bulk_takeover");case y.x.spCombinedGoalsList:case y.x.spMAGGoalList:return l("sp_goals_list");case y.x.spCampaignList:return l("sp_campaigns_list");case y.x.costOfGoodsPerUnit:return l("cogs");case y.x.productTags:return l("product_tags");default:return""}})()}),i&&(0,s.jsxs)(oe.CS.div,{style:u,children:[(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:t}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:a}),(0,s.jsx)(d.gL,{typography:d.c0.caption,color:d.yP.gray1,children:o})]}),n&&(0,s.jsx)(d.lD,{variant:d.Yx.quaternary,text:l(i?"show_less":"show_more"),onClick:()=>c((e=>!e)),size:d.gO.small})]})};var ne=a(20092);const ie=({rows:e,bulkHistoryHeaders:t,transferType:a,loading:r,limit:o,setLimit:l,offset:n,setOffset:i,totalRecords:c})=>{const{t:u}=(0,p.c)(),y=(0,s.jsx)(ne.A,{offset:n,pageSize:o,totalRows:c,minPageSize:50,onOffsetChange:e=>{i(e)},onPageSizeChange:e=>{i(0),l(e)},isCompact:!0}),g=u("upload"===a?"no_uploads_yet":"no_downloads_yet"),_=u("upload"===a?"your_recent_upload_history":"your_recent_download_history");return(0,s.jsx)(d.Ni,{rounded:!1,headers:t,actionBar:!1,rows:e,readOnlyStyling:!0,loading:r,empty:(0,s.jsx)(d.tN,{title:g,iconType:"upload"===a?d.iz.upload:d.iz.download,iconSize:"w-10 h-10",gradientIcon:!1,bodyText:[_]}),"data-cy":`bulk-ops-${a.toLowerCase()}
1-history-table`,footer:y})},ce=({selectedTabId:e,setSelectedTabId:t,historyTableRef:a})=>{const{t:l,tICU:i}=(0,p.c)(),c=(0,O.GQ)(),u=(0,o.d4)((e=>e.companies?.activeGeoCompany?.id)),[_,h]=(0,r.useState)([]),[x,b]=(0,r.useState)(0),[j,f]=(0,r.useState)(50),{magGoalsBulkOperations:k}=(0,m.E0)(),v=(0,Z.I)({queryKey:[T.B.bulkOpsHistoryTable,u,e,j,x],queryFn:()=>(0,G.cw)(u,e===n.js.Download?n.De.DOWNLOAD:n.De.UPLOAD,j,x),enabled:Boolean(u),retry:5,retryDelay:e=>Math.min(1e3*2**e,3e4),refetchInterval:e=>e.state.data?5e3:0,gcTime:0});(0,r.useEffect)((()=>{v.isError&&(0,P.X6)({toastType:P.Ck.error,title:l("error"),description:l("there_was_an_error_getting_your_bulk_ops_history")})}),[v.isError]);const{getAdType:w,getGranularityLevel:C}=g();(0,r.useEffect)((()=>{let e=0,t=[];v.data?.results?.forEach((a=>{(a.bulk_operation_type!==y.x.spMAGGoalList||k)&&(t.push({key:String(e),data:{email:a.email_address,actionDate:a.creation_date,transferType:a.transfer_type,bulkOperationType:a.bulk_operation_type,fileName:a.uploaded_file_name,adType:w(a.bulk_operation_type),granularity:C(a.bulk_operation_type),status:a.status,workflowProgress:a.workflow_progress,workflowResult:a.workflow_result,resultURI:a.result_uri}}),e+=1)})),h(t)}),[v.data,k]);const L=(()=>{const{t:e}=(0,p.c)();return[{key:"identifier",title:"",cell:re,colspan:1.6,sortable:!1,selectable:!1,selected:!0},{key:"summary",get title(){return e("summary")},cell:le,colspan:1.6,sortable:!1,selectable:!1,selected:!0},{key:"status",get title(){return e("status")},cell:te,colspan:1.6,sortable:!1,selectable:!1,selected:!0}]})();return(0,s.jsxs)(d.Wt,{shadow:!0,border:!0,rounded:!0,ref:a,children:[(0,s.jsx)("div",{className:"mb-2 flex w-full items-center space-x-4 px-6 pt-6",children:(0,s.jsx)(d.gL,{color:d.yP.grayDark3,typography:d.c0.label3,children:l("download_and_upload_history")})}),(0,s.jsx)("div",{className:"mb-7 flex w-full items-center justify-between pl-6",children:(0,s.jsx)(d.gL,{color:d.yP.gray1,typography:d.c0.caption,children:(0,S.R)(l("bulk_ops_tab_history_table.file_upload_limit"),{rehypeReactOptions:{components:{strong:e=>(0,s.jsx)("span",{className:"font-semibold text-gray-1",...e})}}})})}),(0,s.jsx)(d.FN,{className:"!rounded-t-none !border-0 px-6 pb-7",tabs:[{id:n.js.Upload,title:l("uploads")},{id:n.js.Download,title:l("downloads")}],selectedTabId:e,onTabChange:e=>{c(N.yL.BulkOperationsHistoryViewed,{object:"Bulk Operations",action:"History Viewed"}),b(0),t(e)},size:d.vc.Small}),(0,s.jsx)(ie,{rows:_,bulkHistoryHeaders:(()=>{const t=L[0],a=v.data?.total||0;return t.title=((e,t)=>i("download"===t?"download_count":"upload_count",{count:e}))(a,e),L[0]=t,L})(),transferType:e,loading:v.isPending,limit:j,setLimit:f,totalRecords:v.data?.total||0,setOffset:b,offset:x})]})};var de=a(66422),pe=a(20603);const ue=()=>{const{t:e}=(0,p.c)();return(0,s.jsx)(de.A,{flag:pe.nh.HAS_SEEN_MAGCT_BULK_OPERATIONS,title:e("bulk_operations.magct_banner.title"),description:e("bulk_operations.magct_banner.description")})},ye=()=>{const{t:e}=(0,p.c)();return(0,s.jsx)(de.A,{flag:pe.nh.HAS_SEEN_BANNER_PRODUCT_TAGS,title:e("product_tags.new_feature_banner.title"),description:e("product_tags.new_feature_banner.description"),buttons:[{text:e("learn_more"),variant:d.Yx.secondary,onClick:()=>window.open("https://help.perpetua.io/en/articles/8957391-sales-traffic-product-tags-draft#h_8498835178","_blank noopener noreferrer")}]})};var ge=a(66997);const _e=()=>{const{t:e}=(0,p.c)(),t=(0,o.d4)((e=>e.companies.activeCompany.is_vendor)),[a]=(0,l.ok)(),i=(0,ge.Pg)(),[c,d]=(0,r.useState)(n.Wl.PerpetuaManaged),[u,y]=(0,r.useState)(n.fR.SponsoredProducts),[g,_]=(0,r.useState)(n.tt.GoalsAndSegments),[x,b]=(0,r.useState)([n.R9.GoalsAndAdGroups]),[j,f]=(0,r.useState)(n.js.Upload),v=(0,r.useRef)(null),{magGoalsBulkOperations:w}=(0,m.E0)();return(0,k.JY)({title:e("bulk_operations"),datePickerState:h.n.HIDDEN}),(0,r.useEffect)((()=>{const e=a.get("selectedRadioButton"),t=a.get("selectedGranularityLevel");Object.values(n.Wl).includes(e)&&d(e),Object.values(n.tt).includes(t)&&_(t),i({selectedRadioButton:null,selectedGranularityLevel:null})}),[a,i]),(0,r.useEffect)((()=>{t&&c===n.Wl.CostOfGoodsPerUnit&&d(n.Wl.PerpetuaManaged)}),[t,c]),(0,s.jsxs)("div",{className:"flex w-[900px] flex-col space-y-4",children:[(0,s.jsx)(ye,{}),w&&(0,s.jsx)(ue,{}),(0,s.jsx)(D,{selectedRadioButton:c,setSelectedRadioButton:d,selectedAdType:u,setSelectedAdType:y,selectedGranularityLevel:g,setSelectedGranularityLevel:_,setSelectedTabId:f,selectedRowInclusionCheckboxes:x,setSelectedRowInclusionCheckboxes:b,historyTableRef:v}),(0,s.jsx)(X,{selectedRadioButton:c,selectedAdType:u,selectedGranularityLevel:g,setSelectedTabId:f}),(0,s.jsx)(ce,{selectedTabId:j,setSelectedTabId:f,historyTableRef:v})]})}},34832:(e,t,a)=>{a.d(t,{I:()=>r});var s=a(64628);function r(e,t){return function(e,t){const a=new Set(t);return e.filter((e=>!a.has(e)))}(function(e,t){return(0,s.s)(e.concat(t))}(e,t),function(e,t){const a=new Set(t);return e.filter((e=>a.has(e)))}(e,t))}}}]);
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.