this.wc=this.wc||{},this.wc.printShippingLabelBanner=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=466)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t,n){e.exports=n(47)()},11:function(e,t){e.exports=window.wc.data},116:function(e,t,n){"use strict";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=n(22);var r=n(0);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}t.a=function(e){var t=e.icon,n=e.size,c=void 0===n?24:n,a=function(e,t){if(null==e)return{};var n,o,r=Object(i.a)(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,["icon","size"]);return Object(r.cloneElement)(t,function(e){for(var t=1;t(i.includes(t)||(e[t]=r[t]),e),{});Object.keys(r.admin||{}).forEach(e=>{i.includes(e)||(s[e]=r.admin[e])});const c=s.adminUrl,a=(s.countries,s.currency),l=s.locale,u=s.orderStatuses;s.siteTitle,s.wcAssetUrl;function d(e,t=!1,n=(e=>e)){if(i.includes(e))throw new Error(Object(o.__)("Mutable settings should be accessed via data store."));return n(s.hasOwnProperty(e)?s[e]:t,t)}function p(e,t,n=(e=>e)){if(i.includes(e))throw new Error(Object(o.__)("Mutable settings should be mutated via data store."));s[e]=n(t)}function m(e){return(c||"")+e}function h(e){return new Promise((t,n)=>{document.querySelector(`#${e.handle}-js`)&&t();const o=document.createElement("script");o.src=e.src,o.id=e.handle+"-js",o.async=!0,o.onload=t,o.onerror=n,document.body.appendChild(o)})}},14:function(e,t){e.exports=window.wp.compose},16:function(e,t){e.exports=window.wc.tracks},17:function(e,t){e.exports=window.wp.apiFetch},18:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=c(n(5)),r=c(n(69)),s=c(n(72));function c(e){return e&&e.__esModule?e:{default:e}}var a=void 0;function l(e,t){var n,s,c,u,d,p,m,h,f=[],b={};for(p=0;p "+a);if("componentClose"===d.type)throw new Error("Missing opening component token: `"+d.value+"`");if("componentOpen"===d.type){n=t[d.value],c=p;break}f.push(t[d.value])}else f.push(d.value);return n&&(u=function(e,t){var n,o,i=t[e],r=0;for(o=e+1;o=0||(i[n]=e[n]);return i}n.d(t,"a",(function(){return o}))},251:function(e,t,n){},3:function(e,t){e.exports=window.wp.components},38:function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.default=e.exports,e.exports.__esModule=!0},4:function(e,t){e.exports=window.lodash},466:function(e,t,n){"use strict";n.r(t);var o=n(0),i=n(11),r=n(13),s=n(38),c=n.n(s),a=n(2),l=n(3),u=n(14),d=n(18),p=n.n(d),m=n(1),h=n.n(m),f=n(4),b=n(7),w=n(16);n(251);class g extends o.Component{constructor(...e){super(...e),c()(this,"setDismissed",e=>{this.props.updateOptions({woocommerce_shipping_dismissed_timestamp:e})}),c()(this,"hideBanner",()=>{document.getElementById("woocommerce-admin-print-label").style.display="none"}),c()(this,"remindMeLaterClicked",()=>{const{onCloseAll:e,trackElementClicked:t}=this.props;this.setDismissed(Date.now()),e(),this.hideBanner(),t("shipping_banner_dismiss_modal_remind_me_later")}),c()(this,"closeForeverClicked",()=>{const{onCloseAll:e,trackElementClicked:t}=this.props;this.setDismissed(-1),e(),this.hideBanner(),t("shipping_banner_dismiss_modal_close_forever")})}render(){const{onClose:e,visible:t}=this.props;return t?Object(o.createElement)(l.Modal,{title:Object(a.__)("Are you sure?",'woocommerce'),onRequestClose:e,className:"wc-admin-shipping-banner__dismiss-modal"},Object(o.createElement)("p",{className:"wc-admin-shipping-banner__dismiss-modal-help-text"},Object(a.__)("With WooCommerce Shipping you can Print shipping labels from your WooCommerce dashboard at the lowest USPS rates.",'woocommerce')),Object(o.createElement)("div",{className:"wc-admin-shipping-banner__dismiss-modal-actions"},Object(o.createElement)(l.Button,{isSecondary:!0,onClick:this.remindMeLaterClicked},Object(a.__)("Remind me later",'woocommerce')),Object(o.createElement)(l.Button,{isPrimary:!0,onClick:this.closeForeverClicked},Object(a.__)("I don't need this",'woocommerce')))):null}}var y=Object(u.compose)(Object(b.withDispatch)(e=>{const{updateOptions:t}=e(i.OPTIONS_STORE_NAME);return{updateOptions:t}}))(g),v=n(116),O=n(8),_=Object(o.createElement)(O.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(o.createElement)(O.Path,{d:"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z"}));const j="install",S="activate",E="setup",k="start",P={["download"]:Object(a.__)("download",'woocommerce'),[j]:Object(a.__)("install",'woocommerce'),[S]:Object(a.__)("activate",'woocommerce'),[E]:Object(a.__)("set up",'woocommerce'),[k]:Object(a.__)("start",'woocommerce')};function x({isSetupError:e,errorReason:t}){return e?Object(o.createElement)("div",{className:"wc-admin-shipping-banner-install-error"},Object(o.createElement)(v.a,{icon:_,className:"warning-icon"}),(e=>{const t=e in P?P[e]:P[E];return Object(a.sprintf)(Object(a.__)("Unable to %s the plugin. Refresh the page and try again.",'woocommerce'),t)})(t)):null}var C=n(17),A=n.n(C);const R=Object(r.f)("wcAdminAssetUrl","");class B extends o.Component{constructor(e){super(e),c()(this,"isSetupError",()=>this.state.wcsSetupError),c()(this,"closeDismissModal",()=>{this.setState({isDismissModalOpen:!1}),this.trackElementClicked("shipping_banner_dismiss_modal_close_button")}),c()(this,"openDismissModal",()=>{this.setState({isDismissModalOpen:!0}),this.trackElementClicked("shipping_banner_dimiss")}),c()(this,"hideBanner",()=>{this.setState({showShippingBanner:!1})}),c()(this,"createShippingLabelClicked",()=>{const{activePlugins:e}=this.props;this.setState({isShippingLabelButtonBusy:!0}),this.trackElementClicked("shipping_banner_create_label"),e.includes("woocommerce-services")?this.acceptTosAndGetWCSAssets():this.installAndActivatePlugins("woocommerce-services")}),c()(this,"woocommerceServiceLinkClicked",()=>{this.trackElementClicked("shipping_banner_woocommerce_service_link")}),c()(this,"trackBannerEvent",(e,t={})=>{const{activePlugins:n,isJetpackConnected:o}=this.props;Object(w.recordEvent)(e,{banner_name:"wcadmin_install_wcs_prompt",jetpack_installed:n.includes("jetpack"),jetpack_connected:o,wcs_installed:n.includes("woocommerce-services"),...t})}),c()(this,"trackImpression",()=>{this.trackBannerEvent("banner_impression")}),c()(this,"trackElementClicked",e=>{this.trackBannerEvent("banner_element_clicked",{element:e})}),c()(this,"getInstallText",()=>{const{activePlugins:e}=this.props;return e.includes("woocommerce-services")?Object(a.__)('You\'ve already installed WooCommerce Shipping. By clicking "Create shipping label", you agree to its {{tosLink}}Terms of Service{{/tosLink}}.','woocommerce'):Object(a.__)('By clicking "Create shipping label", {{wcsLink}}WooCommerce Shipping{{/wcsLink}} will be installed and you agree to its {{tosLink}}Terms of Service{{/tosLink}}.','woocommerce')});const t=new URL(window.location.href).searchParams.get("post");this.state={showShippingBanner:!0,isDismissModalOpen:!1,setupErrorReason:E,orderId:parseInt(t,10),wcsAssetsLoaded:!1,wcsAssetsLoading:!1,wcsSetupError:!1,isShippingLabelButtonBusy:!1,installText:this.getInstallText(),isWcsModalOpen:!1}}componentDidMount(){const{showShippingBanner:e}=this.state;e&&this.trackImpression()}async installAndActivatePlugins(e){const{installPlugins:t,activatePlugins:n,isRequesting:o}=this.props;if(o)return!1;if(!0!==(await t([e])).success)return void this.setState({setupErrorReason:j,wcsSetupError:!0});!0===(await n([e])).success?this.acceptTosAndGetWCSAssets():this.setState({setupErrorReason:S,wcsSetupError:!0})}acceptTosAndGetWCSAssets(){return A()({path:"/wc/v1/connect/tos",method:"POST",data:{accepted:!0}}).then(()=>A()({path:"/wc/v1/connect/assets",method:"GET"})).then(e=>this.loadWcsAssets(e)).catch(()=>this.setState({wcsSetupError:!0}))}generateMetaBoxHtml(e,t,n){const o=JSON.stringify(n).replace(/"/g,""");return`\n
\n\t
\n\t\t

${t}

\n\t\t
\n\t\t\t\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t
\n\t
\n
\n`}loadWcsAssets({assets:e}){if(this.state.wcsAssetsLoaded||this.state.wcsAssetsLoading)return void this.openWcsModal();this.setState({wcsAssetsLoading:!0});const t=e.wc_connect_admin_script,n=e.wc_connect_admin_style;if(void 0===window.wcsPluginData){const e=t.substring(0,t.lastIndexOf("/")+1);window.wcsPluginData={assetPath:e}}const{orderId:o}=this.state,{itemsCount:i}=this.props,r=this.generateMetaBoxHtml("woocommerce-order-label",Object(a.__)("Shipping Label",'woocommerce'),{order:{id:o},context:"shipping_label",items:i});document.getElementById("woocommerce-order-data").insertAdjacentHTML("beforebegin",r);const s=this.generateMetaBoxHtml("woocommerce-order-shipment-tracking",Object(a.__)("Shipment Tracking",'woocommerce'),{order:{id:o},context:"shipment_tracking",items:i});document.getElementById("woocommerce-order-actions").insertAdjacentHTML("afterend",s),window.jQuery&&(window.jQuery("#normal-sortables").sortable("refresh"),window.jQuery("#side-sortables").sortable("refresh"),window.jQuery("#woocommerce-order-label").hide()),Promise.all([new Promise((e,n)=>{const o=document.createElement("script");o.src=t,o.async=!0,o.onload=e,o.onerror=n,document.body.appendChild(o)}),new Promise((e,t)=>{if(""!==n){const o=document.getElementsByTagName("head")[0],i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.href=n,i.media="all",i.onload=e,i.onerror=t,o.appendChild(i)}else e()})]).then(()=>{this.setState({wcsAssetsLoaded:!0,wcsAssetsLoading:!1,isShippingLabelButtonBusy:!1}),this.openWcsModal()})}openWcsModal(){window.wcsGetAppStoreAsync&&window.wcsGetAppStoreAsync("wc-connect-create-shipping-label").then(e=>{const t=e.getState(),{orderId:n}=this.state,o=t.ui.selectedSiteId,i=e.subscribe(()=>{const t=e.getState(),r=Object(f.get)(t,["extensions","woocommerce","woocommerceServices",o,"shippingLabel",n],null),s=Object(f.get)(t,["extensions","woocommerce","woocommerceServices",o,"labelSettings"],null),c=Object(f.get)(t,["extensions","woocommerce","woocommerceServices",o,"packages"],null),l=Object(f.get)(t,["extensions","woocommerce","sites",o,"data","locations"]);r&&s&&s.meta&&c&&l&&(r.loaded&&s.meta.isLoaded&&c.isLoaded&&Object(f.isArray)(l)&&!this.state.isWcsModalOpen?(window.jQuery&&(this.setState({isWcsModalOpen:!0}),window.jQuery(".shipping-label__new-label-button").click()),e.dispatch({type:"NOTICE_CREATE",notice:{duration:1e4,status:"is-success",text:Object(a.__)("Plugin installed and activated",'woocommerce')}})):r.showPurchaseDialog&&(i(),window.jQuery&&window.jQuery("#woocommerce-order-label").show()))});document.getElementById("woocommerce-admin-print-label").style.display="none"})}render(){const{isDismissModalOpen:e,showShippingBanner:t,isShippingLabelButtonBusy:n}=this.state;return t?Object(o.createElement)("div",null,Object(o.createElement)("div",{className:"wc-admin-shipping-banner-container"},Object(o.createElement)("img",{className:"wc-admin-shipping-banner-illustration",src:R+"shippingillustration.svg",alt:Object(a.__)("Shipping ",'woocommerce')}),Object(o.createElement)("div",{className:"wc-admin-shipping-banner-blob"},Object(o.createElement)("h3",null,Object(a.__)("Print discounted shipping labels with a click.",'woocommerce')),Object(o.createElement)("p",null,p()({mixedString:this.state.installText,components:{tosLink:Object(o.createElement)(l.ExternalLink,{href:"https://wordpress.com/tos",target:"_blank",type:"external"}),wcsLink:Object(o.createElement)(l.ExternalLink,{href:"https://woocommerce.com/products/shipping/?utm_medium=product",target:"_blank",type:"external",onClick:this.woocommerceServiceLinkClicked})}})),Object(o.createElement)(x,{isSetupError:this.isSetupError(),errorReason:this.state.setupErrorReason})),Object(o.createElement)(l.Button,{disabled:n,isPrimary:!0,isBusy:n,onClick:this.createShippingLabelClicked},Object(a.__)("Create shipping label",'woocommerce')),Object(o.createElement)("button",{onClick:this.openDismissModal,type:"button",className:"notice-dismiss",disabled:this.state.isShippingLabelButtonBusy},Object(o.createElement)("span",{className:"screen-reader-text"},Object(a.__)("Close Print Label Banner.",'woocommerce')))),Object(o.createElement)(y,{visible:e,onClose:this.closeDismissModal,onCloseAll:this.hideBanner,trackElementClicked:this.trackElementClicked})):null}}B.propTypes={itemsCount:h.a.number.isRequired,isJetpackConnected:h.a.bool.isRequired,activePlugins:h.a.array.isRequired,activatePlugins:h.a.func.isRequired,installPlugins:h.a.func.isRequired,isRequesting:h.a.bool.isRequired};var L=Object(u.compose)(Object(b.withSelect)(e=>{const{isPluginsRequesting:t,isJetpackConnected:n,getActivePlugins:o}=e(i.PLUGINS_STORE_NAME);return{isRequesting:t("activatePlugins")||t("installPlugins"),isJetpackConnected:n(),activePlugins:o()}}),Object(b.withDispatch)(e=>{const{activatePlugins:t,installPlugins:n}=e(i.PLUGINS_STORE_NAME);return{activatePlugins:t,installPlugins:n}}))(B);const T=document.getElementById("wc-admin-shipping-banner-root"),M=T.dataset.args&&JSON.parse(T.dataset.args)||{},I=Object(i.withPluginsHydration)({...Object(r.f)("plugins"),jetpackStatus:Object(r.f)("dataEndpoints",{}).jetpackStatus})(L);Object(o.render)(Object(o.createElement)(I,{itemsCount:M.items}),T)},47:function(e,t,n){"use strict";var o=n(48);function i(){}function r(){}r.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,r,s){if(s!==o){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:r,resetWarningCache:i};return n.PropTypes=n,n}},48:function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5:function(e,t){e.exports=window.React},50:function(e,t,n){"use strict";function o(e){return function(){return e}}var i=function(){};i.thatReturns=o,i.thatReturnsFalse=o(!1),i.thatReturnsTrue=o(!0),i.thatReturnsNull=o(null),i.thatReturnsThis=function(){return this},i.thatReturnsArgument=function(e){return e},e.exports=i},69:function(e,t,n){"use strict";var o=n(5),i="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,r=n(50),s=n(70),c=n(71),a="function"==typeof Symbol&&Symbol.iterator;function l(e,t){return e&&"object"==typeof e&&null!=e.key?(n=e.key,o={"=":"=0",":":"=2"},"$"+(""+n).replace(/[=:]/g,(function(e){return o[e]}))):t.toString(36);var n,o}function u(e,t,n,o){var r,c=typeof e;if("undefined"!==c&&"boolean"!==c||(e=null),null===e||"string"===c||"number"===c||"object"===c&&e.$$typeof===i)return n(o,e,""===t?"."+l(e,0):t),1;var d=0,p=""===t?".":t+":";if(Array.isArray(e))for(var m=0;m