top-overlay-navbar
Version:
This is a modern, customizable overlay navbar built with React and Framer Motion.
14 lines (13 loc) • 35.9 kB
JavaScript
;var e=require("react"),t=require("framer-motion");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e);"function"==typeof SuppressedError&&SuppressedError;var a={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},o=e.createContext&&e.createContext(a),i=["attr","size","title"];function l(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){var n;return(t="symbol"==typeof(n=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?n:n+"")in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(t){return t&&t.map(((t,r)=>e.createElement(t.tag,c({key:r},t.attr),h(t.child))))}function m(t){return r=>e.createElement(p,u({attr:c({},t.attr)},r),h(t.child))}function p(t){var r=r=>{var n,{attr:a,size:o,title:s}=t,d=l(t,i),h=o||r.size||"1em";return r.className&&(n=r.className),t.className&&(n=(n?n+" ":"")+t.className),e.createElement("svg",u({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,a,d,{className:n,style:c(c({color:t.color||r.color},r.style),t.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),s&&e.createElement("title",null,s),t.children)};return void 0!==o?e.createElement(o.Consumer,null,(e=>r(e))):r(a)}function f(e){return m({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M528.12 301.319l47.273-208C578.806 78.301 567.391 64 551.99 64H159.208l-9.166-44.81C147.758 8.021 137.93 0 126.529 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24h69.883l70.248 343.435C147.325 417.1 136 435.222 136 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-15.674-6.447-29.835-16.824-40h209.647C430.447 426.165 424 440.326 424 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-22.172-12.888-41.332-31.579-50.405l5.517-24.276c3.413-15.018-8.002-29.319-23.403-29.319H218.117l-6.545-32h293.145c11.206 0 20.92-7.754 23.403-18.681z"},child:[]}]})(e)}function v(e){return m({tag:"svg",attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(e)}function y(e){return m({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM64 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L96 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(e)}var g,w={};
/**
* react-router v7.1.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
function b(e,t){if(!1===e||null==e)throw new Error(t)}function x(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function C({pathname:e="/",search:t="",hash:r=""}){return t&&"?"!==t&&(e+="?"===t.charAt(0)?t:"?"+t),r&&"#"!==r&&(e+="#"===r.charAt(0)?r:"#"+r),e}function E(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function S(e,t,r="/"){return function(e,t,r,n){let a="string"==typeof t?E(t):t,o=B(a.pathname||"/",r);if(null==o)return null;let i=R(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let r=e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]));return r?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(i);let l=null;for(let e=0;null==l&&e<i.length;++e){let t=z(o);l=D(i[e],t,n)}return l}(e,t,r,!1)}function R(e,t=[],r=[],n=""){let a=(e,a,o)=>{let i={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};i.relativePath.startsWith("/")&&(b(i.relativePath.startsWith(n),`Absolute route path "${i.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),i.relativePath=i.relativePath.slice(n.length));let l=U([n,i.relativePath]),u=r.concat(i);e.children&&e.children.length>0&&(b(!0!==e.index,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),R(e.children,t,u,l)),(null!=e.path||e.index)&&t.push({path:l,score:A(l,e.index),routesMeta:u})};return e.forEach(((e,t)=>{if(""!==e.path&&e.path?.includes("?"))for(let r of O(e.path))a(e,t,r);else a(e,t)})),t}function O(e){let t=e.split("/");if(0===t.length)return[];let[r,...n]=t,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===n.length)return a?[o,""]:[o];let i=O(n.join("/")),l=[];return l.push(...i.map((e=>""===e?o:[o,e].join("/")))),a&&l.push(...i),l.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(){if(g)return w;g=1,Object.defineProperty(w,"__esModule",{value:!0}),w.parse=function(e,t){const r=new o,n=e.length;if(n<2)return r;const a=t?.decode||u;let s=0;do{const t=e.indexOf("=",s);if(-1===t)break;const o=e.indexOf(";",s),u=-1===o?n:o;if(t>u){s=e.lastIndexOf(";",t-1)+1;continue}const c=i(e,s,t),d=l(e,t,c),h=e.slice(c,d);if(void 0===r[h]){let n=i(e,t+1,u),o=l(e,u,n);const s=a(e.slice(n,o));r[h]=s}s=u+1}while(s<n);return r},w.serialize=function(o,i,l){const u=l?.encode||encodeURIComponent;if(!e.test(o))throw new TypeError(`argument name is invalid: ${o}`);const s=u(i);if(!t.test(s))throw new TypeError(`argument val is invalid: ${i}`);let c=o+"="+s;if(!l)return c;if(void 0!==l.maxAge){if(!Number.isInteger(l.maxAge))throw new TypeError(`option maxAge is invalid: ${l.maxAge}`);c+="; Max-Age="+l.maxAge}if(l.domain){if(!r.test(l.domain))throw new TypeError(`option domain is invalid: ${l.domain}`);c+="; Domain="+l.domain}if(l.path){if(!n.test(l.path))throw new TypeError(`option path is invalid: ${l.path}`);c+="; Path="+l.path}if(l.expires){if(!function(e){return"[object Date]"===a.call(e)}(l.expires)||!Number.isFinite(l.expires.valueOf()))throw new TypeError(`option expires is invalid: ${l.expires}`);c+="; Expires="+l.expires.toUTCString()}l.httpOnly&&(c+="; HttpOnly");l.secure&&(c+="; Secure");l.partitioned&&(c+="; Partitioned");if(l.priority){switch("string"==typeof l.priority?l.priority.toLowerCase():void 0){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${l.priority}`)}}if(l.sameSite){switch("string"==typeof l.sameSite?l.sameSite.toLowerCase():l.sameSite){case!0:case"strict":c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"none":c+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${l.sameSite}`)}}return c};const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,n=/^[\u0020-\u003A\u003D-\u007E]*$/,a=Object.prototype.toString,o=(()=>{const e=function(){};return e.prototype=Object.create(null),e})();function i(e,t,r){do{const r=e.charCodeAt(t);if(32!==r&&9!==r)return t}while(++t<r);return r}function l(e,t,r){for(;t>r;){const r=e.charCodeAt(--t);if(32!==r&&9!==r)return t+1}return r}function u(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}}();var $=/^:[\w-]+$/,N=3,k=2,P=1,L=10,T=-2,j=e=>"*"===e;function A(e,t){let r=e.split("/"),n=r.length;return r.some(j)&&(n+=T),t&&(n+=k),r.filter((e=>!j(e))).reduce(((e,t)=>e+($.test(t)?N:""===t?P:L)),n)}function D(e,t,r=!1){let{routesMeta:n}=e,a={},o="/",i=[];for(let e=0;e<n.length;++e){let l=n[e],u=e===n.length-1,s="/"===o?t:t.slice(o.length)||"/",c=M({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},s),d=l.route;if(!c&&u&&r&&!n[n.length-1].route.index&&(c=M({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},s)),!c)return null;Object.assign(a,c.params),i.push({params:a,pathname:U([o,c.pathname]),pathnameBase:_(U([o,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(o=U([o,c.pathnameBase]))}return i}function M(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=function(e,t=!1,r=!0){x("*"===e||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,((e,t,r)=>(n.push({paramName:t,isOptional:null!=r}),r?"/?([^\\/]+)?":"/([^\\/]+)")));e.endsWith("*")?(n.push({paramName:"*"}),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))");let o=new RegExp(a,t?void 0:"i");return[o,n]}(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce(((e,{paramName:t,isOptional:r},n)=>{if("*"===t){let e=l[n]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}const a=l[n];return e[t]=r&&!a?void 0:(a||"").replace(/%2F/g,"/"),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function z(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return x(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function B(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}function F(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function W(e){let t=function(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}(e);return t.map(((e,r)=>r===t.length-1?e.pathname:e.pathnameBase))}function I(e,t,r,n=!1){let a;"string"==typeof e?a=E(e):(a={...e},b(!a.pathname||!a.pathname.includes("?"),F("?","pathname","search",a)),b(!a.pathname||!a.pathname.includes("#"),F("#","pathname","hash",a)),b(!a.search||!a.search.includes("#"),F("#","search","hash",a)));let o,i=""===e||""===a.pathname,l=i?"/":a.pathname;if(null==l)o=r;else{let e=t.length-1;if(!n&&l.startsWith("..")){let t=l.split("/");for(;".."===t[0];)t.shift(),e-=1;a.pathname=t.join("/")}o=e>=0?t[e]:"/"}let u=function(e,t="/"){let{pathname:r,search:n="",hash:a=""}="string"==typeof e?E(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:H(n),hash:J(a)}}(a,o),s=l&&"/"!==l&&l.endsWith("/"),c=(i||"."===l)&&r.endsWith("/");return u.pathname.endsWith("/")||!s&&!c||(u.pathname+="/"),u}var U=e=>e.join("/").replace(/\/\/+/g,"/"),_=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),H=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",J=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var K=["POST","PUT","PATCH","DELETE"];new Set(K);var V=["GET",...K];new Set(V);var Y=n.createContext(null);Y.displayName="DataRouter";var q=n.createContext(null);q.displayName="DataRouterState";var G=n.createContext({isTransitioning:!1});G.displayName="ViewTransition",n.createContext(new Map).displayName="Fetchers",n.createContext(null).displayName="Await";var X=n.createContext(null);X.displayName="Navigation";var Q=n.createContext(null);Q.displayName="Location";var Z=n.createContext({outlet:null,matches:[],isDataRoute:!1});Z.displayName="Route";var ee=n.createContext(null);function te(){return null!=n.useContext(Q)}function re(){return b(te(),"useLocation() may be used only in the context of a <Router> component."),n.useContext(Q).location}ee.displayName="RouteError";var ne="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ae(e){n.useContext(X).static||n.useLayoutEffect(e)}function oe(){let{isDataRoute:e}=n.useContext(Z);return e?function(){let{router:e}=function(e){let t=n.useContext(Y);return b(t,he(e)),t}("useNavigate"),t=me("useNavigate"),r=n.useRef(!1);return ae((()=>{r.current=!0})),n.useCallback((async(n,a={})=>{x(r.current,ne),r.current&&("number"==typeof n?e.navigate(n):await e.navigate(n,{fromRouteId:t,...a}))}),[e,t])}():function(){b(te(),"useNavigate() may be used only in the context of a <Router> component.");let e=n.useContext(Y),{basename:t,navigator:r}=n.useContext(X),{matches:a}=n.useContext(Z),{pathname:o}=re(),i=JSON.stringify(W(a)),l=n.useRef(!1);return ae((()=>{l.current=!0})),n.useCallback(((n,a={})=>{if(x(l.current,ne),!l.current)return;if("number"==typeof n)return void r.go(n);let u=I(n,JSON.parse(i),o,"path"===a.relative);null==e&&"/"!==t&&(u.pathname="/"===u.pathname?t:U([t,u.pathname])),(a.replace?r.replace:r.push)(u,a.state,a)}),[t,r,i,o,e])}()}function ie(e,{relative:t}={}){let{matches:r}=n.useContext(Z),{pathname:a}=re(),o=JSON.stringify(W(r));return n.useMemo((()=>I(e,JSON.parse(o),a,"path"===t)),[e,o,a,t])}function le(e,t,r,a){b(te(),"useRoutes() may be used only in the context of a <Router> component.");let o,{navigator:i}=n.useContext(X),{matches:l}=n.useContext(Z),u=l[l.length-1],s=u?u.params:{},c=u?u.pathname:"/",d=u?u.pathnameBase:"/",h=u&&u.route;{let e=h&&h.path||"";fe(c,!h||e.endsWith("*")||e.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.\n\nPlease change the parent <Route path="${e}"> to <Route path="${"/"===e?"*":`${e}/*`}">.`)}o=re();let m=o.pathname||"/",p=m;if("/"!==d){let e=d.replace(/^\//,"").split("/");p="/"+m.replace(/^\//,"").split("/").slice(e.length).join("/")}let f=S(e,{pathname:p});x(h||null!=f,`No routes matched location "${o.pathname}${o.search}${o.hash}" `),x(null==f||void 0!==f[f.length-1].route.element||void 0!==f[f.length-1].route.Component||void 0!==f[f.length-1].route.lazy,`Matched leaf route at location "${o.pathname}${o.search}${o.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=function(e,t=[],r=null){if(null==e){if(!r)return null;if(r.errors)e=r.matches;else{if(0!==t.length||r.initialized||!(r.matches.length>0))return null;e=r.matches}}let a=e,o=r?.errors;if(null!=o){let e=a.findIndex((e=>e.route.id&&void 0!==o?.[e.route.id]));b(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,e+1))}let i=!1,l=-1;if(r)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(l=e),t.route.id){let{loaderData:e,errors:n}=r,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!n||void 0===n[t.route.id]);if(t.route.lazy||o){i=!0,a=l>=0?a.slice(0,l+1):[a[0]];break}}}return a.reduceRight(((e,u,s)=>{let c,d=!1,h=null,m=null;r&&(c=o&&u.route.id?o[u.route.id]:void 0,h=u.route.errorElement||se,i&&(l<0&&0===s?(fe("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,m=null):l===s&&(d=!0,m=u.route.hydrateFallbackElement||null)));let p=t.concat(a.slice(0,s+1)),f=()=>{let t;return t=c?h:d?m:u.route.Component?n.createElement(u.route.Component,null):u.route.element?u.route.element:e,n.createElement(de,{match:u,routeContext:{outlet:e,matches:p,isDataRoute:null!=r},children:t})};return r&&(u.route.ErrorBoundary||u.route.errorElement||0===s)?n.createElement(ce,{location:r.location,revalidation:r.revalidation,component:h,error:c,children:f(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):f()}),null)}(f&&f.map((e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:U([d,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?d:U([d,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,r,a);return v}function ue(){let e=function(){let e=n.useContext(ee),t=function(e){let t=n.useContext(q);return b(t,he(e)),t}("useRouteError"),r=me("useRouteError");if(void 0!==e)return e;return t.errors?.[r]}(),t=function(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:a},i={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=n.createElement(n.Fragment,null,n.createElement("p",null,"💿 Hey developer 👋"),n.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",n.createElement("code",{style:i},"ErrorBoundary")," or"," ",n.createElement("code",{style:i},"errorElement")," prop on your route.")),n.createElement(n.Fragment,null,n.createElement("h2",null,"Unexpected Application Error!"),n.createElement("h3",{style:{fontStyle:"italic"}},t),r?n.createElement("pre",{style:o},r):null,l)}n.createContext(null);var se=n.createElement(ue,null),ce=class extends n.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?n.createElement(Z.Provider,{value:this.props.routeContext},n.createElement(ee.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function de({routeContext:e,match:t,children:r}){let a=n.useContext(Y);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),n.createElement(Z.Provider,{value:e},r)}function he(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function me(e){let t=function(e){let t=n.useContext(Z);return b(t,he(e)),t}(e),r=t.matches[t.matches.length-1];return b(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}var pe={};function fe(e,t,r){t||pe[e]||(pe[e]=!0,x(!1,r))}n.memo((function({routes:e,future:t,state:r}){return le(e,0,r,t)}));var ve="get",ye="application/x-www-form-urlencoded";function ge(e){return null!=e&&"string"==typeof e.tagName}var we=null;var be=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xe(e){return null==e||be.has(e)?e:(x(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ye}"`),null)}function Ce(e,t){let r,n,a,o,i;if(ge(l=e)&&"form"===l.tagName.toLowerCase()){let i=e.getAttribute("action");n=i?B(i,t):null,r=e.getAttribute("method")||ve,a=xe(e.getAttribute("enctype"))||ye,o=new FormData(e)}else if(function(e){return ge(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return ge(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||i.getAttribute("action");if(n=l?B(l,t):null,r=e.getAttribute("formmethod")||i.getAttribute("method")||ve,a=xe(e.getAttribute("formenctype"))||xe(i.getAttribute("enctype"))||ye,o=new FormData(i,e),!function(){if(null===we)try{new FormData(document.createElement("form"),0),we=!1}catch(e){we=!0}return we}()){let{name:t,type:r,value:n}=e;if("image"===r){let e=t?`${t}.`:"";o.append(`${e}x`,"0"),o.append(`${e}y`,"0")}else t&&o.append(t,n)}}else{if(ge(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ve,n=null,a=ye,i=e}var l;return o&&"text/plain"===a&&(i=o,o=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:o,body:i}}function Ee(e,t){if(!1===e||null==e)throw new Error(t)}function Se(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"==typeof e.imageSrcSet&&"string"==typeof e.imageSizes:"string"==typeof e.rel&&"string"==typeof e.href)}async function Re(e,t,r){return function(e,t){let r=new Set;return new Set(t),e.reduce(((e,t)=>{let n=JSON.stringify(function(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}(t));return r.has(n)||(r.add(n),e.push({key:n,link:t})),e}),[])}((await Promise.all(e.map((async e=>{let n=t.routes[e.route.id];if(n){let e=await async function(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise((()=>{}))}}(n,r);return e.links?e.links():[]}return[]})))).flat(1).filter(Se).filter((e=>"stylesheet"===e.rel||"preload"===e.rel)).map((e=>"stylesheet"===e.rel?{...e,rel:"prefetch",as:"style"}:{...e,rel:"prefetch"})))}function Oe(e,t,r,n,a,o){let i=(e,t)=>!r[t]||e.route.id!==r[t].route.id,l=(e,t)=>r[t].pathname!==e.pathname||r[t].route.path?.endsWith("*")&&r[t].params["*"]!==e.params["*"];return"assets"===o?t.filter(((e,t)=>i(e,t)||l(e,t))):"data"===o?t.filter(((t,o)=>{let u=n.routes[t.route.id];if(!u||!u.hasLoader)return!1;if(i(t,o)||l(t,o))return!0;if(t.route.shouldRevalidate){let n=t.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"==typeof n)return n}return!0})):[]}function $e(e,t){return r=e.map((e=>{let r=t.routes[e.route.id];if(!r)return[];let n=[r.module];return r.imports&&(n=n.concat(r.imports)),n})).flat(1),[...new Set(r)];var r}var Ne=n.createContext(void 0);function ke(){let e=n.useContext(Ne);return Ee(e,"You must render this element inside a <HydratedRouter> element"),e}function Pe(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function Le({page:e,...t}){let{router:r}=function(){let e=n.useContext(Y);return Ee(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}(),a=n.useMemo((()=>S(r.routes,e,r.basename)),[r.routes,e,r.basename]);return a?n.createElement(Te,{page:e,matches:a,...t}):null}function Te({page:e,matches:t,...r}){let a=re(),{manifest:o,routeModules:i}=ke(),{loaderData:l,matches:u}=function(){let e=n.useContext(q);return Ee(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}(),s=n.useMemo((()=>Oe(e,t,u,o,a,"data")),[e,t,u,o,a]),c=n.useMemo((()=>Oe(e,t,u,o,a,"assets")),[e,t,u,o,a]),d=n.useMemo((()=>{if(e===a.pathname+a.search+a.hash)return[];let r=new Set,n=!1;if(t.forEach((e=>{let t=o.routes[e.route.id];t&&t.hasLoader&&(!s.some((t=>t.route.id===e.route.id))&&e.route.id in l&&i[e.route.id]?.shouldRevalidate||t.hasClientLoader?n=!0:r.add(e.route.id))})),0===r.size)return[];let u=function(e){let t="string"==typeof e?new URL(e,"undefined"==typeof window?"server://singlefetch/":window.location.origin):e;return"/"===t.pathname?t.pathname="_root.data":t.pathname=`${t.pathname.replace(/\/$/,"")}.data`,t}(e);return n&&r.size>0&&u.searchParams.set("_routes",t.filter((e=>r.has(e.route.id))).map((e=>e.route.id)).join(",")),[u.pathname+u.search]}),[l,a,o,s,t,e,i]),h=n.useMemo((()=>$e(c,o)),[c,o]),m=function(e){let{manifest:t,routeModules:r}=ke(),[a,o]=n.useState([]);return n.useEffect((()=>{let n=!1;return Re(e,t,r).then((e=>{n||o(e)})),()=>{n=!0}}),[e,t,r]),a}(c);return n.createElement(n.Fragment,null,d.map((e=>n.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...r}))),h.map((e=>n.createElement("link",{key:e,rel:"modulepreload",href:e,...r}))),m.map((({key:e,link:t})=>n.createElement("link",{key:e,...t}))))}function je(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}Ne.displayName="FrameworkContext";var Ae="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;try{Ae&&(window.__reactRouterVersion="7.1.3")}catch(e){}var De=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Me=n.forwardRef((function({onClick:e,discover:t="render",prefetch:r="none",relative:a,reloadDocument:o,replace:i,state:l,target:u,to:s,preventScrollReset:c,viewTransition:d,...h},m){let p,{basename:f}=n.useContext(X),v="string"==typeof s&&De.test(s),y=!1;if("string"==typeof s&&v&&(p=s,Ae))try{let e=new URL(window.location.href),t=s.startsWith("//")?new URL(e.protocol+s):new URL(s),r=B(t.pathname,f);t.origin===e.origin&&null!=r?s=r+t.search+t.hash:y=!0}catch(e){x(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let g=function(e,{relative:t}={}){b(te(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:a}=n.useContext(X),{hash:o,pathname:i,search:l}=ie(e,{relative:t}),u=i;return"/"!==r&&(u="/"===i?r:U([r,i])),a.createHref({pathname:u,search:l,hash:o})}(s,{relative:a}),[w,E,S]=function(e,t){let r=n.useContext(Ne),[a,o]=n.useState(!1),[i,l]=n.useState(!1),{onFocus:u,onBlur:s,onMouseEnter:c,onMouseLeave:d,onTouchStart:h}=t,m=n.useRef(null);n.useEffect((()=>{if("render"===e&&l(!0),"viewport"===e){let e=new IntersectionObserver((e=>{e.forEach((e=>{l(e.isIntersecting)}))}),{threshold:.5});return m.current&&e.observe(m.current),()=>{e.disconnect()}}}),[e]),n.useEffect((()=>{if(a){let e=setTimeout((()=>{l(!0)}),100);return()=>{clearTimeout(e)}}}),[a]);let p=()=>{o(!0)},f=()=>{o(!1),l(!1)};return r?"intent"!==e?[i,m,{}]:[i,m,{onFocus:Pe(u,p),onBlur:Pe(s,f),onMouseEnter:Pe(c,p),onMouseLeave:Pe(d,f),onTouchStart:Pe(h,p)}]:[!1,m,{}]}(r,h),R=function(e,{target:t,replace:r,state:a,preventScrollReset:o,relative:i,viewTransition:l}={}){let u=oe(),s=re(),c=ie(e,{relative:i});return n.useCallback((n=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(n,t)){n.preventDefault();let t=void 0!==r?r:C(s)===C(c);u(e,{replace:t,state:a,preventScrollReset:o,relative:i,viewTransition:l})}}),[s,u,c,r,a,t,e,o,i,l])}(s,{replace:i,state:l,target:u,preventScrollReset:c,relative:a,viewTransition:d});let O=n.createElement("a",{...h,...S,href:p||g,onClick:y||o?e:function(t){e&&e(t),t.defaultPrevented||R(t)},ref:je(m,E),target:u,"data-discover":v||"render"!==t?void 0:"true"});return w&&!v?n.createElement(n.Fragment,null,O,n.createElement(Le,{page:g})):O}));function ze(e){let t=n.useContext(Y);return b(t,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(e)),t}Me.displayName="Link",n.forwardRef((function({"aria-current":e="page",caseSensitive:t=!1,className:r="",end:a=!1,style:o,to:i,viewTransition:l,children:u,...s},c){let d=ie(i,{relative:s.relative}),h=re(),m=n.useContext(q),{navigator:p,basename:f}=n.useContext(X),v=null!=m&&function(e,t={}){let r=n.useContext(G);b(null!=r,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=ze("useViewTransitionState"),o=ie(e,{relative:t.relative});if(!r.isTransitioning)return!1;let i=B(r.currentLocation.pathname,a)||r.currentLocation.pathname,l=B(r.nextLocation.pathname,a)||r.nextLocation.pathname;return null!=M(o.pathname,l)||null!=M(o.pathname,i)}(d)&&!0===l,y=p.encodeLocation?p.encodeLocation(d).pathname:d.pathname,g=h.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;t||(g=g.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&f&&(w=B(w,f)||w);const x="/"!==y&&y.endsWith("/")?y.length-1:y.length;let C,E=g===y||!a&&g.startsWith(y)&&"/"===g.charAt(x),S=null!=w&&(w===y||!a&&w.startsWith(y)&&"/"===w.charAt(y.length)),R={isActive:E,isPending:S,isTransitioning:v},O=E?e:void 0;C="function"==typeof r?r(R):[r,E?"active":null,S?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let $="function"==typeof o?o(R):o;return n.createElement(Me,{...s,"aria-current":O,className:C,ref:c,style:$,to:i,viewTransition:l},"function"==typeof u?u(R):u)})).displayName="NavLink",n.forwardRef((({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:a,replace:o,state:i,method:l=ve,action:u,onSubmit:s,relative:c,preventScrollReset:d,viewTransition:h,...m},p)=>{let f=function(){let{router:e}=ze("useSubmit"),{basename:t}=n.useContext(X),r=me("useRouteId");return n.useCallback((async(n,a={})=>{let{action:o,method:i,encType:l,formData:u,body:s}=Ce(n,t);if(!1===a.navigate){let t=a.fetcherKey||Fe();await e.fetch(t,r,a.action||o,{preventScrollReset:a.preventScrollReset,formData:u,body:s,formMethod:a.method||i,formEncType:a.encType||l,flushSync:a.flushSync})}else await e.navigate(a.action||o,{preventScrollReset:a.preventScrollReset,formData:u,body:s,formMethod:a.method||i,formEncType:a.encType||l,replace:a.replace,state:a.state,fromRouteId:r,flushSync:a.flushSync,viewTransition:a.viewTransition})}),[e,t,r])}(),v=function(e,{relative:t}={}){let{basename:r}=n.useContext(X),a=n.useContext(Z);b(a,"useFormAction must be used inside a RouteContext");let[o]=a.matches.slice(-1),i={...ie(e||".",{relative:t})},l=re();if(null==e){i.search=l.search;let e=new URLSearchParams(i.search),t=e.getAll("index");if(t.some((e=>""===e))){e.delete("index"),t.filter((e=>e)).forEach((t=>e.append("index",t)));let r=e.toString();i.search=r?`?${r}`:""}}e&&"."!==e||!o.route.index||(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index");"/"!==r&&(i.pathname="/"===i.pathname?r:U([r,i.pathname]));return C(i)}(u,{relative:c}),y="get"===l.toLowerCase()?"get":"post",g="string"==typeof u&&De.test(u);return n.createElement("form",{ref:p,method:y,action:v,onSubmit:a?s:e=>{if(s&&s(e),e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,a=n?.getAttribute("formmethod")||l;f(n||e.currentTarget,{fetcherKey:t,method:a,navigate:r,replace:o,state:i,relative:c,preventScrollReset:d,viewTransition:h})},...m,"data-discover":g||"render"!==e?void 0:"true"})})).displayName="Form";var Be=0,Fe=()=>`__${String(++Be)}__`;new TextEncoder;exports.OverlayNavbar=function(r){var n=r.brandName,a=void 0===n?"BrandName":n,o=r.menuLinks,i=void 0===o?[]:o,l=r.cartCount,u=void 0===l?3:l,s=r.CartButton,c=void 0===s?function(t){var r=t.cartCount;return e.createElement("div",{className:"relative text-2xl cursor-pointer hover:text-gray-500 transition-all","aria-label":"Cart with ".concat(r," items")},e.createElement(f,null),r>0&&e.createElement("span",{className:"absolute -top-2 -right-2 bg-red-600 text-white text-sm w-5 h-5 flex items-center justify-center rounded-full"},r))}:s,d=r.backgroundColor,h=void 0===d?"#1F2937":d,m=r.onMenuItemClick,p=void 0===m?function(){}:m,g=r.sliceVariants,w=void 0===g?{hidden:{x:"-100%"},visible:function(e){return{x:0,transition:{duration:.6,delay:.1*e,ease:"easeOut"}}},exit:{x:"-100%",transition:{duration:.5,ease:"easeIn"}}}:g,b=r.contentVariants,x=void 0===b?{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{delay:.5,ease:"easeOut"}},exit:{opacity:0,y:20,transition:{duration:.3}}}:b,C=r.toggleButtonClassName,E=void 0===C?"text-xl p-3 text-white bg-[#1F2937] hover:text-gray-300 focus:outline-none rounded-full fixed top-6 left-6 z-50 transition-all":C,S=r.menuContainerClassName,R=void 0===S?"absolute inset-0 flex flex-col sm:flex-row items-center justify-center sm:justify-between px-8 py-6 text-white text-lg":S,O=r.menuItemClassName,$=void 0===O?"cursor-pointer hover:text-gray-400 transition-all":O,N=r.cartButtonClassName,k=void 0===N?"relative p-10 cursor-pointer":N,P=e.useState(!1),L=P[0],T=P[1],j=function(){return T(!L)};return e.createElement("div",{className:"relative"},e.createElement("button",{onClick:j,"aria-expanded":L,"aria-controls":"overlay-menu",className:E},L?e.createElement(v,null):e.createElement(y,null)),e.createElement(t.AnimatePresence,null,L&&e.createElement(t.motion.div,{className:"fixed inset-0 z-40",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.3}}},function(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}([],Array(i.length),!0).map((function(r,n){return e.createElement(t.motion.div,{key:n,custom:n,initial:"hidden",animate:"visible",exit:"exit",variants:w,className:"absolute w-full",style:{height:"".concat(100/i.length,"%"),top:"".concat(100/i.length*n,"%"),backgroundColor:h}})})),e.createElement(t.motion.div,{initial:"hidden",animate:"visible",exit:"exit",variants:x,className:R},e.createElement(t.motion.div,{variants:x,className:"text-3xl font-semibold cursor-pointer hover:text-gray-400 transition-all"},e.createElement(Me,{to:"/",onClick:j},a)),e.createElement(t.motion.ul,{className:"flex flex-col sm:flex-row items-center space-x-0 sm:space-x-8 sm:space-y-0 space-y-4 sm:ml-0 ml-4",variants:x},i.map((function(r,n){return e.createElement(t.motion.li,{key:n,whileHover:{scale:1.1},className:$,onClick:function(){p(r.label),j()}},e.createElement(Me,{to:r.route},r.label))}))),e.createElement(t.motion.div,{variants:x,className:k},e.createElement(c,{cartCount:u}))))))};
//# sourceMappingURL=index.js.map