"use strict";(globalThis.webpackChunkgoogle_listings_and_ads=globalThis.webpackChunkgoogle_listings_and_ads||[]).push([[553],{521:(e,s,n)=>{n.d(s,{A:()=>r});var t=n(7143),a=n(6520),i=n(7692),o=n(2775);const l="products",g={products:[],intervals:[],totals:{}};function r(e){const s=(0,o.A)();return(0,t.useSelect)(n=>{const{getReport:t}=n(a.Ui),o=t(l,e,s,"primary"),r=t(l,e,s,"secondary"),d=o.loaded&&r.loaded;let u=g;return d&&o.data&&r.data&&(u={products:o.data.products||g.products,intervals:o.data.intervals||g.intervals,totals:(0,i.bM)(o.data.totals,r.data.totals,o.reportQuery.fields)}),{data:u,loaded:d}},[e,s])}},6343:(e,s,n)=>{n.r(s),n.d(s,{default:()=>T});var t=n(6087),a=n(6427),i=n(7723),o=n(8468),l=n(2434),g=n(9927),r=n(7343),d=n(7892),u=n(9457);const c={confirmationModal:"_GQ4sGfGTeKA7JPcBsrS"};var h=n(4848);function _({onContinue:e,onRequestClose:s}){return(0,h.jsxs)(u.A,{className:c.confirmationModal,title:(0,i.__)("Before you save…","google-listings-and-ads"),buttons:[(0,h.jsx)(d.A,{isSecondary:!0,onClick:s,children:(0,i.__)("Don't save","google-listings-and-ads")},"cancel"),(0,h.jsx)(d.A,{isPrimary:!0,onClick:e,children:(0,i.__)("Continue to save","google-listings-and-ads")},"continue")],onRequestClose:s,children:[(0,h.jsx)("p",{children:(0,i.__)("Results typically improve with time.","google-listings-and-ads")}),(0,h.jsx)("p",{children:(0,i.__)("Changes will result in the loss of any optimisations learned over time.","google-listings-and-ads")}),(0,h.jsx)("p",{children:(0,i.__)("We recommend allowing your listings to run for at least 14 days after set up without changing them for optimal performance.","google-listings-and-ads")})]})}var p=n(5847),v=n(873),m=n(1650),f=n(6523),A=n(5622),S=n(5640),y=n(4716),C=n(5455),w=n(5807),j=n(8606),x=n(2635),b=n(6876),R=n(6473);function T(){const{targetAudience:e,getFinalCountries:s}=(0,p.A)(),{settings:n,saveSettings:d,syncSettings:u}=(0,v.A)(),{saveTargetAudience:c}=(0,l.j)(),{saveShippingRates:T}=(0,C.A)(),{saveShippingTimes:q}=(0,w.A)(),[E,k]=(0,t.useState)(e),[F,M]=(0,t.useState)(n),{hasFinishedResolution:G,data:P}=(0,f.A)(),[B,N]=(0,t.useState)(P),{hasFinishedResolution:Q,data:U}=(0,A.A)(),[Y,D]=(0,t.useState)(U),[J,K]=(0,t.useState)(null);(0,t.useEffect)(()=>M(n),[n]),(0,t.useEffect)(()=>k(e),[e]),(0,t.useEffect)(()=>N(P),[P]),(0,t.useEffect)(()=>D(U),[U]);const{createNotice:L}=(0,S.A)(),W=!(0,o.isEqual)(...[E,e].map(e=>({...e,countries:new Set(e?.countries)}))),z=!(0,o.isEqual)(F,n),H=(O=P,(I=B).length!==O.length||(0,y.A)(I,O).length>0);var I,O;const V=!(0,o.isEqual)(new Set(Y),new Set(U)),X=W||z||H||V;(0,m.A)((0,i.__)("You have unsaved changes. Are you sure you want to leave?","google-listings-and-ads"),X);const Z=E?.countries?E:null,$=F?.shipping_rate?F:null,ee=G?P:null,se=Q?U:null;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.A,{}),(0,h.jsx)(g.A,{}),(0,h.jsx)(r.A,{targetAudience:Z,resolveFinalCountries:s,onTargetAudienceChange:k,settings:$,onSettingsChange:M,shippingRates:ee,onShippingRatesChange:N,shippingTimes:se,onShippingTimesChange:D,onRequestSubmit:()=>new Promise(e=>{K(()=>s=>{e(s),K(null)})}),onContinue:async()=>{try{const e=[c(E),d(F),T(B),q(Y)],s=await(0,j.A)(e,[(0,i.__)("Target audience","google-listings-and-ads"),(0,i.__)("Merchant Center Settings","google-listings-and-ads"),(0,i.__)("Shipping rates","google-listings-and-ads"),(0,i.__)("Shipping times","google-listings-and-ads")]);await u(),s?L("error",s):L("success",(0,i.__)("Your changes have been saved and will be synced to your Google Merchant Center account.","google-listings-and-ads")),(0,R.ce)("gla_free_campaign_edited")}catch(e){(0,b.h)(e,(0,i.__)("Unable to save your changes.","google-listings-and-ads"),(0,i.__)("Something went wrong while saving your changes. Please try again later.","google-listings-and-ads"))}},submitLabel:(0,i.__)("Save changes","google-listings-and-ads")}),(0,h.jsx)(a.Flex,{justify:"flex-end",children:(0,h.jsx)(r.A.SubmitButton,{})}),J&&(0,h.jsx)(_,{onContinue:()=>J(!0),onRequestClose:()=>J(!1)})]})}}}]);