"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5079],{7108:function(e,r,n){n.d(r,{K:function(){return c},X:function(){return s}});var t=n(5893),i=n(7294),a=n(3977),u=(0,i.createContext)(null),c=function(e){var r=e.children,n=(0,i.useState)(null),c=n[0],s=n[1];return(0,i.useEffect)((function(){if(null==c){s((0,a.ZF)({apiKey:"AIzaSyCUdiPo7C2nz1T2hurD0-1eB_vClJySNek",authDomain:"ivory-forklift-354912.firebaseapp.com",projectId:"ivory-forklift-354912",storageBucket:"ivory-forklift-354912.appspot.com",messagingSenderId:"172676932140",appId:"1:172676932140:web:3e038a74547feee35de789"}))}}),[c]),(0,t.jsx)(u.Provider,{value:c,children:r})};function s(){return(0,i.useContext)(u)}},4867:function(e,r,n){n.d(r,{J3:function(){return t},JN:function(){return m},KV:function(){return g},Ny:function(){return s},Ry:function(){return c},Vz:function(){return u},ew:function(){return f},hf:function(){return i},r_:function(){return a},tP:function(){return p},up:function(){return o},xB:function(){return l}});var t=[{id:"free",title:"Free",priceMonthly:0,priceYearly:0,features:["homepage.pricing.features.oneUser","homepage.pricing.features.oneImageAtOnce","homepage.pricing.features.bestEffortSupport"],featuresYearly:["homepage.pricing.features.oneUser","homepage.pricing.features.oneImageAtOnce","homepage.pricing.features.bestEffortSupport"],oneLine:"500 images/month",oneLineYearly:"500 images/month",cta:"homepage.pricing.features.cta.tryNow",mostPopular:!1,isFree:!0,isWeeklyPass:!1,maxImagesAtOnce:1},{id:"weekly",title:"100 Images",priceMonthly:2.99,priceYearly:2.99,features:["homepage.pricing.features.oneUser","homepage.pricing.features.weeklyMaximum","homepage.pricing.features.maxAtOnce.standard","homepage.pricing.features.bestEffortSupport","homepage.pricing.features.noAdvertisement"],featuresYearly:["homepage.pricing.features.oneUser","homepage.pricing.features.weeklyMaximum","homepage.pricing.features.maxAtOnce.standard","homepage.pricing.features.bestEffortSupport","homepage.pricing.features.noAdvertisement"],oneLine:"100 images only",oneLineYearly:"",cta:"homepage.pricing.features.cta.choosePlan",mostPopular:!1,isFree:!1,isWeeklyPass:!0,maxImagesAtOnce:5},{id:"standard",title:"Standard",priceMonthly:9.99,priceYearly:99.99,features:["homepage.pricing.features.oneUser","homepage.pricing.features.picturesPerYear.standard.monthly","homepage.pricing.features.maxAtOnce.standard","homepage.pricing.features.bestEffortSupport","homepage.pricing.features.noAdvertisement"],featuresYearly:["homepage.pricing.features.oneUser","homepage.pricing.features.picturesPerYear.standard.yearly","homepage.pricing.features.maxAtOnce.standard","homepage.pricing.features.bestEffortSupport","homepage.pricing.features.noAdvertisement"],oneLine:"500 images",oneLineYearly:"6k images",cta:"homepage.pricing.features.cta.choosePlan",mostPopular:!0,isFree:!1,isWeeklyPass:!1,maxImagesAtOnce:5},{id:"agency",title:"Agency",priceMonthly:29.99,priceYearly:299.99,features:["homepage.pricing.features.unlimitedUsers","homepage.pricing.features.picturesPerYear.agency.monthly","homepage.pricing.features.maxAtOnce.agency","homepage.pricing.features.supportResponse","homepage.pricing.features.compression","homepage.pricing.features.noAdvertisement"],featuresYearly:["homepage.pricing.features.unlimitedUsers","homepage.pricing.features.picturesPerYear.agency.yearly","homepage.pricing.features.maxAtOnce.agency","homepage.pricing.features.supportResponse","homepage.pricing.features.compression","homepage.pricing.features.noAdvertisement"],oneLine:"1500 images",oneLineYearly:"18k images",cta:"homepage.pricing.features.cta.choosePlan",mostPopular:!1,isFree:!1,isWeeklyPass:!1,maxImagesAtOnce:10}];function i(e){return!!e&&"standard"==e.id}function a(e){return!!e&&"agency"==e.id}function u(e){return!!e&&e.isFree}function c(e){return i(e)||function(e){return!!e&&"weekly"==e.id}(e)}function s(e){return"price_1QDRAgCADSwhglQi02Wvza1c"===e}function o(){var e=t[0];if(!e.isFree)throw new Error("Something went wrong! Cannot find Free plan");return e}function p(){return t.find((function(e){return"agency"==e.id}))}function l(){return t.find((function(e){return"weekly"==e.id}))}function f(e){var r=t.find((function(r){return r.id==e}));if(!r)throw new Error("Something went wrong!");return r}function g(e,r){switch(e){case"standard":switch(r){case"monthly":return"price_1NIWuRCADSwhglQiW9bPzaeR";case"yearly":return"price_1NIWv4CADSwhglQi7dP7bcOE"}throw console.error(e,r),new Error("Should not happen");case"agency":switch(r){case"monthly":return"price_1NIWx7CADSwhglQirfID8uuu";case"yearly":return"price_1NIWydCADSwhglQiss6I1tTf"}case"weekly":if("weekly"==r)return"price_1QDRAgCADSwhglQi02Wvza1c"}throw console.error(e,r),Error("not found")}function m(e,r,n,t){var i=g(e,r),a=function(e,r){switch(e){case"standard":switch(r){case"monthly":return"price_1NQ9UZCADSwhglQiZ6ZwVLGV";case"yearly":return"price_1NQ9UlCADSwhglQiQVygiTmG"}throw console.error(e,r),new Error("Should not happen");case"agency":switch(r){case"monthly":return"price_1NQ9VWCADSwhglQiVa8H5oTH";case"yearly":return"price_1NQ9VkCADSwhglQifutTSXDl"}case"weekly":if("weekly"==r)return"price_1QDRAgCADSwhglQi02Wvza1c"}throw console.error(e,r),Error("not found")}(e,r),u=[],c="";return s(i)?(u=[{price:i,quantity:1}],c="payment"):(u=[{price:i},{price:a,quantity:1}],c="subscription"),{automatic_tax:!0,tax_id_collection:!0,allow_promotion_codes:!0,line_items:u,success_url:n,cancel_url:t,mode:c}}},5079:function(e,r,n){n.d(r,{SE:function(){return y},fS:function(){return d}});var t=n(7568),i=n(1799),a=n(9396),u=n(7582),c=n(5893),s=n(7294),o=n(7927),p=n(7108),l=n(4867),f=n(1112),g=n(19),m=["price_1LnLCACADSwhglQiXIhrQKad","price_1LnLCXCADSwhglQiKZh8FEEv","price_1LnLHKCADSwhglQih7NX2zqP","price_1LnLHqCADSwhglQitjwS8Gu7","price_1NIWuRCADSwhglQiW9bPzaeR","price_1NIWv4CADSwhglQi7dP7bcOE","price_1NIWx7CADSwhglQirfID8uuu","price_1NIWydCADSwhglQiss6I1tTf"];var h=(0,s.createContext)(null),d=function(e){var r=e.children,n=(0,s.useState)(null),d=n[0],y=n[1],v=(0,s.useState)(null),w=v[0],A=v[1],P=(0,p.X)();return(0,s.useEffect)((function(){null!=P&&null==w&&A((0,o.v0)()),w&&(0,o.Aj)(w,(function(e){if(e){var r=function(){var e=(0,t.Z)((function(){return(0,u.__generator)(this,(function(e){switch(e.label){case 0:return[4,(0,f.c)(w)];case 1:return[2,e.sent()]}}))}));return function(){return e.apply(this,arguments)}}();r().then((function(r){var n;null!=r?(n=r.isAgencyMember?(0,l.tP)():null==r.stripeRole?(0,l.up)():(0,l.ew)(r.stripeRole),y({user:e,auth:w,activePlan:n,isAgencyMember:r.isAgencyMember,agencyParentId:r.parentUid})):y({user:e,auth:w,activePlan:(0,l.up)(),isAgencyMember:!1,agencyParentId:null})})).catch((function(e){}))}else y({user:null,auth:w,activePlan:(0,l.up)(),isAgencyMember:!1,agencyParentId:null})}))}),[P,w]),(0,s.useMemo)((function(){null!=w&&w.currentUser}),[w]),(0,s.useEffect)((function(){if(d&&d.activePlan){var e=!d.activePlan.isFree,r=!d.subscriptionId,n=!d.activePlan.isWeeklyPass;if(e&&r&&n&&null!=d.user){var t=d.user.uid;d.isAgencyMember&&(t=d.agencyParentId);var u=(0,g.ad)(),c=(0,g.IO)((0,g.hJ)(u,"customers",t,"subscriptions"),(0,g.ar)("status","in",["trialing","active"]),(0,g.Xo)("created","desc"),(0,g.b9)(1));(0,g.cf)(c,(function(e){var r=e.docs[0].data().items.filter((function(e){return function(e){return m.includes(e)}(e.plan.id)}))[0];if(r){var n=r.id;y((function(e){return e?(0,a.Z)((0,i.Z)({},e),{subscriptionId:n}):e}))}}),(function(e){}))}var s=d.activePlan.isFree;if(null!=d.user&&s&&r){var o=d.user.uid,p=(0,g.ad)(),f=(0,g.IO)((0,g.hJ)(p,"customers",o,"payments"),(0,g.ar)("status","==","succeeded"),(0,g.Xo)("created","desc"),(0,g.b9)(1));(0,g.cf)(f,(function(e){if(1==e.docs.length){var r=e.docs[0],n=r.data();if(n.items.some((function(e){return(0,l.Ny)(e.price.id)}))){var t=n.created,u=new Date(1e3*t),c=new Date;c.setDate((new Date).getDate()-7),u>=c&&y((function(e){return e?(0,a.Z)((0,i.Z)({},e),{activePlan:(0,l.xB)(),paymentId:r.id,paymentCreationDate:u}):e}))}}}),(function(e){}))}}}),[d]),(0,c.jsx)(h.Provider,{value:d,children:r})};function y(){return(0,s.useContext)(h)}},1112:function(e,r,n){n.d(r,{O:function(){return s},c:function(){return u}});var t=n(7568),i=n(7582),a=n(19);function u(e){return c.apply(this,arguments)}function c(){return(c=(0,t.Z)((function(e){var r,n,t,a;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.currentUser.getIdToken(!0)];case 1:return i.sent(),[4,e.currentUser.getIdTokenResult()];case 2:return r=i.sent(),n="memberType"in r.claims&&"agencyMember"==r.claims.memberType,t=null,n&&(t=r.claims.parentUid),a="stripeRole"in r.claims?r.claims.stripeRole:null,[2,{isAgencyMember:n,parentUid:t,stripeRole:a}]}}))}))).apply(this,arguments)}function s(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(null===e||void 0===e?void 0:e.activePlan.isWeeklyPass){var n,t=e.paymentId,i=(0,a.ad)(),u=(0,a.JU)((0,a.hJ)(i,"usage"),null===(n=e.user)||void 0===n?void 0:n.uid,"payments",t);(0,a.QT)(u).then((function(n){if(n.exists())(0,a.r7)(u,"usageCount",(0,a.nP)(r));else{var c=(0,a.JU)(i,"usage",e.user.uid,"payments",t);(0,a.pl)(c,{usageCount:r})}}))}}}}]);