woocommerce/packages/woocommerce-admin/dist/chunks/task-list.js
2021-12-10 12:03:04 +00:00

1 line
77 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[51],{162:function(e,t,o){"use strict";o.d(t,"a",(function(){return s}));var c=o(15),n=o(13);const s=(e,t={})=>{const{pathname:o,search:s}=window.location,a=Object(n.f)("connectNonce","");return t={"wccom-site":Object(n.f)("siteUrl"),"wccom-back":o+s,"wccom-woo-version":Object(n.f)("wcVersion"),"wccom-connect-nonce":a,...t},Object(c.addQueryArgs)(e,t)}},473:function(e,t,o){"use strict";var c=o(0),n=o(8),s=Object(c.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(n.Path,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"}));t.a=s},475:function(e,t,o){"use strict";var c=o(0),n=o(8),s=Object(c.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(n.Path,{d:"M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"}));t.a=s},526:function(e,t,o){"use strict";o.d(t,"a",(function(){return c})),o.d(t,"b",(function(){return n}));const c=(e,t,o="undefined")=>e&&Array.isArray(e)&&e.length?t?e.reduce((e,c)=>(c[t]||(c[t]=o),(e[c[t]]=e[c[t]]||[]).push(c),e),{}):e:{},n=(e,t)=>Object.entries(e).reduce((e,[o])=>({...e,[o]:t}),{})},527:function(e,t,o){"use strict";o.d(t,"b",(function(){return p})),o.d(t,"a",(function(){return u}));var c=o(35),n=o.n(c),s=o(0),a=o(2),i=o(28),r=o(4),l=o(13),m=o(21);const{countries:d}=Object(l.f)("dataEndpoints",{countries:{}});function p(e){const t={};return e.addressLine1.trim().length||(t.addressLine1=Object(a.__)("Please add an address",'woocommerce')),e.countryState.trim().length||(t.countryState=Object(a.__)("Please select a country / region",'woocommerce')),e.city.trim().length||(t.city=Object(a.__)("Please add a city",'woocommerce')),e.postCode.trim().length||(t.postCode=Object(a.__)("Please add a post code",'woocommerce')),t}function u(e){const{getInputProps:t,setValue:o}=e,c=Object(s.useMemo)(()=>d.reduce((e,t)=>{if(!t.states.length)return e.push({key:t.code,label:Object(i.decodeEntities)(t.name)}),e;const o=t.states.map(e=>({key:t.code+":"+e.code,label:Object(i.decodeEntities)(t.name)+" — "+Object(i.decodeEntities)(e.name)}));return e.push(...o),e},[]),[]),l=function(e,t,o){const[c,n]=Object(s.useState)(""),[a,i]=Object(s.useState)(""),l=Object(s.useRef)();return Object(s.useEffect)(()=>{const o=e.find(e=>e.key===t),s=o?o.label.split(/\u2013|\u2014|\-/):[],r=(s[0]||"").trim(),m=(s[1]||"").trim();l.current||r===c&&m===a||(n(r),i(m)),l.current=!1},[t]),Object(s.useEffect)(()=>{c||a||!t||(l.current=!0,o("countryState",""));let n=[];const s=new RegExp(Object(r.escapeRegExp)(c),"i"),i=new RegExp(Object(r.escapeRegExp)(a.replace(/\s/g,""))+"$","i");if((a.length||c.length)&&(n=e.filter(e=>(c.length?s:i).test(e.label))),c.length&&a.length){const e=a.length<3;n=n.filter(t=>i.test((e?t.key:t.label).replace("-","").replace(/\s/g,"")));const t=c.length<3;if(n.length>1){let e=[];e=n.filter(e=>s.test(t?e.key:e.label)),e.length>0&&(n=e)}if(n.length>1){let t=[];t=n.filter(t=>i.test((e?t.key:t.label).replace("-","").replace(/\s/g,""))),1===t.length&&(n=t)}}1===n.length&&t!==n[0].key&&(l.current=!0,o("countryState",n[0].key))},[c,a,e,o]),Object(s.createElement)(s.Fragment,null,Object(s.createElement)("input",{onChange:e=>n(e.target.value),value:c,name:"country",type:"text",className:"woocommerce-select-control__autofill-input",tabIndex:"-1",autoComplete:"country"}),Object(s.createElement)("input",{onChange:e=>i(e.target.value),value:a,name:"state",type:"text",className:"woocommerce-select-control__autofill-input",tabIndex:"-1",autoComplete:"address-level1"}))}(c,t("countryState").value,o);return Object(s.createElement)("div",{className:"woocommerce-store-address-fields"},Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("Address line 1",'woocommerce'),required:!0,autoComplete:"address-line1"},t("addressLine1"))),Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("Address line 2 (optional)",'woocommerce'),required:!0,autoComplete:"address-line2"},t("addressLine2"))),Object(s.createElement)(m.SelectControl,n()({label:Object(a.__)("Country / Region",'woocommerce'),required:!0,autoComplete:"new-password",options:c,excludeSelectedOptions:!1,showAllOnFocus:!0,isSearchable:!0},t("countryState"),{controlClassName:t("countryState").className}),l),Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("City",'woocommerce'),required:!0},t("city"),{autoComplete:"address-level2"})),Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("Post code",'woocommerce'),required:!0,autoComplete:"postal-code"},t("postCode"))))}},538:function(e,t,o){},593:function(e,t,o){},594:function(e,t,o){},595:function(e,t,o){},596:function(e,t,o){},597:function(e,t,o){},598:function(e,t,o){},611:function(e,t,o){"use strict";o.r(t);var c=o(0),n=o(2),s=o(3),a=o(475),i=o(7),r=o(11),l=o(122),m=o(16),d=o(21),p=(o(541),o(14)),u=o(4),_=o(28),b=o(13),g=o(60),h=o(509),O=o(162);class j extends c.Component{constructor(e){super(e),this.state={purchaseNowButtonBusy:!1,purchaseLaterButtonBusy:!1}}onClickPurchaseNow(){const{productIds:e,onClickPurchaseNow:t}=this.props;if(this.setState({purchaseNowButtonBusy:!0}),!e.length)return;Object(m.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:e,purchase_install:!0});const o=Object(O.a)("https://woocommerce.com/cart?utm_medium=product",{"wccom-replace-with":e.join(",")});t?t(o):window.location=o}onClickPurchaseLater(){const{productIds:e}=this.props;Object(m.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:e,purchase_install:!1}),this.setState({purchaseLaterButtonBusy:!0}),this.props.onClickPurchaseLater()}onClose(){const{onClose:e,productIds:t}=this.props;Object(m.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:t,purchase_install:!1}),e()}renderProducts(){const{productIds:e,productTypes:t}=this.props,{themes:o=[]}=Object(b.f)("onboarding",{}),s=[];return e.forEach(e=>{const a=Object(u.find)(t,t=>t.product===e);a&&s.push({title:a.label,content:a.description});const i=Object(u.find)(o,t=>t.id===e);i&&s.push({title:Object(n.sprintf)(Object(n.__)("%s — %s per year",'woocommerce'),i.title,Object(_.decodeEntities)(i.price)),content:Object(c.createElement)("span",{dangerouslySetInnerHTML:Object(h.a)(i.excerpt)})})}),Object(c.createElement)(d.List,{items:s})}render(){const{purchaseNowButtonBusy:e,purchaseLaterButtonBusy:t}=this.state;return Object(c.createElement)(s.Modal,{title:Object(n.__)("Would you like to add the following paid features to your store now?",'woocommerce'),onRequestClose:()=>this.onClose(),className:"woocommerce-cart-modal"},this.renderProducts(),Object(c.createElement)("p",{className:"woocommerce-cart-modal__help-text"},Object(n.__)("You won't have access to this functionality until the extensions have been purchased and installed.",'woocommerce')),Object(c.createElement)("div",{className:"woocommerce-cart-modal__actions"},Object(c.createElement)(s.Button,{isLink:!0,isBusy:t,onClick:()=>this.onClickPurchaseLater()},Object(n.__)("I'll do it later",'woocommerce')),Object(c.createElement)(s.Button,{isPrimary:!0,isBusy:e,onClick:()=>this.onClickPurchaseNow()},Object(n.__)("Buy now",'woocommerce'))))}}var w=Object(p.compose)(Object(i.withSelect)(e=>{const{getInstalledPlugins:t}=e(r.PLUGINS_STORE_NAME),{getProductTypes:o,getProfileItems:c}=e(r.ONBOARDING_STORE_NAME),n=c(),s=t(),a=o();return{profileItems:n,productIds:Object(g.e)(a,n,!1,s),productTypes:a}}))(j),y=o(30),k=o(12),E=o(17),S=o.n(E);class v extends c.Component{constructor(e){super(e);const{hasHomepage:t,hasProducts:o}=e.tasksStatus;this.stepVisibility={homepage:!t,import:!o},this.state={isDirty:!1,isPending:!1,logo:null,stepIndex:0,isUpdatingLogo:!1,isUpdatingNotice:!1,storeNoticeText:e.demoStoreNotice||""},this.completeStep=this.completeStep.bind(this),this.createHomepage=this.createHomepage.bind(this),this.importProducts=this.importProducts.bind(this),this.updateLogo=this.updateLogo.bind(this),this.updateNotice=this.updateNotice.bind(this)}componentDidMount(){const{themeMods:e}=this.props.tasksStatus;e&&e.custom_logo&&this.setState({logo:{id:e.custom_logo}})}componentDidUpdate(e){const{isPending:t,logo:o}=this.state,{demoStoreNotice:c}=this.props;!o||o.url||t||(this.setState({isPending:!0}),wp.media.attachment(o.id).fetch().then(()=>{const e=wp.media.attachment(o.id).get("url");this.setState({isPending:!1,logo:{id:o.id,url:e}})})),c&&e.demoStoreNotice!==c&&this.setState({storeNoticeText:c})}completeStep(){const{stepIndex:e}=this.state;this.getSteps()[e+1]?this.setState({stepIndex:e+1}):Object(k.getHistory)().push(Object(k.getNewPath)({},"/",{}))}importProducts(){const{clearTaskStatusCache:e,createNotice:t}=this.props;this.setState({isPending:!0}),Object(m.recordEvent)("tasklist_appearance_import_demo",{}),S()({path:r.WC_ADMIN_NAMESPACE+"/onboarding/tasks/import_sample_products",method:"POST"}).then(o=>{o.failed&&o.failed.length?t("error",Object(n.__)("There was an error importing some of the sample products",'woocommerce')):(t("success",Object(n.__)("All sample products have been imported",'woocommerce')),e()),this.setState({isPending:!1}),this.completeStep()}).catch(e=>{t("error",e.message),this.setState({isPending:!1})})}createHomepage(){const{clearTaskStatusCache:e,createNotice:t}=this.props;this.setState({isPending:!0}),Object(m.recordEvent)("tasklist_appearance_create_homepage",{create_homepage:!0}),S()({path:"/wc-admin/onboarding/tasks/create_homepage",method:"POST"}).then(o=>{e(),t(o.status,o.message,{actions:o.edit_post_link?[{label:Object(n.__)("Customize",'woocommerce'),onClick:()=>{Object(m.queueRecordEvent)("tasklist_appearance_customize_homepage",{}),window.location=o.edit_post_link+"&wc_onboarding_active_task=homepage"}}]:null}),this.setState({isPending:!1}),this.completeStep()}).catch(e=>{t("error",e.message),this.setState({isPending:!1})})}async updateLogo(){const{clearTaskStatusCache:e,createNotice:t,stylesheet:o,themeMods:c,updateOptions:s}=this.props,{logo:a}=this.state,i={...c,custom_logo:a?a.id:null};Object(m.recordEvent)("tasklist_appearance_upload_logo"),this.setState({isUpdatingLogo:!0});const r=await s({["theme_mods_"+o]:i});e(),r.success?(this.setState({isUpdatingLogo:!1}),t("success",Object(n.__)("Store logo updated sucessfully",'woocommerce')),this.completeStep()):t("error",r.message)}async updateNotice(){const{clearTaskStatusCache:e,createNotice:t,updateOptions:o}=this.props,{storeNoticeText:c}=this.state;Object(m.recordEvent)("tasklist_appearance_set_store_notice",{added_text:Boolean(c.length)}),this.setState({isUpdatingNotice:!0});const s=await o({woocommerce_task_list_appearance_complete:!0,woocommerce_demo_store:c.length?"yes":"no",woocommerce_demo_store_notice:c});e(),s.success?(this.setState({isUpdatingNotice:!1}),t("success",Object(n.__)("🎨 Your store is looking great! Don't forget to continue personalizing it",'woocommerce')),this.completeStep()):t("error",s.message)}getSteps(){const{isDirty:e,isPending:t,logo:o,storeNoticeText:a,isUpdatingLogo:i}=this.state,r=[{key:"import",label:Object(n.__)("Import sample products",'woocommerce'),description:Object(n.__)("Well add some products that will make it easier to see what your store looks like",'woocommerce'),content:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(s.Button,{onClick:this.importProducts,isBusy:t,isPrimary:!0},Object(n.__)("Import products",'woocommerce')),Object(c.createElement)(s.Button,{onClick:()=>this.completeStep()},Object(n.__)("Skip",'woocommerce'))),visible:this.stepVisibility.import},{key:"homepage",label:Object(n.__)("Create a custom homepage",'woocommerce'),description:Object(n.__)("Create a new homepage and customize it to suit your needs",'woocommerce'),content:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(s.Button,{isPrimary:!0,isBusy:t,onClick:this.createHomepage},Object(n.__)("Create homepage",'woocommerce')),Object(c.createElement)(s.Button,{isTertiary:!0,onClick:()=>{Object(m.recordEvent)("tasklist_appearance_create_homepage",{create_homepage:!1}),this.completeStep()}},Object(n.__)("Skip",'woocommerce'))),visible:this.stepVisibility.homepage},{key:"logo",label:Object(n.__)("Upload a logo",'woocommerce'),description:Object(n.__)("Ensure your store is on-brand by adding your logo",'woocommerce'),content:t?null:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(d.ImageUpload,{image:o,onChange:e=>this.setState({isDirty:!0,logo:e})}),Object(c.createElement)(s.Button,{disabled:!o&&!e,onClick:this.updateLogo,isBusy:i,isPrimary:!0},Object(n.__)("Proceed",'woocommerce')),Object(c.createElement)(s.Button,{isTertiary:!0,onClick:()=>this.completeStep()},Object(n.__)("Skip",'woocommerce'))),visible:!0},{key:"notice",label:Object(n.__)("Set a store notice",'woocommerce'),description:Object(n.__)("Optionally display a prominent notice across all pages of your store",'woocommerce'),content:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(d.TextControl,{label:Object(n.__)("Store notice text",'woocommerce'),placeholder:Object(n.__)("Store notice text",'woocommerce'),value:a,onChange:e=>this.setState({storeNoticeText:e})}),Object(c.createElement)(s.Button,{onClick:this.updateNotice,isPrimary:!0},Object(n.__)("Complete task",'woocommerce'))),visible:!0}];return Object(u.filter)(r,e=>e.visible)}render(){const{isPending:e,stepIndex:t,isUpdatingLogo:o,isUpdatingNotice:n}=this.state,a=this.getSteps()[t].key;return Object(c.createElement)("div",{className:"woocommerce-task-appearance"},Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardBody,null,Object(c.createElement)(d.Stepper,{isPending:n||o||e,isVertical:!0,currentStep:a,steps:this.getSteps()}))))}}var f=Object(p.compose)(Object(i.withSelect)(e=>{const{getOption:t}=e(r.OPTIONS_STORE_NAME),{getTasksStatus:o}=e(r.ONBOARDING_STORE_NAME),c=o();return{demoStoreNotice:t("woocommerce_demo_store_notice"),stylesheet:t("stylesheet"),tasksStatus:c}}),Object(i.withDispatch)(e=>{const{createNotice:t}=e("core/notices"),{updateOptions:o}=e(r.OPTIONS_STORE_NAME),{invalidateResolutionForStoreSelector:c}=e(r.ONBOARDING_STORE_NAME);return{clearTaskStatusCache:()=>c("getTasksStatus"),createNotice:t,updateOptions:o}}))(v),C=o(20),T=(o(593),o(507));o(594);const N=({description:e,imageUrl:t,installAndActivate:o=(()=>{}),isActive:a,isBusy:i,isDisabled:r,isInstalled:l,manageUrl:d,name:p,slug:u})=>Object(c.createElement)("div",{className:"woocommerce-plugin-list__plugin"},t&&Object(c.createElement)("div",{className:"woocommerce-plugin-list__plugin-logo"},Object(c.createElement)("img",{src:t,alt:Object(n.sprintf)(Object(n.__)("%s logo",'woocommerce'),p)})),Object(c.createElement)("div",{className:"woocommerce-plugin-list__plugin-text"},Object(c.createElement)(C.Text,{variant:"subtitle.small",as:"h4"},p),Object(c.createElement)(C.Text,{variant:"subtitle.small"},e)),Object(c.createElement)("div",{className:"woocommerce-plugin-list__plugin-action"},a&&d&&Object(c.createElement)(s.Button,{disabled:r,isBusy:i,isSecondary:!0,href:Object(b.e)(d),onClick:()=>Object(m.recordEvent)("marketing_manage",{extension_name:u})},Object(n.__)("Manage","woocommmerce-admin")),l&&!a&&Object(c.createElement)(s.Button,{disabled:r,isBusy:i,isSecondary:!0,onClick:()=>o(u)},Object(n.__)("Activate","woocommmerce-admin")),!l&&Object(c.createElement)(s.Button,{disabled:r,isBusy:i,isSecondary:!0,onClick:()=>o(u)},Object(n.__)("Get started","woocommmerce-admin"))));o(595);const x=({currentPlugin:e,installAndActivate:t=(()=>{}),plugins:o=[],title:n})=>Object(c.createElement)("div",{className:"woocommerce-plugin-list"},n&&Object(c.createElement)("div",{className:"woocommerce-plugin-list__title"},Object(c.createElement)(C.Text,{variant:"sectionheading",as:"h3"},n)),o.map(o=>{const{description:n,imageUrl:s,isActive:a,isInstalled:i,manageUrl:r,slug:l,name:m}=o;return Object(c.createElement)(N,{key:l,description:n,manageUrl:r,name:m,imageUrl:s,installAndActivate:t,isActive:a,isBusy:e===l,isDisabled:!!e,isInstalled:i,slug:l})})),P=["reach","grow"],A=(e,t,o)=>{const c=[],n=[];return e.forEach(e=>{if(!P.includes(e.key))return;const s=[];if(e.plugins.forEach(e=>{const n=((e,t,o)=>{const{description:c,image_url:n,key:s,manage_url:a,name:i}=e,r=s.split(":")[0];return{description:c,slug:r,imageUrl:n,isActive:t.includes(r),isInstalled:o.includes(r),manageUrl:a,name:i}})(e,t,o);n.isInstalled?c.push(n):s.push(n)}),!s.length)return;const a={...e,plugins:s};n.push(a)}),[c,n]},I=({trackedCompletedActions:e})=>{const[t,o]=Object(c.useState)(null),{installAndActivatePlugins:a}=Object(i.useDispatch)(r.PLUGINS_STORE_NAME),{updateOptions:l}=Object(i.useDispatch)(r.OPTIONS_STORE_NAME),{activePlugins:d,freeExtensions:p,installedPlugins:u,isResolving:_}=Object(i.useSelect)(e=>{const{getActivePlugins:t,getInstalledPlugins:o}=e(r.PLUGINS_STORE_NAME),{getFreeExtensions:c,hasFinishedResolution:n}=e(r.ONBOARDING_STORE_NAME);return{activePlugins:t(),freeExtensions:c(),installedPlugins:o(),isResolving:!n("getFreeExtensions")}}),[b,g]=Object(c.useMemo)(()=>A(p,d,u),[u,d,p]),h=t=>{o(t),a([t]).then(c=>{Object(m.recordEvent)("tasklist_marketing_install",{selected_extension:t,installed_extensions:b.map(e=>e.slug)}),e.includes("marketing")||l({woocommerce_task_list_tracked_completed_actions:[...e,"marketing"]}),Object(T.a)(c),o(null)}).catch(e=>{Object(T.a)(e),o(null)})};return _?Object(c.createElement)(s.Spinner,null):Object(c.createElement)("div",{className:"woocommerce-task-marketing"},!!b.length&&Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardHeader,null,Object(c.createElement)(C.Text,{variant:"title.small",as:"h2",className:"woocommerce-task-card__title"},Object(n.__)("Installed marketing extensions",'woocommerce'))),Object(c.createElement)(x,{currentPlugin:t,installAndActivate:h,plugins:b})),!!g.length&&Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardHeader,null,Object(c.createElement)(C.Text,{variant:"title.small",as:"h2",className:"woocommerce-task-card__title"},Object(n.__)("Recommended marketing extensions",'woocommerce')),Object(c.createElement)(C.Text,{as:"span"},Object(n.__)('We recommend adding one of the following marketing tools for your store. The extension will be installed and activated for you when you click "Get started".','woocommerce'))),g.map(e=>{const{key:o,title:n,plugins:s}=e;return Object(c.createElement)(x,{currentPlugin:t,installAndActivate:h,key:o,plugins:s,title:n})})))};var R=o(116),M=o(8),B=Object(c.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(M.Path,{d:"M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"})),G=o(473),L=Object(c.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(c.createElement)(M.Path,{d:"M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"})),F=Object(c.createElement)(M.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Object(c.createElement)(M.Path,{d:"M19 6.2h-5.9l-.6-1.1c-.3-.7-1-1.1-1.8-1.1H5c-1.1 0-2 .9-2 2v11.8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8.2c0-1.1-.9-2-2-2zm.5 11.6c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h5.8c.2 0 .4.1.4.3l1 2H19c.3 0 .5.2.5.5v9.5zM8 12.8h8v-1.5H8v1.5zm0 3h8v-1.5H8v1.5z"})),U=Object(c.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(M.Path,{d:"M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"}));o(596);const D=()=>[{key:"physical",title:Object(n.__)("Physical product",'woocommerce'),subtitle:Object(n.__)("Tangible items that get delivered to customers",'woocommerce')},{key:"digital",title:Object(n.__)("Digital product",'woocommerce'),subtitle:Object(n.__)("Items that customers download or access through your website",'woocommerce')},{key:"variable",title:Object(n.__)("Variable product",'woocommerce'),subtitle:Object(n.__)("Products with several versions that customers can choose from",'woocommerce')},{key:"subscription",title:Object(n.__)("Subscription product",'woocommerce'),subtitle:Object(n.__)("Products that customers receive or gain access to regularly by paying in advance",'woocommerce')}];function z({onClose:e}){const[t,o]=Object(c.useState)(null),[a,l]=Object(c.useState)(!1),{createProductFromTemplate:d}=Object(i.useDispatch)(r.ITEMS_STORE_NAME),{countryCode:p,profileItems:u}=Object(i.useSelect)(e=>{const{getProfileItems:t}=e(r.ONBOARDING_STORE_NAME),{getSettings:o}=e(r.SETTINGS_STORE_NAME),{general:c={}}=o("general");return{countryCode:Object(g.b)(c.woocommerce_default_country),profileItems:t()}}),{installedPlugins:_}=Object(i.useSelect)(e=>{const{getInstalledPlugins:t}=e(r.PLUGINS_STORE_NAME);return{installedPlugins:t()}}),h=window.wcAdminFeatures&&!window.wcAdminFeatures.subscriptions||"US"!==p||!u.product_types.includes("subscriptions")||!_.includes("woocommerce-payments")?D().filter(e=>"subscription"!==e.key):D(),O=Object(y.applyFilters)("woocommerce_admin_onboarding_product_templates",h);return Object(c.createElement)(s.Modal,{title:Object(n.__)("Start with a template"),isDismissible:!0,onRequestClose:()=>e(),className:"woocommerce-product-template-modal"},Object(c.createElement)("div",{className:"woocommerce-product-template-modal__wrapper"},Object(c.createElement)("div",{className:"woocommerce-product-template-modal__list"},Object(c.createElement)(s.RadioControl,{selected:t,options:O.map(e=>({label:Object(c.createElement)(c.Fragment,null,Object(c.createElement)("span",{className:"woocommerce-product-template-modal__list-title"},e.title),Object(c.createElement)("span",{className:"woocommerce-product-template-modal__list-subtitle"},e.subtitle)),value:e.key})),onChange:o})),Object(c.createElement)("div",{className:"woocommerce-product-template-modal__actions"},Object(c.createElement)(s.Button,{isPrimary:!0,isBusy:a,disabled:!t||a,onClick:()=>{l(!0),Object(m.recordEvent)("tasklist_product_template_selection",{product_type:t}),"subscription"!==t?t?d({template_name:t,status:"draft"},{_fields:["id"]}).then(e=>{if(e&&e.id){const t=Object(b.e)(`post.php?post=${e.id}&action=edit&wc_onboarding_active_task=products&tutorial=true`);window.location=t}},e=>{Object(T.a)(e),l(!1)}):e&&(Object(m.recordEvent)("tasklist_product_template_dismiss"),e()):window.location=Object(b.e)("post-new.php?post_type=product&subscription_pointers=true")}},Object(n.__)("Go")))))}function H(){const[e,t]=Object(c.useState)(null),{countryCode:o,profileItems:a}=Object(i.useSelect)(e=>{const{getProfileItems:t}=e(r.ONBOARDING_STORE_NAME),{getSettings:o}=e(r.SETTINGS_STORE_NAME),{general:c={}}=o("general");return{countryCode:Object(g.b)(c.woocommerce_default_country),profileItems:t()}}),{installedPlugins:l}=Object(i.useSelect)(e=>{const{getInstalledPlugins:t}=e(r.PLUGINS_STORE_NAME);return{installedPlugins:t()}}),p=[{key:"addProductTemplate",title:Object(c.createElement)(c.Fragment,null,Object(n.__)("Start with a template",'woocommerce'),Object(c.createElement)(d.Pill,null,Object(n.__)("Recommended",'woocommerce'))),content:Object(n.__)("Use a template to add physical, digital, and variable products",'woocommerce'),before:Object(c.createElement)(R.a,{icon:B}),after:Object(c.createElement)(R.a,{icon:G.a}),onClick:()=>Object(m.recordEvent)("tasklist_add_product",{method:"product_template"})},{key:"addProductManually",title:Object(n.__)("Add manually",'woocommerce'),content:Object(n.__)("For small stores we recommend adding products manually",'woocommerce'),before:Object(c.createElement)(R.a,{icon:L}),after:Object(c.createElement)(R.a,{icon:G.a}),onClick:()=>Object(m.recordEvent)("tasklist_add_product",{method:"manually"}),href:Object(b.e)("post-new.php?post_type=product&wc_onboarding_active_task=products&tutorial=true")},{key:"importProducts",title:Object(n.__)("Import via CSV",'woocommerce'),content:Object(n.__)("For larger stores we recommend importing all products at once via CSV file",'woocommerce'),before:Object(c.createElement)(R.a,{icon:F}),after:Object(c.createElement)(R.a,{icon:G.a}),onClick:()=>Object(m.recordEvent)("tasklist_add_product",{method:"import"}),href:Object(b.e)("edit.php?post_type=product&page=product_importer&wc_onboarding_active_task=product-import")},{key:"migrateProducts",title:Object(n.__)("Import from another service",'woocommerce'),content:Object(n.__)("For stores currently selling elsewhere we suggest using a product migration service",'woocommerce'),before:Object(c.createElement)(R.a,{icon:U}),after:Object(c.createElement)(R.a,{icon:G.a}),onClick:()=>Object(m.recordEvent)("tasklist_add_product",{method:"migrate"}),href:"https://woocommerce.com/products/cart2cart/?utm_medium=product",target:"_blank"}];if(window.wcAdminFeatures&&window.wcAdminFeatures.subscriptions&&"US"===o&&a.product_types.includes("subscriptions")&&l.includes("woocommerce-payments")){p.find(({key:e})=>"addProductTemplate"===e).content=Object(n.__)("Use a template to add physical, digital, variable, and subscription products",'woocommerce')}const u=p.map(e=>({...e,onClick:()=>(e=>{e.onClick(),"addProductTemplate"===e.key&&t(!0)})(e)}));return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardBody,{size:null},Object(c.createElement)(d.List,{items:u}))),e?Object(c.createElement)(z,{onClose:()=>t(null)}):null)}var q=o(35),V=o.n(q),J=o(18),W=o.n(J),Y=o(1),Z=o.n(Y);class $ extends c.Component{constructor(e){super(e),this.state={isConnecting:!1},this.connectJetpack=this.connectJetpack.bind(this),e.setIsPending(!0)}componentDidUpdate(e){const{createNotice:t,error:o,isRequesting:c,onError:n,setIsPending:s}=this.props;e.isRequesting&&!c&&s(!1),o&&o!==e.error&&(n&&n(),t("error",o))}async connectJetpack(){const{jetpackConnectUrl:e,onConnect:t}=this.props;this.setState({isConnecting:!0},()=>{t&&t(),window.location=e})}render(){const{hasErrors:e,isRequesting:t,onSkip:o,skipText:a,onAbort:i,abortText:r}=this.props;return Object(c.createElement)(c.Fragment,null,e?Object(c.createElement)(s.Button,{isPrimary:!0,onClick:()=>window.location.reload()},Object(n.__)("Retry",'woocommerce')):Object(c.createElement)(s.Button,{disabled:t,isBusy:this.state.isConnecting,isPrimary:!0,onClick:this.connectJetpack},Object(n.__)("Connect",'woocommerce')),o&&Object(c.createElement)(s.Button,{onClick:o},a||Object(n.__)("No thanks",'woocommerce')),i&&Object(c.createElement)(s.Button,{onClick:i},r||Object(n.__)("Abort",'woocommerce')))}}$.propTypes={createNotice:Z.a.func.isRequired,error:Z.a.string,hasErrors:Z.a.bool,isRequesting:Z.a.bool,jetpackConnectUrl:Z.a.string,onConnect:Z.a.func,onError:Z.a.func,onSkip:Z.a.func,redirectUrl:Z.a.string,skipText:Z.a.string,setIsPending:Z.a.func,onAbort:Z.a.func,abortText:Z.a.string},$.defaultProps={setIsPending:()=>{}};var Q=Object(p.compose)(Object(i.withSelect)((e,t)=>{const{getJetpackConnectUrl:o,isPluginsRequesting:c,getPluginsError:n}=e(r.PLUGINS_STORE_NAME),s={redirect_url:t.redirectUrl||window.location.href},a=c("getJetpackConnectUrl");return{error:n("getJetpackConnectUrl")||"",isRequesting:a,jetpackConnectUrl:o(s)}}),Object(i.withDispatch)(e=>{const{createNotice:t}=e("core/notices");return{createNotice:t}}))($),K=o(527);class X extends c.Component{constructor(){super(...arguments),this.onSubmit=this.onSubmit.bind(this)}async onSubmit(e){const{onComplete:t,createNotice:o,isSettingsError:c,updateAndPersistSettingsForGroup:s,settings:a}=this.props;await s("general",{general:{...a,woocommerce_store_address:e.addressLine1,woocommerce_store_address_2:e.addressLine2,woocommerce_default_country:e.countryState,woocommerce_store_city:e.city,woocommerce_store_postcode:e.postCode}}),c?o("error",Object(n.__)("There was a problem saving your store location",'woocommerce')):t(e)}getInitialValues(){const{settings:e}=this.props,{woocommerce_store_address:t,woocommerce_store_address_2:o,woocommerce_store_city:c,woocommerce_default_country:n,woocommerce_store_postcode:s}=e;return{addressLine1:t||"",addressLine2:o||"",city:c||"",countryState:n||"",postCode:s||""}}render(){const{isSettingsRequesting:e}=this.props;return e?null:Object(c.createElement)(d.Form,{initialValues:this.getInitialValues(),onSubmit:this.onSubmit,validate:K.b},({getInputProps:e,handleSubmit:t,setValue:o})=>Object(c.createElement)(c.Fragment,null,Object(c.createElement)(K.a,{getInputProps:e,setValue:o}),Object(c.createElement)(s.Button,{isPrimary:!0,onClick:t},Object(n.__)("Continue",'woocommerce'))))}}var ee=Object(c.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(c.createElement)(M.Path,{d:"M9 0C4.03 0 0 4.03 0 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zM1.11 9.68h2.51c.04.91.167 1.814.38 2.7H1.84c-.403-.85-.65-1.764-.73-2.7zm8.57-5.4V1.19c.964.366 1.756 1.08 2.22 2 .205.347.386.708.54 1.08l-2.76.01zm3.22 1.35c.232.883.37 1.788.41 2.7H9.68v-2.7h3.22zM8.32 1.19v3.09H5.56c.154-.372.335-.733.54-1.08.462-.924 1.255-1.64 2.22-2.01zm0 4.44v2.7H4.7c.04-.912.178-1.817.41-2.7h3.21zm-4.7 2.69H1.11c.08-.936.327-1.85.73-2.7H4c-.213.886-.34 1.79-.38 2.7zM4.7 9.68h3.62v2.7H5.11c-.232-.883-.37-1.788-.41-2.7zm3.63 4v3.09c-.964-.366-1.756-1.08-2.22-2-.205-.347-.386-.708-.54-1.08l2.76-.01zm1.35 3.09v-3.04h2.76c-.154.372-.335.733-.54 1.08-.464.92-1.256 1.634-2.22 2v-.04zm0-4.44v-2.7h3.62c-.04.912-.178 1.817-.41 2.7H9.68zm4.71-2.7h2.51c-.08.936-.327 1.85-.73 2.7H14c.21-.87.337-1.757.38-2.65l.01-.05zm0-1.35c-.046-.894-.176-1.78-.39-2.65h2.16c.403.85.65 1.764.73 2.7l-2.5-.05zm1-4H13.6c-.324-.91-.793-1.76-1.39-2.52 1.244.56 2.325 1.426 3.14 2.52h.04zm-9.6-2.52c-.597.76-1.066 1.61-1.39 2.52H2.65c.815-1.094 1.896-1.96 3.14-2.52zm-3.15 12H4.4c.324.91.793 1.76 1.39 2.52-1.248-.567-2.33-1.445-3.14-2.55l-.01.03zm9.56 2.52c.597-.76 1.066-1.61 1.39-2.52h1.76c-.82 1.08-1.9 1.933-3.14 2.48l-.01.04z"})),te=o(501);class oe extends c.Component{constructor(){super(...arguments),this.updateShippingZones=this.updateShippingZones.bind(this)}getShippingMethods(e,t=null){return e&&e.methods&&Array.isArray(e.methods)?t?e.methods?e.methods.filter(e=>e.method_id===t):[]:e.methods:[]}disableShippingMethods(e,t){t.length&&t.forEach(t=>{S()({method:"POST",path:`/wc/v3/shipping/zones/${e.id}/methods/${t.instance_id}`,data:{enabled:!1}})})}async updateShippingZones(e){const{clearTaskStatusCache:t,createNotice:o,shippingZones:c}=this.props;let s=!1,a=!1;c.forEach(t=>{0===t.id?s=t.toggleable&&e[t.id+"_enabled"]:a=""!==e[t.id+"_rate"]&&parseFloat(e[t.id+"_rate"])!==parseFloat(0);const o=this.getShippingMethods(t),c=parseFloat(e[t.id+"_rate"])===parseFloat(0)?"free_shipping":"flat_rate",n=this.getShippingMethods(t,c).length?this.getShippingMethods(t,c)[0]:null;if(!t.toggleable||e[t.id+"_enabled"]){if(n){const e=o.filter(e=>e.instance_id!==n.instance_id);this.disableShippingMethods(t,e)}S()({method:"POST",path:n?`/wc/v3/shipping/zones/${t.id}/methods/${n.instance_id}`:`/wc/v3/shipping/zones/${t.id}/methods`,data:{method_id:c,enabled:!0,settings:{cost:e[t.id+"_rate"]}}})}else this.disableShippingMethods(t,o)}),Object(m.recordEvent)("tasklist_shipping_set_costs",{shipping_cost:a,rest_world:s}),t(),o("success",Object(n.__)("Your shipping rates have been updated",'woocommerce')),this.props.onComplete()}renderInputPrefix(){const{symbolPosition:e,symbol:t}=this.context.getCurrencyConfig();return 0===e.indexOf("right")?null:Object(c.createElement)("span",{className:"woocommerce-shipping-rate__control-prefix"},t)}renderInputSuffix(e){const{symbolPosition:t,symbol:o}=this.context.getCurrencyConfig();return 0===t.indexOf("right")?Object(c.createElement)("span",{className:"woocommerce-shipping-rate__control-suffix"},o):parseFloat(e)===parseFloat(0)?Object(c.createElement)("span",{className:"woocommerce-shipping-rate__control-suffix"},Object(n.__)("Free shipping",'woocommerce')):null}getFormattedRate(e){const{formatDecimalString:t}=this.context,o=t(e);return e.length&&o.length?t(e):t(0)}getInitialValues(){const{formatDecimalString:e}=this.context,t={};return this.props.shippingZones.forEach(o=>{const c=this.getShippingMethods(o),n=c.length&&c[0].settings.cost?this.getFormattedRate(c[0].settings.cost.value):e(0);t[o.id+"_rate"]=n,c.length&&c[0].enabled?t[o.id+"_enabled"]=!0:t[o.id+"_enabled"]=!1}),t}validate(e){const t={};return Object.keys(e).filter(e=>e.endsWith("_rate")).forEach(o=>{e[o]<0&&(t[o]=Object(n.__)("Shipping rates can not be negative numbers.",'woocommerce'))}),t}render(){const{buttonText:e,shippingZones:t}=this.props;return t.length?Object(c.createElement)(d.Form,{initialValues:this.getInitialValues(),onSubmit:this.updateShippingZones,validate:this.validate},({getInputProps:o,handleSubmit:a,setTouched:i,setValue:r,values:l})=>Object(c.createElement)(c.Fragment,null,Object(c.createElement)("div",{className:"woocommerce-shipping-rates"},t.map(e=>Object(c.createElement)("div",{className:"woocommerce-shipping-rate",key:e.id},Object(c.createElement)("div",{className:"woocommerce-shipping-rate__icon"},e.locations?e.locations.map(e=>Object(c.createElement)(d.Flag,{size:24,code:e.code,key:e.code})):Object(c.createElement)(R.a,{icon:ee})),Object(c.createElement)("div",{className:"woocommerce-shipping-rate__main"},e.toggleable?Object(c.createElement)("label",{htmlFor:"woocommerce-shipping-rate__toggle-"+e.id,className:"woocommerce-shipping-rate__name"},e.name,Object(c.createElement)(s.FormToggle,V()({id:"woocommerce-shipping-rate__toggle-"+e.id},o(e.id+"_enabled")))):Object(c.createElement)("div",{className:"woocommerce-shipping-rate__name"},e.name),(!e.toggleable||l[e.id+"_enabled"])&&Object(c.createElement)(d.TextControlWithAffixes,V()({label:Object(n.__)("Shipping cost",'woocommerce'),required:!0},o(e.id+"_rate"),{onBlur:()=>{i(e.id+"_rate"),r(e.id+"_rate",this.getFormattedRate(l[e.id+"_rate"]))},prefix:this.renderInputPrefix(),suffix:this.renderInputSuffix(l[e.id+"_rate"]),className:"muriel-input-text woocommerce-shipping-rate__control-wrapper"})))))),Object(c.createElement)(s.Button,{isPrimary:!0,onClick:a},e||Object(n.__)("Update",'woocommerce')))):null}}oe.propTypes={buttonText:Z.a.string,onComplete:Z.a.func.isRequired,createNotice:Z.a.func.isRequired,shippingZones:Z.a.array},oe.defaultProps={shippingZones:[]},oe.contextType=te.a;var ce=Object(p.compose)(Object(i.withDispatch)(e=>{const{invalidateResolutionForStoreSelector:t}=e(r.ONBOARDING_STORE_NAME);return{clearTaskStatusCache:()=>t("getTasksStatus")}}))(oe);class ne extends c.Component{constructor(e){super(e),this.initialState={isPending:!1,step:"store_location",shippingZones:[]},this.activePlugins=e.activePlugins,this.state=this.initialState,this.completeStep=this.completeStep.bind(this)}componentDidMount(){this.reset()}reset(){this.setState(this.initialState)}async fetchShippingZones(){this.setState({isPending:!0});const{countryCode:e,countryName:t}=this.props,o=[],c=await S()({path:"/wc/v3/shipping/zones"});let s=!1;if(await Promise.all(c.map(async t=>{if(0===t.id)return t.methods=await S()({path:`/wc/v3/shipping/zones/${t.id}/methods`}),t.name=Object(n.__)("Rest of the world",'woocommerce'),t.toggleable=!0,void o.push(t);t.locations=await S()({path:`/wc/v3/shipping/zones/${t.id}/locations`});t.locations.find(t=>e===t.code)&&(t.methods=await S()({path:`/wc/v3/shipping/zones/${t.id}/methods`}),o.push(t),s=!0)})),!s){const c=await S()({method:"POST",path:"/wc/v3/shipping/zones",data:{name:t}});c.locations=await S()({method:"POST",path:`/wc/v3/shipping/zones/${c.id}/locations`,data:[{code:e,type:"country"}]}),o.push(c)}o.reverse(),this.setState({isPending:!1,shippingZones:o})}componentDidUpdate(e,t){const{countryCode:o,settings:c}=this.props,{woocommerce_store_address:n,woocommerce_default_country:s,woocommerce_store_postcode:a}=c,{step:i}=this.state;"rates"!==i||e.countryCode===o&&"rates"===t.step||this.fetchShippingZones();const r=Boolean(n&&s&&a);"store_location"===i&&r&&this.completeStep()}completeStep(){const{createNotice:e}=this.props,{step:t}=this.state,o=this.getSteps(),c=o.findIndex(e=>e.key===t),s=o[c+1];s?this.setState({step:s.key}):(e("success",Object(n.__)("📦 Shipping is done! Don't worry, you can always change it later",'woocommerce')),Object(k.getHistory)().push(Object(k.getNewPath)({},"/",{})))}getPluginsToActivate(){const{countryCode:e}=this.props,t=[];return["GB","CA","AU"].includes(e)?t.push("woocommerce-shipstation-integration"):"US"===e&&(t.push("woocommerce-services"),t.push("jetpack")),Object(u.difference)(t,this.activePlugins)}getSteps(){const{countryCode:e,isJetpackConnected:t,settings:o}=this.props,s=this.getPluginsToActivate(),a=!t&&"US"===e,i=[{key:"store_location",label:Object(n.__)("Set store location",'woocommerce'),description:Object(n.__)("The address from which your business operates",'woocommerce'),content:Object(c.createElement)(X,V()({},this.props,{onComplete:e=>{const t=Object(g.b)(e.countryState);Object(m.recordEvent)("tasklist_shipping_set_location",{country:t}),this.completeStep()}})),visible:!0},{key:"rates",label:Object(n.__)("Set shipping costs",'woocommerce'),description:Object(n.__)("Define how much customers pay to ship to different destinations",'woocommerce'),content:Object(c.createElement)(ce,V()({buttonText:s.length||a?Object(n.__)("Proceed",'woocommerce'):Object(n.__)("Complete task",'woocommerce'),shippingZones:this.state.shippingZones,onComplete:this.completeStep},this.props)),visible:"disabled"!==o.woocommerce_ship_to_countries},{key:"label_printing",label:Object(n.__)("Enable shipping label printing",'woocommerce'),description:s.includes("woocommerce-shipstation-integration")?W()({mixedString:Object(n.__)("We recommend using ShipStation to save time at the post office by printing your shipping labels at home. Try ShipStation free for 30 days. {{link}}Learn more{{/link}}.",'woocommerce'),components:{link:Object(c.createElement)(d.Link,{href:"https://woocommerce.com/products/shipstation-integration?utm_medium=product",target:"_blank",type:"external"})}}):Object(n.__)("With WooCommerce Shipping you can save time by printing your USPS and DHL Express shipping labels at home",'woocommerce'),content:Object(c.createElement)(d.Plugins,V()({onComplete:(e,t)=>{Object(T.a)(t),Object(m.recordEvent)("tasklist_shipping_label_printing",{install:!0,plugins_to_activate:s}),this.completeStep()},onError:(e,t)=>Object(T.a)(t),onSkip:()=>{Object(m.recordEvent)("tasklist_shipping_label_printing",{install:!1,plugins_to_activate:s}),Object(k.getHistory)().push(Object(k.getNewPath)({},"/",{}))},pluginSlugs:s},this.props)),visible:s.length},{key:"connect",label:Object(n.__)("Connect your store",'woocommerce'),description:Object(n.__)("Connect your store to WordPress.com to enable label printing",'woocommerce'),content:Object(c.createElement)(Q,V()({redirectUrl:Object(b.e)("admin.php?page=wc-admin"),completeStep:this.completeStep},this.props,{onConnect:()=>{Object(m.recordEvent)("tasklist_shipping_connect_store")}})),visible:a}];return Object(u.filter)(i,e=>e.visible)}render(){const{isPending:e,step:t}=this.state,{isUpdateSettingsRequesting:o}=this.props;return Object(c.createElement)("div",{className:"woocommerce-task-shipping"},Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardBody,null,Object(c.createElement)(d.Stepper,{isPending:e||o,isVertical:!0,currentStep:t,steps:this.getSteps()}))))}}var se=Object(p.compose)(Object(i.withSelect)(e=>{const{getSettings:t,isUpdateSettingsRequesting:o}=e(r.SETTINGS_STORE_NAME),{getActivePlugins:c,isJetpackConnected:n}=e(r.PLUGINS_STORE_NAME),{general:s={}}=t("general"),a=Object(g.b)(s.woocommerce_default_country),{countries:i=[]}=Object(b.f)("dataEndpoints",{}),l=a?i.find(e=>e.code===a):null,m=l?l.name:null,d=c();return{countryCode:a,countryName:m,isUpdateSettingsRequesting:o("general"),settings:s,activePlugins:d,isJetpackConnected:n()}}),Object(i.withDispatch)(e=>{const{createNotice:t}=e("core/notices"),{updateAndPersistSettingsForGroup:o}=e(r.SETTINGS_STORE_NAME);return{createNotice:t,updateAndPersistSettingsForGroup:o}}))(ne);class ae extends c.Component{constructor(e){super(e);const{hasCompleteAddress:t,pluginsToActivate:o}=e;this.initialState={isPending:!1,stepIndex:t?1:0,cachedPluginsToActivate:o},this.state=this.initialState,this.completeStep=this.completeStep.bind(this)}componentDidMount(){const{query:e}=this.props,{auto:t}=e;this.reset(),"true"===t&&this.enableAutomatedTax()}reset(){this.setState(this.initialState)}shouldShowSuccessScreen(){const{isJetpackConnected:e,hasCompleteAddress:t,pluginsToActivate:o}=this.props;return t&&!o.length&&e&&this.isTaxJarSupported()}isTaxJarSupported(){const{countryCode:e,tasksStatus:t}=this.props,{automatedTaxSupportedCountries:o=[],taxJarActivated:c}=t;return!c&&o.includes(e)}completeStep(){const{stepIndex:e}=this.state;this.getSteps()[e+1]&&this.setState({stepIndex:e+1})}async manuallyConfigureTaxRates(){const{generalSettings:e,updateAndPersistSettingsForGroup:t}=this.props;"yes"!==e.woocommerce_calc_taxes?(this.setState({isPending:!0}),t("general",{general:{...e,woocommerce_calc_taxes:"yes"}}).then(()=>this.redirectToTaxSettings()).catch(e=>Object(T.a)(e))):this.redirectToTaxSettings()}updateAutomatedTax(e){const{clearTaskStatusCache:t,createNotice:o,updateAndPersistSettingsForGroup:c,generalSettings:s,taxSettings:a}=this.props;Promise.all([c("tax",{tax:{...a,wc_connect_taxes_enabled:e?"yes":"no"}}),c("general",{general:{...s,woocommerce_calc_taxes:"yes"}})]).then(()=>{t(),e?(o("success",Object(n.__)("You're awesome! One less item on your to-do list ✅",'woocommerce')),Object(k.getHistory)().push(Object(k.getNewPath)({},"/",{}))):this.redirectToTaxSettings()}).catch(()=>{o("error",Object(n.__)("There was a problem updating your tax settings",'woocommerce'))})}redirectToTaxSettings(){window.location=Object(b.e)("admin.php?page=wc-settings&tab=tax&section=standard&wc_onboarding_active_task=tax")}doNotChargeSalesTax(){const{updateOptions:e}=this.props;Object(m.queueRecordEvent)("tasklist_tax_connect_store",{connect:!1,no_tax:!0}),e({woocommerce_no_sales_tax:!0,woocommerce_calc_taxes:"no"}).then(()=>{window.location=Object(b.e)("admin.php?page=wc-admin")})}getSteps(){const{generalSettings:e,isJetpackConnected:t,isPending:o,tosAccepted:a,updateOptions:i}=this.props,{cachedPluginsToActivate:r}=this.state;let l,p;r.includes("woocommerce-services")?(l=Object(n.__)("Install Jetpack and WooCommerce Tax",'woocommerce'),p=Object(n.__)("By installing Jetpack and WooCommerce Tax you agree to the {{link}}Terms of Service{{/link}}.",'woocommerce')):(l=Object(n.__)("Install Jetpack",'woocommerce'),p=Object(n.__)("By installing Jetpack you agree to the {{link}}Terms of Service{{/link}}.",'woocommerce'));const _=[{key:"store_location",label:Object(n.__)("Set store location",'woocommerce'),description:Object(n.__)("The address from which your business operates",'woocommerce'),content:Object(c.createElement)(X,V()({},this.props,{onComplete:e=>{const t=Object(g.b)(e.countryState);Object(m.recordEvent)("tasklist_tax_set_location",{country:t}),this.completeStep()},isSettingsRequesting:!1,settings:e})),visible:!0},{key:"plugins",label:l,description:Object(n.__)("Jetpack and WooCommerce Tax allow you to automate sales tax calculations",'woocommerce'),content:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(d.Plugins,{onComplete:(e,t)=>{Object(T.a)(t),Object(m.recordEvent)("tasklist_tax_install_extensions",{install_extensions:!0}),i({woocommerce_setup_jetpack_opted_in:!0}),this.completeStep()},onError:(e,t)=>Object(T.a)(t),onSkip:()=>{Object(m.queueRecordEvent)("tasklist_tax_install_extensions",{install_extensions:!1}),this.manuallyConfigureTaxRates()},skipText:Object(n.__)("Set up manually",'woocommerce'),onAbort:()=>this.doNotChargeSalesTax(),abortText:Object(n.__)("I don't charge sales tax",'woocommerce')}),!a&&Object(c.createElement)(C.Text,{variant:"caption",className:"woocommerce-task__caption",size:"12",lineHeight:"16px"},W()({mixedString:p,components:{link:Object(c.createElement)(d.Link,{href:"https://wordpress.com/tos/",target:"_blank",type:"external"})}}))),visible:(r.length||!a)&&this.isTaxJarSupported()},{key:"connect",label:Object(n.__)("Connect your store",'woocommerce'),description:Object(n.__)("Connect your store to WordPress.com to enable automated sales tax calculations",'woocommerce'),content:Object(c.createElement)(Q,V()({},this.props,{onConnect:()=>{Object(m.recordEvent)("tasklist_tax_connect_store",{connect:!0,no_tax:!1})},onSkip:()=>{Object(m.queueRecordEvent)("tasklist_tax_connect_store",{connect:!1,no_tax:!1}),this.manuallyConfigureTaxRates()},skipText:Object(n.__)("Set up tax rates manually",'woocommerce'),onAbort:()=>this.doNotChargeSalesTax(),abortText:Object(n.__)("My business doesn't charge sales tax",'woocommerce')})),visible:!t&&this.isTaxJarSupported()},{key:"manual_configuration",label:Object(n.__)("Configure tax rates",'woocommerce'),description:Object(n.__)("Head over to the tax rate settings screen to configure your tax rates",'woocommerce'),content:Object(c.createElement)(c.Fragment,null,Object(c.createElement)(s.Button,{disabled:o,isPrimary:!0,isBusy:o,onClick:()=>{Object(m.recordEvent)("tasklist_tax_config_rates"),this.manuallyConfigureTaxRates()}},Object(n.__)("Configure",'woocommerce')),Object(c.createElement)("p",null,"yes"!==e.woocommerce_calc_taxes&&W()({mixedString:Object(n.__)('By clicking "Configure" you\'re enabling tax rates and calculations. More info {{link}}here{{/link}}.','woocommerce'),components:{link:Object(c.createElement)(d.Link,{href:"https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/?utm_medium=product#section-1",target:"_blank",type:"external"})}}))),visible:!this.isTaxJarSupported()}];return Object(u.filter)(_,e=>e.visible)}enableAutomatedTax(){Object(m.recordEvent)("tasklist_tax_setup_automated_proceed",{setup_automatically:!0}),this.updateAutomatedTax(!0)}renderSuccessScreen(){const{isPending:e}=this.props;return Object(c.createElement)("div",{className:"woocommerce-task-tax__success"},Object(c.createElement)("span",{className:"woocommerce-task-tax__success-icon",role:"img","aria-labelledby":"woocommerce-task-tax__success-message"},"🎊"),Object(c.createElement)(d.H,{id:"woocommerce-task-tax__success-message"},Object(n.__)("Good news!",'woocommerce')),Object(c.createElement)("p",null,W()({mixedString:Object(n.__)("{{strong}}Jetpack{{/strong}} and {{strong}}WooCommerce Tax{{/strong}} can automate your sales tax calculations for you.",'woocommerce'),components:{strong:Object(c.createElement)("strong",null)}})),Object(c.createElement)(s.Button,{disabled:e,isPrimary:!0,isBusy:e,onClick:this.enableAutomatedTax.bind(this)},Object(n.__)("Yes please",'woocommerce')),Object(c.createElement)(s.Button,{disabled:e,isTertiary:!0,onClick:()=>{Object(m.recordEvent)("tasklist_tax_setup_automated_proceed",{setup_automatically:!1}),this.updateAutomatedTax(!1)}},Object(n.__)("No thanks, I'll set up manually",'woocommerce')),Object(c.createElement)(s.Button,{disabled:e,isTertiary:!0,onClick:()=>this.doNotChargeSalesTax()},Object(n.__)("I don't charge sales tax",'woocommerce')))}render(){const{stepIndex:e}=this.state,{isPending:t,isResolving:o}=this.props;if(o)return Object(c.createElement)(d.Spinner,null);const n=this.getSteps()[e];return Object(c.createElement)("div",{className:"woocommerce-task-tax"},Object(c.createElement)(s.Card,{className:"woocommerce-task-card"},Object(c.createElement)(s.CardBody,null,this.shouldShowSuccessScreen()?this.renderSuccessScreen():Object(c.createElement)(d.Stepper,{isPending:t||o,isVertical:!0,currentStep:n.key,steps:this.getSteps()}))))}}var ie=Object(p.compose)(Object(i.withSelect)(e=>{const{getSettings:t,isUpdateSettingsRequesting:o}=e(r.SETTINGS_STORE_NAME),{getOption:c,hasFinishedResolution:n}=e(r.OPTIONS_STORE_NAME),{getActivePlugins:s,isJetpackConnected:a,isPluginsRequesting:i}=e(r.PLUGINS_STORE_NAME),{getTasksStatus:l}=e(r.ONBOARDING_STORE_NAME),{general:m={}}=t("general"),d=Object(g.b)(m.woocommerce_default_country),{woocommerce_store_address:p,woocommerce_default_country:_,woocommerce_store_postcode:b}=m,h=Boolean(p&&_&&b),{tax:O={}}=t("tax"),j=s(),w=Object(u.difference)(["jetpack","woocommerce-services"],j),y=c("wc_connect_options")||{},k=c("woocommerce_setup_jetpack_opted_in"),E=y.tos_accepted||"1"===k,S=l(),v=o("tax")||o("general"),f=i("getJetpackConnectUrl")||!n("getOption",["woocommerce_setup_jetpack_opted_in"])||!n("getOption",["wc_connect_options"])||void 0===k||void 0===y;return{countryCode:d,generalSettings:m,hasCompleteAddress:h,isJetpackConnected:a(),isPending:v,isResolving:f,pluginsToActivate:w,tasksStatus:S,taxSettings:O,tosAccepted:E}}),Object(i.withDispatch)(e=>{const{createNotice:t}=e("core/notices"),{updateOptions:o}=e(r.OPTIONS_STORE_NAME),{updateAndPersistSettingsForGroup:c}=e(r.SETTINGS_STORE_NAME),{invalidateResolutionForStoreSelector:n}=e(r.ONBOARDING_STORE_NAME);return{clearTaskStatusCache:()=>n("getTasksStatus"),createNotice:t,updateAndPersistSettingsForGroup:c,updateOptions:o}}))(ae),re=o(6),le=o.n(re),me=o(271),de=o(542);o(538);const pe=({isRecommended:e,markConfigured:t,paymentGateway:o})=>{var n,a;const{image:i,content:r,id:l,plugins:d=[],title:p,loading:u,enabled:_=!1,installed:b=!1,needsSetup:g=!0,requiredSettings:h,settingsUrl:O,is_local_partner:j}=o,w=Object(C.useSlot)("woocommerce_payment_gateway_configure_"+l),y=Object(C.useSlot)("woocommerce_payment_gateway_setup_"+l),k=Boolean(null==w||null===(n=w.fills)||void 0===n?void 0:n.length)||Boolean(null==y||null===(a=y.fills)||void 0===a?void 0:a.length),E=Boolean(d.length||h.length||k),S=e&&g,v=le()("woocommerce-task-payment","woocommerce-task-card",g&&"woocommerce-task-payment-not-configured","woocommerce-task-payment-"+l);return Object(c.createElement)(c.Fragment,{key:l},Object(c.createElement)(s.CardBody,{style:{paddingLeft:0,marginBottom:0},className:v},Object(c.createElement)(s.CardMedia,{isBorderless:!0},Object(c.createElement)("img",{src:i,alt:p})),Object(c.createElement)("div",{className:"woocommerce-task-payment__description"},S&&Object(c.createElement)(me.RecommendedRibbon,{isLocalPartner:j}),Object(c.createElement)(C.Text,{as:"h3",className:"woocommerce-task-payment__title"},p,b&&g&&!!d.length&&Object(c.createElement)(me.SetupRequired,null)),Object(c.createElement)("div",{className:"woocommerce-task-payment__content"},r)),Object(c.createElement)("div",{className:"woocommerce-task-payment__footer"},Object(c.createElement)(de.a,{manageUrl:O,id:l,hasSetup:E,needsSetup:g,isEnabled:_,isInstalled:b,hasPlugins:Boolean(d.length),isRecommended:e,isLoading:u,markConfigured:t,onSetUp:()=>Object(m.recordEvent)("tasklist_payment_setup",{selected:l})}))),Object(c.createElement)(s.CardDivider,null))},ue=({heading:e,markConfigured:t,recommendation:o,paymentGateways:n})=>Object(c.createElement)(s.Card,null,Object(c.createElement)(s.CardHeader,{as:"h2"},e),n.map(e=>{const{id:n}=e;return Object(c.createElement)(pe,{key:n,isRecommended:o===n,markConfigured:t,paymentGateway:e})})),_e=()=>{const e=le()("woocommerce-task-payment","woocommerce-task-card");return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(s.CardBody,{style:{paddingLeft:0,marginBottom:0},className:e},Object(c.createElement)(s.CardMedia,{isBorderless:!0},Object(c.createElement)("span",{className:"is-placeholder"})),Object(c.createElement)("div",{className:"woocommerce-task-payment__description"},Object(c.createElement)(C.Text,{as:"h3",className:"woocommerce-task-payment__title"},Object(c.createElement)("span",{className:"is-placeholder"})),Object(c.createElement)("div",{className:"woocommerce-task-payment__content"},Object(c.createElement)("span",{className:"is-placeholder"}))),Object(c.createElement)("div",{className:"woocommerce-task-payment__footer"},Object(c.createElement)("span",{className:"is-placeholder"}))),Object(c.createElement)(s.CardDivider,null))},be=()=>Object(c.createElement)(s.Card,{"aria-hidden":"true",className:"is-loading woocommerce-payment-gateway-suggestions-list-placeholder"},Object(c.createElement)(s.CardHeader,{as:"h2"},Object(c.createElement)("span",{className:"is-placeholder"})),Object(c.createElement)(_e,null),Object(c.createElement)(_e,null),Object(c.createElement)(_e,null)),ge=({markConfigured:e,paymentGateway:t})=>{var o;const{id:a,connectionUrl:l,setupHelpText:p,settingsUrl:u,title:_,requiredSettings:b}=t,{createNotice:g}=Object(i.useDispatch)("core/notices"),{updatePaymentGateway:O}=Object(i.useDispatch)(r.PAYMENT_GATEWAYS_STORE_NAME),j=Object(C.useSlot)("woocommerce_payment_gateway_configure_"+a),w=Boolean(null==j||null===(o=j.fills)||void 0===o?void 0:o.length),{isUpdating:y}=Object(i.useSelect)(e=>{const{isPaymentGatewayUpdating:t}=e(r.PAYMENT_GATEWAYS_STORE_NAME);return{isUpdating:t()}}),k=t=>{O(a,{enabled:!0,settings:t}).then(t=>{t&&t.id===a&&(e(a),g("success",Object(n.sprintf)(Object(n.__)("%s configured successfully",'woocommerce'),_)))}).catch(()=>{g("error",Object(n.__)("There was a problem saving your payment settings",'woocommerce'))})},E=p&&Object(c.createElement)("p",{dangerouslySetInnerHTML:Object(h.a)(p)}),S=Object(c.createElement)(d.DynamicForm,{fields:b,isBusy:y,onSubmit:k,submitLabel:Object(n.__)("Proceed",'woocommerce'),validate:e=>((e,t)=>{const o={},c=e=>t.find(t=>t.id===e);for(const[t,n]of Object.entries(e)){const e=c(t),s=e.label.replace(/([A-Z][a-z]+)/g,e=>e.toLowerCase());n||"checkbox"===e.type||(o[t]="Please enter your "+s)}return o})(e,b)});return w?Object(c.createElement)(me.WooPaymentGatewayConfigure.Slot,{fillProps:{defaultForm:S,defaultSubmit:k,defaultFields:b,markConfigured:()=>e(a),paymentGateway:t},id:a}):l?Object(c.createElement)(c.Fragment,null,E,Object(c.createElement)(s.Button,{isPrimary:!0,onClick:()=>Object(m.recordEvent)("tasklist_payment_connect_start",{payment_method:a}),href:l},Object(n.__)("Connect",'woocommerce'))):b.length?Object(c.createElement)(c.Fragment,null,E,S):Object(c.createElement)(c.Fragment,null,E||Object(c.createElement)("p",null,Object(n.__)("You can manage this payment gateway's settings by clicking the button below",'woocommerce')),Object(c.createElement)(s.Button,{isPrimary:!0,href:u},Object(n.__)("Set up",'woocommerce')))};o(597);const he=({markConfigured:e,paymentGateway:t})=>{var o;const{id:a,plugins:l=[],title:p,postInstallScripts:u,installed:_}=t,g=Object(C.useSlot)("woocommerce_payment_gateway_setup_"+a),h=Boolean(null==g||null===(o=g.fills)||void 0===o?void 0:o.length),[O,j]=Object(c.useState)(!1);Object(c.useEffect)(()=>{Object(m.recordEvent)("payments_task_stepper_view",{payment_method:a})},[]);const{invalidateResolutionForStoreSelector:w}=Object(i.useDispatch)(r.PAYMENT_GATEWAYS_STORE_NAME),{isOptionUpdating:y,isPaymentGatewayResolving:k,needsPluginInstall:E}=Object(i.useSelect)(e=>{const{isOptionsUpdating:t}=e(r.OPTIONS_STORE_NAME),{isResolving:o}=e(r.PAYMENT_GATEWAYS_STORE_NAME),c=e(r.PLUGINS_STORE_NAME).getActivePlugins(),n=l.filter(e=>!c.includes(e));return{isOptionUpdating:t(),isPaymentGatewayResolving:o("getPaymentGateways"),needsPluginInstall:!!n.length}});Object(c.useEffect)(()=>{if(!E)if(u&&u.length){const e=u.map(e=>Object(b.d)(e));Promise.all(e).then(()=>{j(!0)})}else j(!0)},[u,E]);const S=Object(c.useMemo)(()=>l&&l.length?{key:"install",label:Object(n.sprintf)(Object(n.__)("Install %s",'woocommerce'),p),content:Object(c.createElement)(d.Plugins,{onComplete:(e,t)=>{Object(T.a)(t),w("getPaymentGateways"),Object(m.recordEvent)("tasklist_payment_install_method",{plugins:l})},onError:(e,t)=>Object(T.a)(t),autoInstall:!0,pluginSlugs:l})}:null,[]),v=Object(c.useMemo)(()=>({key:"configure",label:Object(n.sprintf)(Object(n.__)("Configure your %(title)s account",'woocommerce'),{title:p}),content:_?Object(c.createElement)(ge,{markConfigured:e,paymentGateway:t}):null}),[_]),f=E||y||k||!O,N=Object(c.createElement)(d.Stepper,{isVertical:!0,isPending:f,currentStep:E?"install":"configure",steps:[S,v].filter(Boolean)});return Object(c.createElement)(s.Card,{className:"woocommerce-task-payment-method woocommerce-task-card"},Object(c.createElement)(s.CardBody,null,h?Object(c.createElement)(me.WooPaymentGatewaySetup.Slot,{fillProps:{defaultStepper:N,defaultInstallStep:S,defaultConfigureStep:v,markConfigured:()=>e(a),paymentGateway:t},id:a}):N))},Oe=()=>{const e=le()("is-loading","woocommerce-task-payment-method","woocommerce-task-card");return Object(c.createElement)(s.Card,{"aria-hidden":"true",className:e},Object(c.createElement)(s.CardBody,null,Object(c.createElement)(d.Stepper,{isVertical:!0,currentStep:"none",steps:[{key:"first",label:""},{key:"second",label:""}]})))};var je=o(539),we=o(88);const ye={account_name:"",account_number:"",bank_name:"",sort_code:"",iban:"",bic:""};Object(we.registerPlugin)("wc-admin-payment-gateway-setup-bacs",{render:()=>{const e=Object(i.useSelect)(e=>e(r.OPTIONS_STORE_NAME).isOptionsUpdating()),{createNotice:t}=Object(i.useDispatch)("core/notices"),{updateOptions:o}=Object(i.useDispatch)(r.OPTIONS_STORE_NAME),a=e=>{const t={};return e.account_number||e.iban||(t.account_number=t.iban=Object(n.__)("Please enter an account number or IBAN",'woocommerce')),t};return Object(c.createElement)(c.Fragment,null,Object(c.createElement)(me.WooPaymentGatewaySetup,{id:"bacs"},({markConfigured:i})=>Object(c.createElement)(d.Form,{initialValues:ye,onSubmit:e=>(async(e,c)=>{if((await o({woocommerce_bacs_settings:{enabled:"yes"},woocommerce_bacs_accounts:[e]})).success)return c(),void t("success",Object(n.__)("Direct bank transfer details added successfully",'woocommerce'));t("error",Object(n.__)("There was a problem saving your payment settings",'woocommerce'))})(e,i),validate:a},({getInputProps:t,handleSubmit:o})=>Object(c.createElement)(c.Fragment,null,Object(c.createElement)(d.H,null,Object(n.__)("Add your bank details",'woocommerce')),Object(c.createElement)("p",null,Object(n.__)("These details are required to receive payments via bank transfer",'woocommerce')),Object(c.createElement)("div",{className:"woocommerce-task-payment-method__fields"},Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("Account name",'woocommerce'),required:!0},t("account_name"))),Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("Account number",'woocommerce'),required:!0},t("account_number"))),Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("Bank name",'woocommerce'),required:!0},t("bank_name"))),Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("Sort code",'woocommerce'),required:!0},t("sort_code"))),Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("IBAN",'woocommerce'),required:!0},t("iban"))),Object(c.createElement)(d.TextControl,V()({label:Object(n.__)("BIC / Swift",'woocommerce'),required:!0},t("bic")))),Object(c.createElement)(s.Button,{isPrimary:!0,isBusy:e,onClick:o},Object(n.__)("Save",'woocommerce'))))))},scope:'woocommerce'});const ke=({query:e})=>{const{invalidateResolutionForStoreSelector:t}=Object(i.useDispatch)(r.ONBOARDING_STORE_NAME),{updatePaymentGateway:o}=Object(i.useDispatch)(r.PAYMENT_GATEWAYS_STORE_NAME),{getPaymentGateway:s,paymentGatewaySuggestions:a,installedPaymentGateways:l,isResolving:d}=Object(i.useSelect)(e=>({getPaymentGateway:e(r.PAYMENT_GATEWAYS_STORE_NAME).getPaymentGateway,getOption:e(r.OPTIONS_STORE_NAME).getOption,installedPaymentGateways:e(r.PAYMENT_GATEWAYS_STORE_NAME).getPaymentGateways(),isResolving:e(r.ONBOARDING_STORE_NAME).isResolving("getPaymentGatewaySuggestions"),paymentGatewaySuggestions:e(r.ONBOARDING_STORE_NAME).getPaymentGatewaySuggestions()}),[]),p=Object(c.useMemo)(()=>{const e=l.reduce((e,t)=>(e[t.id]=t,e),{});return a.reduce((t,o)=>{const{id:c}=o,n=e[o.id]?e[c]:{},s={installed:!!e[c],postInstallScripts:n.post_install_scripts,enabled:n.enabled||!1,needsSetup:n.needs_setup,settingsUrl:n.settings_url,connectionUrl:n.connection_url,setupHelpText:n.setup_help_text,title:n.title,requiredSettings:n.required_settings_keys?n.required_settings_keys.map(e=>n.settings[e]).filter(Boolean):[],...o};return t.set(c,s),t},new Map)},[l,a]);Object(c.useEffect)(()=>{p.size&&Object(m.recordEvent)("tasklist_payments_options",{options:Array.from(p.values()).map(e=>e.id)})},[p]);const u=Object(c.useCallback)(async(e,c={})=>{if(!p.get(e))throw`Payment gateway ${e} not found in available gateways list`;(e=>{if(!e)return;const c=s(e);c&&!c.enabled&&o(e,{enabled:!0}).then(()=>{t("getTasksStatus")})})(e),Object(m.recordEvent)("tasklist_payment_connect_method",{payment_method:e}),Object(k.getHistory)().push(Object(k.getNewPath)({...c},"/",{}))},[p]),_=Object(c.useMemo)(()=>Array.from(p.values()).filter(e=>e.recommendation_priority).sort((e,t)=>e.recommendation_priority-t.recommendation_priority).map(e=>e.id).shift(),[p]),b=Object(c.useMemo)(()=>{if(!e.id||d||!p.size)return null;const t=p.get(e.id);if(!t)throw`Current gateway ${e.id} not found in available gateways list`;return t},[d,e,p]),[g,h,O]=Object(c.useMemo)(()=>Array.from(p.values()).reduce((e,t)=>{const[o,c,n]=e;return"woocommerce_payments"!==t.id||t.installed&&!t.needsSetup?t.enabled?c.push(t):n.push(t):o.push(t),e},[[],[],[]]),[p]);return e.id&&!b?Object(c.createElement)(Oe,null):b?Object(c.createElement)(he,{paymentGateway:b,markConfigured:u}):Object(c.createElement)("div",{className:"woocommerce-task-payments"},!p.size&&Object(c.createElement)(be,null),!!g.length&&Object(c.createElement)(je.a,{paymentGateway:g[0]}),!!h.length&&Object(c.createElement)(ue,{heading:Object(n.__)("Enabled payment gateways",'woocommerce'),recommendation:_,paymentGateways:h}),!!O.length&&Object(c.createElement)(ue,{heading:Object(n.__)("Additional payment gateways",'woocommerce'),recommendation:_,paymentGateways:O,markConfigured:u}))};var Ee=o(526),Se=o(543);function ve(e,t,o,c){Object(m.recordEvent)("task_view",{task_name:e,wcs_installed:c.includes("woocommerce-services"),wcs_active:o.includes("woocommerce-services"),jetpack_installed:c.includes("jetpack"),jetpack_active:o.includes("jetpack"),jetpack_connected:t})}function fe(e,t){if(e.completed||t.completed)return e.completed?1:-1;const o=e.level||3,c=t.level||3;return o===c?0:o>c?1:-1}o(598);function Ce(e,t,o){return[...new Set([...e,...t])].filter(e=>!o.includes(e))}var Te=({query:e,name:t,eventName:o,isComplete:a,dismissedTasks:l,remindMeLaterTasks:p,tasks:u,trackedCompletedTasks:_,title:b,collapsible:g=!1,onComplete:h,onHide:O,expandingItems:j=!1})=>{const{createNotice:w}=Object(i.useDispatch)("core/notices"),{updateOptions:y}=Object(i.useDispatch)(r.OPTIONS_STORE_NAME),{profileItems:E}=Object(i.useSelect)(e=>{const{getProfileItems:t}=e(r.ONBOARDING_STORE_NAME);return{profileItems:t()}}),S=Object(c.useRef)(e);Object(c.useEffect)(()=>{R()},[]),Object(c.useEffect)(()=>{const{task:t}=S.current,{task:o}=e;t!==o&&(window.document.documentElement.scrollTop=0,S.current=e),x(),P()},[e]);const v=Date.now(),f=u.filter(e=>e.visible&&!l.includes(e.key)&&(!p[e.key]||p[e.key]<v)),T=f.filter(e=>e.completed).map(e=>e.key),N=u.filter(e=>e.visible&&!e.completed&&!l.includes(e.key)),x=()=>{const e=`woocommerce_${t}_complete`,o=a?{[e]:"no"}:{[e]:"yes"};(!N.length&&!a||N.length&&a)&&(y({...o}),"function"==typeof h&&h())},P=()=>{const e=function(e,t){if(!t)return[];return e.filter(e=>t.includes(e))}(T,_),t=(o=e,c=_,f.filter(e=>c.includes(e.key)&&!o.includes(e.key)).map(e=>e.key));var o,c;(function(e,t,o){if(t.length>0)return!0;if(0===o.length)return!1;return!o.every(t=>e.indexOf(t)>=0)})(e,t,T)&&y({woocommerce_task_list_tracked_completed_tasks:Ce(T,_,t)})},A=e=>{const t=l.filter(t=>t!==e);y({woocommerce_task_list_dismissed_tasks:t}),Object(m.recordEvent)(o+"_undo_dismiss_task",{task_name:e})},I=e=>{const{[e]:t,...c}=p;y({woocommerce_task_list_remind_me_later_tasks:c}),Object(m.recordEvent)(o+"_undo_remindmelater_task",{task_name:e})},R=()=>{e.task||Object(m.recordEvent)(o+"_view",{number_tasks:f.length,store_connected:E.wccom_connected})},M=f.map(e=>(e.onClick||(e.onClick=t=>{if(Object(m.recordEvent)(o+"_click",{task_name:e.key}),"A"===t.target.nodeName)return!1;Object(k.updateQueryString)({task:e.key})}),e));if(!M.length)return Object(c.createElement)("div",{className:"woocommerce-task-dashboard__container"});const B=Object(n.sprintf)(Object(n._n)("Show %i more task.","Show %i more tasks.",M.length-2,'woocommerce'),M.length-2),G=Object(n.__)("Show less",'woocommerce'),L=g?C.CollapsibleList:C.List,F=g?{collapseLabel:G,expandLabel:B,show:2,onCollapse:()=>Object(m.recordEvent)(o+"_collapse"),onExpand:()=>Object(m.recordEvent)(o+"_expand")}:{};return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("div",{className:"woocommerce-task-dashboard__container"},Object(c.createElement)(s.Card,{size:"large",className:"woocommerce-task-card woocommerce-homescreen-card"},Object(c.createElement)(s.CardHeader,{size:"medium"},Object(c.createElement)("div",{className:"wooocommerce-task-card__header"},Object(c.createElement)(C.Text,{size:"20",lineHeight:"28px",variant:"title.small"},b),Object(c.createElement)(d.Badge,{count:N.length})),Object(c.createElement)("div",{className:"woocommerce-card__menu woocommerce-card__header-item"},Object(c.createElement)(d.EllipsisMenu,{label:Object(n.__)("Task List Options",'woocommerce'),renderContent:()=>Object(c.createElement)("div",{className:"woocommerce-task-card__section-controls"},Object(c.createElement)(s.Button,{onClick:()=>(e=>{const c={[`woocommerce_${t}_hidden`]:"yes"};Object(m.recordEvent)(o+"_completed",{action:e,completed_task_count:T.length,incomplete_task_count:N.length}),y({...c}),"function"==typeof O&&O()})("remove_card")},Object(n.__)("Hide this",'woocommerce')))}))),Object(c.createElement)(L,V()({animation:"custom"},F),M.map(e=>Object(c.createElement)(C.TaskItem,{key:e.key,title:e.title,completed:e.completed,content:e.content,expandable:j&&e.expandable,expanded:j&&e.expanded,onClick:e.onClick,onDismiss:e.isDismissable?()=>(({key:e,onDismiss:t})=>{w("success",Object(n.__)("Task dismissed"),{actions:[{label:Object(n.__)("Undo",'woocommerce'),onClick:()=>A(e)}]}),Object(m.recordEvent)(o+"_dismiss_task",{task_name:e}),y({woocommerce_task_list_dismissed_tasks:[...l,e]}),t&&t()})(e):void 0,onSnooze:e.allowRemindMeLater?()=>(({key:e,onDismiss:t})=>{w("success",Object(n.__)("Task postponed until tomorrow",'woocommerce'),{actions:[{label:Object(n.__)("Undo",'woocommerce'),onClick:()=>I(e)}]}),Object(m.recordEvent)(o+"_remindmelater_task",{task_name:e});const c=Date.now()+864e5;y({woocommerce_task_list_remind_me_later_tasks:{...p,[e]:c}}),t&&t()})(e):void 0,time:e.time,level:e.level,action:e.action,actionLabel:e.actionLabel,additionalInfo:e.additionalInfo,showActionButton:e.showActionButton,onExpand:e.onExpand,onCollapse:e.onCollapse}))))))},Ne=o(253);const xe=({taskContainer:e,query:t})=>{const o=Object(c.useRef)(),{isJetpackConnected:n,activePlugins:s,installedPlugins:a}=Object(i.useSelect)(e=>{const{getActivePlugins:t,getInstalledPlugins:o,isJetpackConnected:c}=e(r.PLUGINS_STORE_NAME);return{activePlugins:t(),isJetpackConnected:c(),installedPlugins:o()}});return Object(c.useEffect)(()=>{const{task:e}=t;o.current!==e&&(window.document.documentElement.scrollTop=0),o.current=e,(()=>{const{task:e}=t;e&&ve(e,n,s,a)})()},[t]),e&&t.task?Object(c.createElement)("div",{className:"woocommerce-task-dashboard__container"},Object(c.cloneElement)(e,{query:t})):null};var Pe=o(540);const Ae=[],Ie=e=>{const{getFreeExtensions:t,getProductTypes:o,getProfileItems:c,getTasksStatus:n,hasFinishedResolution:s}=e(r.ONBOARDING_STORE_NAME),{getSettings:a}=e(r.SETTINGS_STORE_NAME),{getOption:i,hasFinishedResolution:l}=e(r.OPTIONS_STORE_NAME),{getActivePlugins:m,getInstalledPlugins:d,isJetpackConnected:p}=e(r.PLUGINS_STORE_NAME),u=c(),_=i("woocommerce_task_list_tracked_completed_tasks")||Ae,b=i("woocommerce_task_list_tracked_completed_actions")||Ae,{general:h={}}=a("general"),O=Object(g.b)(h.woocommerce_default_country),{woocommerce_store_address:j,woocommerce_default_country:w,woocommerce_store_postcode:y}=h,k=Boolean(j&&w&&y),E=m(),S=d(),v=n(),f=o();return{activePlugins:E,countryCode:O,dismissedTasks:i("woocommerce_task_list_dismissed_tasks"),freeExtensions:t(),remindMeLaterTasks:i("woocommerce_task_list_remind_me_later_tasks"),isExtendedTaskListComplete:"yes"===i("woocommerce_extended_task_list_complete"),isExtendedTaskListHidden:"yes"===i("woocommerce_extended_task_list_hidden"),isJetpackConnected:p(),isSetupTaskListHidden:"yes"===i("woocommerce_task_list_hidden"),isTaskListComplete:"yes"===i("woocommerce_task_list_complete"),installedPlugins:S,productTypes:f,trackedCompletedActions:b,onboardingStatus:v,profileItems:u,trackedCompletedTasks:_,hasCompleteAddress:k,isResolving:!(l("getOption",["woocommerce_task_list_complete"])&&l("getOption",["woocommerce_task_list_hidden"])&&l("getOption",["woocommerce_extended_task_list_complete"])&&l("getOption",["woocommerce_extended_task_list_hidden"])&&l("getOption",["woocommerce_task_list_remind_me_later_tasks"])&&l("getOption",["woocommerce_task_list_tracked_completed_tasks"])&&l("getOption",["woocommerce_task_list_dismissed_tasks"])&&s("getProductTypes"))}};t.default=({userPreferences:e,query:t})=>{const{createNotice:o}=Object(i.useDispatch)("core/notices"),{updateOptions:p}=Object(i.useDispatch)(r.OPTIONS_STORE_NAME),{invalidateResolutionForStoreSelector:u}=Object(i.useDispatch)(r.ONBOARDING_STORE_NAME),{installAndActivatePlugins:_}=Object(i.useDispatch)(r.PLUGINS_STORE_NAME),{trackedCompletedTasks:b,activePlugins:h,countryCode:O,freeExtensions:j,installedPlugins:E,productTypes:S,isJetpackConnected:v,onboardingStatus:C,profileItems:T,isSetupTaskListHidden:N,dismissedTasks:x,remindMeLaterTasks:P,isTaskListComplete:R,isExtendedTaskListHidden:M,isExtendedTaskListComplete:B,hasCompleteAddress:G,trackedCompletedActions:L,isResolving:F}=Object(i.useSelect)(Ie),[U,D]=Object(c.useState)(!1),[z,q]=Object(l.useExperiment)("woocommerce_tasklist_progression");Object(c.useEffect)(()=>{document.body.classList.add("woocommerce-onboarding"),document.body.classList.add("woocommerce-task-dashboard__body"),u("getProductTypes")},[]);const V=()=>{U||Object(m.recordEvent)("tasklist_purchase_extensions"),D(!U)},J=e=>Object(c.createElement)(Te,{name:"extended_task_list",eventName:"extended_tasklist",collapsible:!0,dismissedTasks:x||[],remindMeLaterTasks:P||[],isComplete:B,query:t,tasks:e,title:Object(n.__)("Things to do next",'woocommerce'),trackedCompletedTasks:b||[]}),W=function({activePlugins:e,countryCode:t,createNotice:o,freeExtensions:s,installAndActivatePlugins:a,installedPlugins:i,isJetpackConnected:r,onboardingStatus:l,profileItems:m,query:d,toggleCartModal:p,onTaskSelect:u,hasCompleteAddress:_,trackedCompletedActions:b,productTypes:h}){const{hasPaymentGateway:O,hasPhysicalProducts:j,hasProducts:w,isAppearanceComplete:E,isTaxComplete:S,shippingZonesCount:v,wcPayIsConnected:C}={hasPaymentGateway:!1,hasPhysicalProducts:!1,hasProducts:!1,isAppearanceComplete:!1,isTaxComplete:!1,shippingZonesCount:0,wcPayIsConnected:!1,...l},T=Object(g.a)(h,m,i),{products:N,remainingProducts:x,uniqueItemsList:P}=T,R=-1!==i.indexOf("woocommerce-payments"),M=-1!==e.indexOf("woocommerce-services"),{completed:B,product_types:G,business_extensions:L}=m,F=(L||[]).includes("woocommerce-payments");let U,D=Object(n.__)("Add paid extensions to my store",'woocommerce');if(1===P.length){var z;const{name:e}=P[0],t=Object(n.__)("Add %s to my store",'woocommerce');D=Object(n.sprintf)(t,e),U=null===(z=N.find(({label:t})=>t===e))||void 0===z?void 0:z.description}else{const e=P.map(({name:e})=>e),t=e.pop();let o=e.join(", ");e.length>1&&(o+=","),U=Object(n.sprintf)(Object(n.__)("Good choice! You chose to add %1$s and %2$s to your store.",'woocommerce'),o,t)}const{automatedTaxSupportedCountries:q=[],taxJarActivated:V}=l,J=!V&&q.includes(t),W=_&&M&&J;let Y=Object(n.__)("Let's go",'woocommerce'),Z=Object(n.__)("Set your store location and configure tax rate settings.",'woocommerce');W&&(Y=Object(n.__)("Yes please",'woocommerce'),Z=Object(n.__)("Good news! WooCommerce Services and Jetpack can automate your sales tax calculations for you.",'woocommerce'));const[$,Q]=A(s,e,i),K=[{key:"store_details",title:Object(n.__)("Store details",'woocommerce'),content:Object(n.__)("Your store address is required to set the origin country for shipping, currencies, and payment options.",'woocommerce'),container:null,action:Object(n.__)("Let's go",'woocommerce'),onClick:()=>{u("store_details"),Object(k.getHistory)().push(Object(k.getNewPath)({},"/setup-wizard",{}))},completed:B,visible:!0,time:Object(n.__)("4 minutes",'woocommerce'),type:"setup"},{key:"purchase",title:D,content:U,container:null,action:Object(n.__)("Purchase & install now",'woocommerce'),onClick:()=>(u("purchase"),x.length?p():null),visible:N.length,completed:N.length&&!x.length,time:Object(n.__)("2 minutes",'woocommerce'),isDismissable:!0,type:"setup"},{key:"products",title:Object(n.__)("Add my products",'woocommerce'),content:Object(n.__)("Start by adding the first product to your store. You can add your products manually, via CSV, or import them from another service.",'woocommerce'),container:Object(c.createElement)(H,null),onClick:()=>{u("products"),Object(k.updateQueryString)({task:"products"})},completed:w,visible:!0,time:Object(n.__)("1 minute per product",'woocommerce'),type:"setup"},{key:"woocommerce-payments",title:Object(n.__)("Get paid with WooCommerce Payments",'woocommerce'),content:Object(n.__)("You're only one step away from getting paid. Verify your business details to start managing transactions with WooCommerce Payments.",'woocommerce'),action:Object(n.__)("Finish setup","woocommmerce-admin"),expanded:!0,container:Object(c.createElement)(c.Fragment,null),completed:C,onClick:async t=>{if("A"===t.target.nodeName)return!1;await new Promise((t,c)=>(ve("wcpay",r,e,i),u("woocommerce-payments"),Object(je.b)(c,o,a)))},visible:F&&R&&Object(je.c)(t),additionalInfo:Object(n.__)('By setting up, you are agreeing to the <a href="https://wordpress.com/tos/" target="_blank">Terms of Service</a>','woocommerce'),time:Object(n.__)("2 minutes",'woocommerce'),type:"setup"},{key:"payments",title:Object(n.__)("Set up payments",'woocommerce'),content:Object(n.__)("Choose payment providers and enable payment methods at checkout.",'woocommerce'),container:Object(c.createElement)(ke,{query:d}),completed:O,onClick:()=>{u("payments"),Object(k.updateQueryString)({task:"payments"})},visible:window.wcAdminFeatures["payment-gateway-suggestions"]&&(!R||!F||!Object(je.c)(t)),time:Object(n.__)("2 minutes",'woocommerce'),type:"setup"},{key:"tax",title:Object(n.__)("Set up tax",'woocommerce'),content:Z,container:Object(c.createElement)(ie,null),action:Y,onClick:(e,t={})=>{const{isExpanded:o}=t;u("tax"),Object(k.updateQueryString)({task:"tax",auto:W&&o})},completed:S,visible:!0,time:Object(n.__)("1 minute",'woocommerce'),type:"setup"},{key:"shipping",title:Object(n.__)("Set up shipping",'woocommerce'),content:Object(n.__)("Set your store location and where you'll ship to.",'woocommerce'),container:Object(c.createElement)(se,null),action:Object(n.__)("Let's go",'woocommerce'),onClick:()=>{v>0?window.location=Object(Se.b)({type:"wc-settings",tab:"shipping"}).href:(u("shipping"),Object(k.updateQueryString)({task:"shipping"}))},completed:v>0,visible:G&&G.includes("physical")||j,time:Object(n.__)("1 minute",'woocommerce'),type:"setup"},{key:"marketing",title:Object(n.__)("Set up marketing tools",'woocommerce'),content:Object(n.__)("Add recommended marketing tools to reach new customers and grow your business",'woocommerce'),container:Object(c.createElement)(I,{trackedCompletedActions:b}),onClick:()=>{u("marketing"),Object(k.updateQueryString)({task:"marketing"})},completed:!!$.length&&b.includes("marketing")||!Q.length,visible:window.wcAdminFeatures&&window.wcAdminFeatures["remote-free-extensions"]&&(!!Q.length||!!$.length),time:Object(n.__)("1 minute",'woocommerce'),type:"setup"},{key:"appearance",title:Object(n.__)("Personalize my store",'woocommerce'),content:Object(n.__)("Add your logo, create a homepage, and start designing your store.",'woocommerce'),container:Object(c.createElement)(f,null),action:Object(n.__)("Let's go",'woocommerce'),onClick:()=>{u("appearance"),Object(k.updateQueryString)({task:"appearance"})},completed:E,visible:!0,time:Object(n.__)("2 minutes",'woocommerce'),type:"setup"}],X=Object(y.applyFilters)("woocommerce_admin_onboarding_task_list",K,d);for(const e of X)e.level=e.level?parseInt(e.level,10):3;return Object(Ee.a)(X,"type","extension")}({activePlugins:h,countryCode:O,createNotice:o,freeExtensions:j,installAndActivatePlugins:_,installedPlugins:E,isJetpackConnected:v,onboardingStatus:C,profileItems:T,query:t,toggleCartModal:V,onTaskSelect:t=>{const o=(t=>{const o=e.task_list_tracked_started_tasks;return o&&o[t]?o[t]:0})(t);Object(m.recordEvent)("tasklist_click",{task_name:t}),(e=>!!b&&b.includes(e))(t)||((t,o)=>{const c=e.task_list_tracked_started_tasks||{};e.updateUserPreferences({task_list_tracked_started_tasks:{...c||{},[t]:o}})})(t,o+1)},hasCompleteAddress:G,trackedCompletedActions:L,productTypes:S}),{extension:Y,setup:Z}=W,{task:$}=t,Q=Array.isArray(Y)&&Y.sort(fe),K=(e=>{const{task:o}=t,c=e.find(e=>e.key===o);return c||null})([...Q||[],...Z||[]]);if($&&!K)return null;if(K)return Object(c.createElement)(xe,{taskContainer:K.container,query:t});if(F)return Object(c.createElement)(Pe.a,null);const X="extended_task_list"===window.location.hash.substr(1);return Object(c.createElement)(c.Fragment,null,Z&&(!N||$)&&(z?Object(c.createElement)(Pe.a,null):Object(c.createElement)(Te,{name:"task_list",eventName:"tasklist",expandingItems:"treatment"===(null==q?void 0:q.variationName),dismissedTasks:x||[],remindMeLaterTasks:P||[],isComplete:R,query:t,tasks:Z,title:Object(n.__)("Get ready to start selling",'woocommerce'),trackedCompletedTasks:b||[],onComplete:()=>p({woocommerce_default_homepage_layout:"two_columns"}),onHide:()=>p({woocommerce_default_homepage_layout:"two_columns"})})),Q&&Object(c.createElement)(Ne.a,null,Object(c.createElement)(s.MenuGroup,{className:"woocommerce-layout__homescreen-display-options",label:Object(n.__)("Display",'woocommerce')},Object(c.createElement)(s.MenuItem,{className:"woocommerce-layout__homescreen-extension-tasklist-toggle",icon:!M&&a.a,isSelected:!M,role:"menuitemcheckbox",onClick:()=>{const e=!M;Object(m.recordEvent)(e?"extended_tasklist_hide":"extended_tasklist_show"),p({woocommerce_extended_task_list_hidden:e?"yes":"no"})}},Object(n.__)("Show things to do next",'woocommerce')))),Q&&!M&&(X?Object(c.createElement)(d.ScrollTo,{offset:"-20"},J(Q)):J(Q)),U&&Object(c.createElement)(w,{onClose:()=>V(),onClickPurchaseLater:()=>V()}))}}}]);