sirius-press/wordpress/wp-includes/js/dist/script-modules/route/index.min.js

27 lines
75 KiB
JavaScript
Raw Normal View History

var sn=Object.create;var Wo=Object.defineProperty;var an=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var un=Object.getPrototypeOf,ln=Object.prototype.hasOwnProperty;var ct=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var fn=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of cn(o))!ln.call(t,n)&&n!==e&&Wo(t,n,{get:()=>o[n],enumerable:!(r=an(o,n))||r.enumerable});return t};var C=(t,o,e)=>(e=t!=null?sn(un(t)):{},fn(o||!t||!t.__esModule?Wo(e,"default",{value:t,enumerable:!0}):e,t));var K=ct((Hi,dr)=>{dr.exports=window.ReactJSXRuntime});var A=ct((Ki,pr)=>{pr.exports=window.React});var Rr=ct(gr=>{"use strict";var Vt=A();function Qn(t,o){return t===o&&(t!==0||1/t===1/o)||t!==t&&o!==o}var ts=typeof Object.is=="function"?Object.is:Qn,es=Vt.useState,os=Vt.useEffect,rs=Vt.useLayoutEffect,ns=Vt.useDebugValue;function ss(t,o){var e=o(),r=es({inst:{value:e,getSnapshot:o}}),n=r[0].inst,s=r[1];return rs(function(){n.value=e,n.getSnapshot=o,go(n)&&s({inst:n})},[t,e,o]),os(function(){return go(n)&&s({inst:n}),t(function(){go(n)&&s({inst:n})})},[t]),ns(e),e}function go(t){var o=t.getSnapshot;t=t.value;try{var e=o();return!ts(t,e)}catch{return!0}}function is(t,o){return o()}var as=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?is:ss;gr.useSyncExternalStore=Vt.useSyncExternalStore!==void 0?Vt.useSyncExternalStore:as});var yr=ct((Xi,vr)=>{"use strict";vr.exports=Rr()});var Pr=ct(Sr=>{"use strict";var Me=A(),cs=yr();function us(t,o){return t===o&&(t!==0||1/t===1/o)||t!==t&&o!==o}var ls=typeof Object.is=="function"?Object.is:us,fs=cs.useSyncExternalStore,hs=Me.useRef,ds=Me.useEffect,ps=Me.useMemo,ms=Me.useDebugValue;Sr.useSyncExternalStoreWithSelector=function(t,o,e,r,n){var s=hs(null);if(s.current===null){var i={hasValue:!1,value:null};s.current=i}else i=s.current;s=ps(function(){function a(d){if(!f){if(f=!0,l=d,d=r(d),n!==void 0&&i.hasValue){var p=i.value;if(n(p,d))return u=p}return u=d}if(p=u,ls(l,d))return p;var m=r(d);return n!==void 0&&n(p,m)?(l=d,p):(l=d,u=m)}var f=!1,l,u,h=e===void 0?null:e;return[function(){return a(o())},h===null?void 0:function(){return a(h())}]},[o,e,r,n]);var c=fs(t,s[0],s[1]);return ds(function(){i.hasValue=!0,i.value=c},[c]),ms(c),c}});var wr=ct((Qi,_r)=>{"use strict";_r.exports=Pr()});var Fr=ct((Ca,Ir)=>{Ir.exports=window.ReactDOM});var qr=ct((Nu,Gr)=>{Gr.exports=window.wp.privateApis});var ge=new WeakMap,zo=new WeakMap,Gt={current:[]},je=!1,Kt=0,Ht=new Set,me=new Map;function jo(t){for(let o of t){if(Gt.current.includes(o))continue;Gt.current.push(o),o.recompute();let e=zo.get(o);if(e)for(let r of e){let n=ge.get(r);n?.length&&jo(n)}}}function hn(t){let o={prevVal:t.prevState,currentVal:t.state};for(let e of t.listeners)e(o)}function dn(t){let o={prevVal:t.prevState,currentVal:t.state};for(let e of t.listeners)e(o)}function Re(t){if(Kt>0&&!me.has(t)&&me.set(t,t.prevState),Ht.add(t),!(Kt>0)&&!je)try{for(je=!0;Ht.size>0;){let o=Array.from(Ht);Ht.clear();for(let e of o){let r=me.get(e)??e.prevState;e.prevState=r,hn(e)}for(let e of o){let r=ge.get(e);r&&(Gt.current.push(e),jo(r))}for(let e of o){let r=ge.get(e);if(r)for(let n of r)dn(n)}}}finally{je=!1,Gt.current=[],me.clear()}}function ut(t){Kt++;try{t()}finally{if(Kt--,Kt===0){let o=Ht.values().next().value;o&&Re(o)}}}function Ho(t){return typeof t=="function"}var qt=class{constructor(o,e){this.listeners=new Set,this.subscribe=r=>{var n,s;this.listeners.add(r);let i=(s=(n=this.options)==null?void 0:n.onSubscribe)==null?void 0:s.call(n,r,this);return()=>{this.listeners.delete(r),i?.()}},this.prevState=o,this.state=o,this.options=e}setState(o){var e,r,n;this.prevState=this.state,(e=this.options)!=null&&e.updateFn?this.state=this.options.updateFn(this.prevState)(o):Ho(o)?this.state=o(this.prevState):this.state=o,(n=(r=this.options)==null?void 0:r.onUpdate)==null||n.call(r),Re(this)}};var lt="__TSR_index",Ko="popstate",Go="beforeunload";function Ke(t){let o=t.getLocation(),e=new Set,r=i=>{o=t.getLocation(),e.forEach(c=>c({location:o,action:i}))},n=i=>{t.notifyOnIndexChange
`)+";$_TSR.c()"}}):null}function jr(){let t=L();if(!t.isScrollRestoring||!t.isServer||typeof t.options.scrollRestoration=="function"&&!t.options.scrollRestoration({location:t.latestLocation}))return null;let e=(t.options.getScrollRestorationKey||Zt)(t.latestLocation),r=e!==Zt(t.latestLocation)?e:void 0,n={storageKey:At,shouldScrollRestoration:!0};return r&&(n.key=r),(0,zr.jsx)(Wr,{children:`(${_e.toString()})(${JSON.stringify(n)})`})}var Ne=W.memo(function({matchId:o}){let e=L(),r=M({select:v=>{let P=v.matches.find(S=>S.id===o);return z(P,`Could not find match for matchId "${o}". Please file an issue!`),{routeId:P.routeId,ssr:P.ssr,_displayPending:P._displayPending}},structuralSharing:!0}),n=e.routesById[r.routeId],s=n.options.pendingComponent??e.options.defaultPendingComponent,i=s?(0,T.jsx)(s,{}):null,c=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,f=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,l=r.ssr===!1||r.ssr==="data-only",u=(!n.isRoot||n.options.wrapInSuspense||l)&&(n.options.wrapInSuspense??s??(n.options.errorComponent?.preload||l))?W.Suspense:vt,h=c?Dt:vt,d=f?Dr:vt,p=M({select:v=>v.loadedAt}),m=M({select:v=>{let P=v.matches.findIndex(S=>S.id===o);return v.matches[P-1]?.routeId}}),R=n.isRoot?n.options.shellComponent??vt:vt;return(0,T.jsxs)(R,{children:[(0,T.jsx)(Ct.Provider,{value:o,children:(0,T.jsx)(u,{fallback:i,children:(0,T.jsx)(h,{getResetKey:()=>p,errorComponent:c||Ut,onCatch:(v,P)=>{if($(v))throw v;at(!1,`Error in route match: ${o}`),a?.(v,P)},children:(0,T.jsx)(d,{fallback:v=>{if(!f||v.routeId&&v.routeId!==r.routeId||!v.routeId&&!n.isRoot)throw v;return W.createElement(f,v)},children:l||r._displayPending?(0,T.jsx)(mr,{fallback:i,children:(0,T.jsx)(Hr,{matchId:o})}):(0,T.jsx)(Hr,{matchId:o})})})})}),m===O&&e.options.scrollRestoration?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ws,{}),(0,T.jsx)(jr,{})]}):null]})});function ws(){let t=L(),o=W.useRef(void 0);return(0,T.jsx)("script",{suppressHydrationWarning:!0,ref:e=>{e&&(o.current===void 0||o.current.href!==t.latestLocation.href)&&(t.emit({type:"onRendered",...tt(t.state)}),o.current=t.latestLocation)}},t.latestLocation.state.__TSR_key)}var Hr=W.memo(function({matchId:o}){let e=L(),{match:r,key:n,routeId:s}=M({select:a=>{let f=a.matches.find(p=>p.id===o),l=f.routeId,h=(e.routesById[l].options.remountDeps??e.options.defaultRemountDeps)?.({routeId:l,loaderDeps:f.loaderDeps,params:f._strictParams,search:f._strictSearch});return{key:h?JSON.stringify(h):void 0,routeId:l,match:{id:f.id,status:f.status,error:f.error,_forcePending:f._forcePending,_displayPending:f._displayPending}}},structuralSharing:!0}),i=e.routesById[s],c=W.useMemo(()=>{let a=i.options.component??e.options.defaultComponent;return a?(0,T.jsx)(a,{},n):(0,T.jsx)($e,{})},[n,i.options.component,e.options.defaultComponent]);if(r._displayPending)throw e.getMatch(r.id)?._nonReactive.displayPendingPromise;if(r._forcePending)throw e.getMatch(r.id)?._nonReactive.minPendingPromise;if(r.status==="pending"){let a=i.options.pendingMinMs??e.options.defaultPendingMinMs;if(a){let f=e.getMatch(r.id);if(f&&!f._nonReactive.minPendingPromise&&!e.isServer){let l=X();f._nonReactive.minPendingPromise=l,setTimeout(()=>{l.resolve(),f._nonReactive.minPendingPromise=void 0},a)}}throw e.getMatch(r.id)?._nonReactive.loadPromise}if(r.status==="notFound")return z($(r.error),"Expected a notFound error"),Mo(e,i,r.error);if(r.status==="redirected")throw z(V(r.error),"Expected a redirect error"),e.getMatch(r.id)?._nonReactive.loadPromise;if(r.status==="error"){if(e.isServer){let a=(i.options.errorComponent??e.options.defaultErrorComponent)||Ut;return(0,T.jsx)(a,{error:r.error,reset:void 0,info:{componentStack:""}})}throw r.error}return c}),$e=W.memo(function(){let o=L(),e=W.useContext(Ct),r=M({select:f=>f.matches.find(l=>l.id===e)?.routeId}),n=o.routesById[r],s=M({select:f=>{let u=f.matches.find(h=>h.id===e);return z(u,`Could not find parent match for matchId "${e}"`),u.globalNotFound}}),i=M({select:f=>{let l=f
/*! Bundled license information:
use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
(**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js:
(**
* @license React
* use-sync-external-store-shim/with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
*/