ui5-lib-guard-router 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/{dist/.ui5 → .ui5}/build-manifest.json +56 -8
  2. package/CHANGELOG.md +190 -0
  3. package/README.md +695 -327
  4. package/dist/index.d.ts +9 -5
  5. package/dist/resources/ui5/guard/router/.library +1 -1
  6. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js +222 -0
  7. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js.map +1 -0
  8. package/dist/resources/ui5/guard/router/GuardConfig.d.ts +89 -0
  9. package/dist/resources/ui5/guard/router/GuardConfig.d.ts.map +1 -0
  10. package/dist/resources/ui5/guard/router/GuardConfig.js +2 -0
  11. package/dist/resources/ui5/guard/router/GuardConfig.js.map +1 -0
  12. package/dist/resources/ui5/guard/router/GuardModules-dbg.js +253 -0
  13. package/dist/resources/ui5/guard/router/GuardModules-dbg.js.map +1 -0
  14. package/dist/resources/ui5/guard/router/GuardModules.d.ts +72 -0
  15. package/dist/resources/ui5/guard/router/GuardModules.d.ts.map +1 -0
  16. package/dist/resources/ui5/guard/router/GuardModules.js +2 -0
  17. package/dist/resources/ui5/guard/router/GuardModules.js.map +1 -0
  18. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js +122 -121
  19. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js.map +1 -1
  20. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts +45 -26
  21. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts.map +1 -1
  22. package/dist/resources/ui5/guard/router/GuardPipeline.js +1 -1
  23. package/dist/resources/ui5/guard/router/GuardPipeline.js.map +1 -1
  24. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js +3 -3
  25. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js.map +1 -1
  26. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts +3 -3
  27. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts.map +1 -1
  28. package/dist/resources/ui5/guard/router/NavigationOutcome.js.map +1 -1
  29. package/dist/resources/ui5/guard/router/PatternTree-dbg.js +156 -0
  30. package/dist/resources/ui5/guard/router/PatternTree-dbg.js.map +1 -0
  31. package/dist/resources/ui5/guard/router/PatternTree.d.ts +71 -0
  32. package/dist/resources/ui5/guard/router/PatternTree.d.ts.map +1 -0
  33. package/dist/resources/ui5/guard/router/PatternTree.js +2 -0
  34. package/dist/resources/ui5/guard/router/PatternTree.js.map +1 -0
  35. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js +84 -0
  36. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js.map +1 -0
  37. package/dist/resources/ui5/guard/router/RouteMeta.d.ts +33 -0
  38. package/dist/resources/ui5/guard/router/RouteMeta.d.ts.map +1 -0
  39. package/dist/resources/ui5/guard/router/RouteMeta.js +2 -0
  40. package/dist/resources/ui5/guard/router/RouteMeta.js.map +1 -0
  41. package/dist/resources/ui5/guard/router/Router-dbg.js +882 -1020
  42. package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
  43. package/dist/resources/ui5/guard/router/Router.d.ts +360 -211
  44. package/dist/resources/ui5/guard/router/Router.d.ts.map +1 -1
  45. package/dist/resources/ui5/guard/router/Router.js +1 -1
  46. package/dist/resources/ui5/guard/router/Router.js.map +1 -1
  47. package/dist/resources/ui5/guard/router/library-dbg.js +1 -1
  48. package/dist/resources/ui5/guard/router/library-dbg.js.map +1 -1
  49. package/dist/resources/ui5/guard/router/library-preload.js +8 -4
  50. package/dist/resources/ui5/guard/router/library-preload.js.map +1 -1
  51. package/dist/resources/ui5/guard/router/library.js +1 -1
  52. package/dist/resources/ui5/guard/router/library.js.map +1 -1
  53. package/dist/resources/ui5/guard/router/manifest.json +5 -2
  54. package/dist/resources/ui5/guard/router/types-dbg.js.map +1 -1
  55. package/dist/resources/ui5/guard/router/types.d.ts +94 -39
  56. package/dist/resources/ui5/guard/router/types.d.ts.map +1 -1
  57. package/package.json +10 -6
  58. package/src/GuardConfig.ts +272 -0
  59. package/src/GuardModules.ts +249 -0
  60. package/src/GuardPipeline.ts +155 -128
  61. package/src/NavigationOutcome.ts +3 -3
  62. package/src/PatternTree.ts +145 -0
  63. package/src/RouteMeta.ts +82 -0
  64. package/src/Router.ts +1089 -1130
  65. package/src/manifest.json +5 -2
  66. package/src/types.ts +79 -22
  67. package/tsconfig.json +0 -11
@@ -1,10 +1,14 @@
1
1
  //@ui5-bundle ui5/guard/router/library-preload.js
2
- sap.ui.predefine("ui5/guard/router/GuardPipeline", ["sap/base/Log"],function(r){"use strict";const e="ui5.guard.router.Router";function t(r){if(typeof r!=="object"||r===null){return false}const{route:e}=r;return typeof e==="string"&&e.length>0}function a(r){if(typeof r!=="object"&&typeof r!=="function"||r===null){return false}return typeof r.then==="function"}class n{_globalGuards=[];_enterGuards=new Map;_leaveGuards=new Map;addGlobalGuard(r){this._globalGuards.push(r)}removeGlobalGuard(r){const e=this._globalGuards.indexOf(r);if(e!==-1){this._globalGuards.splice(e,1)}}addEnterGuard(r,e){this._addToGuardMap(this._enterGuards,r,e)}removeEnterGuard(r,e){this._removeFromGuardMap(this._enterGuards,r,e)}addLeaveGuard(r,e){this._addToGuardMap(this._leaveGuards,r,e)}removeLeaveGuard(r,e){this._removeFromGuardMap(this._leaveGuards,r,e)}clear(){this._globalGuards=[];this._enterGuards.clear();this._leaveGuards.clear()}evaluate(r,e){const t=!e?.skipLeaveGuards&&r.fromRoute!==""&&this._leaveGuards.has(r.fromRoute);const n=this._globalGuards.length>0||r.toRoute!==""&&this._enterGuards.has(r.toRoute);if(!t&&!n){return{action:"allow"}}const u=r=>{if(a(r)){return r.then(r=>{if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}}).catch(r=>({action:"error",error:r}))}if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}};const o=()=>{const e=this._runEnterGuards(r.toRoute,r);return u(e)};try{if(t){const e=this._runLeaveGuards(r);if(a(e)){return e.then(e=>{if(e!==true)return{action:"block"};if(r.signal.aborted)return{action:"block"};return o()}).catch(r=>({action:"error",error:r}))}if(e!==true)return{action:"block"}}return o()}catch(r){return{action:"error",error:r}}}_addToGuardMap(r,e,t){let a=r.get(e);if(!a){a=[];r.set(e,a)}a.push(t)}_removeFromGuardMap(r,e,t){const a=r.get(e);if(!a)return;const n=a.indexOf(t);if(n!==-1)a.splice(n,1);if(a.length===0)r.delete(e)}_runLeaveGuards(t){const n=this._leaveGuards.get(t.fromRoute);if(!n||n.length===0)return true;const u=n.slice();for(let n=0;n<u.length;n++){try{const r=u[n](t);if(a(r)){return this._continueGuardsAsync(r,u,n,t,r=>this._validateLeaveGuardResult(r),"Leave guard",true)}if(r!==true)return this._validateLeaveGuardResult(r)}catch(a){r.error(`Leave guard [${n}] on route "${t.fromRoute}" threw, navigation failed`,a instanceof Error?a:String(a),e);if(t.signal.aborted)return false;throw a}}return true}_runEnterGuards(r,e){const t=this._runGuards(this._globalGuards,e);if(a(t)){return t.then(t=>{if(t!==true)return t;if(e.signal.aborted)return false;return this._runRouteGuards(r,e)})}if(t!==true)return t;return this._runRouteGuards(r,e)}_runRouteGuards(r,e){if(!r||!this._enterGuards.has(r))return true;return this._runGuards(this._enterGuards.get(r),e)}_runGuards(t,n){t=t.slice();for(let u=0;u<t.length;u++){try{const r=t[u](n);if(a(r)){return this._continueGuardsAsync(r,t,u,n,r=>this._validateGuardResult(r),"Enter guard",false)}if(r!==true)return this._validateGuardResult(r)}catch(t){r.error(`Enter guard [${u}] on route "${n.toRoute}" threw, navigation failed`,t instanceof Error?t:String(t),e);if(n.signal.aborted)return false;throw t}}return true}async _continueGuardsAsync(t,a,n,u,o,i,s){let l=n;try{const r=await t;if(r!==true)return o(r);for(let r=n+1;r<a.length;r++){if(u.signal.aborted)return false;l=r;const e=await a[r](u);if(e!==true)return o(e)}return true}catch(t){if(!u.signal.aborted){const a=s?u.fromRoute:u.toRoute;r.error(`${i} [${l}] on route "${a}" threw, navigation failed`,t instanceof Error?t:String(t),e);throw t}return false}}_validateGuardResult(a){if(typeof a==="boolean")return a;if(typeof a==="string"&&a.length>0)return a;if(t(a))return a;r.warning("Guard returned invalid value, treating as block",String(a),e);return false}_validateLeaveGuardResult(t){if(typeof t==="boolean")return t;r.warning("Leave guard returned non-boolean value, treating as block",String(t),e);return false}}n.isPromiseLike=a;return n});
2
+ sap.ui.predefine("ui5/guard/router/GuardConfig", ["sap/base/Log","./GuardPipeline"],function(e,n){"use strict";const t=n["LOG_COMPONENT"];function r(e){if(typeof e!=="object"||e===null||Array.isArray(e))return false;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function i(...e){const n=new Set(e);return e=>typeof e==="string"&&n.has(e)}const o=i("ignore","warn","throw");const u=i("guard","bypass","off");const a=i("block","lazy");const s=i("none","pattern-tree");const g={error:e.Level.ERROR,warning:e.Level.WARNING,info:e.Level.INFO,debug:e.Level.DEBUG};const f=e=>typeof e==="string"&&Object.hasOwn(g,e);function d(e,n){if(e.startsWith("module:")){return e.slice("module:".length).replace(/\./g,"/")}const t=n?n+"."+e:e;return t.replace(/\./g,"/")}function c(e,n){const t=e.indexOf("#");const r=t===-1?e:e.slice(0,t);const i=t===-1?undefined:e.slice(t+1);return{modulePath:d(r,n),exportKey:i}}function l(n,i){if(!r(n)){e.warning("guardRouter.guards is not a plain object, skipping",JSON.stringify(n),t);return[]}const o=[];function u(n,r,u,a){for(const s of n){if(typeof s!=="string"||s.length===0){e.warning(`guardRouter.guards${a}: invalid entry, skipping`,JSON.stringify(s),t);continue}const n=c(s,i);o.push({route:r,type:u,...n})}}for(const[i,o]of Object.entries(n)){if(Array.isArray(o)){u(o,i,"enter",`["${i}"]`)}else if(r(o)){if(i==="*"&&o.leave!==undefined){e.warning('guardRouter.guards["*"].leave: global leave guards are not supported, skipping',undefined,t)}for(const n of Object.keys(o)){if(n==="enter"||n==="leave")continue;e.warning(`guardRouter.guards["${i}"].${n}: unknown key, expected enter or leave, skipping`,undefined,t)}for(const n of["enter","leave"]){const r=o[n];if(r===undefined||i==="*"&&n==="leave")continue;if(!Array.isArray(r)){e.warning(`guardRouter.guards["${i}"].${n}: expected string[], skipping`,JSON.stringify(r),t);continue}if(i==="*"){e.info('guardRouter.guards["*"]: object form; treating enter as global',undefined,t)}u(r,i,n,`["${i}"].${n}`)}}else{e.warning(`guardRouter.guards["${i}"]: expected string[] or { enter?, leave? }, skipping`,JSON.stringify(o),t)}}return o}const p={unknownRouteRegistration:"warn",navToPreflight:"guard",guardLoading:"lazy",inheritance:"none"};function y(n,r,i,o){const u=n[r];if(u===undefined)return;if(i(u)){o[r]=u}else{e.warning(`guardRouter.${r} has invalid value, using default`,JSON.stringify(u),t)}}function v(n){if(n===undefined)return;if(!f(n)){e.error("guardRouter.logLevel has invalid value, ignoring it",JSON.stringify(n),t);return}const r=g[n];if(r>e.getLevel(t))e.setLevel(r,t)}function O(n){if(!r(n)){if(n!==undefined){e.warning("guardRouter config is not a plain object, using defaults",JSON.stringify(n),t)}return p}v(n.logLevel);const i={...p};y(n,"unknownRouteRegistration",o,i);y(n,"navToPreflight",u,i);y(n,"guardLoading",a,i);y(n,"inheritance",s,i);return i}function R(n){const i=new Map;if(n===undefined)return i;if(!r(n)){e.warning("guardRouter.routeMeta: expected object, skipping",JSON.stringify(n),t);return i}for(const[o,u]of Object.entries(n)){if(r(u)){i.set(o,Object.freeze({...u}))}else{e.warning(`guardRouter.routeMeta["${o}"]: expected object, skipping`,JSON.stringify(u),t)}}return i}function w(e,n){const t=O(e);if(!r(e))return{options:t,routeMeta:new Map,guards:[]};return{options:t,routeMeta:R(e.routeMeta),guards:e.guards===undefined?[]:l(e.guards,n)}}var b={__esModule:true};b.isRecord=r;b.parseGuardRouterConfig=w;return b});
3
+ sap.ui.predefine("ui5/guard/router/GuardModules", ["sap/base/Log","./GuardPipeline","./GuardConfig"],function(n,e,t){"use strict";const r=e["isPromiseLike"];const i=e["LOG_COMPONENT"];const u=e["nameGuard"];const o=t["isRecord"];function s(n){return typeof n==="function"}function f(e,t){n.warning(`guardRouter.guards: "${e}" ${t}`,undefined,i)}function a(n){return n.slice(n.lastIndexOf("/")+1)}function d(n){return/^\d+$/.test(n)?Number(n):NaN}function c(e,t,r){const u=a(t);if(s(e)){if(r!==undefined){if(Object.hasOwn(e,r)){const n=Reflect.get(e,r);if(s(n))return[{name:r,fn:n}]}n.debug(`guardRouter.guards: "${t}#${r}" is a single function, ignoring export key`,undefined,i)}return[{name:r??u,fn:e}]}if(Array.isArray(e)){if(e.length===0){f(t,"exported an empty array, skipping");return[]}if(r!==undefined){const n=d(r);if(Number.isNaN(n)||n>=e.length){f(t,`#${r} - index out of range, skipping`);return[]}const i=e[n];if(!s(i)){f(t,`#${r} is not a function, skipping`);return[]}return[{name:`${u}#${r}`,fn:i}]}const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!s(i)){f(t,`[${r}] is not a function, skipping`);continue}n.push({name:`${u}#${r}`,fn:i})}return n}if(o(e)){const n=Object.entries(e).filter(([n])=>n!=="__esModule");if(n.length===0){f(t,"exported an empty object, skipping");return[]}if(r!==undefined){const i=Object.hasOwn(e,r)?[r,e[r]]:n[d(r)];if(i===undefined){f(t,`#${r} - key not found, skipping`);return[]}const[u,o]=i;if(!s(o)){f(t,`#${r} is not a function, skipping`);return[]}return[{name:u,fn:o}]}const i=[];for(const[e,r]of n){if(!s(r)){f(t,`.${e} is not a function, skipping`);continue}i.push({name:e,fn:r})}return i}f(t,"did not export a function, array, or plain object, skipping");return[]}function p(n,e,t){return c(n,e,t).map(({name:n,fn:e})=>{u(e,n);return e})}function l(n,e){for(let t=0;t<n.length;t++){const i=n[t](e);if(r(i))return g(i,n.slice(t+1),e);if(i!==true)return i}return true}async function g(n,e,t){const r=await n;if(r!==true)return r;if(t.signal.aborted)return false;return l(e,t)}function m(e,t){return new Promise((r,u)=>{sap.ui.require([e],r,e=>{n.warning(`guardRouter.guards: ${t}`,String(e),i);u(e)})})}function $(n){return Promise.all(n.map(async n=>{const{modulePath:e,exportKey:t}=n;const r=await m(e,`failed to load module "${e}", skipping`).then(n=>p(n,e,t),()=>[]);return{descriptor:n,guards:r}}))}function y(n){const{modulePath:e,exportKey:t}=n;const r=a(e);if(t===undefined){const n=sap.ui.require(e);if(n!==undefined)return p(n,e)}let i;const o=(n,r)=>{if(i===undefined){const r=c(n,e,t);if(r.length===1)u(s,r[0].name);i=r.map(n=>n.fn)}return l(i,r)};const s=n=>{const t=sap.ui.require(e);if(t!==undefined)return o(t,n);return m(e,`lazy load of "${e}" failed`).then(e=>n.signal.aborted?false:o(e,n))};u(s,t===undefined?r:`${r}#${t}`);return[s]}var h={__esModule:true};h.resolveModuleExports=c;h.runGuardsInOrder=l;h.loadGuardModules=$;h.createLazyGuards=y;return h});
4
+ sap.ui.predefine("ui5/guard/router/GuardPipeline", ["sap/base/Log"],function(r){"use strict";const e="ui5.guard.router.Router";function t(r){if(typeof r!=="object"||r===null){return false}return"route"in r&&typeof r.route==="string"&&r.route.length>0}function n(r){if(typeof r!=="object"&&typeof r!=="function"||r===null){return false}return"then"in r&&typeof r.then==="function"}let a;void new Promise(r=>{a=Function.prototype.toString.call(r)});function u(r){return typeof r==="function"&&r.name===""&&r.length===1&&Function.prototype.toString.call(r)===a}const i=new WeakMap;function o(r,e){i.set(r,e)}function s(r,e,t){const n=i.get(t);return n===undefined?`${r} [${e}]`:`${r} [${e}] "${n}"`}function l(r){if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}}function d(r){return{action:"error",error:r}}class c{_globalGuards=[];_enterGuards=new Map;_leaveGuards=new Map;addGlobalGuard(r){this._globalGuards.push(r)}removeGlobalGuard(r){const e=this._globalGuards.indexOf(r);if(e!==-1){this._globalGuards.splice(e,1)}}addEnterGuard(r,e,t){this._addToGuardMap(this._enterGuards,r,e,t)}removeEnterGuard(r,e){this._removeFromGuardMap(this._enterGuards,r,e)}addLeaveGuard(r,e,t){this._addToGuardMap(this._leaveGuards,r,e,t)}removeLeaveGuard(r,e){this._removeFromGuardMap(this._leaveGuards,r,e)}clear(){this._globalGuards=[];this._enterGuards.clear();this._leaveGuards.clear()}evaluate(r,e){const t=e?.skipLeaveGuards||r.fromRoute===""?[]:[r.fromRoute,...e?.alsoLeaving??[]];const a=[r.toRoute,...e?.alsoEntering??[]];const u=()=>{const e=this._runEnterGuards(a,r);return n(e)?e.then(l).catch(d):l(e)};try{const e=this._runForEach(t,r,e=>this._runGuards(this._leaveGuards.get(e)??[],r,e,r=>this._validateLeaveGuardResult(r),"Leave guard"));if(n(e)){return e.then(e=>{if(e!==true)return{action:"block"};if(r.signal.aborted)return{action:"block"};return u()}).catch(d)}if(e!==true)return{action:"block"};return u()}catch(r){return d(r)}}_addToGuardMap(r,e,t,n){let a=r.get(e);if(!a){a=[];r.set(e,a)}const u=n===undefined?-1:a.indexOf(n);if(u===-1)a.push(t);else a.splice(u,0,t)}_removeFromGuardMap(r,e,t){const n=r.get(e);if(!n)return;const a=n.indexOf(t);if(a!==-1)n.splice(a,1);if(n.length===0)r.delete(e)}_runForEach(r,e,t,a=0){for(let u=a;u<r.length;u++){const a=t(r[u]);if(n(a)){return a.then(n=>{if(n!==true)return n;if(e.signal.aborted)return false;return this._runForEach(r,e,t,u+1)})}if(a!==true)return a}return true}_runEnterGuards(r,e){const t=()=>this._runForEach(r,e,r=>this._runRouteGuards(r,e));const a=this._runGuards(this._globalGuards,e,e.toRoute,r=>this._validateGuardResult(r),"Enter guard");if(n(a)){return a.then(r=>{if(r!==true)return r;if(e.signal.aborted)return false;return t()})}if(a!==true)return a;return t()}_runRouteGuards(r,e){const t=r?this._enterGuards.get(r):undefined;if(!t)return true;return this._runGuards(t,e,r,r=>this._validateGuardResult(r),"Enter guard")}_runGuards(t,a,u,i,o){t=t.slice();for(let l=0;l<t.length;l++){try{const r=t[l](a);if(n(r)){return this._continueGuardsAsync(r,t,l,a,i,o,u)}if(r!==true)return i(r)}catch(n){if(a.signal.aborted)return false;r.error(`${s(o,l,t[l])} on route "${u}" threw, navigation failed`,n instanceof Error?n:String(n),e);throw n}}return true}async _continueGuardsAsync(t,n,a,u,i,o,l){let d=a;try{const r=await t;if(r!==true)return i(r);for(let r=a+1;r<n.length;r++){if(u.signal.aborted)return false;d=r;const e=await n[r](u);if(e!==true)return i(e)}return true}catch(t){if(!u.signal.aborted){r.error(`${s(o,d,n[d])} on route "${l}" threw, navigation failed`,t instanceof Error?t:String(t),e);throw t}return false}}_validateGuardResult(n){if(typeof n==="boolean")return n;if(typeof n==="string"&&n.length>0)return n;if(t(n))return n;r.warning("Guard returned invalid value, treating as block",String(n),e);return false}_validateLeaveGuardResult(t){if(typeof t==="boolean")return t;r.warning("Leave guard returned non-boolean value, treating as block",String(t),e);return false}}c.LOG_COMPONENT=e;c.isPromiseLike=n;c.isPromiseResolver=u;c.nameGuard=o;return c});
3
5
  sap.ui.predefine("ui5/guard/router/NavigationOutcome", [],function(){"use strict";const e=Object.freeze({Committed:"committed",Bypassed:"bypassed",Blocked:"blocked",Redirected:"redirected",Cancelled:"cancelled",Error:"error"});return e});
4
- sap.ui.predefine("ui5/guard/router/Router", ["sap/m/routing/Router","sap/base/Log","sap/ui/core/library","./NavigationOutcome","./GuardPipeline"],function(t,e,i,n,r){"use strict";function s(t){return t&&t.__esModule&&typeof t.default!=="undefined"?t.default:t}const o=s(n);const a=s(r);const u=r["isPromiseLike"];const h=i.routing.HistoryDirection;const c="ui5.guard.router.Router";function d(t){return typeof t==="object"&&t!==null}const f={kind:"idle"};function l(t){if(typeof t!=="object"||t===null||Array.isArray(t))return false;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function p(...t){const e=new Set(t);return t=>typeof t==="string"&&e.has(t)}const g=p("ignore","warn","throw");const _=p("guard","bypass","off");const m=p("block","lazy");const v=p("none","pattern-tree");const y=/^:[^:]*\*?:$/;function R(t){const e=t.indexOf("{?");if(e!==-1)return t.slice(0,e);const i=t.indexOf(":?");if(i!==-1)return t.slice(0,i);return t}function b(t){return t.split("/").map(R).filter(t=>t!==""&&!y.test(t))}function k(t,e){if(t==="")return true;const i=b(t);if(i.length===0)return false;const n=b(e);if(n.length<=i.length)return false;return i.every((t,e)=>{const i=n[e];if(t===i)return true;return t.startsWith("{")&&i.startsWith("{")})}function G(t,e){if(t.startsWith("module:")){return t.slice("module:".length).replace(/\./g,"/")}const i=e?e+"."+t:t;return i.replace(/\./g,"/")}function w(t,e){const i=t.indexOf("#");const n=i===-1?t:t.slice(0,i);const r=i===-1?undefined:t.slice(i+1);const s=G(n,e);const o=n.split(".").pop()??n;const a=r??o;return{modulePath:s,name:a,exportKey:r}}function H(t,i){e.warning(`guardRouter.guards: "${t}" ${i}`,undefined,c)}function M(t,i,n,r){const s=i.split("/").pop()??i;if(typeof t==="function"){if(r!==undefined){e.debug(`guardRouter.guards: "${i}#${r}" is a single function, ignoring export key`,undefined,c)}return[{name:n,fn:t}]}if(Array.isArray(t)){if(t.length===0){H(i,"exported an empty array, skipping");return[]}if(r!==undefined){const e=parseInt(r,10);if(Number.isNaN(e)||e<0||e>=t.length){H(i,`#${r} - index out of range, skipping`);return[]}const n=t[e];if(typeof n!=="function"){H(i,`#${r} is not a function, skipping`);return[]}return[{name:`${s}#${r}`,fn:n}]}const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(typeof r!=="function"){H(i,`[${n}] is not a function, skipping`);continue}e.push({name:`${s}#${n}`,fn:r})}return e}if(l(t)){const e=Object.entries(t);if(e.length===0){H(i,"exported an empty object, skipping");return[]}if(r!==undefined){let n=t[r];let s=r;if(n===undefined){const t=parseInt(r,10);if(!Number.isNaN(t)&&t>=0&&t<e.length){const[i,r]=e[t];n=r;s=i}}if(n===undefined){H(i,`#${r} - key not found, skipping`);return[]}if(typeof n!=="function"){H(i,`#${r} is not a function, skipping`);return[]}return[{name:s,fn:n}]}const n=[];for(const[t,r]of e){if(typeof r!=="function"){H(i,`.${t} is not a function, skipping`);continue}n.push({name:t,fn:r})}return n}H(i,"did not export a function, array, or plain object, skipping");return[]}function N(t,i){if(!l(t)){e.warning("guardRouter.guards is not a plain object, skipping",JSON.stringify(t),c);return[]}const n=[];function r(t,r,s,o){for(const a of t){if(typeof a!=="string"||a.length===0){e.warning(`guardRouter.guards${o}: invalid entry, skipping`,JSON.stringify(a),c);continue}const t=w(a,i);n.push({route:r,type:s,...t})}}for(const[i,n]of Object.entries(t)){if(Array.isArray(n)){r(n,i,"enter",`["${i}"]`)}else if(l(n)){const t=n;if(i==="*"&&t.leave!==undefined){e.warning('guardRouter.guards["*"].leave: global leave guards are not supported, skipping',undefined,c)}if(i==="*"&&t.enter===undefined&&t.leave!==undefined){continue}if(i==="*"&&t.enter!==undefined){e.info('guardRouter.guards["*"]: object form; treating enter as global',undefined,c)}if(Array.isArray(t.enter)){r(t.enter,i,"enter",`["${i}"].enter`)}if(i!=="*"&&Array.isArray(t.leave)){r(t.leave,i,"leave",`["${i}"].leave`)}}else{e.warning(`guardRouter.guards["${i}"]: expected string[] or { enter?, leave? }, skipping`,JSON.stringify(n),c)}}return n}const P={unknownRouteRegistration:"warn",navToPreflight:"guard",guardLoading:"lazy",inheritance:"none"};function S(t,i,n,r){if(t[i]!==undefined){if(n(t[i])){r[i]=t[i]}else{e.warning(`guardRouter.${i} has invalid value, using default`,JSON.stringify(t[i]),c)}}}function $(t){if(!l(t)){if(t!==undefined){e.warning("guardRouter config is not a plain object, using defaults",JSON.stringify(t),c)}return P}const i={...P};S(t,"unknownRouteRegistration",g,i);S(t,"navToPreflight",_,i);S(t,"guardLoading",m,i);S(t,"inheritance",v,i);return i}const D=10;const O=t.extend("ui5.guard.router.Router",{constructor:function i(...n){const[r,s,o,...u]=n;const h=s;const d=l(h);const{guardRouter:p,...g}=d?h:{};t.prototype.constructor.apply(this,[r,d?g:s,o,...u]);this._options=P;this._pipeline=new a;this._currentRoute="";this._currentHash=null;this._phase=f;this._parseGeneration=0;this._suppressedHash=null;this._settlementResolvers=[];this._lastSettlement=null;this._pendingGuardDescriptors=[];this._sourceDescriptors=[];this._destroyed=false;this._manifestMeta=new Map;this._runtimeMeta=new Map;this._resolvedMetaCache=new Map;this._routeNames=[];this._options=$(p);if(Array.isArray(r)){this._routeNames=r.filter(t=>l(t)&&typeof t.name==="string").map(t=>t.name)}else if(l(r)){this._routeNames=Object.keys(r)}if(l(p)&&p.routeMeta!==undefined){if(l(p.routeMeta)){for(const[t,i]of Object.entries(p.routeMeta)){if(l(i)){this._manifestMeta.set(t,Object.freeze({...i}))}else{e.warning(`guardRouter.routeMeta["${t}"]: expected object, skipping`,JSON.stringify(i),c)}}}else{e.warning("guardRouter.routeMeta: expected object, skipping",JSON.stringify(p.routeMeta),c)}}if(l(p)&&p.guards!==undefined){let t="";if(o){const e=o.getManifestEntry("sap.app");if(l(e)&&typeof e.id==="string"){t=e.id}}this._pendingGuardDescriptors=N(p.guards,t);if(this._pendingGuardDescriptors.length>0&&this._options.guardLoading==="lazy"){const t=[...new Set(this._pendingGuardDescriptors.map(t=>t.modulePath))];sap.ui.require(t)}}},initialize:function i(){if(this._pendingGuardDescriptors.length===0){return t.prototype.initialize.call(this)}const n=this._pendingGuardDescriptors;this._pendingGuardDescriptors=[];this._sourceDescriptors=n;const r=this._options.inheritance==="pattern-tree"?this._expandGuardDescriptors(n):n;if(this._options.guardLoading==="lazy"){this._registerLazyGuards(r);return t.prototype.initialize.call(this)}this._loadAndRegisterGuards(r).then(()=>{if(!this._destroyed)t.prototype.initialize.call(this)}).catch(i=>{if(this._destroyed)return;e.error("guardRouter.guards: module loading failed, initializing without manifest guards",String(i),c);t.prototype.initialize.call(this)});return this},addRoute:function e(i,...n){t.prototype.addRoute.apply(this,[i,...n]);if(!this._routeNames)return;const r=i.name;if(typeof r!=="string")return;if(this._routeNames.includes(r))return;this._routeNames.push(r);this._resolvedMetaCache.clear();if(this._options.inheritance!=="pattern-tree")return;if(this._sourceDescriptors.length===0)return;const s=this.getRoute(r);if(!s)return;const o=s.getPattern();if(o===undefined)return;const a=this._expandGuardDescriptorsForNewRoute(r,o);if(a.length===0)return;this._registerLazyGuards(a)},_expandGuardDescriptorsForNewRoute:function t(e,i){const n=[];for(const t of this._sourceDescriptors){if(t.route==="*")continue;if(t.route!==e){const r=this.getRoute(t.route);const s=r?.getPattern();if(s!==undefined&&k(s,i)){n.push({...t,route:e})}}else{for(const{name:r,pattern:s}of this._collectRoutePatterns()){if(r===e)continue;if(k(i,s)){n.push({...t,route:r})}}}}return n.toSorted((t,e)=>{const i=this.getRoute(t.route)?.getPattern()??"";const n=this.getRoute(e.route)?.getPattern()??"";return b(i).length-b(n).length})},addGuard:function t(e){if(!this._isFn(e,"addGuard"))return this;this._pipeline.addGlobalGuard(e);return this},removeGuard:function t(e){if(!this._isFn(e,"removeGuard"))return this;this._pipeline.removeGlobalGuard(e);return this},addRouteGuard:function t(i,n){if(d(n)){if(!this._handleUnknownRouteRegistration(i,"addRouteGuard")){return this}let t=false;if(n.beforeEnter!==undefined){t=true;if(this._isFn(n.beforeEnter,"addRouteGuard",i)){this._pipeline.addEnterGuard(i,n.beforeEnter)}}if(n.beforeLeave!==undefined){t=true;if(this._isFn(n.beforeLeave,"addRouteGuard",i)){this._pipeline.addLeaveGuard(i,n.beforeLeave)}}if(!t){e.info("addRouteGuard: config has no beforeEnter or beforeLeave",i,c);return this}return this}if(!this._isFn(n,"addRouteGuard",i))return this;if(!this._handleUnknownRouteRegistration(i,"addRouteGuard")){return this}this._pipeline.addEnterGuard(i,n);return this},removeRouteGuard:function t(e,i){if(d(i)){if(typeof i.beforeEnter==="function"){this.removeRouteGuard(e,i.beforeEnter)}if(typeof i.beforeLeave==="function"){this.removeLeaveGuard(e,i.beforeLeave)}return this}if(!this._isFn(i,"removeRouteGuard",e))return this;this._pipeline.removeEnterGuard(e,i);return this},addLeaveGuard:function t(e,i){if(!this._isFn(i,"addLeaveGuard",e))return this;if(!this._handleUnknownRouteRegistration(e,"addLeaveGuard")){return this}this._pipeline.addLeaveGuard(e,i);return this},_resolveNavToArgs:function t(e,i,n){if(typeof e==="boolean"){return{replace:e,guardOptions:typeof i==="object"&&i!==null?i:undefined}}return{componentTargetInfo:e,replace:typeof i==="boolean"?i:undefined,guardOptions:n}},_isFn:function t(i,n,r){if(typeof i==="function")return true;e.warning(`${n}: not a function, ignoring`,r,c);return false},_handleUnknownRouteRegistration:function t(i,n){if(this.getRoute(i))return true;switch(this._options.unknownRouteRegistration){case"ignore":return true;case"throw":throw new Error(`${n} called for unknown route "${i}". `+`Set guardRouter.unknownRouteRegistration to "warn" or "ignore" to allow this.`);case"warn":default:e.warning(`${n}: unknown route, guard registered anyway`,i,c);return true}},removeLeaveGuard:function t(e,i){if(!this._isFn(i,"removeLeaveGuard",e))return this;this._pipeline.removeLeaveGuard(e,i);return this},getRouteMeta:function t(i){if(i!==""&&!this.getRoute(i)){e.warning("getRouteMeta: unknown route, returning empty metadata",i,c);return O._EMPTY_META}const n=this._resolvedMetaCache.get(i);if(n)return n;let r;if(this._options.inheritance==="pattern-tree"){r=this._resolveInheritedMeta(i)}else{r=this._resolveFlatMeta(i)}if(Object.keys(r).length===0){this._resolvedMetaCache.set(i,O._EMPTY_META);return O._EMPTY_META}this._resolvedMetaCache.set(i,r);return r},setRouteMeta:function t(i,n){if(!l(n)){e.warning("setRouteMeta: expected object, ignoring",i,c);return this}if(i!==""&&!this._handleUnknownRouteRegistration(i,"setRouteMeta")){return this}this._runtimeMeta.set(i,Object.freeze({...n}));this._resolvedMetaCache.clear();return this},navigationSettled:function t(){if(this._phase.kind!=="evaluating"){return Promise.resolve(this._lastSettlement??{status:o.Committed,route:this._currentRoute,hash:this._currentHash??""})}return new Promise(t=>{this._settlementResolvers.push(t)})},attachNavigationSettled:function t(e,i,n){this.attachEvent("navigationSettled",e,i,n);return this},detachNavigationSettled:function t(e,i){this.detachEvent("navigationSettled",e,i);return this},_flushSettlement:function t(e){this._lastSettlement=e;const i=this._settlementResolvers;this._settlementResolvers=[];for(const t of i){t(e)}this.fireEvent("navigationSettled",e)},navTo:function i(n,r,s,o,a){const{componentTargetInfo:h,replace:d,guardOptions:f}=this._resolveNavToArgs(s,o,a);if(this._phase.kind==="committing"&&this._phase.origin==="redirect"){t.prototype.navTo.call(this,n,r,h,d);return this}const l=this.getRoute(n);if(!l){this._cancelPendingNavigation();t.prototype.navTo.call(this,n,r,h,d);return this}const p=l.getURL(r??{});const g=this.getRouteInfoByHash(p);const _=g?.name??"";if(this._currentHash!==null&&p===this._currentHash){this._cancelPendingNavigation();return this}if(this._phase.kind==="evaluating"&&p===this._phase.attempt.hash){return this}this._cancelPendingNavigation();const m=f?.skipGuards===true;if(m||this._options.navToPreflight==="bypass"){this._phase={kind:"committing",hash:p,route:_,origin:"preflight"};t.prototype.navTo.call(this,n,r,h,d);if(this._phase.kind==="committing"&&this._phase.hash===p){this._commitNavigation(p,_)}return this}if(this._options.navToPreflight==="off"){t.prototype.navTo.call(this,n,r,h,d);return this}const v=new AbortController;const y=this._parseGeneration;this._phase={kind:"evaluating",attempt:{hash:p,route:_,controller:v,generation:y}};const R=this._createGuardContext(_,p,g,v.signal);const b=this._pipeline.evaluate(R);if(u(b)){b.then(t=>{if(y!==this._parseGeneration||this._phase.kind!=="evaluating"){e.debug("Async preflight result discarded (superseded by newer navigation)",p,c);return}this._applyPreflightDecision(t,n,r,h,d,p,_,R.bag)}).catch(t=>{if(y!==this._parseGeneration)return;e.error(`Async preflight guard failed for route "${n}", navigation failed`,String(t),c);this._errorNavigation(t,p,false)});return this}this._applyPreflightDecision(b,n,r,h,d,p,_,R.bag);return this},_applyPreflightDecision:function e(i,n,r,s,o,a,u,h){switch(i.action){case"allow":this._phase={kind:"committing",hash:a,route:u,origin:"preflight"};t.prototype.navTo.call(this,n,r,s,o);if(this._phase.kind==="committing"&&this._phase.hash===a){this._commitNavigation(a,u)}break;case"block":this._blockNavigation(a,false);break;case"redirect":this._startRedirectChain(i.target,a,false,h);break;case"error":this._errorNavigation(i.error,a,false);break}},parse:function t(i){if(this._suppressedHash!==null){if(i===this._suppressedHash){this._suppressedHash=null;return}this._suppressedHash=null}if(this._phase.kind==="committing"){this._commitNavigation(i,this._phase.route!==""?this._phase.route:this.getRouteInfoByHash(i)?.name??"");return}if(this._currentHash!==null&&i===this._currentHash){this._cancelPendingNavigation();return}const n=this.getRouteInfoByHash(i);const r=n?.name??"";this._cancelPendingNavigation();const s=new AbortController;const o=this._parseGeneration;this._phase={kind:"evaluating",attempt:{hash:i,route:r,controller:s,generation:o}};const a=this._createGuardContext(r,i,n,s.signal);const h=this._pipeline.evaluate(a);if(u(h)){h.then(t=>{if(o!==this._parseGeneration||this._phase.kind!=="evaluating"){e.debug("Async guard result discarded (superseded by newer navigation)",i,c);return}this._applyDecision(t,i,r,a.bag)}).catch(t=>{if(o!==this._parseGeneration)return;e.error(`Guard pipeline failed for "${i}", navigation failed`,String(t),c);this._errorNavigation(t,i)});return}this._applyDecision(h,i,r,a.bag)},stop:function e(){this._cancelPendingNavigation();this._suppressedHash=null;this._currentRoute="";this._currentHash=null;this._lastSettlement=null;t.prototype.stop.call(this);return this},_cancelPendingNavigation:function t(){++this._parseGeneration;if(this._phase.kind==="evaluating"){this._phase.attempt.controller.abort();this._flushSettlement({status:o.Cancelled,route:this._currentRoute,hash:this._currentHash??""})}this._phase=f},_applyDecision:function t(e,i,n,r){switch(e.action){case"allow":this._phase={kind:"committing",hash:i,route:n,origin:"parse"};this._commitNavigation(i,n);break;case"block":this._blockNavigation(i);break;case"redirect":this._startRedirectChain(e.target,i,true,r);break;case"error":this._errorNavigation(e.error,i);break}},_commitNavigation:function e(i,n){const r=this._phase.kind==="committing"&&this._phase.origin==="redirect";this._currentHash=i;this._currentRoute=n??this.getRouteInfoByHash(i)?.name??"";this._phase=f;this._flushSettlement({status:r?o.Redirected:this._currentRoute===""?o.Bypassed:o.Committed,route:this._currentRoute,hash:i});t.prototype.parse.call(this,i)},_redirect:function t(i,n){const r=typeof i==="string"?i:i.route;let s=null;const o=typeof i==="string"?{}:i.parameters??{};const a=this.getRoute(r);if(a){try{s=a.getURL(o)}catch{s=null}}if(s!==null&&n.visited.has(s)){e.error(`Guard redirect loop detected: ${[...n.visited,s].join(" -> ")}`,undefined,c);this._blockNavigation(n.attemptedHash,n.restoreHash);return}if(n.visited.size>D){e.error(`Guard redirect chain exceeded maximum depth (${D}): ${[...n.visited].join(" -> ")}`,undefined,c);this._blockNavigation(n.attemptedHash,n.restoreHash);return}if(s!==null){n.visited.add(s)}if(s===null){const t=this._lastSettlement;this._phase={kind:"committing",hash:"",route:r,origin:"redirect"};try{if(typeof i==="string"){this.navTo(i,{},{},true)}else{this.navTo(i.route,i.parameters??{},i.componentTargetInfo,true)}}finally{if(this._phase.kind==="committing"){this._phase=f}}if(this._lastSettlement===t){e.warning(`Guard redirect target "${r}" did not produce a navigation, treating as blocked`,undefined,c);this._blockNavigation(n.attemptedHash,n.restoreHash)}return}const h=s;const d=this.getRouteInfoByHash(h);const l={toRoute:d?.name??"",toHash:h,toArguments:d?.arguments??{},fromRoute:n.fromRoute,fromHash:n.fromHash,signal:n.signal,bag:n.bag,toMeta:this.getRouteMeta(d?.name??""),fromMeta:this.getRouteMeta(n.fromRoute)};const p=this._pipeline.evaluate(l,{skipLeaveGuards:true});if(u(p)){p.then(t=>{if(n.generation!==this._parseGeneration)return;this._applyRedirectDecision(t,i,h,n)}).catch(t=>{if(n.generation!==this._parseGeneration)return;e.error(`Guard pipeline failed during redirect chain for "${r}", navigation failed`,String(t),c);this._errorNavigation(t,n.attemptedHash,n.restoreHash)});return}this._applyRedirectDecision(p,i,h,n)},_applyRedirectDecision:function t(i,n,r,s){switch(i.action){case"allow":{const t=typeof n==="string"?n:n.route;const i=this._lastSettlement;this._phase={kind:"committing",hash:r,route:t,origin:"redirect"};try{if(typeof n==="string"){this.navTo(n,{},{},true)}else{this.navTo(n.route,n.parameters??{},n.componentTargetInfo,true)}}finally{if(this._phase.kind==="committing"){this._phase=f}}if(this._lastSettlement===i){const i=r===(this._currentHash??"");if(i){this._phase={kind:"committing",hash:this._currentHash??"",route:this._currentRoute,origin:"redirect"};this._commitNavigation(this._currentHash??"",this._currentRoute);return}e.warning(`Guard redirect target "${t}" did not produce a navigation, treating as blocked`,undefined,c);this._blockNavigation(s.attemptedHash,s.restoreHash)}break}case"block":this._blockNavigation(s.attemptedHash,s.restoreHash);break;case"redirect":this._redirect(i.target,s);break;case"error":this._errorNavigation(i.error,s.attemptedHash,s.restoreHash);break}},_createGuardContext:function t(e,i,n,r){return{toRoute:e,toHash:i,toArguments:n?.arguments??{},fromRoute:this._currentRoute,fromHash:this._currentHash??"",signal:r,bag:new Map,toMeta:this.getRouteMeta(e),fromMeta:this.getRouteMeta(this._currentRoute)}},_startRedirectChain:function t(e,i,n,r){const{attempt:s}=this._phase;const o=new Set;o.add(i);this._redirect(e,{visited:o,attemptedHash:i,restoreHash:n,fromRoute:this._currentRoute,fromHash:this._currentHash??"",signal:s.controller.signal,generation:s.generation,bag:r})},_blockNavigation:function t(e,i=true){this._phase=f;this._flushSettlement({status:o.Blocked,route:this._currentRoute,hash:this._currentHash??""});this._restoreHashIfNeeded(e,i)},_errorNavigation:function t(e,i,n=true){this._phase=f;this._flushSettlement({status:o.Error,route:this._currentRoute,hash:this._currentHash??"",error:e});this._restoreHashIfNeeded(i,n)},_restoreHashIfNeeded:function t(e,i){if(!i)return;if(this._currentHash===null&&e&&e!==""){this._restoreHash("",false);return}this._restoreHash(this._currentHash??"")},_restoreHash:function t(e,i=true){const n=this.getHashChanger();if(n){this._suppressedHash=i?e:null;n.replaceHash(e,h.Unknown);if(this._suppressedHash===e){this._suppressedHash=null}}},_collectRoutePatterns:function t(){const e=[];for(const t of this._routeNames){const i=this.getRoute(t);if(i){const n=i.getPattern();if(n!==undefined){e.push({name:t,pattern:n})}}}return e},_expandGuardDescriptors:function t(e){const i=this._collectRoutePatterns();if(i.length===0)return e;const n=new Map(i.map(t=>[t.name,t.pattern]));const r=[];for(const t of e){r.push(t);if(t.route==="*")continue;const e=n.get(t.route);if(e===undefined)continue;for(const{name:n,pattern:s}of i){if(n===t.route)continue;if(k(e,s)){r.push({...t,route:n})}}}return r.toSorted((t,e)=>{if(t.route==="*"||e.route==="*")return 0;const i=n.get(t.route)??"";const r=n.get(e.route)??"";return b(i).length-b(r).length})},_resolveFlatMeta:function t(e){const i=this._manifestMeta.get(e);const n=this._runtimeMeta.get(e);if(!i&&!n)return O._EMPTY_META;if(!n)return i;if(!i)return n;return Object.freeze({...i,...n})},_resolveInheritedMeta:function t(e){const i=this._collectRoutePatterns();const n=i.find(t=>t.name===e);if(!n)return this._resolveFlatMeta(e);const r=i.filter(t=>t.name!==e&&(this._manifestMeta.has(t.name)||this._runtimeMeta.has(t.name))&&k(t.pattern,n.pattern));r.sort((t,e)=>b(t.pattern).length-b(e.pattern).length);const s={};for(const t of r){const e=this._manifestMeta.get(t.name);if(e)Object.assign(s,e);const i=this._runtimeMeta.get(t.name);if(i)Object.assign(s,i)}const o=this._manifestMeta.get(e);if(o)Object.assign(s,o);const a=this._runtimeMeta.get(e);if(a)Object.assign(s,a);if(Object.keys(s).length===0)return O._EMPTY_META;return Object.freeze(s)},_loadAndRegisterGuards:function t(i){const n=i.map(t=>new Promise(i=>{sap.ui.require([t.modulePath],e=>{i({descriptor:t,moduleExport:e})},n=>{e.warning(`guardRouter.guards: failed to load module "${t.modulePath}", skipping`,String(n),c);i({descriptor:t,moduleExport:null})})}));return Promise.all(n).then(t=>{for(const{descriptor:i,moduleExport:n}of t){if(n===null)continue;const t=M(n,i.modulePath,i.name,i.exportKey);for(const{fn:n}of t){try{this._registerGuardFromDescriptor(i,n)}catch(t){e.error(`guardRouter.guards: failed to register "${i.modulePath}"`,String(t),c)}}}})},_registerGuardFromDescriptor:function t(e,i){if(e.route==="*"){this.addGuard(i)}else if(e.type==="leave"){if(!this._handleUnknownRouteRegistration(e.route,"addLeaveGuard"))return;this._pipeline.addLeaveGuard(e.route,i)}else{this.addRouteGuard(e.route,i)}},_registerLazyGuards:function t(i){for(const t of i){const{modulePath:i,exportKey:n,name:r}=t;if(n!==undefined){const s=t=>{const s=sap.ui.require(i);if(s!==undefined){const e=M(s,i,r,n);if(e.length===0)return true;return e[0].fn(t)}return new Promise((s,o)=>{sap.ui.require([i],e=>{const o=M(e,i,r,n);if(o.length===0){s(true);return}s(o[0].fn(t))},t=>{e.warning(`guardRouter.guards: lazy load of "${i}" failed`,String(t),c);o(t)})})};this._registerGuardFromDescriptor(t,s);continue}const s=sap.ui.require(i);if(s!==undefined){const e=M(s,i,r);for(const i of e){this._registerGuardFromDescriptor(t,i.fn)}continue}let o=false;const a=n=>new Promise((s,a)=>{sap.ui.require([i],e=>{const a=M(e,i,r);if(a.length===0){s(true);return}if(!o){o=true;for(let e=1;e<a.length;e++){this._registerGuardFromDescriptor(t,a[e].fn)}}s(a[0].fn(n))},t=>{e.warning(`guardRouter.guards: lazy load of "${i}" failed`,String(t),c);a(t)})});this._registerGuardFromDescriptor(t,a)}},destroy:function e(){this._destroyed=true;this._pipeline.clear();this._pendingGuardDescriptors=[];this._sourceDescriptors=[];this._cancelPendingNavigation();this._suppressedHash=null;this._lastSettlement=null;this._manifestMeta.clear();this._runtimeMeta.clear();this._resolvedMetaCache.clear();t.prototype.destroy.call(this);return this}});O._EMPTY_META=Object.freeze({});return O});
5
- sap.ui.predefine("ui5/guard/router/library", ["sap/ui/core/Lib","sap/ui/base/DataType","sap/ui/core/library","sap/m/library","./NavigationOutcome"],function(e,i,r,t,u){"use strict";function a(e){return e&&e.__esModule&&typeof e.default!=="undefined"?e.default:e}const n=a(u);const o=e.init({apiVersion:2,name:"ui5.guard.router",version:"1.6.2",dependencies:["sap.ui.core","sap.m"],types:["ui5.guard.router.NavigationOutcome"],interfaces:[],controls:[],elements:[],noLibraryCSS:true});i.registerEnum("ui5.guard.router.NavigationOutcome",n);return o});
6
+ sap.ui.predefine("ui5/guard/router/PatternTree", [],function(){"use strict";const t=/^:[^:]*:$/;function e(t){const e=t.indexOf("{?");if(e!==-1)return t.slice(0,e);const n=t.indexOf(":?");if(n!==-1)return t.slice(0,n);return t}function n(n){return n.split("/").map(e).filter(e=>e!==""&&!t.test(e))}function r(t,e){if(t==="")return true;const r=n(t);if(r.length===0)return false;const o=n(e);if(o.length<=r.length)return false;return r.every((t,e)=>{const n=o[e];if(t===n)return true;return t.startsWith("{")&&n.startsWith("{")})}function o(t,e){return n(e.get(t)??"").length}function u(t,e){return t.toSorted((t,n)=>o(t.route,e)-o(n.route,e))}function i(t,e){if(e.length===0)return t;const n=new Map(e.map(t=>[t.name,t.pattern]));const o=[];for(const i of u(t,n)){o.push(i);if(i.route==="*")continue;const t=n.get(i.route);if(t===undefined)continue;for(const{name:n,pattern:u}of e){if(n!==i.route&&r(t,u)){o.push({...i,route:n})}}}return o}function s(t,e,n){const o=new Map(n.map(t=>[t.name,t.pattern]));const i=o.get(e);if(i===undefined)return[];const s=[];for(const f of u(t,o)){if(f.route==="*")continue;if(f.route===e){for(const{name:t,pattern:o}of n){if(t!==e&&r(i,o)){s.push({...f,route:t})}}}else{const t=o.get(f.route);if(t!==undefined&&r(t,i)){s.push({...f,route:e})}}}return s}var f={__esModule:true};f.patternSegments=n;f.isPatternAncestor=r;f.byRouteDepth=u;f.expandToDescendants=i;f.expandForNewRoute=s;return f});
7
+ sap.ui.predefine("ui5/guard/router/RouteMeta", ["./PatternTree"],function(e){"use strict";const t=e["isPatternAncestor"];const s=e["patternSegments"];const r=Object.freeze({});class n{_runtime=new Map;_resolved=new Map;constructor(e,t){this._manifest=e;this._routes=t}get(e){let t=this._resolved.get(e);if(t===undefined){t=this._routes?this._resolveInherited(e,this._routes()):this._resolveOwn(e);if(Object.keys(t).length===0)t=r;this._resolved.set(e,t)}return t}set(e,t){this._runtime.set(e,Object.freeze({...t}));this._resolved.clear()}invalidate(){this._resolved.clear()}clear(){this._manifest.clear();this._runtime.clear();this._resolved.clear()}_resolveOwn(e){const t=this._manifest.get(e);const s=this._runtime.get(e);if(!s)return t??r;if(!t)return s;return Object.freeze({...t,...s})}_resolveInherited(e,r){const n=r.find(t=>t.name===e);if(!n)return this._resolveOwn(e);const i=r.filter(e=>t(e.pattern,n.pattern)).toSorted((e,t)=>s(e.pattern).length-s(t.pattern).length).map(e=>e.name);i.push(e);const o={};for(const e of i){Object.assign(o,this._manifest.get(e),this._runtime.get(e))}return Object.freeze(o)}}n.EMPTY_META=r;return n});
8
+ sap.ui.predefine("ui5/guard/router/Router", ["sap/m/routing/Router","sap/base/Log","sap/ui/core/library","sap/ui/core/routing/HashChanger","sap/ui/core/routing/History","./NavigationOutcome","./GuardPipeline","./GuardConfig","./GuardModules","./PatternTree","./RouteMeta"],function(t,e,s,i,n,r,a,o,h,u,c){"use strict";function d(t){return t&&t.__esModule&&typeof t.default!=="undefined"?t.default:t}const l=d(r);const _=d(a);const f=a["isPromiseLike"];const p=a["isPromiseResolver"];const g=a["LOG_COMPONENT"];const m=o["isRecord"];const H=o["parseGuardRouterConfig"];const v=h["createLazyGuards"];const R=h["loadGuardModules"];const y=u["byRouteDepth"];const k=u["expandForNewRoute"];const w=u["expandToDescendants"];const b=d(c);const G=c["EMPTY_META"];const N=s.routing.HistoryDirection;function C(t){const e=t=>t==="guardRouter";return new Proxy(t,{get:(t,s,i)=>e(s)?undefined:Reflect.get(t,s,i),has:(t,s)=>!e(s)&&Reflect.has(t,s),ownKeys:t=>Reflect.ownKeys(t).filter(t=>!e(t)),getOwnPropertyDescriptor:(t,s)=>e(s)?undefined:Reflect.getOwnPropertyDescriptor(t,s)})}function L(t){return typeof t==="object"&&t!==null}let M=null;let P=null;window.navigation?.addEventListener("currententrychange",t=>{const e=window.location.href;if(P!==e)P=null;const s=window.navigation.currentEntry;if(s&&t.navigationType==="traverse"){M={offset:s.index-t.from.index,href:e}}else if(M?.href!==e){M=null}});const D={kind:"idle"};const E=10;const T=t.extend("ui5.guard.router.Router",{constructor:function e(s,i,n,...r){const a=m(i);const o=a?i.guardRouter:undefined;t.prototype.constructor.apply(this,[s,a?C(i):i,n,...r]);this._pipeline=new _;this._currentRoute="";this._currentHash=null;this._phase=D;this._parseGeneration=0;this._suppressedHash=null;this._undo=null;this._reportedHash=null;this._lastReport=null;this._reportOutdated=false;this._rootHashChanger=null;this._stoppedRoute="";this._settlementResolvers=[];this._lastSettlement=null;this._sourceDescriptors=[];this._manifestGuards=[];this._destroyed=false;this._nativeMatching=false;this._matchWaiters=[];this._blockLoad=null;this._ownerComponent=n;this._routeNames??=[];this._greedyRouteNames??=[];this._mirrorMatchingProcess();let h="";const u=n?.getManifestEntry("sap.app");if(m(u)&&typeof u.id==="string"){h=u.id}const c=H(o,h);this._options=c.options;this._meta=new b(c.routeMeta,this._options.inheritance==="pattern-tree"?()=>this._collectRoutePatterns():null);this._pendingGuardDescriptors=c.guards;if(this._options.guardLoading==="lazy"){const t=[...new Set(this._pendingGuardDescriptors.map(t=>t.modulePath))];sap.ui.require(t,undefined,()=>{})}},_mirrorMatchingProcess:function t(){Object.defineProperty(this,"_bMatchingProcessStarted",{get:()=>this._isMatching(),set:t=>{this._nativeMatching=t}})},_isMatching:function t(){return this._nativeMatching||this._phase.kind==="evaluating"&&this._phase.postponed===true},attachRouteMatched:function e(s,i,n){if(p(s)&&(!this.isInitialized()||this._isMatching())){this._matchWaiters.push(s)}return t.prototype.attachRouteMatched.call(this,s,i,n)},_settleMatchWaiters:function t(){if(this._phase.kind==="evaluating"&&this._phase.postponed)return;const e=this._matchWaiters;this._matchWaiters=[];if(this._nativeMatching)return;for(const t of e)t()},initialize:function t(e){if(this._blockLoad){if(!this._blockLoad.start){this._blockLoad.start=true;this._blockLoad.ignoreInitialHash=e}return this}if(this._pendingGuardDescriptors.length===0){return this._start(e)}const s=this._pendingGuardDescriptors.map(t=>({...t,source:t}));this._pendingGuardDescriptors=[];this._sourceDescriptors=s;const i=this._options.inheritance==="pattern-tree"?w(s,this._collectRoutePatterns()):s;if(this._options.guardLoading==="lazy"){this._registerLazyGuards(i);return this._start(e)}const n={start:true,ignoreInitialHash:e};this._blockLoad=n;void R(i).then(t=>{this._blockLoad=null;if(this._destroyed)return;for(const{descriptor:e,guards:s}of t){for(const t of s)this._registerManifestGuard(e,t)}if(n.start)this._start(n.ignoreInitialHash)});return this},_start:function e(s){const n=!this.isInitialized();if(n){this.getHashChanger().attachEvent("hashChanged",this._onHashReported,this);this._rootHashChanger=i.getInstance();this._rootHashChanger.attachEvent("hashChanged",this._onRootHashChanged,this)}t.prototype.initialize.call(this,s);if(n&&s){const t=this.getHashChanger().getHash();this._currentRoute=this._stoppedRoute;this._currentHash=t??null}return this},_onHashReported:function t(e){const s=e.getParameter("newHash");const i=this.getHashChanger().getHash();this._reportedHash=s;this._reportOutdated=i!==s&&i===this._lastReport;if(!this._reportOutdated)this._lastReport=s},_onRootHashChanged:function t(e){const s=e.getParameter("newHash");const n=e.getParameter("oldHash")??"";const r=i.getInstance();if(r===this._rootHashChanger){this._completeUndo(s,n);return}r.detachEvent("hashChanged",this._onRootHashChanged,this);r.attachEvent("hashChanged",this._onRootHashChanged,this);this._rootHashChanger=r;queueMicrotask(()=>this._completeUndo(s,n))},_completeUndo:function t(e,s){const i=this._undo;if(!i||i.first!==e)return;i.fullHash??=s;if(this._phase.kind==="restoring"&&this._phase.awaitsReport)this._replaceFullHash(i.fullHash)},addRoute:function e(s,i){t.prototype.addRoute.call(this,s,i);const n=s.name;this._routeNames??=[];this._greedyRouteNames??=[];if(this._routeNames.includes(n))return;this._routeNames.push(n);if(s.greedy)this._greedyRouteNames.push(n);if(!this._meta)return;this._meta.invalidate();if(this._options.inheritance!=="pattern-tree")return;const r=this._collectRoutePatterns();const a=y(this._sourceDescriptors,new Map(r.map(t=>[t.name,t.pattern])));const o=t=>a.findIndex(e=>e.source===t.source);for(const t of k(this._sourceDescriptors,n,r)){const e=o(t);const s=this._manifestGuards.filter(s=>s.descriptor.route===t.route&&s.descriptor.type===t.type&&o(s.descriptor)>e).toSorted((t,e)=>o(t.descriptor)-o(e.descriptor))[0];for(const e of v(t))this._registerManifestGuard(t,e,s?.fn)}},addGuard:function t(e){if(!this._isFn(e,"addGuard"))return this;this._pipeline.addGlobalGuard(e);return this},removeGuard:function t(e){if(!this._isFn(e,"removeGuard"))return this;this._pipeline.removeGlobalGuard(e);return this},addRouteGuard:function t(s,i){if(L(i)){this._handleUnknownRouteRegistration(s,"addRouteGuard");let t=false;if(i.beforeEnter!==undefined){t=true;if(this._isFn(i.beforeEnter,"addRouteGuard",s)){this._pipeline.addEnterGuard(s,i.beforeEnter)}}if(i.beforeLeave!==undefined){t=true;if(this._isFn(i.beforeLeave,"addRouteGuard",s)){this._pipeline.addLeaveGuard(s,i.beforeLeave)}}if(!t){e.info("addRouteGuard: config has no beforeEnter or beforeLeave",s,g)}return this}if(!this._isFn(i,"addRouteGuard",s))return this;this._handleUnknownRouteRegistration(s,"addRouteGuard");this._pipeline.addEnterGuard(s,i);return this},removeRouteGuard:function t(e,s){if(L(s)){if(typeof s.beforeEnter==="function"){this.removeRouteGuard(e,s.beforeEnter)}if(typeof s.beforeLeave==="function"){this.removeLeaveGuard(e,s.beforeLeave)}return this}if(!this._isFn(s,"removeRouteGuard",e))return this;this._pipeline.removeEnterGuard(e,s);return this},addLeaveGuard:function t(e,s){if(!this._isFn(s,"addLeaveGuard",e))return this;this._handleUnknownRouteRegistration(e,"addLeaveGuard");this._pipeline.addLeaveGuard(e,s);return this},_resolveNavToArgs:function t(e,s,i){if(typeof e==="boolean"){return{replace:e,guardOptions:typeof s==="object"?s:undefined}}return{componentTargetInfo:e,replace:typeof s==="boolean"?s:undefined,guardOptions:typeof s==="object"?s:i}},_isFn:function t(s,i,n){if(typeof s==="function")return true;e.warning(`${i}: not a function, ignoring`,n,g);return false},_handleUnknownRouteRegistration:function t(s,i,n="guard registered"){if(this.getRoute(s))return;switch(this._options.unknownRouteRegistration){case"ignore":return;case"throw":throw new Error(`${i} called for unknown route "${s}". `+`Set guardRouter.unknownRouteRegistration to "warn" or "ignore" to allow this.`);case"warn":e.warning(`${i}: unknown route, ${n} anyway`,s,g)}},removeLeaveGuard:function t(e,s){if(!this._isFn(s,"removeLeaveGuard",e))return this;this._pipeline.removeLeaveGuard(e,s);return this},getRouteMeta:function t(s){if(s!==""&&!this.getRoute(s)){e.warning("getRouteMeta: unknown route, returning empty metadata",s,g);return G}return this._meta.get(s)},setRouteMeta:function t(s,i){if(!m(i)){e.warning("setRouteMeta: expected object, ignoring",s,g);return this}if(s!=="")this._handleUnknownRouteRegistration(s,"setRouteMeta","metadata stored");this._meta.set(s,i);return this},navigationSettled:function t(){if(this._phase.kind==="idle"||this._phase.kind==="committing"){return Promise.resolve(this._lastSettlement??{status:l.Committed,route:this._currentRoute,hash:this._currentHash??""})}return new Promise(t=>{this._settlementResolvers.push(t)})},attachNavigationSettled:function t(e,s,i){return this.attachEvent("navigationSettled",e,s,i)},detachNavigationSettled:function t(e,s){this.detachEvent("navigationSettled",e,s);return this},_flushSettlement:function t(s){this._lastSettlement=s;e.debug(`Navigation settled: ${s.status}`,s.hash,g);queueMicrotask(()=>this._settleMatchWaiters());const i=this._settlementResolvers;this._settlementResolvers=[];for(const t of i){t(s)}try{this.fireEvent("navigationSettled",s)}catch(t){e.error("A navigationSettled handler threw",String(t),g)}},navTo:function s(i,n,r,a,o){const{componentTargetInfo:h,replace:u,guardOptions:c}=this._resolveNavToArgs(r,a,o);if(this._phase.kind==="committing"&&this._phase.origin==="redirect"){t.prototype.navTo.call(this,i,n,h,u);return this}if(!this.isInitialized()){t.prototype.navTo.call(this,i,n,h,u);return this}const d=this.getRoute(i);if(!d){this._cancelPendingNavigation(true);t.prototype.navTo.call(this,i,n,h,u);return this}const l=d.getURL(n??{});const _=this._matchRoute(l);const p=_.name;if(l===this._currentHash){this._cancelPendingNavigation(true);const e=this.getHashChanger().getHash();if(e===undefined||e===l){t.prototype.navTo.call(this,i,n,h,u)}return this}const m=c?.skipGuards===true||this._options.navToPreflight==="bypass";if(!m&&this._phase.kind==="evaluating"&&l===this._phase.attempt.hash){return this}if(!m&&this._options.navToPreflight==="off"){t.prototype.navTo.call(this,i,n,h,u);return this}const H=this._pendingRestoresHash();this._cancelPendingNavigation();if(m){this._navigateAllowed(i,n,h,u,l,p,H);return this}const v=this._startAttempt(l,H);const{generation:R}=v;const y=this._createGuardContext(_,l,v.controller.signal);const k=this._evaluateGuards(y);if(f(k)){this._applyWhenDecided(k,t=>{if(R!==this._parseGeneration){e.debug("Async preflight result discarded (superseded by newer navigation)",l,g);return}this._applyPreflightDecision(t,i,n,h,u,l,p,y.bag,v)},l,H);return this}this._applyPreflightDecision(k,i,n,h,u,l,p,y.bag,v);return this},_navigateAllowed:function e(s,n,r,a,o,h,u){this._phase={kind:"committing",route:h,hash:o,origin:"preflight",restoreHash:u,writtenOver:i.getInstance().getHash()};try{t.prototype.navTo.call(this,s,n,r,a);if(!this._commitAfterNavTo(r)){this._blockNavigation(o,u)}}finally{if(this._phase.kind==="committing"){this._phase=D}}},_applyPreflightDecision:function t(e,s,i,n,r,a,o,h,u){if(u.generation!==this._parseGeneration)return;switch(e.action){case"allow":this._navigateAllowed(s,i,n,r,a,o,u.restoreHash);break;case"block":this._blockNavigation(a,u.restoreHash);break;case"redirect":this._startRedirectChain(e.target,a,h,u,r);break;case"error":this._errorNavigation(e.error,a,u.restoreHash);break}},parse:function s(r){if(this._destroyed){t.prototype.parse.call(this,r);return}const a=this._reportedHash===r;this._reportedHash=null;if(a&&this._reportOutdated)return;if(r===this._suppressedHash)return;const o=this._undo;if(o?.started&&o.fullHash===i.getInstance().getHash()){this._undo=null;this._currentHash=r;this._finishRestore(r);return}const h=this._phase;const u=h.kind==="awaitingHash"?h.commit:h.kind==="committing"?h:null;if(u?.hash===r){this._phase=u;this._commitNavigation(r,u.route);return}const c=this._currentHash;if(r===c){if(this._pendingRestoresHash()){if(this._phase.kind==="evaluating")this._cancelPendingNavigation();else this._undo=null}else{t.prototype.parse.call(this,r)}return}const d=this._matchRoute(r);const l=d.name;const _=this._pendingRestoresHash()?o:null;const p=this._phase.kind==="restoring";this._cancelPendingNavigation();if(this._currentHash!==c)return;this._undo=p?null:this._describeUndo(_,a);if(this._undo&&u===h&&!u.restoreHash)this._undo.fullHash=u.writtenOver;const m=a?n.getInstance().getDirection():undefined;const H=this._startAttempt(r,true,m);const{generation:v}=H;const R=this._createGuardContext(d,r,H.controller.signal);const y=this._evaluateGuards(R);if(f(y)){this._applyWhenDecided(y,t=>{if(v!==this._parseGeneration){e.debug("Async guard result discarded (superseded by newer navigation)",r,g);return}this._applyDecision(t,r,l,R.bag,H)},r,true);return}this._applyDecision(y,r,l,R.bag,H)},stop:function e(){if(this._blockLoad)this._blockLoad.start=false;this._cancelPendingNavigation();this._undo=null;if(this._currentHash!==null)this._stoppedRoute=this._currentRoute;this._currentRoute="";this._currentHash=null;this._lastSettlement=null;this._detachHashListeners();t.prototype.stop.call(this);return this},_detachHashListeners:function t(){this.getHashChanger().detachEvent("hashChanged",this._onHashReported,this);i.getInstance().detachEvent("hashChanged",this._onRootHashChanged,this);this._rootHashChanger=null},_cancelPendingNavigation:function t(e=false){++this._parseGeneration;const s=this._phase;const i=this._pendingRestoresHash();this._phase=D;if(s.kind==="idle"||s.kind==="committing")return;if(s.kind==="restoring"){this._flushSettlement(s.result);return}if(s.kind==="evaluating")s.attempt.controller.abort();this._settleUncommitted({status:l.Cancelled,route:this._currentRoute,hash:this._currentHash??""},s.kind==="evaluating"?s.attempt.hash:s.commit.hash,e&&i)},_pendingRestoresHash:function t(){const e=this._phase;if(e.kind==="evaluating")return e.attempt.restoreHash;if(e.kind==="committing")return e.restoreHash;return e.kind==="awaitingHash"&&e.commit.restoreHash},_startAttempt:function t(e,s,i){if(this._phase.kind==="evaluating")this._phase.attempt.controller.abort();const n={hash:e,controller:new AbortController,generation:++this._parseGeneration,restoreHash:s,direction:i};this._phase={kind:"evaluating",attempt:n};return n},_applyWhenDecided:function t(s,i,n,r){if(this._phase.kind==="evaluating")this._phase={...this._phase,postponed:true};s.then(t=>{const s=this._lastSettlement;try{i(t)}catch(t){e.error("Navigation failed after its guards had settled",t instanceof Error?t:String(t),g);if(this._lastSettlement===s){this._errorNavigation(t,n,r)}}})},_applyDecision:function t(e,s,i,n,r){if(r.generation!==this._parseGeneration)return;switch(e.action){case"allow":this._phase={kind:"committing",route:i,hash:s,origin:"parse",restoreHash:false};this._commitNavigation(s,i);break;case"block":this._blockNavigation(s);break;case"redirect":this._startRedirectChain(e.target,s,n,r,true);break;case"error":this._errorNavigation(e.error,s);break}},_alignTitleHistory:function t(e){if(e===N.NewEntry||e===N.Forwards){Reflect.set(this,"_bLastHashReplaced",false)}else if(e===N.Backwards){const t=this.getTitleHistory();const e=t.at(-1);const s=t.at(-2);if(m(e)&&m(s)&&!e.isHome&&e.title!==s.title){t.splice(-2,1)}}},_commitNavigation:function e(s,i){const n=this._phase.kind==="committing"&&this._phase.origin==="redirect";if(this._phase.kind==="committing")this._alignTitleHistory(this._phase.direction);this._undo=null;this._currentHash=s;this._currentRoute=i;this._phase=D;this._flushSettlement({status:n?l.Redirected:this._currentRoute===""?l.Bypassed:l.Committed,route:this._currentRoute,hash:s});if(this._currentHash!==s)return;t.prototype.parse.call(this,s)},_commitAfterNavTo:function t(e){const s=this._phase;if(s.kind!=="committing")return true;if(this.getHashChanger().getHash()===s.hash){this._commitNavigation(s.hash,s.route);return true}if(!e||Object.keys(e).length===0)return false;this._phase={kind:"awaitingHash",commit:s};return true},_redirect:function t(s,i){const n=typeof s==="string"?s:s.route;const r=this.getRoute(n);if(!r){e.warning(`Guard redirect target "${n}" is not a known route, treating as blocked`,undefined,g);this._blockNavigation(i.attemptedHash,i.restoreHash);return}let a;try{a=r.getURL(typeof s==="string"?{}:s.parameters??{})}catch(t){e.error(`Guard redirect target "${n}" has no valid hash, navigation failed`,String(t),g);this._errorNavigation(t,i.attemptedHash,i.restoreHash);return}if(i.visited.has(a)){e.error(`Guard redirect loop detected: ${[...i.visited,a].join(" -> ")}`,undefined,g);this._blockNavigation(i.attemptedHash,i.restoreHash);return}if(i.visited.size>E){e.error(`Guard redirect chain exceeded maximum depth (${E}): ${[...i.visited].join(" -> ")}`,undefined,g);this._blockNavigation(i.attemptedHash,i.restoreHash);return}i.visited.add(a);const o=this._matchRoute(a);const h=o.name;const u=this._createGuardContext(o,a,i.signal,i);const c=this._evaluateGuards(u,true);if(f(c)){this._applyWhenDecided(c,t=>this._applyRedirectDecision(t,s,a,h,i),i.attemptedHash,i.restoreHash);return}this._applyRedirectDecision(c,s,a,h,i)},_applyRedirectDecision:function e(s,n,r,a,o){if(o.generation!==this._parseGeneration)return;switch(s.action){case"allow":{const e=typeof n==="string"?undefined:n.componentTargetInfo;if(r===this._currentHash){this._phase=D;this._settleUncommitted({status:l.Redirected,route:this._currentRoute,hash:r},o.attemptedHash,o.restoreHash,typeof n!=="string"&&e?()=>{if(this.getHashChanger().getHash()!==r)return;t.prototype.navTo.call(this,n.route,n.parameters??{},e,o.replace)}:undefined);break}this._phase={kind:"committing",route:a,hash:r,origin:"redirect",direction:o.direction,restoreHash:o.restoreHash,writtenOver:i.getInstance().getHash()};try{const t=this.getHashChanger().getHash()===r;if(typeof n==="string"){if(!t)this.navTo(n,{},{},o.replace)}else if(!t||e){this.navTo(n.route,n.parameters??{},e,o.replace)}if(!this._commitAfterNavTo(e)){this._blockNavigation(o.attemptedHash,o.restoreHash)}}finally{if(this._phase.kind==="committing"){this._phase=D}}break}case"block":this._blockNavigation(o.attemptedHash,o.restoreHash);break;case"redirect":this._redirect(s.target,o);break;case"error":this._errorNavigation(s.error,o.attemptedHash,o.restoreHash);break}},_matchRoute:function t(e){const s=this.getRouteInfoByHash(e);return{name:s?.name??"",arguments:s?.arguments??{}}},_greedyMatches:function t(e,s){return this._greedyRouteNames.filter(t=>t!==s&&this.getRoute(t)?.match(e))},_evaluateGuards:function t(e,s=false){return this._pipeline.evaluate(e,{skipLeaveGuards:s,alsoLeaving:this._greedyMatches(e.fromHash,e.fromRoute),alsoEntering:this._greedyMatches(e.toHash,e.toRoute)})},_createGuardContext:function t(e,s,i,n){const r=n?n.fromRoute:this._currentRoute;return{toRoute:e.name,toHash:s,toArguments:e.arguments,fromRoute:r,fromHash:n?n.fromHash:this._currentHash??"",signal:i,bag:n?n.bag:new Map,toMeta:this.getRouteMeta(e.name),fromMeta:this.getRouteMeta(r),ownerComponent:this._ownerComponent}},_startRedirectChain:function t(e,s,i,n,r){const a=new Set;a.add(s);this._redirect(e,{visited:a,attemptedHash:s,restoreHash:n.restoreHash,replace:r,direction:n.direction,fromRoute:this._currentRoute,fromHash:this._currentHash??"",signal:n.controller.signal,generation:n.generation,bag:i})},_blockNavigation:function t(e,s=true){this._phase=D;this._settleUncommitted({status:l.Blocked,route:this._currentRoute,hash:this._currentHash??""},e,s)},_errorNavigation:function t(e,s,i=true){this._phase=D;this._settleUncommitted({status:l.Error,route:this._currentRoute,hash:this._currentHash??"",error:e},s,i)},_settleUncommitted:function t(e,s,i,n){const r=i&&this._currentHash===null&&!!s;if(i&&!r&&!this._undoHashChange(e,n))return;this._flushSettlement(e);n?.();if(r&&this._currentHash===null)this._restoreHash("",false)},_describeUndo:function t(e,s){if(!s)return e;const n=i.getInstance().getHash();const r=M;if(!e)return{first:n,fullHash:undefined,shown:n,step:r,started:false};const a=e.step&&r?e.step.offset+r.offset:0;return{first:e.first,fullHash:e.fullHash,shown:n,step:r&&a?{offset:a,href:r.href}:null,started:false}},_undoHashChange:function t(e,s){const n=this._undo;const r=this._currentHash;const a=i.getInstance().getHash();if(n===null||r===null||n.shown!==a||n.fullHash===a){this._restoreHash(r??"");return true}const o=window.location.href;n.started=true;this._phase={kind:"restoring",result:e,whenBack:s};if(P===o){}else if(n.step){P=o;window.history.go(-n.step.offset)}else if(n.fullHash===undefined){this._phase={...this._phase,awaitsReport:true}}else{this._replaceFullHash(n.fullHash)}return false},_replaceFullHash:function t(e){i.getInstance().replaceHash(e,N.Unknown);this._finishRestore()},_finishRestore:function t(e){const s=this._phase;if(s.kind!=="restoring")return;this._phase=D;this._flushSettlement(e===undefined?s.result:{...s.result,hash:e});s.whenBack?.()},_restoreHash:function t(e,s=true){const i=this.getHashChanger();if(i.getHash()===e)return;this._suppressedHash=s?e:null;void i.replaceHash(e,N.Unknown);this._suppressedHash=null},_collectRoutePatterns:function t(){const e=[];for(const t of this._routeNames){const s=this.getRoute(t)?.getPattern();if(s!==undefined)e.push({name:t,pattern:s})}return e},_registerManifestGuard:function t(s,i,n){try{if(s.route==="*"){this.addGuard(i);return}if(s.type==="leave"){this._handleUnknownRouteRegistration(s.route,"addLeaveGuard");this._pipeline.addLeaveGuard(s.route,i,n)}else{this._handleUnknownRouteRegistration(s.route,"addRouteGuard");this._pipeline.addEnterGuard(s.route,i,n)}this._manifestGuards.push({descriptor:s,fn:i})}catch(t){e.error(`guardRouter.guards: failed to register "${s.modulePath}"`,String(t),g)}},_registerLazyGuards:function t(e){for(const t of e){for(const e of v(t))this._registerManifestGuard(t,e)}},destroy:function e(){if(this._destroyed)return this;this._destroyed=true;this._pipeline.clear();this._pendingGuardDescriptors=[];this._sourceDescriptors=[];this._manifestGuards=[];this._cancelPendingNavigation();this._lastSettlement=null;this._detachHashListeners();this._meta.clear();t.prototype.destroy.call(this);return this}});return T});
9
+ sap.ui.predefine("ui5/guard/router/library", ["sap/ui/core/Lib","sap/ui/base/DataType","sap/ui/core/library","sap/m/library","./NavigationOutcome"],function(e,i,r,t,u){"use strict";function a(e){return e&&e.__esModule&&typeof e.default!=="undefined"?e.default:e}const n=a(u);const o=e.init({apiVersion:2,name:"ui5.guard.router",version:"1.7.0",dependencies:["sap.ui.core","sap.m"],types:["ui5.guard.router.NavigationOutcome"],interfaces:[],controls:[],elements:[],noLibraryCSS:true});i.registerEnum("ui5.guard.router.NavigationOutcome",n);return o});
6
10
  sap.ui.require.preload({
7
- "ui5/guard/router/manifest.json":'{"_version":"2.0.0","sap.app":{"id":"ui5.guard.router","type":"library","applicationVersion":{"version":"1.6.2"},"title":"UI5 Router extension with async navigation guards","description":"Extends sap.m.routing.Router with async navigation guards, running before route matching begins."},"sap.ui":{"technology":"UI5","deviceTypes":{"desktop":true,"tablet":true,"phone":true}},"sap.ui5":{"contentDensities":{"compact":true,"cozy":true},"dependencies":{"minUI5Version":"1.144.0","libs":{"sap.ui.core":{},"sap.m":{}}}}}',
11
+ "ui5/guard/router/manifest.json":'{"_version":"2.0.0","sap.app":{"id":"ui5.guard.router","type":"library","applicationVersion":{"version":"1.7.0"},"title":"UI5 Router extension with async navigation guards","description":"Extends sap.m.routing.Router with async navigation guards, running before route matching begins."},"sap.ui":{"technology":"UI5","deviceTypes":{"desktop":true,"tablet":true,"phone":true}},"sap.ui5":{"library":{"i18n":false},"contentDensities":{"compact":true,"cozy":true},"dependencies":{"minUI5Version":"1.136.0","libs":{"sap.ui.core":{},"sap.m":{}}}}}',
8
12
  "ui5/guard/router/types.js":function(){
9
13
 
10
14
  }