!function(e){var n={};function t(i){if(n[i])return n[i].exports;var a=n[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,t),a.l=!0,a.exports}t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var a in e)t.d(i,a,function(n){return e[n]}.bind(null,a));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=18)}([function(e,n){e.exports=React},function(e,n,t){e.exports=t(20)},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.css-handles@1.x/useCssHandles"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.order-manager@0.x/OrderForm"]},function(e,n){e.exports=ReactApollo},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.order-manager@0.x/OrderQueue"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["carajas.global-context@0.x/UseGlobalContextAvantiRegionalization"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["carajas.global-context@0.x/UseGlobalContextAvantiRegionalizationSet"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.css-handles@1.x/applyModifiers"]},function(e,n){e.exports=__RENDER_8_RUNTIME__},function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"getAdressSimulation"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"cep"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"country"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"sender"},value:{kind:"StringValue",value:"carajas.avanti-regionalization@0.1.14",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"getAdress"},arguments:[{kind:"Argument",name:{kind:"Name",value:"cep"},value:{kind:"Variable",name:{kind:"Name",value:"cep"}}},{kind:"Argument",name:{kind:"Name",value:"country"},value:{kind:"Variable",name:{kind:"Name",value:"country"}}}],directives:[{kind:"Directive",name:{kind:"Name",value:"runtimeMeta"},arguments:[{kind:"Argument",name:{kind:"Name",value:"hash"},value:{kind:"StringValue",value:"5582f5f05b14a35071badac12221ced38c0d7e24859ec2aea2e2de6af9eaae8c",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addressType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"addressId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"postalCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"city"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"country"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"street"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"neighborhood"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"complement"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"reference"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"geoCoordinates"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:424}};t.loc.source={body:'query getAdressSimulation($cep: String!, $country: String!) @context(sender: "carajas.avanti-regionalization@0.1.14") {\n getAdress(cep: $cep, country: $country) @runtimeMeta(hash: "5582f5f05b14a35071badac12221ced38c0d7e24859ec2aea2e2de6af9eaae8c") {\n addressType\n addressId\n postalCode\n city\n state\n country\n street\n neighborhood\n complement\n reference\n geoCoordinates\n __typename\n }\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var i={};function a(e,n){for(var t=0;t0;){var l=s;s=new Set,l.forEach((function(e){o.has(e)||(o.add(e),(i[e]||new Set).forEach((function(e){s.add(e)})))}))}return o.forEach((function(n){var i=a(e,n);i&&t.definitions.push(i)})),t}(t,"getAdressSimulation")},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.getPublicPath=n.register=void 0;var i="__RENDER_8_RUNTIME__",a="__RENDER_8_COMPONENTS__",r=!("undefined"==typeof window||!window.document);r&&!window.global&&(window.global=window),window[a]=window[a]||{},n.register=function(e,n,t,r,o){var s="".concat(t,"/").concat(o),l="".concat(r,"/").concat(o),u=function(){return function(e,n){try{var t=e();return t.__esModule?t.default:t.default||t}catch(e){throw new Error("An error happened while requiring the app ".concat(n,", please check your app's code.\\n").concat(e.stack))}}(e,s)};if(window[i]&&window[i].registerComponent){var c=!!window.__RENDER_LAZY__;window[i].registerComponent(n,c?u:u(),t,o,c)}else{var d=u();window[i]&&window[i].withHMR?window[a][s]=window[a][l]=window[i].withHMR(n,d):window[a][s]=window[a][l]=d}return{}},n.getPublicPath=function(e){var n=window.__hostname__,t="/_v/public/assets/v1/published/";return r&&window.__RUNTIME__&&(n=__RUNTIME__.assetServerPublishedHost||window.location.hostname,t=__RUNTIME__.assetServerPublishedPath||"/_v/public/assets/v1/published/"),"https://"+n+t+"".concat(e,"/public/react/")}},function(e,n,t){e.exports=t(21)},function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"logisticsOrderForm"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"newCep"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"productID"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"productQuantity"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"productSeller"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"sender"},value:{kind:"StringValue",value:"carajas.avanti-regionalization@0.1.14",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"getOrderformSimulator"},arguments:[{kind:"Argument",name:{kind:"Name",value:"newCep"},value:{kind:"Variable",name:{kind:"Name",value:"newCep"}}},{kind:"Argument",name:{kind:"Name",value:"productID"},value:{kind:"Variable",name:{kind:"Name",value:"productID"}}},{kind:"Argument",name:{kind:"Name",value:"productQuantity"},value:{kind:"Variable",name:{kind:"Name",value:"productQuantity"}}},{kind:"Argument",name:{kind:"Name",value:"productSeller"},value:{kind:"Variable",name:{kind:"Name",value:"productSeller"}}}],directives:[{kind:"Directive",name:{kind:"Name",value:"runtimeMeta"},arguments:[{kind:"Argument",name:{kind:"Name",value:"hash"},value:{kind:"StringValue",value:"2ae826d06995e52c4f2ad0d8bcf524816d60d5c838092d9fce357646e6e48b95",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"logisticsInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"slas"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"availableDeliveryWindows"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"endDateUtc"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"listPrice"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"price"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"startDateUtd"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"tax"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"deliveryChannel"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"pickupDistance"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"pickupPointId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"price"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"shippingEstimate"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"pickupStoreInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"friendlyName"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"address"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"postalCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"city"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"country"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"street"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"neighborhood"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"complement"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"reference"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"addressType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:1121}};t.loc.source={body:'query logisticsOrderForm($newCep: String!, $productID: String!, $productQuantity: Int!, $productSeller: String!) @context(sender: "carajas.avanti-regionalization@0.1.14") {\n getOrderformSimulator(newCep: $newCep, productID: $productID, productQuantity: $productQuantity, productSeller: $productSeller) @runtimeMeta(hash: "2ae826d06995e52c4f2ad0d8bcf524816d60d5c838092d9fce357646e6e48b95") {\n id\n logisticsInfo {\n slas {\n id\n availableDeliveryWindows {\n endDateUtc\n listPrice\n price\n startDateUtd\n tax\n __typename\n }\n deliveryChannel\n name\n pickupDistance\n pickupPointId\n price\n shippingEstimate\n pickupStoreInfo {\n friendlyName\n address {\n postalCode\n city\n state\n country\n street\n neighborhood\n complement\n reference\n addressType\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var i={};function a(e,n){for(var t=0;t0;){var l=s;s=new Set,l.forEach((function(e){o.has(e)||(o.add(e),(i[e]||new Set).forEach((function(e){s.add(e)})))}))}return o.forEach((function(n){var i=a(e,n);i&&t.definitions.push(i)})),t}(t,"logisticsOrderForm")},function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"updateSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"fields"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"SessionFieldsJSONInput"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"items"}},type:{kind:"ListType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"sender"},value:{kind:"StringValue",value:"carajas.avanti-regionalization@0.1.14",block:!1}}]},{kind:"Directive",name:{kind:"Name",value:"runtimeMeta"},arguments:[{kind:"Argument",name:{kind:"Name",value:"hash"},value:{kind:"StringValue",value:"8e48e96743ab63c2430951585a923e047182aeb4ef36841bd8c4faea56c292cf",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"fields"},value:{kind:"Variable",name:{kind:"Name",value:"fields"}}},{kind:"Argument",name:{kind:"Name",value:"items"},value:{kind:"Variable",name:{kind:"Name",value:"items"}}}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"provider"},value:{kind:"StringValue",value:"vtex.session-client",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SessionSuccess"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"namespaces"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SessionError"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"message"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:486}};t.loc.source={body:'mutation updateSession($fields: SessionFieldsJSONInput!, $items: [String]) @context(sender: "carajas.avanti-regionalization@0.1.14") @runtimeMeta(hash: "8e48e96743ab63c2430951585a923e047182aeb4ef36841bd8c4faea56c292cf") {\n updateSession(fields: $fields, items: $items) @context(provider: "vtex.session-client") {\n ... on SessionSuccess {\n id\n namespaces\n __typename\n }\n ... on SessionError {\n type\n message\n __typename\n }\n __typename\n }\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var i={};function a(e,n){for(var t=0;t0;){var l=s;s=new Set,l.forEach((function(e){o.has(e)||(o.add(e),(i[e]||new Set).forEach((function(e){s.add(e)})))}))}return o.forEach((function(n){var i=a(e,n);i&&t.definitions.push(i)})),t}(t,"updateSession")},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.checkout-resources@0.x/MutationUpdateSelectedAddress"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.checkout-resources@0.x/MutationEstimateShipping"]},function(e,n){e.exports=__RENDER_8_COMPONENTS__["vtex.checkout-resources@0.x/MutationSelectDeliveryOption"]},function(e,n,t){"use strict";t.r(n),function(e){var n=t(11);t.p=Object(n.getPublicPath)("carajas.avanti-regionalization@0.1.14");var i=Object(n.register)((function(){return t(23)}),e,"carajas.avanti-regionalization@0.1.14","carajas.avanti-regionalization@0.x","Regionalization");i.renderHotReload,i.setupHMR}.call(this,t(19)(e))},function(e,n){e.exports=function(e){if(!e.webpackPolyfill){var n=Object.create(e);n.children||(n.children=[]),Object.defineProperty(n,"loaded",{enumerable:!0,get:function(){return n.l}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return n.i}}),Object.defineProperty(n,"exports",{enumerable:!0}),n.webpackPolyfill=1}return n}},function(e,n){e.exports=regeneratorRuntime},function(e,n,t){"use strict";var i,a=(i=t(0))&&"object"==typeof i&&"default"in i?i.default:i,r=t(22);function o(){return(o=Object.assign||function(e){for(var n=1;ni.length&&v(e,n.length-1);)n=n.slice(0,n.length-1);return n.length}for(var a=i.length,r=n.length;r>=i.length;r--){var o=n[r];if(!v(e,r)&&p(e,r,o)){a=r+1;break}}return a}function k(e,n){return g(e,n)===e.mask.length}function h(e,n){var t=e.maskChar,i=e.mask,a=e.prefix;if(!t){for((n=b(e,"",n,0)).lengthn.length&&(n+=a.slice(n.length,i)),s.every((function(t){for(;c=t,v(e,u=i)&&c!==a[u];){if(i>=n.length&&(n+=a[i]),s=t,r&&v(e,i)&&s===r)return!0;if(++i>=a.length)return!1}var s,u,c;return!p(e,i,t)&&t!==r||(ia.start?d=(c=function(e,n,t,i){var a=e.mask,r=e.maskChar,o=t.split(""),s=i;return o.every((function(n){for(;o=n,v(e,t=i)&&o!==a[t];)if(++i>=a.length)return!1;var t,o;return(p(e,i,n)||n===r)&&i++,i=r.length?m=r.length:m=o.length&&me.length)&&(n=e.length);for(var t=0,i=new Array(n);t=1,J=/^([\d]{2})\.*([\d]{3})-*([\d]{3})/,X=null===(n=null===(e=null==R?void 0:R.general_screen_configuration)||void 0===e?void 0:e[0])||void 0===n?void 0:n.jokerProduct,K=d()(),ee=null===(i=null===(t=null==R?void 0:R.general_screen_configuration)||void 0===t?void 0:t[0])||void 0===i?void 0:i.deliveryText,ne=null===(c=null===(l=null==R?void 0:R.general_screen_configuration)||void 0===l?void 0:l[0])||void 0===c?void 0:c.warningText,te=o.a.useCallback((function(){K&&K((function(e){return Object.assign(Object.assign({},e),{openModal:!1})}))}),[K]),ie=function(e){var n,t,i=null==b?void 0:b.replace(J,"$1$2-$3");if(Z&&!Z.selectedAddress&&e)L(e);else{var a=null===(t=null===(n=null==Z?void 0:Z.selectedAddress)||void 0===n?void 0:n.postalCode)||void 0===t?void 0:t.replace(J,"$1$2-$3"),r=null==Z?void 0:Z.availableAddresses.filter((function(e){return(null==e?void 0:e.postalCode)===(null==b?void 0:b.replace(J,"$1$2-$3"))}));a!==i&&(r&&r.length>0?V(r[0]):L(e))}},ae=function(){var e=y(h.a.mark((function e(n,t){return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n,window.localStorage.setItem("aditionalShippingData",JSON.stringify({activeTab:"delivery",selectedLeanShippingOption:"CHEAPEST",originComponent:"omnishipping"})),window.localStorage.setItem("activeDeliveryChannel","delivery"),window.localStorage.setItem("selectedSla",JSON.stringify(i)),B(n.name),null==K||K((function(e){return Object.assign(Object.assign({},e),{delivery:Object.assign(Object.assign({},null==R?void 0:R.delivery),{cep:b,city:null==t?void 0:t.city,state:null==t?void 0:t.state}),deliveryChannel:"delivery",isRegionalize:!0,slaSelected:n})})),P({variables:{fields:{postalCode:b,country:"BRA"}}},ie(t),te);case 5:case"end":return e.stop()}var i}),e)})));return function(n,t){return e.apply(this,arguments)}}();Object(r.useEffect)((function(){var e,n,t;(null===(e=null==R?void 0:R.delivery)||void 0===e?void 0:e.cep)&&(null===(n=null==R?void 0:R.delivery)||void 0===n?void 0:n.cep)!==b&&w(null===(t=null==R?void 0:R.delivery)||void 0===t?void 0:t.cep)}),[null===(m=null==R?void 0:R.delivery)||void 0===m?void 0:m.cep]);var re=function(){var e=y(h.a.mark((function e(n){var t,i;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("/_v/correios/cep/".concat(n));case 3:if((t=e.sent).ok){e.next=6;break}return e.abrupt("return",{name:"Error"});case 6:return e.next=8,t.json();case 8:return i=e.sent,e.abrupt("return",i);case 12:return e.prev=12,e.t0=e.catch(0),e.abrupt("return",{name:"Error"});case 15:case"end":return e.stop()}}),e,null,[[0,12]])})));return function(n){return e.apply(this,arguments)}}(),oe=function(){var e=y(h.a.mark((function e(n){var t;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,re(n);case 2:if("Error"!=(t=e.sent).name){e.next=5;break}return e.abrupt("return");case 5:w(t.cep||n),q(t);case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return Object(r.useEffect)((function(){var e=(null==b?void 0:b.replace(/\D/g,""))||"";8===e.length?oe(b):0===e.length&&null!==$&&q(null)}),[b]),o.a.createElement("form",{className:f()(p.deliveryForm,[I?"error":""]),onSubmit:function(e){try{e.preventDefault(),e.stopPropagation(),D(!0),Q({query:F.a,variables:{cep:b,country:"BRA"}}).then((function(e){var n;if(e){var t=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.getAdress;t&&Q({query:_.a,variables:{newCep:b,productID:X,productQuantity:1,productSeller:"1"}}).then(function(){var e=y(h.a.mark((function e(n){var i,a,r,o,s,l;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null===(r=null===(a=null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.getOrderformSimulator)||void 0===a?void 0:a.logisticsInfo)||void 0===r?void 0:r[0],s=null==o?void 0:o.slas.filter((function(e){return"delivery"===e.deliveryChannel})),l=null==s?void 0:s[0]){e.next=7;break}return D(!1),T(!0),e.abrupt("return");case 7:ae(l,t);case 8:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()).catch((function(e){D(!1),T(!0),console.error("Error on sendCepFromForm",e)}))}})).catch((function(e){D(!1),T(!0),console.error("Error on sendCepFromForm",e)}))}catch(e){console.error(e),D(!1)}}},!Y&&o.a.createElement("span",{className:p.deliveryTitle},ee),o.a.createElement("div",{className:p.deliveryAction},o.a.createElement(S.a,{className:p.deliveryInput,mask:"99999-999",onChange:function(e){return w(e.target.value)},value:b,type:"text",placeholder:"Digite seu CEP"}),o.a.createElement("button",{className:p.deliveryButton,id:"deliveryButton"},x?o.a.createElement(O,null):"Buscar")),null!==$&&o.a.createElement("div",{className:p.addressInfo},o.a.createElement("span",null,null==$?void 0:$.localidade," - ",null==$?void 0:$.uf)),o.a.createElement(C.Link,{className:p.deliveryLink,to:"https://buscacepinter.correios.com.br/app/endereco/index.php",target:"_blank",rel:"noreferrer"},"Não sei o CEP"),I&&o.a.createElement("div",{className:p.formError},o.a.createElement("span",{className:p.formErrorTitle},"Infelizmente não atendemos esta região.")),Y&&o.a.createElement("span",{className:p.deliveryWarning},ne))}function q(){return Q.apply(this,arguments)}function Q(){return(Q=y(h.a.mark((function e(){var n,t,i,a,r,o;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,new Promise((function(e,n){(null===navigator||void 0===navigator?void 0:navigator.geolocation)?navigator.geolocation.getCurrentPosition(e,n,{enableHighAccuracy:!0}):n(new Error("Geolocation not supported"))}));case 3:return n=e.sent,t=n.coords.latitude,i=n.coords.longitude,a="https://nominatim.openstreetmap.org/reverse?lat=".concat(t,"&lon=").concat(i,"&format=json"),e.next=9,fetch(a,{headers:{Accept:"application/json","User-Agent":"AvantiRegionalization/1.0"}});case 9:if((r=e.sent).ok){e.next=12;break}return e.abrupt("return",null);case 12:return e.next=14,r.json();case 14:return o=e.sent,e.abrupt("return",o);case 18:return e.prev=18,e.t0=e.catch(0),e.abrupt("return",null);case 21:case"end":return e.stop()}}),e,null,[[0,18]])})))).apply(this,arguments)}var H=function(e){var n=e.onZipcode,t=e.className,i=e.children,s=a(Object(r.useState)(!1),2),l=s[0],u=s[1],c=a(Object(r.useState)(!1),2),d=c[0],m=c[1],v=function(){var e=y(h.a.mark((function e(){var t;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u(!0),m(!1),e.prev=2,e.next=5,q();case 5:null!=(t=e.sent)?null==n||n(t):m(!0),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),m(!0);case 12:return e.prev=12,u(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[2,9,12,15]])})));return function(){return e.apply(this,arguments)}}();return o.a.createElement(o.a.Fragment,null,o.a.createElement("button",{type:"button",className:t,onClick:v,disabled:l},l?"Obtendo localização...":null!=i?i:"Usar minha localização"),d&&!l&&o.a.createElement("span",{role:"alert",style:{display:"block",marginTop:4,fontSize:"0.85rem"}},"Não foi possível obter seu CEP. Verifique a permissão de localização ou insira o CEP manualmente."))};function Z(e){var n=e.setWindowsControle,t=e.setRegionalization,i=e.setOpenRegionalization,a=e.isHome,r=v()(g).handles,s=u()();return o.a.createElement("div",{className:r.optionsWindow},o.a.createElement("button",{className:r.optionDelivery,onClick:function(){return n({optionsWindow:!1,deliveryWindow:!0})}},o.a.createElement("span",{className:r.optionsWindowTitle},"Insira seu CEP")),o.a.createElement(H,{className:r.useMyLocationButton,onZipcode:function(e){null!=e.address.postcode&&(null==t||t((function(n){var t,i,a;return Object.assign(Object.assign({},n),{delivery:Object.assign(Object.assign({},null==s?void 0:s.delivery),{cep:null===(t=null==e?void 0:e.address)||void 0===t?void 0:t.postcode,city:null===(i=null==e?void 0:e.address)||void 0===i?void 0:i.city,state:null===(a=null==e?void 0:e.address)||void 0===a?void 0:a.state}),deliveryChannel:"delivery",isRegionalize:!0})})),n({optionsWindow:!1,deliveryWindow:!0}),setTimeout((function(){var e=document.getElementById("deliveryButton");null==e||e.click()}),1e3))}},o.a.createElement("span",{className:r.optionsWindowTitle},"Usar minha localização")),a&&o.a.createElement("button",{className:r.optionClose,onClick:function(){null==t||t((function(e){return Object.assign(Object.assign({},e),{openModal:!1})})),i(!1)}},o.a.createElement("span",{className:r.optionsWindowTitle},"Só quero dar uma olhadinha")))}function G(){var e=v()(g).handles;return o.a.createElement("svg",{className:e.closeIcon,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.a.createElement("path",{d:"M6 7.23985L1.50554 11.7343C1.32841 11.9114 1.12177 12 0.885609 12C0.649446 12 0.442804 11.9114 0.265683 11.7343C0.0885611 11.5572 0 11.3506 0 11.1144C0 10.8782 0.0885611 10.6716 0.265683 10.4945L4.76015 6L0.265683 1.50554C0.0885611 1.32841 0 1.12177 0 0.885609C0 0.649446 0.0885611 0.442804 0.265683 0.265683C0.442804 0.0885611 0.649446 0 0.885609 0C1.12177 0 1.32841 0.0885611 1.50554 0.265683L6 4.76015L10.4945 0.265683C10.6716 0.0885611 10.8782 0 11.1144 0C11.3506 0 11.5572 0.0885611 11.7343 0.265683C11.9114 0.442804 12 0.649446 12 0.885609C12 1.12177 11.9114 1.32841 11.7343 1.50554L7.23985 6L11.7343 10.4945C11.9114 10.6716 12 10.8782 12 11.1144C12 11.3506 11.9114 11.5572 11.7343 11.7343C11.5572 11.9114 11.3506 12 11.1144 12C10.8782 12 10.6716 11.9114 10.4945 11.7343L6 7.23985Z",fill:"#404040"}))}function Y(e){var n,t,i,a,r,s=e.setWindowsControle,l=e.windowsControle,c=e.setOpenRegionalization,m=e.isHome,p=v()(g).handles,k=u()(),h=(null==l?void 0:l.deliveryWindow)?(null===(n=null==k?void 0:k.delivery)||void 0===n?void 0:n.isValid)?"deliveryOpen":"deliveryOpen-error":"optionsOpen",b=null===(i=null===(t=null==k?void 0:k.general_screen_configuration)||void 0===t?void 0:t[0])||void 0===i?void 0:i.optionTitle,y=null===(r=null===(a=null==k?void 0:k.general_screen_configuration)||void 0===a?void 0:a[0])||void 0===r?void 0:r.deliveryTitle,C=(null==l?void 0:l.deliveryWindow)?y:b,w=d()();return o.a.createElement("div",{className:f()(p.modal,[h])},o.a.createElement("div",{className:p.modalHead},o.a.createElement("span",{className:p.modalTitle},C)),m&&o.a.createElement("button",{onClick:function(){null==w||w((function(e){return Object.assign(Object.assign({},e),{openModal:!1})})),c(!1)},className:p.modalClose,"aria-label":"Fechar modal"},o.a.createElement(G,null)),(null==l?void 0:l.optionsWindow)&&o.a.createElement(Z,{setRegionalization:w,setWindowsControle:s,setOpenRegionalization:c,isHome:m}),(null==l?void 0:l.deliveryWindow)&&o.a.createElement($,null))}function J(){var e=v()(g).handles;return o.a.createElement("svg",{className:e.locationIcon,width:"22",height:"27",viewBox:"0 0 22 27",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.a.createElement("path",{d:"M10.9938 1C8.34439 1.00371 5.8046 2.05781 3.93121 3.9312C2.05782 5.80459 1.00371 8.34439 1 10.9938C0.99943 11.6213 1.05892 12.2475 1.17765 12.8638C1.17765 12.8996 1.20415 13.0103 1.24623 13.1988C1.39802 13.8815 1.62213 14.546 1.91476 15.1811C3.87578 19.3728 6.84455 23.0135 10.5559 25.7779C10.6817 25.8794 10.8384 25.9347 11 25.9347C11.1616 25.9347 11.3183 25.8794 11.4441 25.7779C15.1539 23.0119 18.1223 19.3716 20.0852 15.1811C20.3779 14.5498 20.6021 13.8889 20.7538 13.2098C20.7959 13.0212 20.8161 12.9121 20.8223 12.8747C20.9385 12.2581 20.9979 11.6321 21 11.0047C20.9951 8.35252 19.9392 5.81043 18.0637 3.93521C16.1882 2.06 13.6459 1.00453 10.9938 1ZM19.4198 12.6254C19.4198 12.6363 19.4198 12.6456 19.4198 12.6565C19.4198 12.6674 19.3996 12.7609 19.3731 12.8809V12.8918C19.2423 13.4795 19.0479 14.0511 18.7934 14.5967C18.7934 14.5967 18.7934 14.6123 18.7825 14.617C17.006 18.4301 14.3358 21.7584 10.9984 24.3193C7.66109 21.7584 4.99086 18.4301 3.21443 14.617C3.21443 14.617 3.21443 14.6014 3.20352 14.5967C2.95283 14.0496 2.75859 13.4784 2.62382 12.8918V12.8809C2.59265 12.7609 2.58174 12.683 2.57707 12.6565C2.57239 12.63 2.57707 12.6363 2.57707 12.6207C2.33709 11.3787 2.37466 10.099 2.68707 8.87319C2.99949 7.6474 3.57902 6.50583 4.38419 5.53019C5.18937 4.55456 6.20027 3.76899 7.34453 3.22971C8.4888 2.69043 9.73814 2.41078 11.0031 2.41078C12.2681 2.41078 13.5174 2.69043 14.6617 3.22971C15.806 3.76899 16.8169 4.55456 17.622 5.53019C18.4272 6.50583 19.0068 7.6474 19.3192 8.87319C19.6316 10.099 19.6691 11.3787 19.4292 12.6207L19.4198 12.6254Z",fill:"#007367",stroke:"#007367","stroke-width":"0.5"}),o.a.createElement("path",{d:"M10.9936 5.56445C9.89789 5.56445 8.82679 5.88936 7.91575 6.4981C7.0047 7.10684 6.29463 7.97207 5.87532 8.98436C5.45601 9.99666 5.3463 11.1106 5.56006 12.1852C5.77383 13.2599 6.30146 14.247 7.07624 15.0218C7.85102 15.7966 8.83814 16.3242 9.91279 16.5379C10.9874 16.7517 12.1013 16.642 13.1136 16.2227C14.1259 15.8034 14.9912 15.0933 15.5999 14.1823C16.2086 13.2712 16.5336 12.2001 16.5336 11.1044C16.5311 9.63589 15.9466 8.22821 14.9082 7.1898C13.8698 6.15139 12.4621 5.56693 10.9936 5.56445ZM10.9936 15.4133C10.1414 15.4133 9.3083 15.1606 8.59971 14.6871C7.89112 14.2136 7.33884 13.5407 7.01272 12.7534C6.68659 11.966 6.60126 11.0996 6.76752 10.2638C6.93378 9.42796 7.34416 8.6602 7.94677 8.05759C8.54937 7.45498 9.31713 7.0446 10.153 6.87834C10.9888 6.71209 11.8552 6.79742 12.6425 7.12355C13.4299 7.44968 14.1028 8.00195 14.5763 8.71054C15.0497 9.41913 15.3025 10.2522 15.3025 11.1044C15.3012 12.2468 14.8468 13.3421 14.039 14.1499C13.2312 14.9577 12.136 15.4121 10.9936 15.4133Z",fill:"#007367",stroke:"#007367","stroke-width":"0.5"}))}function X(e){var n=e.setOpenRegionalization,t=v()(g).handles,i=Object(s.useOrderForm)().orderForm.shipping.selectedAddress,a=null==i?void 0:i.postalCode,r=d()(),l=Object(N.useQuery)(F.a,{variables:{cep:a,country:"BRA"},skip:!a}).data,u=null==l?void 0:l.getAdress;return o.a.createElement("button",{onClick:function(){null==r||r((function(e){return Object.assign(Object.assign({},e),{openModal:!0})})),n(!0)},className:t.cepTrigger},o.a.createElement(J,null),u?o.a.createElement("span",{className:t.cepTriggerRegionalized},o.a.createElement("span",{className:t.cepTriggerWrapper},o.a.createElement("span",{className:t.cepTriggerSubtitle},null==u?void 0:u.city," - ",null==u?void 0:u.state),o.a.createElement("span",{className:t.cepTriggerLink},"Alterar"))):o.a.createElement("span",{className:t.cepTriggerNotRegionalized},"Informe seu CEP"))}n.default=function(){var e=v()(g).handles,n=Object(s.useOrderForm)().orderForm,t=n.id,i=n.shipping.selectedAddress,l=a(Object(r.useState)(!1),2),c=l[0],m=l[1],p=a(Object(r.useState)({optionsWindow:!0,deliveryWindow:!1}),2),f=p[0],k=p[1],h=u()(),b=null==h?void 0:h.openModal,y=d()(),w=Object(C.useRuntime)().page,S="store.orderplaced"===w,N="store.home"===w,O=c&&"default-order-form"!==t;return Object(r.useEffect)((function(){!S&&b&&m(!0)}),[b]),Object(r.useEffect)((function(){k({deliveryWindow:!!i,optionsWindow:!i}),"default-order-form"===t||i||S||m(!0)}),[i]),o.a.createElement(o.a.Fragment,null,o.a.createElement(X,{setOpenRegionalization:m}),O&&o.a.createElement(Y,{setWindowsControle:k,windowsControle:f,setOpenRegionalization:m,isHome:N}),O&&o.a.createElement("div",{onClick:function(){N&&(null==y||y((function(e){return Object.assign(Object.assign({},e),{openModal:!1})})),m(!1))},className:e.modalOverflow}))}}]);