Current File : /home/resuelf/www/wp-content/plugins/gutenberg/build/router/index.min.js |
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{privateApis:function(){return m}});var n=window.React,r=window.wp.element;function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}var a,i=a||(a={});i.Pop="POP",i.Push="PUSH",i.Replace="REPLACE";function u(e){e.preventDefault(),e.returnValue=""}function c(){var e=[];return{get length(){return e.length},push:function(t){return e.push(t),function(){e=e.filter((function(e){return e!==t}))}},call:function(t){e.forEach((function(e){return e&&e(t)}))}}}var s=window.wp.url;const l=function(e){function t(){var e=l.location,t=f.state||{};return[t.idx,{pathname:e.pathname,search:e.search,hash:e.hash,state:t.usr||null,key:t.key||"default"}]}function n(e){return"string"==typeof e?e:function(e){var t=e.pathname,n=e.search;return(void 0===t?"/":t)+(void 0===n?"":n)+(void 0===(e=e.hash)?"":e)}(e)}function r(e,t){return void 0===t&&(t=null),o({pathname:v.pathname,hash:"",search:""},"string"==typeof e?function(e){var t={};if(e){var n=e.indexOf("#");0<=n&&(t.hash=e.substr(n),e=e.substr(0,n)),0<=(n=e.indexOf("?"))&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}(e):e,{state:t,key:Math.random().toString(36).substr(2,8)})}function i(e){h=e,e=t(),p=e[0],v=e[1],y.call({action:h,location:v})}function s(e){f.go(e)}void 0===e&&(e={});var l=void 0===(e=e.window)?document.defaultView:e,f=l.history,d=null;l.addEventListener("popstate",(function(){if(d)g.call(d),d=null;else{var e=a.Pop,n=t(),r=n[0];if(n=n[1],g.length){if(null!=r){var o=p-r;o&&(d={action:e,location:n,retry:function(){s(-1*o)}},s(o))}}else i(e)}}));var h=a.Pop,p=(e=t())[0],v=e[1],y=c(),g=c();return null==p&&(p=0,f.replaceState(o({},f.state,{idx:p}),"")),{get action(){return h},get location(){return v},createHref:n,push:function e(t,o){var u=a.Push,c=r(t,o);if(!g.length||(g.call({action:u,location:c,retry:function(){e(t,o)}}),0)){var s=[{usr:c.state,key:c.key,idx:p+1},n(c)];c=s[0],s=s[1];try{f.pushState(c,"",s)}catch(e){l.location.assign(s)}i(u)}},replace:function e(t,o){var u=a.Replace,c=r(t,o);g.length&&(g.call({action:u,location:c,retry:function(){e(t,o)}}),1)||(c=[{usr:c.state,key:c.key,idx:p},n(c)],f.replaceState(c[0],"",c[1]),i(u))},go:s,back:function(){s(-1)},forward:function(){s(1)},listen:function(e){return y.push(e)},block:function(e){var t=g.push(e);return 1===g.length&&l.addEventListener("beforeunload",u),function(){t(),g.length||l.removeEventListener("beforeunload",u)}}}}(),f=l.push,d=l.replace;l.push=function(e,t){const n=(0,s.getQueryArgs)(window.location.href),r=(0,s.removeQueryArgs)(window.location.href,...Object.keys(n)),o=(0,s.addQueryArgs)(r,e);return f.call(l,o,t)},l.replace=function(e,t){const n=(0,s.getQueryArgs)(window.location.href),r=(0,s.removeQueryArgs)(window.location.href,...Object.keys(n)),o=(0,s.addQueryArgs)(r,e);return d.call(l,o,t)};var h=l;const p=(0,r.createContext)(),v=(0,r.createContext)();function y(e){const t=new URLSearchParams(e.search);return{...e,params:Object.fromEntries(t.entries())}}var g=window.wp.privateApis;const{lock:w,unlock:b}=(0,g.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/router"),m={};w(m,{useHistory:function(){return(0,r.useContext)(v)},useLocation:function(){return(0,r.useContext)(p)},RouterProvider:function({children:e}){const[t,o]=(0,r.useState)((()=>y(h.location)));return(0,r.useEffect)((()=>h.listen((({location:e})=>{o(y(e))}))),[]),(0,n.createElement)(v.Provider,{value:h},(0,n.createElement)(p.Provider,{value:t},e))}}),(window.wp=window.wp||{}).router=t}();
//# sourceMappingURL=index.min.js.map