1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="e78ad212-66aa-b9b9-59a0-3f20c6adf1c1")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,394269,562280,e=>{"use strict";let t=console;e.s(["defaultLogger",0,t],394269);var a=e.i(95184);e.s(["Removable",0,class{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,a.isValidTimeout)(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(e){this.cacheTime=Math.max(this.cacheTime||0,null!=e?e:a.isServer?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}],562280)},41641,e=>{"use strict";var t=e.i(394269),a=e.i(851075),r=e.i(562280),s=e.i(402435);class i extends r.Removable{constructor(e){super(),this.defaultOptions=e.defaultOptions,this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.logger=e.logger||t.defaultLogger,this.observers=[],this.state=e.state||n(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(e){this.dispatch({type:"setState",state:e})}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.observers=this.observers.filter(t=>t!==e),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){var e,t;return null!=(e=null==(t=this.retryer)?void 0:t.continue())?e:this.execute()}async execute(){var e,t,a,r,i,n,o,u,c,l,d,h,p,f,y,g,m,v,b,T;let P=()=>{var e;return this.retryer=(0,s.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(e,t)=>{this.dispatch({type:"failed",failureCount:e,error:t})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},_="loading"===this.state.status;try{if(!_){this.dispatch({type:"loading",variables:this.options.variables}),await (null==(c=(l=this.mutationCache.config).onMutate)?void 0:c.call(l,this.state.variables,this));let e=await (null==(d=(h=this.options).onMutate)?void 0:d.call(h,this.state.variables));e!==this.state.context&&this.dispatch({type:"loading",context:e,variables:this.state.variables})}let s=await P();return await (null==(e=(t=this.mutationCache.config).onSuccess)?void 0:e.call(t,s,this.state.variables,this.state.context,this)),await (null==(a=(r=this.options).onSuccess)?void 0:a.call(r,s,this.state.variables,this.state.context)),await (null==(i=(n=this.mutationCache.config).onSettled)?void 0:i.call(n,s,null,this.state.variables,this.state.context,this)),await (null==(o=(u=this.options).onSettled)?void 0:o.call(u,s,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:s}),s}catch(e){try{throw await (null==(p=(f=this.mutationCache.config).onError)?void 0:p.call(f,e,this.state.variables,this.state.context,this)),await (null==(y=(g=this.options).onError)?void 0:y.call(g,e,this.state.variables,this.state.context)),await (null==(m=(v=this.mutationCache.config).onSettled)?void 0:m.call(v,void 0,e,this.state.variables,this.state.context,this)),await (null==(b=(T=this.options).onSettled)?void 0:b.call(T,void 0,e,this.state.variables,this.state.context)),e}finally{this.dispatch({type:"error",error:e})}}}dispatch(e){let t=t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"loading":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!(0,s.canFetch)(this.options.networkMode),status:"loading",variables:e.variables};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPau
2sed:!1,status:"error"};case"setState":return{...t,...e.state}}};this.state=t(this.state),a.notifyManager.batch(()=>{this.observers.forEach(t=>{t.onMutationUpdate(e)}),this.mutationCache.notify({mutation:this,type:"updated",action:e})})}}function n(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}e.s(["Mutation",0,i,"getDefaultState",0,n])},389717,e=>{"use strict";var t=e.i(95184),a=e.i(394269),r=e.i(851075),s=e.i(402435),i=e.i(562280);class n extends i.Removable{constructor(e){super(),this.abortSignalConsumed=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.logger=e.logger||a.defaultLogger,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||function(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,a=void 0!==t,r=a?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:a?null!=r?r:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(e,a){let r=(0,t.replaceData)(this.state.data,e,this.options);return this.dispatch({data:r,type:"success",dataUpdatedAt:null==a?void 0:a.updatedAt,manual:null==a?void 0:a.manual}),r}setState(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})}cancel(e){var a;let r=this.promise;return null==(a=this.retryer)||a.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(e=>!1!==e.options.enabled)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e)}onFocus(){var e;let t=this.observers.find(e=>e.shouldFetchOnWindowFocus());t&&t.refetch({cancelRefetch:!1}),null==(e=this.retryer)||e.continue()}onOnline(){var e;let t=this.observers.find(e=>e.shouldFetchOnReconnect());t&&t.refetch({cancelRefetch:!1}),null==(e=this.retryer)||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(e,a){var r,i,n,o;if("idle"!==this.state.fetchStatus){if(this.state.dataUpdatedAt&&null!=a&&a.cancelRefetch)this.cancel({silent:!0});else if(this.promise)return null==(n=this.retryer)||n.continueRetry(),this.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let u=(0,t.getAbortController)(),c={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>{if(u)return this.abortSignalConsumed=!0,u.signal}})};l(c);let d=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(c)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),h={fetchOptions:a,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:d};l(h),null==(r=this.options.behavior)||r.onFetch(h),this.revertState=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(i=h.fetchOptions)?void 0:i.meta))&&this.dispatch({type:"fetch",meta:null==(o=h.fetchOptions)?void 0:o.meta});let p=e=>{if((0,s.isCancelledError)(e)&&e.silent||this.dispatch({type:"error",error:e}),!(0,s.isCancelledError)(e)){var t,a,r,i;null==(t=(a=this.cache.config).onError)||t.call(a,e,this),null==(r=(i=this.cache.config).onSettled)||r.call(i,this.state.data,e,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=(0,s.createRetryer)({fn:h.fetchFn,abort:null==u?void 0:u.abort.bind(u),onSuccess:e=>{var t,a,r,s;void 0===e?p(Error(this.queryHash+" data is undefined")):(this.setData(e),null==(t=(a=this.cache.config).onSuccess)||t.call(a,e,this),null==(r=(s=this.cache.config).onSettled)||r.call(s,e,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1)},onError:p,onFail:(e,t)=>{this.dispatch({type:"failed",failureCount:e,error:t})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(e){let t=t=>{var a,r;switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null!=(a=e.meta)?a:null,fetchStatus:(0,s.canFetch)(this.options.networkMode)?"fetching":"paused",...!t.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:null!=(r=e.dataUpdatedAt)?r:D
2ate.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let i=e.error;if((0,s.isCancelledError)(i)&&i.revert&&this.revertState)return{...this.revertState,fetchStatus:"idle"};return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate(e)}),this.cache.notify({query:this,type:"updated",action:e})})}}var o=e.i(786253);class u extends o.Subscribable{constructor(e){super(),this.config=e||{},this.queries=[],this.queriesMap={}}build(e,a,r){var s;let i=a.queryKey,o=null!=(s=a.queryHash)?s:(0,t.hashQueryKeyByOptions)(i,a),u=this.get(o);return u||(u=new n({cache:this,logger:e.getLogger(),queryKey:i,queryHash:o,options:e.defaultQueryOptions(a),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(u)),u}add(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"added",query:e}))}remove(e){let t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(t=>t!==e),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"removed",query:e}))}clear(){r.notifyManager.batch(()=>{this.queries.forEach(e=>{this.remove(e)})})}get(e){return this.queriesMap[e]}getAll(){return this.queries}find(e,a){let[r]=(0,t.parseFilterArgs)(e,a);return void 0===r.exact&&(r.exact=!0),this.queries.find(e=>(0,t.matchQuery)(r,e))}findAll(e,a){let[r]=(0,t.parseFilterArgs)(e,a);return Object.keys(r).length>0?this.queries.filter(e=>(0,t.matchQuery)(r,e)):this.queries}notify(e){r.notifyManager.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}onFocus(){r.notifyManager.batch(()=>{this.queries.forEach(e=>{e.onFocus()})})}onOnline(){r.notifyManager.batch(()=>{this.queries.forEach(e=>{e.onOnline()})})}}e.s(["QueryCache",0,u],389717)},919481,(e,t,a)=>{t.exports=function(e){return void 0===e}},190077,e=>{"use strict";var t,a=new Uint8Array(16);let r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));let n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase();if(!("string"==typeof a&&r.test(a)))throw TypeError("Stringified UUID is invalid");return a};e.s(["v4",0,function(e,r,s){var i=(e=e||{}).random||(e.rng||function(){if(!t&&!(t="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"u">typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(a)})();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,r){s=s||0;for(var o=0;o<16;++o)r[s+o]=i[o];return r}return n(i)}],190077)},96041,767539,556599,463216,605531,566355,597211,617225,384183,28257,263428,595782,516997,820110,143573,842600,e=>{"use strict";e.s(["ProductProvider",()=>e6,"useProduct",()=>e8],96041),e.s(["AffiliatesProgramProvider",()=>O,"useAffiliatesProgram",()=>x],605531),e.s(["BatchesProvider",()=>D,"useBatches",()=>R],566355),e.s(["CheckoutsProvider",()=>eK,"useCheckouts",()=>eL],28257),e.s(["CouponsProvider",()=>eJ,"useCoupons",()=>eY],516997),e.s(["OfferProvider",()=>e2,"useOffer",()=>e5],143573);var t,a=e.i(391398),r=e.i(95184),s=e.i(389717),i=e.i(851075),n=e.i(41641),o=e.i(786253);class u extends o.Subscribable{constructor(e){super(),this.config=e||{},this.mutations=[],this.mutationId=0}build(e,t,a){let r=new n.Mutation({mutationCache:this,logger:e.getLogger(),mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:a,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0});return this.add(r),r}add(e){this.mutations.push(e),this.notify({type:"added",mutation:e})}remove(e){this.mutations=this.mutations.filter(t=>t!==e),this.notify({type:"removed",mutation:e})}clear(){i.notifyManager.batch(()=>
2{this.mutations.forEach(e=>{this.remove(e)})})}getAll(){return this.mutations}find(e){return void 0===e.exact&&(e.exact=!0),this.mutations.find(t=>(0,r.matchMutation)(e,t))}findAll(e){return this.mutations.filter(t=>(0,r.matchMutation)(e,t))}notify(e){i.notifyManager.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}resumePausedMutations(){var e;return this.resuming=(null!=(e=this.resuming)?e:Promise.resolve()).then(()=>{let e=this.mutations.filter(e=>e.state.isPaused);return i.notifyManager.batch(()=>e.reduce((e,t)=>e.then(()=>t.continue().catch(r.noop)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}var c=e.i(208216),l=e.i(388789);function d(){return{onFetch:e=>{e.fetchFn=()=>{var t,a,r,s,i,n;let o,u=null==(t=e.fetchOptions)||null==(a=t.meta)?void 0:a.refetchPage,c=null==(r=e.fetchOptions)||null==(s=r.meta)?void 0:s.fetchMore,l=null==c?void 0:c.pageParam,d=(null==c?void 0:c.direction)==="forward",f=(null==c?void 0:c.direction)==="backward",y=(null==(i=e.state.data)?void 0:i.pages)||[],g=(null==(n=e.state.data)?void 0:n.pageParams)||[],m=g,v=!1,b=e.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+e.options.queryHash+"'")),T=(e,t,a,r)=>(m=r?[t,...m]:[...m,t],r?[a,...e]:[...e,a]),P=(t,a,r,s)=>{if(v)return Promise.reject("Cancelled");if(void 0===r&&!a&&t.length)return Promise.resolve(t);let i={queryKey:e.queryKey,pageParam:r,meta:e.options.meta};return Object.defineProperty(i,"signal",{enumerable:!0,get:()=>{var t,a;return null!=(t=e.signal)&&t.aborted?v=!0:null==(a=e.signal)||a.addEventListener("abort",()=>{v=!0}),e.signal}}),Promise.resolve(b(i)).then(e=>T(t,r,e,s))};if(y.length)if(d){let t=void 0!==l,a=t?l:h(e.options,y);o=P(y,t,a)}else if(f){let t=void 0!==l,a=t?l:p(e.options,y);o=P(y,t,a,!0)}else{m=[];let t=void 0===e.options.getNextPageParam;o=!u||!y[0]||u(y[0],0,y)?P([],t,g[0]):Promise.resolve(T([],g[0],y[0]));for(let a=1;a<y.length;a++)o=o.then(r=>{if(!u||!y[a]||u(y[a],a,y)){let s=t?g[a]:h(e.options,r);return P(r,t,s)}return Promise.resolve(T(r,g[a],y[a]))})}else o=P([]);return o.then(e=>({pages:e,pageParams:m}))}}}}function h(e,t){return null==e.getNextPageParam?void 0:e.getNextPageParam(t[t.length-1],t)}function p(e,t){return null==e.getPreviousPageParam?void 0:e.getPreviousPageParam(t[0],t)}e.s(["hasNextPage",0,function(e,t){if(e.getNextPageParam&&Array.isArray(t)){let a=h(e,t);return null!=a&&!1!==a}},"hasPreviousPage",0,function(e,t){if(e.getPreviousPageParam&&Array.isArray(t)){let a=p(e,t);return null!=a&&!1!==a}},"infiniteQueryBehavior",0,d],767539);var f=e.i(394269);let y=new class{constructor(e={}){this.queryCache=e.queryCache||new s.QueryCache,this.mutationCache=e.mutationCache||new u,this.logger=e.logger||f.defaultLogger,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,1===this.mountCount&&(this.unsubscribeFocus=c.focusManager.subscribe(()=>{c.focusManager.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=l.onlineManager.subscribe(()=>{l.onlineManager.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var e,t;this.mountCount--,0===this.mountCount&&(null==(e=this.unsubscribeFocus)||e.call(this),this.unsubscribeFocus=void 0,null==(t=this.unsubscribeOnline)||t.call(this),this.unsubscribeOnline=void 0)}isFetching(e,t){let[a]=(0,r.parseFilterArgs)(e,t);return a.fetchStatus="fetching",this.queryCache.findAll(a).length}isMutating(e){return this.mutationCache.findAll({...e,fetching:!0}).length}getQueryData(e,t){var a;return null==(a=this.queryCache.find(e,t))?void 0:a.state.data}ensureQueryData(e,t,a){let s=(0,r.parseQueryArgs)(e,t,a),i=this.getQueryData(s.queryKey);return i?Promise.resolve(i):this.fetchQuery(s)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,a){let s=this.queryCache.find(e),i=null==s?void 0:s.state.data,n=(0,r.functionalUpdate)(t,i);if(void 0===n)return;let o=(0,r.parseQueryArgs)(e),u=this.defaultQueryOptions(o);return this.queryCache.build(this,u).setData(n,{...a,manual:!0})}
2setQueriesData(e,t,a){return i.notifyManager.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,a)]))}getQueryState(e,t){var a;return null==(a=this.queryCache.find(e,t))?void 0:a.state}removeQueries(e,t){let[a]=(0,r.parseFilterArgs)(e,t),s=this.queryCache;i.notifyManager.batch(()=>{s.findAll(a).forEach(e=>{s.remove(e)})})}resetQueries(e,t,a){let[s,n]=(0,r.parseFilterArgs)(e,t,a),o=this.queryCache,u={type:"active",...s};return i.notifyManager.batch(()=>(o.findAll(s).forEach(e=>{e.reset()}),this.refetchQueries(u,n)))}cancelQueries(e,t,a){let[s,n={}]=(0,r.parseFilterArgs)(e,t,a);return void 0===n.revert&&(n.revert=!0),Promise.all(i.notifyManager.batch(()=>this.queryCache.findAll(s).map(e=>e.cancel(n)))).then(r.noop).catch(r.noop)}invalidateQueries(e,t,a){let[s,n]=(0,r.parseFilterArgs)(e,t,a);return i.notifyManager.batch(()=>{var e,t;if(this.queryCache.findAll(s).forEach(e=>{e.invalidate()}),"none"===s.refetchType)return Promise.resolve();let a={...s,type:null!=(e=null!=(t=s.refetchType)?t:s.type)?e:"active"};return this.refetchQueries(a,n)})}refetchQueries(e,t,a){let[s,n]=(0,r.parseFilterArgs)(e,t,a),o=Promise.all(i.notifyManager.batch(()=>this.queryCache.findAll(s).filter(e=>!e.isDisabled()).map(e=>{var t;return e.fetch(void 0,{...n,cancelRefetch:null==(t=null==n?void 0:n.cancelRefetch)||t,meta:{refetchPage:s.refetchPage}})}))).then(r.noop);return null!=n&&n.throwOnError||(o=o.catch(r.noop)),o}fetchQuery(e,t,a){let s=(0,r.parseQueryArgs)(e,t,a),i=this.defaultQueryOptions(s);void 0===i.retry&&(i.retry=!1);let n=this.queryCache.build(this,i);return n.isStaleByTime(i.staleTime)?n.fetch(i):Promise.resolve(n.state.data)}prefetchQuery(e,t,a){return this.fetchQuery(e,t,a).then(r.noop).catch(r.noop)}fetchInfiniteQuery(e,t,a){let s=(0,r.parseQueryArgs)(e,t,a);return s.behavior=d(),this.fetchQuery(s)}prefetchInfiniteQuery(e,t,a){return this.fetchInfiniteQuery(e,t,a).then(r.noop).catch(r.noop)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(e){this.defaultOptions=e}setQueryDefaults(e,t){let a=this.queryDefaults.find(t=>(0,r.hashQueryKey)(e)===(0,r.hashQueryKey)(t.queryKey));a?a.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})}getQueryDefaults(e){if(!e)return;let t=this.queryDefaults.find(t=>(0,r.partialMatchKey)(e,t.queryKey));return null==t?void 0:t.defaultOptions}setMutationDefaults(e,t){let a=this.mutationDefaults.find(t=>(0,r.hashQueryKey)(e)===(0,r.hashQueryKey)(t.mutationKey));a?a.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})}getMutationDefaults(e){if(!e)return;let t=this.mutationDefaults.find(t=>(0,r.partialMatchKey)(e,t.mutationKey));return null==t?void 0:t.defaultOptions}defaultQueryOptions(e){if(null!=e&&e._defaulted)return e;let t={...this.defaultOptions.queries,...this.getQueryDefaults(null==e?void 0:e.queryKey),...e,_defaulted:!0};return!t.queryHash&&t.queryKey&&(t.queryHash=(0,r.hashQueryKeyByOptions)(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.useErrorBoundary&&(t.useErrorBoundary=!!t.suspense),t}defaultMutationOptions(e){return null!=e&&e._defaulted?e:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==e?void 0:e.mutationKey),...e,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}({defaultOptions:{queries:{staleTime:3e5,refetchOnWindowFocus:!1}}});e.s(["queryClient",0,y],556599);var g=e.i(2379),m=e.i(797055),v=e.i(835674),b=e.i(650457),T=e.i(383407),P=e.i(203828),_=e.i(191788);e.i(47620);var S=e.i(271179),M=e.i(455404),C=e.i(202402);let $=(0,_.createContext)({}),w=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext_affiliatesManagement"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),{user:s}=(0,C.useAuth)(),[i,n]=(0,_.useState)(!1),[o,u]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[d,h]=(0,_.useState)(1),[p,f]=(0,_.useState)(null),[y,g]=(0,_.useState)(0),[v,b]=(0,_.useState)(null),w=(0,P.useRouter)(),E=async(e,a)=>{u(!0),m.api.post(`products/${e}/manage/affiliates`,a).then(async e=>{M.toast.success(t("context.createAffiliatesMessage.success")),setTimeout(()=>{w.push("/affiliates/manage")},10)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),n(!1)}).finally(()=>u(!1))},O=async(e,a)=>{u(!0);try{let{}=await m.api.put(` 3 products/${e.product_id}/manage/affiliates/${a} 4 `,e);M.toast.success(t("context.updateAffiliatesMessage.success")),await w.back(),b(null)}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}finally{u(!1)}},x=async(e,a)=>{u(!0);try{let{data:r}=await m.api.put(` 5 products/${e}/manage/affiliates/${a}/toggle 6 `);M.toast.success(t("context.updateAffiliatesMessage.success"));let s=p.map(e=>(e.id===a&&(e.is_active=r),e));return f(s),r}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),n(!1)}finally{u(!1)}},A=async(e,t)=>{n(!0);let a=await m.api.get(`products/${e}/manage/affiliates${t?"?withoutPagination=1":""}`);if(200===a.status){let e=[];
6for(let[t,r]of Object.entries(a.data.data))e.push({value:r.id,label:`${r.name}`,...r});f(e)}return n(!1),a},q=async()=>{u(!0);let e=w.asPath.split("?")[1];m.api.get(`/affiliate-export?${void 0!==e?e:""}`,{responseType:"blob"}).then(e=>{let t=window.URL.createObjectURL(new Blob([e.data])),a=document.createElement("a");a.href=t,a.setAttribute("download",`affiliate_report_${Date.now()}.csv`),document.body.appendChild(a),a.click()}),u(!1)},D=async()=>{u(!0);let e=w.asPath.split("?")[1];m.api.get(`/affiliations/ranking/export?${void 0!==e?e:""}`,{responseType:"blob"}).then(e=>{let t=window.URL.createObjectURL(new Blob([e.data])),a=document.createElement("a");a.href=t,a.setAttribute("download",`affiliate_report_${Date.now()}.csv`),document.body.appendChild(a),a.click()}),u(!1)};return(0,_.useEffect)(()=>{w.isReady&&!w.pathname.includes("showcase")&&("/tools/employee-center/[selectedTab]/edit"!==w.pathname||n(!1))},[w]),(0,a.jsx)($.Provider,{value:{isLoading:i,isSetting:o,affiliates:p,pagination:c,affiliate:v,setAffiliate:b,store:E,update:O,destroy:(e,a)=>{u(!0),m.api.delete(`products/${e}/manage/affiliates/${a}`).then(async e=>{M.toast.success(t("context.deleteAffiliatesMessage.success")),f(p.filter(e=>e.id!==a))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),n(!1)}).finally(()=>u(!1))},fetch:(e,t)=>{n(!0),b(null),m.api.get(`affiliations${e??""}`).then(e=>{let a=[],{data:r}=e.data;a=t?[...p,...r]:r;let s=e.data;delete s.data,l(s),f(a)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{n(!1)})},findOne:(e,t)=>{n(!0),b(null),m.api.get(`products/${e}/manage/affiliates/${t}`).then(async e=>{b(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>n(!1))},fetchAffiliates:A,fetchAffiliate:e=>{n(!0),b(null),m.api.get(`products/${e}/manage/affiliates/user/${s.info.id}`).then(e=>{b(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>n(!1))},paginationData:d,setPaginationData:h,toggleAffiliateSales:x,handleCSV:q,fetchRanking:(e,t)=>{n(!0),m.api.get(`affiliations/ranking${e??""}`).then(e=>{let a=[],{data:r}=e.data;a=t?[...p,...r]:r;let s=e.data;delete s.data,l(s),f(a)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>n(!1))},setAffiliates:f,setTab:g,tab:y,handleCSVRanking:D},children:e})};e.s(["AffiliatesManagementProvider",0,w,"useAffiliatesManagement",0,function(){return(0,_.useContext)($)}],463216);let E=(0,_.createContext)({}),O=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext_affiliatesProgramContext"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),[s,i]=(0,_.useState)(!1),[n,o]=(0,_.useState)(!1),[u,c]=(0,_.useState)(),{product:l}=e8(),d=async()=>{o(!0);try{let{data:e}=await m.api.get(`products/${l.id}/affiliate-program`);return c(e),e}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e))}finally{o(!1)}},h=async e=>{i(!0);try{let{data:a}=await m.api.put(`products/${l.id}/affiliate-program`,e);c(a),M.toast.success(t("context.updateAffiliatesMessage.success"))}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e))}i(!1)};return(0,a.jsx)(E.Provider,{value:{affiliateProgramData:u,isSetting:s,fetch:d,setisSetting:i,isLoading:n,saveAffiliatesProgramChanges:h},children:e})};function x(){return(0,_.useContext)(E)}var A=e.i(939056);let q=(0,_.createContext)({}),D=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext_batchesContext"),{t:r}=(0,S.useTranslation)("components_product_list_batches"),[s,i]=(0,_.useState)([]),[n,o]=(0,_.useState)(null),[u,c]=(0,_.useState)(!0),[l,d]=(0,_.useState)(!1),[h,p]=(0,_.useState)(!1),{findOne:f}=e8(),[y,g]=(0,_.useState)(null),v=(0,P.useRouter)(),b=async(e,a,r=!1)=>{d(!0),m.api.post(`products/${e}/manage/batches`,a).then(async a=>{M.toast.success(t("context.createBatchesMessage.success")),r?p(!1):(f(e),setTimeout(()=>{v.push(`/product/${e}/batches`)},10))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>d(!1))},C=(e,a)=>{c(!0),m.api.delete(`products/${e}/manage/batches/${a}`).then(async r=>{f(e),M.toast.success(t("context.deleteBatchesMessage.success")),i(s.filter(e=>e.id!==a))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e)),c(!1)}).finally(()=>c(!1))},$=async e=>{c(!0),m.api.get(`products/${e}/manage/batches`).then(e=>{let{data:t}=e.data;i(t),g(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>c(!1))},w=async e=>{let{data:t}=await m.api.get(`products/${e}/manage/offers`);return t},E=async e=>{let t=Number(v.query.productId);await m.api.post(`products/${t}/manage/batches/${e}/duplicate`).then(e=>{M.toast.success(r("duplicate")),$(t)}).catch(e=>M.toast.error((0,T.handleHTTPErrorMessage)(e)))};return(0,_.useEffect)(()=>
6{if(v.isReady){o(null);let e=Number(v.query.productId),t=Number(v.query.batchId);if(t)c(!0),m.api.get(`products/${e}/manage/batches/${t}`).then(async e=>{o(e.data)}).catch(t=>{[400,401,404].includes(t.response.status)&&v.replace(`/product/${e}/batches`),M.toast.error((0,T.handleHTTPErrorMessage)(t))}).finally(()=>{c(!1)});else c(!1)}},[v]),(0,a.jsx)(q.Provider,{value:{isLoading:u,setIsLoading:c,isSetting:l,store:b,update:(e,a,r,s=!1)=>{d(!0),m.api.put(`products/${e}/manage/batches/${a}`,r).then(async a=>{M.toast.success(t("context.updateBatchesMessage.success")),!0===s?p(!1):setTimeout(()=>{v.push(`/product/${e}/batches`)},10),o(null)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>d(!1))},destroy:C,fetch:e=>{c(!0);let t=[],a=Number(v.query.page);a&&t.push(`page=${a}`),m.api.get(`products/${e}/manage/batches 7 ${0!==t.length?`?${t.join("&")}`:""}`).then(e=>{let{data:t}=e.data;i(t),g(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>c(!1))},findOneOffer:w,batches:s,batch:n,setBatch:o,fetchAll:$,batchesResponseData:y,handleEdit:e=>{let t=Number(v.query.productId);o(e),v.push(`/product/${t}/batches/${e.id}`)},handleDestroy:e=>{A.default.fire({title:String(r("destroyMessage.title")),text:String(r("destroyMessage.text")),showDenyButton:!0,showCancelButton:!1,icon:"warning",denyButtonText:String(r("destroyMessage.deny")),allowOutsideClick:!1,confirmButtonText:String(r("destroyMessage.confirm"))}).then(t=>{t.isConfirmed&&(C(Number(v.query.productId),e),o(null))})},handleDuplicate:e=>{A.default.fire({title:String(r("duplicateMessage.title")),text:String(r("duplicateMessage.text")),showDenyButton:!0,showCancelButton:!1,icon:"warning",denyButtonText:String(r("destroyMessage.deny")),allowOutsideClick:!1,confirmButtonText:String(r("destroyMessage.confirm"))}).then(t=>{t.isConfirmed&&E(e)})},isNewBatchModalOpen:h,setIsNewBatchModalOpen:p},children:e})};function R(){return(0,_.useContext)(q)}var I=((eb={}).TOP="top",eb.SIDE="side",eb.BOTTOM="bottom",eb),N=((eT={}).BANNER="banner",eT.STAMP="stamp",eT.VIDEO="video",eT.RATE="rate",eT.TEXT="text",eT);e.s(["ElementTypes",()=>N,"PlacementTypes",()=>I],597211);var H=((eP={}).COUNTDOWN="countdown",eP.NOTIFICATION="notification",eP.WHATSAPP="whatsapp",eP.EXIT_POPUP="exit_popup",eP.BACK_REDIRECT="back_redirect",eP.CHAT="chat",eP),j=((e_={}).QTD_TODAY="qtd_today",e_.QTD_MINUTES="qtd_minutes",e_.QTD_NOW="qtd_now",e_.QTD_VISITORS="qtd_visitors",e_.CUSTOMER_NAME="customer_name",e_),k=((eS={}).JIVOCHAT="jivochat",eS.ZENDESK="zendesk",eS.TALKTO="talkto",eS.ZOPIM="zopim",eS);e.s(["ChatTypes",()=>k,"NotificationTypes",()=>j,"PluginType",()=>H],617225);var F=e.i(919481);let U={async store(e,t){try{let{data:a}=await m.api.post(`products/${e}/manage/coupons`,t);return a}catch(e){return e}},async update(e,t,a){try{let{data:r}=await m.api.put(`products/${t}/manage/coupons/${e}`,a);return r}catch(e){return e}}},Q={async saveOrUpdate(e,t,a,r,s,i){let n={is_active:!0,is_hidden:!0,name:`DISCOUNT_REJECT_UPSELL_${r}_${a}_${t.code}`,offer_ids:[t.id]};switch(e.type){case"percentage":n.discount=e?.percentage;break;case"fixed":n.fixed_discount=e?.fixed,n.application_method="on_item"}try{return(0,F.default)(i)?await U.store(s,n):await U.update(i,s,n)}catch(e){return e.response.data}},async delete(e,t){try{await m.api.delete(`products/${e}/manage/coupons/${t}`)}catch(e){console.error(e)}}};function B(e){for(var t=arguments.length,a=Array(t>1?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+e+(a.length?" "+a.map(function(e){return"'"+e+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function K(e){return!!e&&!!e[eq]}function L(e){var t;return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var a=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return a===Object||"function"==typeof a&&Function.toString.call(a)===eD}(e)||Array.isArray(e)||!!e[eA]||!!(null==(t=e.constructor)?void 0:t[eA])||J(e)||Y(e))}function V(e,t,a){void 0===a&&(a=!1),0===G(e)?(a?Object.keys:eR)(e).forEach(function(r){a&&"symbol"==typeof r||t(r,e[r],e)}):e.forEach(function(a,r){return t(r,a,e)})}function G(e){var t=e[eq];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:J(e)?2:3*!!Y(e)}function z(e,t){return 2===G(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function W(e,t,a){var r=G(e);2===r?e.set(t,a):3===r?e.add(a):e[t]=a}function J(e){return ew&&e instanceof Map}function Y(e){return eE&&e instanceof Set}function X(e){return e.o||e.t}function Z(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=eI(e);delete t[eq];for(var a=eR(t),r=0;r<a.length;r++){var s=a[r],i=t[s];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(Object.getPrototypeOf(e),t)}function ee(e,t){return void 0===t&&(t=!1),ea(e)||K(e)||!L(e)||(G(e)>1&&(e.set=e.add=e.clear=e.delete=et),Object.freeze(e),t&&V(e,function(e,t){return ee(t,!0)},!0)),e}function et(){B(2)}function ea(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function er(e){var t=eN[e];return t||B(18,e),t}e.s(["UpsellCouponService",0,Q],384183);function es(e,t){t&&(er("Patches"),e.u=[],e.s=[],e.v=t)}function ei(e){en(e),e.p.forEach(eu),e.p=null}function en(e){e===eC&&(eC=e.l)}
7function eo(e){return eC={p:[],l:eC,h:e,m:!0,_:0}}function eu(e){var t=e[eq];0===t.i||1===t.i?t.j():t.g=!0}function ec(e,t){t._=t.p.length;var a=t.p[0],r=void 0!==e&&e!==a;return t.h.O||er("ES5").S(t,e,r),r?(a[eq].P&&(ei(t),B(4)),L(e)&&(e=el(t,e),t.l||eh(t,e)),t.u&&er("Patches").M(a[eq].t,e,t.u,t.s)):e=el(t,a,[]),ei(t),t.u&&t.v(t.u,t.s),e!==ex?e:void 0}function el(e,t,a){if(ea(t))return t;var r=t[eq];if(!r)return V(t,function(s,i){return ed(e,r,t,s,i,a)},!0),t;if(r.A!==e)return t;if(!r.P)return eh(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var s=4===r.i||5===r.i?r.o=Z(r.k):r.o,i=s,n=!1;3===r.i&&(i=new Set(s),s.clear(),n=!0),V(i,function(t,i){return ed(e,r,s,t,i,a,n)}),eh(e,s,!1),a&&e.u&&er("Patches").N(r,a,e.u,e.s)}return r.o}function ed(e,t,a,r,s,i,n){if(K(s)){var o=el(e,s,i&&t&&3!==t.i&&!z(t.R,r)?i.concat(r):void 0);if(W(a,r,o),!K(o))return;e.m=!1}else n&&a.add(s);if(L(s)&&!ea(s)){if(!e.h.D&&e._<1)return;el(e,s),t&&t.A.l||eh(e,s)}}function eh(e,t,a){void 0===a&&(a=!1),!e.l&&e.h.D&&e.m&&ee(t,a)}function ep(e,t){var a=e[eq];return(a?X(a):e)[t]}function ef(e,t){if(t in e)for(var a=Object.getPrototypeOf(e);a;){var r=Object.getOwnPropertyDescriptor(a,t);if(r)return r;a=Object.getPrototypeOf(a)}}function ey(e){e.P||(e.P=!0,e.l&&ey(e.l))}function eg(e){e.o||(e.o=Z(e.t))}function em(e,t,a){var r,s,i,n,o,u,c,l=J(t)?er("MapSet").F(t,a):Y(t)?er("MapSet").T(t,a):e.O?(i=s={i:+!!(r=Array.isArray(t)),A:a?a.A:eC,P:!1,I:!1,R:{},l:a,t:t,k:null,o:null,j:null,C:!1},n=eH,r&&(i=[s],n=ej),u=(o=Proxy.revocable(i,n)).revoke,s.k=c=o.proxy,s.j=u,c):er("ES5").J(t,a);return(a?a.A:eC).p.push(l),l}function ev(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Z(e)}var eb,eT,eP,e_,eS,eM,eC,e$="u">typeof Symbol&&"symbol"==typeof Symbol("x"),ew="u">typeof Map,eE="u">typeof Set,eO="u">typeof Proxy&&void 0!==Proxy.revocable&&"u">typeof Reflect,ex=e$?Symbol.for("immer-nothing"):((eM={})["immer-nothing"]=!0,eM),eA=e$?Symbol.for("immer-draftable"):"__$immer_draftable",eq=e$?Symbol.for("immer-state"):"__$immer_state",eD=""+Object.prototype.constructor,eR="u">typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,eI=Object.getOwnPropertyDescriptors||function(e){var t={};return eR(e).forEach(function(a){t[a]=Object.getOwnPropertyDescriptor(e,a)}),t},eN={},eH={get:function(e,t){if(t===eq)return e;var a,r,s=X(e);if(!z(s,t))return(r=ef(s,t))?"value"in r?r.value:null==(a=r.get)?void 0:a.call(e.k):void 0;var i=s[t];return e.I||!L(i)?i:i===ep(e.t,t)?(eg(e),e.o[t]=em(e.A.h,i,e)):i},has:function(e,t){return t in X(e)},ownKeys:function(e){return Reflect.ownKeys(X(e))},set:function(e,t,a){var r=ef(X(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,a),!0;if(!e.P){var s=ep(X(e),t),i=null==s?void 0:s[eq];if(i&&i.t===a)return e.o[t]=a,e.R[t]=!1,!0;if((a===s?0!==a||1/a==1/s:a!=a&&s!=s)&&(void 0!==a||z(e.t,t)))return!0;eg(e),ey(e)}return e.o[t]===a&&(void 0!==a||t in e.o)||Number.isNaN(a)&&Number.isNaN(e.o[t])||(e.o[t]=a,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==ep(e.t,t)||t in e.t?(e.R[t]=!1,eg(e),ey(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var a=X(e),r=Reflect.getOwnPropertyDescriptor(a,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:a[t]}:r},defineProperty:function(){B(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){B(12)}},ej={};V(eH,function(e,t){ej[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),ej.deleteProperty=function(e,t){return ej.set.call(this,e,t,void 0)},ej.set=function(e,t,a){return eH.set.call(this,e[0],t,a,e[0])};var ek=new(function(){function e(e){var t=this;this.O=eO,this.D=!0,this.produce=function(e,a,r){if("function"==typeof e&&"function"!=typeof a){var s,i=a;return a=e,function(e){var r=this;void 0===e&&(e=i);for(var s=arguments.length,n=Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];return t.produce(e,function(e){var t;return(t=a).call.apply(t,[r,e].concat(n))})}}if("function"!=typeof a&&B(6),void 0!==r&&"function"!=typeof r&&B(7),L(e)){var n=eo(t),o=em(t,e,void 0),u=!0;try{s=a(o),u=!1}finally{u?ei(n):en(n)}return"u">typeof Promise&&s instanceof Promise?s.then(function(e){return es(n,r),ec(e,n)},function(e){throw ei(n),e}):(es(n,r),ec(s,n))}if(!e||"object"!=typeof e){if(void 0===(s=a(e))&&(s=e),s===ex&&(s=void 0),t.D&&ee(s,!0),r){var c=[],l=[];er("Patches").M(e,s,c,l),r(c,l)}return s}B(21,e)},this.produceWithPatches=function(e,a){if("function"==typeof e)return function(a){for(var r=arguments.length,s=Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return t.produceWithPatches(a,function(t){return e.apply(void 0,[t].concat(s))})};var r,s,i=t.produce(e,a,function(e,t){r=e,s=t});return"u">typeof Promise&&i instanceof Promise?i.then(function(e){return[e,r,s]}):[i,r,s]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}
7var t=e.prototype;return t.createDraft=function(e){L(e)||B(8),K(e)&&(K(t=e)||B(22,t),e=function e(t){if(!L(t))return t;var a,r=t[eq],s=G(t);if(r){if(!r.P&&(r.i<4||!er("ES5").K(r)))return r.t;r.I=!0,a=ev(t,s),r.I=!1}else a=ev(t,s);return V(a,function(t,s){var i;r&&(i=r.t,(2===G(i)?i.get(t):i[t])===s)||W(a,t,e(s))}),3===s?new Set(a):a}(t));var t,a=eo(this),r=em(this,e,void 0);return r[eq].C=!0,en(a),r},t.finishDraft=function(e,t){var a=(e&&e[eq]).A;return es(a,t),ec(void 0,a)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!eO&&B(20),this.O=e},t.applyPatches=function(e,t){for(a=t.length-1;a>=0;a--){var a,r=t[a];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}a>-1&&(t=t.slice(a+1));var s=er("Patches").$;return K(e)?s(e,t):this.produce(e,function(e){return s(e,t)})},e}()),eF=ek.produce;ek.produceWithPatches.bind(ek),ek.setAutoFreeze.bind(ek),ek.setUseProxies.bind(ek),ek.applyPatches.bind(ek),ek.createDraft.bind(ek),ek.finishDraft.bind(ek);var eU=e.i(190077);let eQ=[{id:(0,eU.v4)(),placement:I.TOP,type:N.BANNER,replaced:!0,content:{url:""},mobile:!1,items:[]},{id:(0,eU.v4)(),placement:I.SIDE,type:N.BANNER,replaced:!0,content:{url:""},mobile:!1,items:[]},{id:(0,eU.v4)(),placement:I.BOTTOM,type:N.BANNER,replaced:!0,content:{url:""},mobile:!1,items:[]},{id:(0,eU.v4)(),placement:I.TOP,type:N.BANNER,replaced:!0,content:{url:""},mobile:!0,items:[]},{id:(0,eU.v4)(),placement:I.BOTTOM,type:N.BANNER,replaced:!0,content:{url:""},mobile:!0,items:[]}],eB=(0,_.createContext)({}),eK=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext_checkoutsContext"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),s={dragAndDropMessage:{side:{error:{message:t("context.dragAndDropMessage.side.error.message",{returnObjects:!0})}}}},i=(0,P.useRouter)(),{fetchAllProductOffers:n}=e8(),[o,u]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[d,h]=(0,_.useState)(!1),[p,f]=(0,_.useState)(!1),[y,g]=(0,_.useState)(!1),[v,b]=(0,_.useState)([]),[C,$]=(0,_.useState)(null),[w,E]=(0,_.useState)(eQ),[O,x]=(0,_.useState)(null),[A,q]=(0,_.useState)(!1),[D,R]=(0,_.useState)([]),[I,N]=(0,_.useState)([]),[j,k]=(0,_.useState)([]),[F,U]=(0,_.useState)(null),[B,K]=(0,_.useState)(),[L,V]=(0,_.useState)(null),[G,z]=(0,_.useState)(null),[W,J]=(0,_.useState)(null),[Y,X]=(0,_.useState)(!1),[Z,ee]=(0,_.useState)(!1),[et,ea]=(0,_.useState)(!1),[er,es]=(0,_.useState)([]),ei=async(e,a)=>{l(!0),m.api.post(`products/${e}/manage/checkout-builder`,a).then(e=>{M.toast.success(t("context.createCheckoutMessage.success")),ea(!et)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},en=async e=>{l(!0),m.api.put(`products/${e.product_id}/manage/checkout-builder/${e.uuid}`,e).then(e=>{M.toast.success(t("context.updateUpsellButtonsMessage.success"))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},eo=async(e,a)=>{l(!0);let s=e?{...e}:{...C},n=s.plugins?.find(e=>e.type===H.EXIT_POPUP);if(null===s.allow_otp&&(s.allow_otp=!1),null===s.omit_idd&&(s.omit_idd=!1),null==s.sticky_product_header&&(s.sticky_product_header=!0),null!=n&&n?.content.offer_code===void 0){M.toast.error(t("context.updateCheckoutMessage.error")),l(!1);return}er.length>0&&(await Promise.all(er.map(async e=>{await Q.delete(e.product_id,e.id)})),es([])),m.api.put(`products/${C?.product_id}/manage/checkout-builder/${C?.uuid}`,s).then(e=>{a||M.toast.success(t("context.updateCheckoutMessage.success"));let r=v.findIndex(e=>e.uuid===C?.uuid);b(eF(v,t=>{t[r]=e.data})),a||g(!1),i.replace(`/product/${C?.product_id}/checkouts`)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},eu=async e=>{l(!0),m.api.put(`products/${e.product_id}/manage/checkout-builder/${e.uuid}`,e).then(a=>{let r=v.findIndex(t=>t.uuid===e.uuid);b(eF(v,t=>{t[r]=e})),M.toast.success(t("context.updateCheckoutStatusMessage.success")),g(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},ec=async e=>{l(!0),m.api.post(`products/${e.product_id}/manage/checkout-builder/${e.uuid}/duplicate`).then(a=>{M.toast.success(t("context.duplicateCheckoutMessage.success")),eh(e.product_id),g(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},el=async(e,a)=>{l(!0),m.api.post(`products/${a}/manage/checkout-builder/${e.uuid}/duplicate`,e).then(a=>{M.toast.success(t("context.duplicateCheckoutMessage.success")),eh(e.product_id),g(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},ed=async e=>{l(!0),m.api.delete(`products/${e.product_id}/manage/checkout-builder/${e.uuid}`).then(a=>{M.toast.success(t("context.deleteCheckoutMessage.success")),eh(e.product_id),g(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{l(!1)})},eh=async e=>{u(!0),$(null),m.api.get(`products/${e}/manage/checkout-builder`).then(e=>{e&&f(e.data.length>=20),b(e.data.map(e=>(e.active_foreign_purchase=e.active_foreign_purchase??!1,e.one_page_checkout=e.one_page_checkout??!1,e.request_address=e.request_address??!1,e.request_address_after_purchase=e.request_address_after_purchase??!1,e.request_email_confirmation=e.request_email_confirmation??!1,e.back_redirect_url=e.back_redirect_url??"",e.default_thankyou_url=e.default_thankyou_url??"",e)))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{u(!1)})},ep=async e=>{try{let{data:t,...a}=await m.api.get(`products/${Number(i.query.productId)}/manage/checkout-builder`,{params:{last_keys:JSON.stringify(e)}});t&&f(t.length>=20);let r=t.map(e=>(e.active_foreign_purchase=e.active_foreign_purchase??!1,e.one_page_checkout=e.one_page_checkout??!1,e.request_address=e.request_address??!1,e.request_address_after_purchase=e.request_address_after_purchase??!1,e.request_email_confirmation=e.request_email_confirmation??!1,e.back_redirect_url=e.back_redirect_url??"",e.default_thankyou_url=e.default_thankyou_url??"",e));return b(e=>[...e,...r]),t}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}},ef=(e,t)=>{u(!0),m.api.get(`products/${e}/manage/checkout-builder/${t}`).then(e=>{$(e.data),e.data?.elements!=null&&E(e.data.elements),e.data?.plugins!=null&&R(e.data.plugins),e.data?.bumps!=null&&N(e.data.bumps),e.data?.upsell!=null&&U(e.data.upsell)}
7).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{u(!1)})},ey=async()=>{let e=await n(C?.product_id);return k(e=e.filter(e=>C?.offers?.map(e=>e.id).includes(e.id))),e},eg=(e,t)=>{if(h(!0),"all"===e){if($(t),t?.elements.length===0?E(eQ):E(t?.elements),t?.plugins&&R(t?.plugins),t?.bumps){let e=t?.bumps.map(e=>({...e,editing:!1}));z(null),J(null),N(e)}t?.upsell&&U(t?.upsell);return}$(a=>{let r={...a};return r[e]=t,r}),"elements"===e&&E(t),"plugins"===e&&R(t),"bumps"===e&&N(t),"upsell"===e&&U(t)},em=async e=>{l(!0),await new Promise((t,a)=>{m.api.post(`products/${i.query.productId}/manage/checkout-builder/external`,{external_domain_url:e}).then(async e=>{x(e.data),e.data[0]?.reason==="pending_domain_verification"&&q(!0),t(e)}).catch(e=>{}).finally(()=>l(!1))})};return(0,_.useEffect)(()=>{if(L&&null!=C){let e={...C,elements:w,plugins:D},t=localStorage.getItem(L);JSON.stringify(e)!==t&&(h(!0),localStorage.setItem(L,JSON.stringify(e)),$(e))}},[C,w,D]),(0,_.useEffect)(()=>{if(i.isReady){let e=Number(i.query?.productId),t=i.query?.checkoutId;e&&t&&(V("TICTO@CHECKOUTBUILDER@"+t),ef(e,String(t)))}},[i]),(0,a.jsx)(eB.Provider,{value:{isLoading:o,isSetting:c,setIsLoading:u,hasChanges:d,hasNextPage:p,updateCheckout:eg,updateUpsellButtons:en,checkouts:v,checkout:C,setCheckout:$,elements:w,plugins:D,bumps:I,setBumps:N,upsell:F,offers:j,form:B,setForm:K,onRequestCloseNotificationModal:function(){null!=C&&eo(C,!0),X(!1)},isOpenExportElementsModal:Z,isOpenNotificationModal:Y,replaceElements:e=>{if(eg("all",e),e&&null!=e.elements&&e.elements.length>0&&!e.elements?.some(e=>e.hasOwnProperty("items"))){let t=eQ.map(t=>{let a=e.elements.filter(e=>e.placement===t.placement).map(({order:e,...t})=>({...t,grid:!1}));return{...t,items:[...t.items,...a]}});E(t),$(e=>eF(e,e=>{null!=e&&(e.elements=t)})),X(!0);return}e&&null!=e.elements&&e.elements.length>0&&e.elements.some(e=>e.hasOwnProperty("items"))&&!e.elements.some(e=>e.hasOwnProperty("replaced"))?ee(!0):setTimeout(()=>{g(!0)},100)},fetch:eh,findOne:ef,update:eo,store:ei,destroy:ed,duplicate:ec,updateCheckoutStatus:eu,findOffers:ey,handleDragAndDrop:e=>{let a,r,i,{source:n,destination:o}=e;if(!o||n.droppableId===o.droppableId&&n.index===o.index)return;let u=[...w];a=u.find(e=>e.id===n.droppableId||e.items.some(e=>e.id===n.droppableId)),r=u.find(e=>e.id===o.droppableId||e.items.some(e=>e.id===o.droppableId));let c=a.items.some(e=>e.id===n.droppableId),l=a.items[n.index]?.grid,d=a.items[n.index]?.type==="stamp"||a.items[n.index]?.type==="rate",h=a.items[n.index]?.type;if(l&&"side"===r.placement)return void M.toast.error(t("context.dragAndDropMessage.grid.error"));if(d&&"side"!==r.placement)return void M.toast.error(`${t(s.dragAndDropMessage.side.error.message[0])} ${"stamp"===h?t("context.dragAndDropMessage.side.error.stamps"):t("context.dragAndDropMessage.side.error.evaluations")} ${t(s.dragAndDropMessage.side.error.message[1])}`);if(a.mobile&&"banner"===a.type&&"side"===r.placement)return void M.toast.error(t("context.dragAndDropMessage.banner.error"));if(c){let e=[...(i=a.items.find(e=>e.id===n.droppableId)).content],[t]=e.splice(n.index,1);e.splice(o.index,0,t),i.content=e}else{let[e]=a.items.splice(n.index,1);a===r?a.items.splice(o.index,0,e):r.items.splice(o.index,0,e)}E(u)},handleConfirmCopy:e=>{if(ee(!0),null!=C&&null!=C.elements){if(e){let e=C.elements.find(e=>"top"===e.placement&&!1===e.mobile);null!=e&&C.elements.forEach(t=>{t.placement===e.placement&&!0===t.mobile&&(t.items=[...e.items],t.replaced=!0)}),M.toast.success("Elementos exportados para o mobile com sucesso!")}else C.elements.forEach(e=>{e.replaced=!0});E(C.elements)}else E([]);setTimeout(()=>{null!=C&&eo(C,!0),ee(!1)},100)},isCheckoutModalOpen:y,setIsCheckoutModalOpen:g,LoadMoreCheckouts:ep,bumpPreview:G,setBumpPreview:z,setCouponsToBeDeleted:es,comboPreview:W,setComboPreview:J,duplicateAnotherProduct:el,getExternalDomain:em,externalPortal:O,externalPortalEnabled:A,setExternalPortalEnabled:q,checkoutTrigger:et},children:e})};function eL(){return(0,_.useContext)(eB)}var eV=((t={}).Pending="pending",t.Approved="approved",t.PendingUpdate="pending_update",t.PendingDelete="pending_delete",t.Rejected="rejected",t.Deleted="deleted",t);e.s(["CoproductionStatus",()=>eV],263428);let eG=(0,_.createContext)({}),ez=({children:e})=>{let{t}
7=(0,S.useTranslation)("contexts_productContext_coProductionsContext"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),{user:s}=(0,C.useAuth)(),[i,n]=(0,_.useState)("list"),[o,u]=(0,_.useState)([]),[c,l]=(0,_.useState)({}),[d,h]=(0,_.useState)(!0),[p,f]=(0,_.useState)(!1),[g,v]=(0,_.useState)([]),b=(0,P.useRouter)(),$=Number(b.query.productId),w=async()=>{await y.invalidateQueries({queryKey:["coproductions","producer",[eV.Approved,eV.PendingUpdate,eV.PendingDelete],$,s?.info?.id,s?.info?.current_team_id]})},E=async(e,a)=>{f(!0),m.api.post(`products/${e}/manage/coproductions`,a).then(async a=>{M.toast.success(t("context.createCoProductionMessage.success")),setTimeout(()=>{b.push(`/product/${e}/coproduction/manage`)},10),await w()}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>f(!1))},O=e=>{h(!0),m.api.get(`products/${e}/manage/coproductions`).then(e=>{u(e.data.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>h(!1))},x=(e,t)=>{h(!0),m.api.get(`products/${e}/manage/coproductions/${t}`).then(async e=>{l(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>{h(!1)})};return(0,_.useEffect)(()=>{if(b.isReady){l(null);let e=Number(b.query.productId),t=Number(b.query.coproductionId);t?x(e,t):h(!1)}},[b]),(0,a.jsx)(eG.Provider,{value:{isLoading:d,setIsLoading:h,action:i,setAction:n,isSetting:p,setIsSetting:f,coProductions:o,setCoProductions:u,fetch:O,store:E,coProduction:c,setCoProduction:l,findOne:x,update:(e,a,s)=>{f(!0),m.api.put(`products/${e}/manage/coproductions/${a}`,s).then(async a=>{M.toast.success(t("context.updateCoProductionMessage.success")),await w(),setTimeout(()=>{b.push(`/product/${e}/coproduction/manage`)},10),l(null)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>f(!1))},destroy:(e,a)=>{f(!0),m.api.delete(`products/${e}/manage/coproductions/${a}`).then(async e=>{M.toast.success(t("context.deleteCoProductionMessage.success")),O(Number(b.query.productId)),await w()}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>f(!1))},formattedData:g,setFormattedData:v},children:e})};e.s(["CoProductionsProvider",0,ez,"useCoProductions",0,function(){return(0,_.useContext)(eG)}],595782);let eW=(0,_.createContext)({}),eJ=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext_couponsContext"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),[s,i]=(0,_.useState)("list"),[n,o]=(0,_.useState)([]),[u,c]=(0,_.useState)(null),[l,d]=(0,_.useState)(null),[h,p]=(0,_.useState)(!1),[f,y]=(0,_.useState)(!1),{product:g}=e8(),v=(0,P.useRouter)(),b=async(e,a)=>{y(!0),0===a.usage_limit||""===String(a.usage_limit)?a.usage_limit=null:a.usage_limit=a.usage_limit,m.api.post(`products/${e}/manage/coupons`,a).then(async a=>{M.toast.success(t("context.createCouponMessage.success")),setTimeout(()=>{v.push(`/product/${e}/coupons`)},10)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),p(!1)}).finally(()=>y(!1))},C=async(e,a,s)=>{y(!0),0===s.usage_limit||""===String(s.usage_limit)?s.usage_limit=null:s.usage_limit=s.usage_limit,m.api.put(`products/${a}/manage/coupons/${e}`,s).then(async e=>{M.toast.success(t("context.updateCouponMessage.success")),setTimeout(()=>{v.push(`/product/${a}/coupons`)},10)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),p(!1)}).finally(()=>y(!1))},$=async e=>{try{let{data:a}=await m.api.put(`products/${g.id}/manage/coupons/${e.id}`,{...e}),r=n.map(e=>e.id===a.id?a:e);o(r),M.toast.success(t("context.updateCouponStatusMessage.success"))}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}};return(0,_.useEffect)(()=>{if(v.isReady){d(null);let e=Number(v.query.productId),t=Number(v.query.couponId);t&&(p(!0),m.api.get(`products/${e}/manage/coupons/${t}`).then(async e=>{d(e.data),p(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),p(!1)}))}},[v]),(0,a.jsx)(eW.Provider,{value:{isLoading:h,setIsLoading:p,couponsResponseData:u,isSetting:f,action:s,setAction:i,store:b,update:C,destroy:e=>{y(!0),m.api.delete(`products/${g.id}/manage/coupons/${e}`).then(async a=>{M.toast.success(t("context.deleteCouponMessage.success")),o(n.filter(t=>t.id!==e))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),p(!1)}).finally(()=>y(!1))},coupons:n,coupon:l,fetch:(e,t)=>{p(!0),m.api.get(`products/${e}/manage/coupons${t??""}`).then(async e=>{let{data:t}=e.data;o(t),c(e.data),p(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),p(!1)})},setCoupon:d,updateCouponStatus:$},children:e})};function eY(){return(0,_.useContext)(eW)}let eX=(0,_.createContext)({}),eZ=({children:e})=>{let[t,r]=(0,_.useState)(),[s,i]=(0,_.useState)(!0),{productId:n}=(0,P.useRouter)().query;return(0,a.jsx)(eX.Provider,{value:{isLoading:s,fetch:()=>{i(!0),m.api.get(`products/${n}/dashboard`).then(e=>{r(e.data)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>i(!1))},dashboard:t},children:e})};e.s(["DashboardProductProvider",0,eZ,"useDashboardProduct",0,function(){return(0,_.useContext)(eX)}],820110);var e0=e.i(948294);let e1=(0,_.createContext)({}),e2=({children:e})=>{let{t}
7=(0,S.useTranslation)("contexts_productContext_offerContext"),{t:r}=(0,S.useTranslation)("components_product_list_offers"),{t:s}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),[i,n]=(0,_.useState)(!1),[o,u]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[d,h]=(0,_.useState)(!1),[p,f]=(0,_.useState)({data:[]}),[y,g]=(0,_.useState)(null),[b,C]=(0,_.useState)(1),$=(0,P.useRouter)(),{product:w}=e8(),[E,O]=(0,_.useState)([]),[x,A]=(0,_.useState)([]),[q,D]=(0,_.useState)(!1),R=new Set(["price","fake_initial_price","pix_recurring_min_amount","pix_recurring_max_amount","installment_fee_bank_slip","subscription.first_charge_price"]),I=(e,t)=>{if(!R.has(e))return t;let a=Number(t.replace(/[^\d-]/g,""));return Number.isFinite(a)?(a/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}):t},N=e=>null==e?"-":"boolean"==typeof e?e?"Sim":"Não":"object"==typeof e?JSON.stringify(e):String(e),H=async e=>{D(!0),A([]);try{let t=await m.api.get(`products/${e.product_id}/manage/offers/${e.id}/history`),a=(t.data?.data??t.data??[]).flatMap(e=>Object.keys(e.new_values||{}).map(t=>({date:e.created_at,user:e.user_name??"-",profile:e.profile??"-",field:t,oldValue:N(e.old_values?.[t]),newValue:N(e.new_values?.[t])})));A(a)}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,s))}finally{D(!1)}},j=async()=>{n(!0);let e=$.asPath?.split("?")[1],t=await m.api.get(`products/${w?.id}/manage/offers?${e||""}`);if(200===t.status){let{data:e}=t;f(e)}return n(!1),t},k=async(e,t)=>{let a=await m.api.get(`${t?`products/${e}/manage/offers?${t}`:`products/${e}/manage/offers`}`);if(200===a.status){let{data:e}=a;f(e)}return a},F=async e=>{n(!0);let t=await m.api.get(`products/${e}/manage/offers`);if(200===t.status){let e={data:[]};for(let[a,r]of Object.entries(t.data.data))e.data.push({value:r.id,label:`${r.name}`,...r});f(e)}return n(!1),t},U=async(e,t)=>{l(!0);let a=await m.api.post(`products/${t}/manage/offers`,e);if(200===a.status){(0,v.clarityEvent)(v.CLARITY_EVENTS.offerCreated);let{data:e}=a,t={...p};t.data.unshift(e),f(t),h(!d)}return l(!1),a},Q=async(e,a,r)=>{l(!0);let s=await m.api.put(`products/${e}/manage/offers/${a}`,r);if(200===s.status){let{data:e}=s,a={...p},r=a.data.findIndex(t=>t.id===e.id);a.data[r]=e,f(a),M.toast.success(t("current.statusMessage.success"))}return l(!1),s},B=(e,t)=>{n(!0),m.api.get(`products/${e}/manage/offers/${t}`).then(async e=>{g(e.data),n(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,s)),setTimeout(()=>{422===e.response.status&&$.push(`/product/${$.query.productId}/offers`)},1e3)}).finally(()=>n(!1))},K=async e=>{l(!0),e.name=`${t("current.findProductMessage.copy")} - [${e.name}]`,e?.freight&&e?.freight?.type!=="shipping_company"&&delete e.freight.free_states,e?.freight==null||Array.isArray(e?.freight?.blocked_states)||(e.freight.blocked_states=[]),null!=e.freight&&(void 0===e.freight.fixed_price||null===e.freight.fixed_price||0===e.freight.fixed_price||isNaN(e.freight.fixed_price))&&delete e?.freight.fixed_price,await U(e,e.product_id).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,s))}),await j()},L=async(e,a)=>{l(!0);try{let r=await m.api.put(`products/${a}/manage/offers/${e}/toggle`);return M.toast.success(t("current.statusMessage.success")),r.data}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,s))}finally{l(!1)}},V=async e=>{if(p?.data){let t=new Map(p.data.map(e=>[e.id,e])),a=e.map(e=>t.get(e)).filter(e=>!!e);f({...p,data:a})}try{return await m.api.put(`products/${w?.id}/manage/offers/reorder`,{order:e}),M.toast.success(t("current.statusMessage.success")),!0}catch(e){return f(p),M.toast.error((0,T.handleHTTPErrorMessage)(e,s)),!1}};return(0,_.useEffect)(()=>{if($.isReady){g(null);let e=Number($.query.productId),t=Number($.query.offerId);t?B(e,t):n(!1)}},[$]),(0,a.jsx)(e1.Provider,{value:{setIsLoading:n,isLoading:i,isSetting:c,fetchAll:j,store:U,offers:p,offer:y,setOffer:g,update:Q,duplicate:K,subscriptionInterval:b,setSubscriptionInterval:C,findOne:B,fetch:k,fetchOffers:F,changeStatus:L,toggleIsHidden:e=>{l(!0),m.api.put(`products/${w?.id}/manage/offers/${e}/hide`).then(e=>{M.toast.success(t("current.statusMessage.success")),l(!1),j()}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,s)),l(!1)}).finally(()=>l(!1))},setIsFree:u,isFree:o,selectedProducts:E,setSelectedProducts:O,offerTrigger:d,destroy:e=>{l(!0),m.api.delete(`products/${w?.id}/manage/offers/${e}/destroy`).then(e=>{M.toast.success(t("current.deleteOfferMessage.success")),l(!1),j()}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,s)),l(!1)}).finally(()=>l(!1))},reorderOffers:V,historyRows:x,isLoadingHistory:q,fetchHistory:H,exportHistoryCsv:(e,t)=>{let a=new Map;
7x.forEach(e=>{let t=`${String(e.date)}|${String(e.user)}|${String(e.profile)}`,r=a.get(t),s={field:String(e.field),oldValue:String(e.oldValue),newValue:String(e.newValue)};r?r.items.push(s):a.set(t,{date:String(e.date),user:String(e.user),profile:String(e.profile),items:[s]})});let s=[t,...Array.from(a.values()).map(e=>{let t=`${(0,e0.formatDate)(e.date)} ${new Date(e.date).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`,a=e.items.map(e=>{let t=e.field;return String(r(`historyModal.fields.${t}`)??t)}).join(" | "),s=e.items.map(e=>I(e.field,e.oldValue)).join(" | "),i=e.items.map(e=>I(e.field,e.newValue)).join(" | ");return[t,e.user,e.profile,a,s,i]})].map(e=>e.map(e=>`"${String(e??"").replace(/"/g,'""')}"`).join(",")).join("\n"),i=new Blob([`\uFEFF${s}`],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`historico-oferta-${e?.code??e?.id}-${Date.now()}.csv`,o.click(),URL.revokeObjectURL(n)}},children:e})};function e5(){return(0,_.useContext)(e1)}let e4=(0,_.createContext)({}),e9=({children:e})=>{let[t,r]=(0,_.useState)([]),[s,i]=(0,_.useState)(null),[n,o]=(0,_.useState)(!0),[u,c]=(0,_.useState)(!1),l=(0,P.useRouter)(),d=async(e,t)=>{c(!0),m.api.post(`products/${e}/manage/pages`,t).then(async t=>{M.toast.success("Página criada com sucesso"),setTimeout(()=>{l.push(`/product/${e}/affiliates-program/pages`)},10)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e)),o(!1)}).finally(()=>c(!1))},h=(e,t)=>{m.api.get(`products/${e}/manage/pages/${t}`).then(async e=>{i(e.data),o(!1)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e)),o(!1)}).finally(()=>o(!1))};return(0,_.useEffect)(()=>{if(l.isReady){i(null);let e=Number(l.query.productId),t=Number(l.query.pageId);t?h(e,t):o(!1)}},[l]),(0,a.jsx)(e4.Provider,{value:{isLoading:n,setIsLoading:o,isSetting:u,store:d,update:(e,t,a)=>{c(!0),m.api.put(`products/${e}/manage/pages/${t}`,a).then(async t=>{M.toast.success("Dados atualizados com sucesso."),setTimeout(()=>{l.push(`/product/${e}/affiliates-program/pages`)},10),i(null)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e)),o(!1)}).finally(()=>c(!1))},destroy:(e,a)=>{c(!0),m.api.delete(`products/${e}/manage/pages/${a}`).then(async e=>{M.toast.success("Página deletada com sucesso."),r(t.filter(e=>e.id!==a))}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e)),o(!1)}).finally(()=>c(!1))},fetch:(e,t)=>{o(!0),m.api.get(`${t?`products/${e}/manage/pages?${t}`:`products/${e}/manage/pages`}`).then(e=>{let{data:t}=e.data;r(t)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e))}).finally(()=>o(!1))},findOne:h,pages:t,page:s,setPage:i},children:e})};e.s(["PagesProvider",0,e9,"usePages",0,function(){return(0,_.useContext)(e4)}],842600);let e3=(0,_.createContext)({}),e6=({children:e})=>{let{t}=(0,S.useTranslation)("contexts_productContext"),{t:r}=(0,S.useTranslation)("utils_handleHTTPErrorMessage"),s=(0,P.useRouter)(),{user:i}=(0,C.useAuth)(),n="/sales/report"===s.asPath.split("?")[0],[o,u]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[d,h]=(0,_.useState)(!1),[p,f]=(0,_.useState)(!1),[$,E]=(0,_.useState)(!1),[x,A]=(0,_.useState)(!1),q=async(e,a,i)=>{f(!0),m.api.put(`products/${a}`,e).then(async e=>{M.toast.success(t("updateMessage.success")),!1===i&&setTimeout(()=>{s.replace(`/product/${a}/info`)},10),L(a)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>f(!1))},R=async()=>{await y.invalidateQueries({queryKey:["products",i.info.id,i.info.current_team_id,"producer"]})},I=e=>{let{page:t}=s.query,a=["products",i.info.id,i.info.current_team_id,"producer","",t],r=y.getQueryData(a);if(r){let t=r.map(t=>t.id===e.id?e:t);y.setQueryData(a,t)}},N=async e=>{f(!0);try{if(await m.api.put(`products/${e}/manage/status`),M.toast.success(t("sendMessage.success")),c){let t=[...c.data],a=t.findIndex(t=>t.id===e);t[a].status=g.ProductStatus.PENDING,l({...c,data:t})}window.location.reload()}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}finally{f(!1)}},H=async e=>{let t=await m.api.get(`products/${e}/manage/status`);return t?.data[0]?.description},j=async e=>{try{let a=await m.api.put(`products/${e}/toggle`);return M.toast.success(t("changeStatusMessage.success")),a.data}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e))}finally{}},k=async e=>{f(!0);try{let a=await m.api.post("products",{...e,is_active:!0});return(0,v.clarityEvent)(v.CLARITY_EVENTS.productCreated),M.toast.success(t("storeMessage.success")),await R(),a}catch(e){throw(0,v.clarityEvent)(v.CLARITY_EVENTS.productCreateFailed),M.toast.error((0,T.handleHTTPErrorMessage)(e)),h(!1),e}finally{f(!1)}},F=async e=>{f(!0),await m.api.delete(`products/${e}`).then(async e=>{M.toast.success(t("destroyMessage.success")),await R()}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),h(!1)}).finally(()=>f(!1))},U=async e=>{f(!0);try{let a=await b.ProductService.storeIsHidden(e);M.toast.success(t("storeHiddenMessage.success")),I(a)}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),h(!1)}finally{f(!1)}},Q=async e=>{f(!0);try{let a=await b.ProductService.toggleIsHidden(e);M.toast.success(t("restoreHiddenMessage.success")),I(a)}catch(e){M.toast.error((0,T.handleHTTPErrorMessage)(e,r)),h(!1)}finally{f(!1)}},B=async e=>{let{id:a,...s}=e;f(!0),s.name=`${t("current.findProductMessage.copy")} - [${s.name}]`,s.status="draft",await k(s).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}),window.location.reload()},K=async()=>{let e=Promise.all([await m.api.get("products/categories"),await m.api.get("products/types")]);return e.then(e=>{let t={...e[1]};if(200===t.status){let e={data:[]};for(let[a,r]of Object.entries(t.data))e.data.push({value:a,label:r});t.data=e}e[1]=t}),e},L=e=>{h(!0),m.api.get(`products/${e}`).then(async e=>{let{data:t}=e;u(t)}).catch(e=>{M.toast.error((0,T.handleHTTPErrorMessage)(e,r))}).finally(()=>h(!1))},V=async(e,t,a,r,s)=>{f(!0);let i=[];
7t&&t?.length!==0&&(t.forEach(e=>{i.push(`${e.name}=${e.value}`)}),r&&i.push("withTrashedRelations=1"),s&&i.push("withoutPagination=1")),e&&e?.length!==0&&e.forEach(e=>{i.push(`filter[${e.name}]=${e.value}`)}),i=i.filter(e=>!!e);let n=`products${0!==i.length?"?"+i.join("&"):""}${0!==i.length?"&":"?"}`+(void 0!==a?`page=${a}`:""),o=await m.api.get(n);return f(!1),l(o.data),o},G=async e=>{let t=e?`products/affiliate?filter[name]=${e}`:"products/affiliate";return await m.api.get(t)},z=async(e,t)=>{E(!0);let a=[];t&&t?.length!==0&&t?.forEach(e=>{a.push(`filter[${e.name}]=${e.value}`)});try{if("number"==typeof e){let{data:t}=(await m.api.get(`products/${e}/manage/offers${0!==a.length?"?"+a.join("&"):""}`)).data;return E(!1),t}{let{data:t}=await m.api.get(`offers?productIds=${e}`);return E(!1),t}}catch{return n||M.toast.error("Erro ao obter ofertas"),[]}},W=(0,_.useCallback)(async(e,t=!1)=>{E(!0);try{let{data:a}=(await m.api.get(`products/${e}/manage/offers?filter[hasProviderCommission]=${t?"true":"false"}`)).data;return E(!1),a}catch{n||M.toast.error("Erro ao obter ofertas")}E(!1)},[n]);return(0,_.useEffect)(()=>{if(s.isReady&&!s.pathname.includes("showcase")){let e=s.query.productId;e?o&&o.id===Number(e)||L(Number(e)):u(null)}},[s.isReady,s.query.productId,s.pathname]),(0,a.jsx)(e3.Provider,{value:{isLoading:d,isSetting:p,store:k,getCategoriesAndTypes:K,update:q,send:N,getAnalysisReason:H,product:o,setProduct:u,fetchProducts:V,products:c,fetchAffiliate:G,fetchAllProductOffers:z,fetchAllProductOffersByProviderCommission:W,changeStatus:j,isFetchingOffers:$,isFetchingProducts:x,findOne:L,destroy:F,storeIsHidden:U,duplicate:B,restoreIsHidden:Q},children:(0,a.jsx)(eZ,{children:(0,a.jsx)(eJ,{children:(0,a.jsx)(e2,{children:(0,a.jsx)(D,{children:(0,a.jsx)(e9,{children:(0,a.jsx)(O,{children:(0,a.jsx)(w,{children:(0,a.jsx)(ez,{children:(0,a.jsx)(eK,{children:e})})})})})})})})})})};function e8(){return(0,_.useContext)(e3)}},2379,e=>{"use strict";var t,a,r=((t={}).PHYSICAL="physical",t.EVENT="event",t.COURSE="course",t.SOFTWARE="software",t.EBOOK="ebook",t.SUBSCRIPTION="subscription",t.OTHER="other",t.MENTORING="mentoring",t.CONSULTANCY="consultancy",t.ARTIFICIAL_INTELLIGENCE="artificial_intelligence",t),s=((a={}).DRAFT="draft",a.PRE_APPROVED="pre-approved",a.APPROVED="approved",a.PENDING="pending",a.PENDING_CORRECTION="pending-correction",a.REPROVED="reproved",a);e.s(["ProductStatus",()=>s,"ProductTypes",()=>r])},835674,e=>{"use strict";let t={signupCompleted:"signup_completed",productCreateStarted:"product_create_started",productCreated:"product_created",productCreateFailed:"product_create_failed",offerCreateStarted:"offer_create_started",offerCreated:"offer_created",firstSaleAchievementViewed:"first_sale_achievement_viewed"},a="xkdhjj0di5",r=(e,...t)=>{try{return(()=>{if(void 0===window.clarity){let e=(...t)=>{(e.q=e.q??[]).push(t)};window.clarity=e}return window.clarity})()(e,...t),!0}catch{return!1}},s=e=>{try{return sessionStorage.getItem(e)}catch{return null}},i=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function n(e){return r("event",e)}let o="ticto:clarity:activation-stage",u="ticto:clarity:first-sale-achievement-viewed";function c(){return null!==s(o)}let l=e=>null==e||Array.isArray(e)||"object"!=typeof e?null:e;e.s(["CLARITY_EVENTS",0,t,"CLARITY_PROJECT_ID",0,a,"clarityEvent",0,n,"clarityIdentify",0,function(e){r("identify",e)},"claritySetActivationStage",0,function(e){c()||r("set","activation_stage_at_session_start",e)&&i(o,e)},"clarityUpgrade",0,function(e){r("upgrade",e)},"hasSyncedActivationStage",0,c,"isClarityConfigured",0,void 0!==a,"maybeTrackFirstSaleAchievement",0,function(e){try{let a=l(e);if(null===a||!0!==a.level_changed_today||a.level?.amount!==350||null!==s(u)||!n(t.firstSaleAchievementViewed))return;i(u,"1")}catch{}},"resolveActivationStage",0,function(e){let t=l(e);if(null===t)return"no_sale";let a=t.total_commissions;return"number"==typeof a&&a>0?"first_sale_done":"no_sale"}])},650457,e=>{"use strict";var t=e.i(797055);let a=async(e,a,r,s,i)=>{let n=[];a&&a?.length!==0&&(a.forEach(e=>{n.push(`${e.name}=${e.value}`)}),s&&n.push("withTrashedRelations=1"),i&&n.push("withoutPagination=1")),e&&e?.length!==0&&e.forEach(e
7=>{n.push(`filter[${e.name}]=${e.value}`)}),n=n.filter(e=>!!e);let o=`products${0!==n.length?"?"+n.join("&"):""}${0!==n.length?"&":"?"}`+(null!==r?`page=${r}`:""),{data:u}=await t.api.get(o);return u},r=async(e,a)=>{let r=[];a&&a?.length!==0&&a.forEach(e=>{r.push(`${e.name}=${e.value}`)}),e&&e?.length!==0&&e.forEach(e=>{r.push(`filter[${e.name}]=${e.value}`)}),r=r.filter(e=>!!e);let s=`products/options${0!==r.length?"?"+r.join("&"):""}`;return await t.api.get(s)},s=async e=>{let{data:a}=await t.api.get(`products/${e}/invoice`);return a},i=async(e,a)=>(await t.api.put(`products/${e}/invoice`,a)).data,n=async(e,a)=>{let{data:r}=await t.api.get(`/integrations?filter[productId]=${e}&filter[type]=${a.join(",")}`);return r.data},o=async e=>(await t.api.put(`products/${e}/toggle-hidden`)).data,u=async e=>(await t.api.delete(`products/${e}/hidden`)).data;e.s(["ProductService",0,{fetch:a,fetchOptions:r,fetchInvoicesSplitSettings:s,fetchIntegrationsByType:n,saveInvoicesSplitSettings:i,toggleIsHidden:o,storeIsHidden:u}])},948294,e=>{"use strict";var t=e.i(55261),a=e.i(514398),r=e.i(684034),s=e.i(673279);let i=/^\s*(\d{1,2})\/(\d{1,2})\/(\d{4})(?:\D+(\d{1,2}):(\d{2})(?::(\d{2}))?)?/,n=e=>{let t=i.exec(e);if(!t)return null;let[,a,r,s,n="0",o="0",u="0"]=t,c=new Date(Number(s),Number(r)-1,Number(a),Number(n),Number(o),Number(u));return isNaN(c.getTime())?null:c},o=e=>{let t=(0,r.parseISO)(e??"");return(0,a.isValid)(t)?t:null};e.s(["formatDate",0,e=>new Date(e).toLocaleString("pt-br",{day:"2-digit",month:"2-digit",year:"numeric"}),"formatDateFromBrToUsPattern",0,e=>{let t=e?.split(" ")[0].split("/"),a=e?.split(" ")[1];if(void 0===t||t.length<=0)return;let r=t[0],s=t[1],i=t[2];return new Date(String(e).includes(":")?`${s}/${r}/${i} ${a}`:`${s}/${r}/${i}`)},"formatDateTime",0,e=>{if(String(e).includes("/")){let a=n(String(e));return a?(0,t.format)(a,"yyyy-MM-dd HH:mm:ss"):"Invalid date"}if("-"===e)return e;let a=new Date(e);return isNaN(a.getTime())?"Invalid date":(0,t.format)(a,"yyyy-MM-dd HH:mm:00")},"formatIsoDate",0,(e,a="dd/MM/yyyy",r="-")=>{let s=o(e);return null!==s?(0,t.format)(s,a):r},"handleI18nDate",0,e=>{switch(s.default.language){case"pt-BR":case"es":default:return e;case"en-US":{let a=n(String(e));return a?(0,t.format)(a,"MM/dd/yyyy"):"Invalid date"}}},"parseIsoDate",0,o,"today",0,e=>{let t=e||"pt-BTR",a=new Date;return{extensive:(e="pt-BR")=>a.toLocaleDateString("es"===t?"es-CL":t,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),ptBR:()=>a.toLocaleDateString("pt-BR"),enUS:()=>a.toLocaleDateString("en-US"),esCL:()=>a.toLocaleDateString("es-CL")}}])}]); 8 9//# debugId=e78ad212-66aa-b9b9-59a0-3f20c6adf1c1 10//# sourceMappingURL=425ez3uyxnwbg.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.