UNPKG

@digital-blueprint/esign-app

Version:

[GitHub Repository](https://github.com/digital-blueprint/esign-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/esign-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/esign-app/) | [Esign Bundle](https://gitlab.tugraz.

466 lines (416 loc) 255 kB
/*! * License: LGPL-2.1-or-later * Dependencies: * * @webcomponents/scoped-custom-element-registry: BSD-3-Clause * @dbp-toolkit/app-shell: LGPL-2.1-or-later * @dbp-toolkit/language-select: LGPL-2.1-or-later * @dbp-toolkit/auth: LGPL-2.1-or-later * @dbp-toolkit/notification: LGPL-2.1-or-later * @dbp-toolkit/theme-switcher: LGPL-2.1-or-later * universal-router: MIT * @dbp-toolkit/matomo: LGPL-2.1-or-later * @tugraz/web-components: LGPL-2.1-or-later */ import{$ as e,A as t,D as n,I as r,J as i,L as a,M as o,S as s,Y as c,Z as l,a as u,b as d,c as f,d as p,g as m,h,i as g,k as _,l as v,n as ee,o as y,r as b,t as x,u as S,w as C,x as w}from"./shared/dbp-lit-element.D0c52m5A.js";import{t as T}from"./shared/notification.DW4NLT-r.js";(function(){function e(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}var t=typeof Object.defineProperties==`function`?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e};function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof global==`object`&&global];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error(`Cannot find global object`)}var r=n(this);function i(e,n){if(n)a:{var i=r;e=e.split(`.`);for(var a=0;a<e.length-1;a++){var o=e[a];if(!(o in i))break a;i=i[o]}e=e[e.length-1],a=i[e],n=n(a),n!=a&&n!=null&&t(i,e,{configurable:!0,writable:!0,value:n})}}i(`Symbol`,function(e){function n(e){if(this instanceof n)throw TypeError(`Symbol is not a constructor`);return new r(`jscomp_symbol_`+(e||``)+`_`+ i++,e)}function r(e,n){this.l=e,t(this,`description`,{configurable:!0,writable:!0,value:n})}if(e)return e;r.prototype.toString=function(){return this.l};var i=0;return n}),i(`Symbol.iterator`,function(n){if(n)return n;n=Symbol(`Symbol.iterator`);for(var i=`Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array`.split(` `),o=0;o<i.length;o++){var s=r[i[o]];typeof s==`function`&&typeof s.prototype[n]!=`function`&&t(s.prototype,n,{configurable:!0,writable:!0,value:function(){return a(e(this))}})}return n});function a(e){return e={next:e},e[Symbol.iterator]=function(){return this},e}function o(t){var n=typeof Symbol<`u`&&Symbol.iterator&&t[Symbol.iterator];return n?n.call(t):{next:e(t)}}function s(e){if(!(e instanceof Array)){e=o(e);for(var t,n=[];!(t=e.next()).done;)n.push(t.value);e=n}return e}var c=typeof Object.create==`function`?Object.create:function(e){function t(){}return t.prototype=e,new t},l=function(){function e(){function e(){}return new e,Reflect.construct(e,[],function(){}),new e instanceof e}if(typeof Reflect<`u`&&Reflect.construct){if(e())return Reflect.construct;var t=Reflect.construct;return function(e,n,r){return e=t(e,n),r&&Reflect.setPrototypeOf(e,r.prototype),e}}return function(e,t,n){return n===void 0&&(n=e),n=c(n.prototype||Object.prototype),Function.prototype.apply.call(e,n,t)||n}}(),u;if(typeof Object.setPrototypeOf==`function`)u=Object.setPrototypeOf;else{var d;a:{var f={a:!0},p={};try{p.__proto__=f,d=p.a;break a}catch{}d=!1}u=d?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw TypeError(e+` is not extensible`);return e}:null}var m=u,h=window;if(h.CustomElementRegistryPolyfill?.formAssociated===void 0){var g={};h.CustomElementRegistryPolyfill=(g.formAssociated=new Set,g)}var _=window.HTMLElement,v=window.customElements.define,ee=window.customElements.get,y=window.customElements,b=new WeakMap,x=new WeakMap,S=new WeakMap,C=new WeakMap;function w(){var e;this.promise=new Promise(function(t){e=t}),this.resolve=e}function T(){this.h=new Map,this.m=new Map,this.j=new Map,this.i=new Map}T.prototype.define=function(e,t){if(e=e.toLowerCase(),this.h.get(e)!==void 0)throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "`+e+`" has already been used with this registry`);if(this.m.get(t)!==void 0)throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);var n=t.prototype.attributeChangedCallback,r=new Set(t.observedAttributes||[]);te(t,r,n);var i=ee.call(y,e),a=i?.s??(t.formAssociated||h.CustomElementRegistryPolyfill.formAssociated.has(e));if(a&&h.CustomElementRegistryPolyfill.formAssociated.add(e),a!=t.formAssociated)try{t.formAssociated=a}catch{}if(n={tagName:e,g:t,connectedCallback:t.prototype.connectedCallback,disconnectedCallback:t.prototype.disconnectedCallback,adoptedCallback:t.prototype.adoptedCallback,attributeChangedCallback:n,formAssociated:a,formAssociatedCallback:t.prototype.formAssociatedCallback,formDisabledCallback:t.prototype.formDisabledCallback,formResetCallback:t.prototype.formResetCallback,formStateRestoreCallback:t.prototype.formStateRestoreCallback,observedAttributes:r},this.h.set(e,n),this.m.set(t,n),i||(i=O(e),v.call(y,e,i)),this===window.customElements&&(S.set(t,n),n.o=i),i=this.i.get(e))for(this.i.delete(e),i=o(i),r=i.next();!r.done;r=i.next())r=r.value,x.delete(r),N(r,n,!0);return i=this.j.get(e),i!==void 0&&(i.resolve(t),this.j.delete(e)),t},T.prototype.upgrade=function(e){var t=[...arguments];F.push(this),y.upgrade.apply(y,s(t)),F.pop()},T.prototype.get=function(e){return this.h.get(e)?.g},T.prototype.whenDefined=function(e){var t=this.h.get(e);return t===void 0?(t=this.j.get(e),t===void 0&&(t=new w,this.j.set(e,t)),t.promise):Promise.resolve(t.g)};function E(e,t,n,r){var i=e.i.get(n);i||e.i.set(n,i=new Set),r?i.add(t):i.delete(t)}var D;window.HTMLElement=function(){var e=D;if(e)return D=void 0,e;var t=S.get(this.constructor);if(!t)throw TypeError(`Illegal constructor (custom element class must be registered with global customElements registry to be newable)`);return e=Reflect.construct(_,[],t.o),Object.setPrototypeOf(e,this.constructor.prototype),b.set(e,t),e},window.HTMLElement.prototype=_.prototype;function O(e){function t(){var t=Reflect.construct(_,[],this.constructor);Object.setPrototypeOf(t,HTMLElement.prototype);a:{var n=t.getRootNode();if(!(n===document||n instanceof ShadowRoot)){if(n=F[F.length-1],n instanceof CustomElementRegistry){var r=n;break a}n=n.getRootNode(),n===document||n instanceof ShadowRoot||(n=(r=C.get(n))?.getRootNode()||document)}r=n.registry}return r||=window.customElements,(n=r.h.get(e))?N(t,n):x.set(t,r),t}return r.Object.defineProperty(t,`formAssociated`,{configurable:!0,enumerable:!0,get:function(){return h.CustomElementRegistryPolyfill.formAssociated.has(e)}}),t.prototype.connectedCallback=function(t){for(var n=[],r=0;r<arguments.length;++r)n[r]=arguments[r];A(this),(r=b.get(this))?r.connectedCallback&&r.connectedCallback.apply(this,n):E(x.get(this),this,e,!0)},t.prototype.disconnectedCallback=function(t){for(var n=[],r=0;r<arguments.length;++r)n[r]=arguments[r];(r=b.get(this))?r.disconnectedCallback&&r.disconnectedCallback.apply(this,n):E(x.get(this),this,e,!1)},t.prototype.adoptedCallback=function(e){var t=[...arguments],n,r;(n=b.get(this))==null||(r=n.adoptedCallback)==null||r.apply(this,t)},t.prototype.formAssociatedCallback=function(e){for(var t=[],n=0;n<arguments.length;++n)t[n]=arguments[n];if(n=b.get(this),n!=null&&n.formAssociated){var r;n==null||(r=n.formAssociatedCallback)==null||r.apply(this,t)}},t.prototype.formDisabledCallback=function(e){for(var t=[],n=0;n<arguments.length;++n)t[n]=arguments[n];if(n=b.get(this),n!=null&&n.formAssociated){var r;n==null||(r=n.formDisabledCallback)==null||r.apply(this,t)}},t.prototype.formResetCallback=function(e){for(var t=[],n=0;n<arguments.length;++n)t[n]=arguments[n];if(n=b.get(this),n!=null&&n.formAssociated){var r;n==null||(r=n.formResetCallback)==null||r.apply(this,t)}},t.prototype.formStateRestoreCallback=function(e){for(var t=[],n=0;n<arguments.length;++n)t[n]=arguments[n];if(n=b.get(this),n!=null&&n.formAssociated){var r;n==null||(r=n.formStateRestoreCallback)==null||r.apply(this,t)}},t}window.CustomElementRegistry=T;function te(e,t,n){if(t.size!==0&&n!==void 0){var r=e.prototype.setAttribute;r&&(e.prototype.setAttribute=function(e,i){if(A(this),e=e.toLowerCase(),t.has(e)){var a=this.getAttribute(e);r.call(this,e,i),n.call(this,e,a,i)}else r.call(this,e,i)});var i=e.prototype.removeAttribute;i&&(e.prototype.removeAttribute=function(e){if(A(this),e=e.toLowerCase(),t.has(e)){var r=this.getAttribute(e);i.call(this,e),n.call(this,e,r,null)}else i.call(this,e)});var a=e.prototype.toggleAttribute;a&&(e.prototype.toggleAttribute=function(e,r){if(A(this),e=e.toLowerCase(),t.has(e)){var i=this.getAttribute(e);a.call(this,e,r),r=this.getAttribute(e),i!==r&&n.call(this,e,i,r)}else a.call(this,e,r)})}}var k;document.readyState===`loading`&&(k=new Set,document.addEventListener(`readystatechange`,function(){k.forEach(function(e){return j(e,b.get(e))})},{once:!0}));function A(e){var t;(t=k)!=null&&t.has(e)&&j(e,b.get(e))}function j(e,t){var n;(n=k)==null||n.delete(e),t.attributeChangedCallback&&t.observedAttributes.forEach(function(n){e.hasAttribute(n)&&t.attributeChangedCallback.call(e,n,null,e.getAttribute(n))})}function M(e){var t=Object.getPrototypeOf(e);if(t!==window.HTMLElement)return t===_?Object.setPrototypeOf(e,window.HTMLElement):M(t)}function N(e,t,n){n=n===void 0?!1:n,Object.setPrototypeOf(e,t.g.prototype),b.set(e,t),D=e;try{new t.g}catch{M(t.g),new t.g}t.attributeChangedCallback&&(k===void 0||e.hasAttributes()?j(e,t):k.add(e)),n&&t.connectedCallback&&e.isConnected&&t.connectedCallback.call(e)}var P=Element.prototype.attachShadow;Element.prototype.attachShadow=function(e,t){for(var n=[],r=1;r<arguments.length;++r)n[r-1]=arguments[r];var i=Object.assign({},e);return r=e.customElements,r=e.registry===void 0?r:e.registry,i=(delete i.customElements,delete i.registry,i),n=P.call.apply(P,[this,i].concat(s(n))),r!==void 0&&(n.customElements=n.registry=r),n};var F=[document];function I(e,t,n){var r=(n?Object.getPrototypeOf(n):e.prototype)[t];e.prototype[t]=function(e){var t=[...arguments];return F.push(this),t=r.apply(n||this,t),t!==void 0&&C.set(t,this),F.pop(),t}}I(ShadowRoot,`createElement`,document),I(ShadowRoot,`createElementNS`,document),I(ShadowRoot,`importNode`,document),I(Element,`insertAdjacentHTML`);function L(e){var t=Object.getOwnPropertyDescriptor(e.prototype,`innerHTML`);Object.defineProperty(e.prototype,`innerHTML`,Object.assign({},t,{set:function(e){F.push(this),t.set.call(this,e),F.pop()}}))}if(L(Element),L(ShadowRoot),Object.defineProperty(window,`customElements`,{value:new CustomElementRegistry,configurable:!0,writable:!0}),window.ElementInternals&&window.ElementInternals.prototype.setFormValue){var R=new WeakMap,z=HTMLElement.prototype.attachInternals,B=[`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`];HTMLElement.prototype.attachInternals=function(e){var t=[...arguments];return t=z.call.apply(z,[this].concat(s(t))),R.set(t,this),t},B.forEach(function(e){var t=window.ElementInternals.prototype,n=t[e];t[e]=function(e){for(var t=[],r=0;r<arguments.length;++r)t[r]=arguments[r];if(r=R.get(this),!0===b.get(r).formAssociated)return n?.call.apply(n,[this].concat(s(t)));throw new DOMException(`Failed to execute `+n+` on 'ElementInternals': The target element is not a form-associated custom element.`)}});var V=function(e){var t=l(Array,[].concat(s(e)),this.constructor);return t.l=e,t},H=V,U=Array;if(H.prototype=c(U.prototype),H.prototype.constructor=H,m)m(H,U);else for(var W in U)if(W!=`prototype`)if(Object.defineProperties){var G=Object.getOwnPropertyDescriptor(U,W);G&&Object.defineProperty(H,W,G)}else H[W]=U[W];H.u=U.prototype,r.Object.defineProperty(V.prototype,`value`,{configurable:!0,enumerable:!0,get:function(){return this.l.find(function(e){return!0===e.checked})?.value||``}});var K=function(e){var t=this,n=new Map;e.forEach(function(e,r){var i=e.getAttribute(`name`),a=n.get(i)||[];t[+r]=e,a.push(e),n.set(i,a)}),this.length=e.length,n.forEach(function(e,n){e&&n!==`length`&&n!==`item`&&n!==`namedItem`&&(t[n]=e.length===1?e[0]:new V(e))})};K.prototype.item=function(e){return this[e]??null},K.prototype[Symbol.iterator]=function(){throw Error(`Method not implemented.`)},K.prototype.namedItem=function(e){return this[e]??null};var ne=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,`elements`,{get:function(){var e=ne.get.call(this),t=[];e=o(e);for(var n=e.next();!n.done;n=e.next()){n=n.value;var r=b.get(n);r&&!0!==r.formAssociated||t.push(n)}return new K(t)}})}}).call(typeof globalThis==`object`?globalThis:window);var E={"activity-example":{"hello-world":`Hallo Welt`},"choose-from-menu":`Bitte wählen Sie eine Aktivität aus dem Menu.`,contact:`Kontakt`,imprint:`Impressum`,login:`Anmelden`,logout:`Abmelden`,"page-not-found":`Die gewünschte Seite wurde nicht gefunden`,"page-updated-needs-reload":`Die Applikation wurde aktualisiert. Bitte laden Sie die Seite neu.`,"privacy-policy":`Datenschutz`,"standard-layout-name":`Standard`,"switch-layout":`Layout wechseln`,"switch-to-standard-layout-label":`Zum Standardlayout wechseln`,"switch-to-wide-layout-label":`Zum Weiten Layout wechseln`,welcome:{headline:`Willkommen!`},"wide-layout-name":`Erweitert`},D={"activity-example":{"hello-world":`Hello World`},"choose-from-menu":`Please choose an activity from the menu.`,contact:`Contact`,imprint:`Legal Notice`,login:`Login`,logout:`Logout`,"page-not-found":`Requested Page Not Found`,"page-updated-needs-reload":`The application has been updated. Please reload the page.`,"privacy-policy":`Privacy Policy`,"standard-layout-name":`Standard`,"switch-layout":`Switch layout`,"switch-to-standard-layout-label":`Switch to Standard Layout`,"switch-to-wide-layout-label":`Switch to Wide Layout`,welcome:{headline:`Welcome!`},"wide-layout-name":`Wide`};function O(){return l({en:D,de:E},`de`,`en`)}var te={de:`Deutsch`,"de-action":`Auf Deutsch anzeigen`,demo:`Hallo Welt`,en:`Englisch`,"en-action":`Auf Englisch anzeigen`},k={de:`German`,"de-action":`Switch to German`,demo:`Hello World`,en:`English`,"en-action":`Switch to English`};function A(){return l({en:k,de:te},`de`,`en`)}var j=class extends m{constructor(){super(),this._lang=`de`,this.languages=[`de`,`en`],this._i18n=A(),this._i18n.t(`de`),this._i18n.t(`de-action`),this._i18n.t(`en`),this._i18n.t(`en-action`)}_getNextLanguage(e){var t=this.languages.indexOf(e),n=this.languages[t+1];return n===void 0&&(n=this.languages[0]),n}_getPreviousLanguage(e){var t=this.languages.indexOf(e),n=this.languages[t-1];return n===void 0&&(n=this.languages[this.languages.length-1]),n}static get properties(){return{lang:{type:String},next:{type:String},languages:{type:Array}}}set lang(e){let t=this.lang,n=this.next;this._lang=e,this.requestUpdate(`lang`,t),this.requestUpdate(`next`,n),t!==e&&(this.sendSetPropertyEvent(`lang`,e),this._i18n.changeLanguage(this.next))}get lang(){return this._lang}set next(e){this.lang=this._getPreviousLanguage(e)}get next(){return this._getNextLanguage(this.lang)}static get styles(){return c` ${_()} :host { display: inline-block; } a:hover { color: var(--dbp-hover-color, var(--dbp-content)); background-color: var(--dbp-hover-background-color); transition: none; } a { padding: 0.3em; display: inline-block; text-decoration: none; transition: background-color 0.15s, color 0.15s; color: var(--dbp-content); } input::-moz-focus-inner { border: 0; } :focus-visible { outline: none !important; outline-width: 0 !important; box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: 0px 0px 4px 2px var(--dbp-primary); } `}onClick(e){e.preventDefault(),this.lang=this.next}render(){return i` <a href="#" title="${this._i18n.t(this.next+`-action`)}" @click=${this.onClick}>${this.next.toUpperCase()}</a> `}},M={"logging-in":`Anmeldung läuft`,login:`Anmelden`,"login-failed":`Kommunikation mit dem Anmeldeserver fehlgeschlagen`,logout:`Abmelden`},N={"logging-in":`Logging in`,login:`Login`,"login-failed":`Communication with the login server failed`,logout:`Logout`};function P(){return l({en:N,de:M},`de`,`en`)}const F=function(e,t){let n=new Promise((t,n)=>{let r=setTimeout(()=>{clearTimeout(r),n(`Timed out in `+e+`ms.`)},e)});return Promise.race([t,n])},I=function(e){try{return new URL(e).href}catch{return new URL(e,window.location.href).href}};var L=class extends EventTarget{constructor(e,t,n,r,i,a){super(),this._baseURL=e,this._realm=t,this._clientId=n,this._keycloak=null,this._initPromise=null,this._silentCheckSsoUri=r,this._checkLoginIframe=i,this._idpHint=a,this._checkId=null,this.MIN_VALIDITY=20,this.CHECK_INTERVAL=10,this.DEBUG=!1,this._onVisibilityChanged=this._onVisibilityChanged.bind(this),document.addEventListener(`visibilitychange`,this._onVisibilityChanged)}close(){document.removeEventListener(`visibilitychange`,this._onVisibilityChanged)}_onVisibilityChanged(){document.visibilityState===`visible`&&this._checkTokeHasExpired()}_onChanged(){let e=new CustomEvent(`changed`,{detail:this._keycloak,bubbles:!0,composed:!0});this.dispatchEvent(e)}_onReady(e){e&&this._onChanged()}async _onTokenExpired(){console.log(`Token has expired`);let e=!1;try{e=await this._keycloak.updateToken(-1)}catch(e){console.log(`Failed to refresh the token`,e);return}console.assert(e,`token should have been refreshed`)}async _checkTokeHasExpired(){let e;if(this._keycloak===null||!this._keycloak.authenticated)return;let t=this.MIN_VALIDITY+this.CHECK_INTERVAL;this.DEBUG&&console.log(`Updating token if not valid for at least ${t}s`);try{e=await this._keycloak.updateToken(t)}catch(e){console.log(`Failed to refresh the token`,e)}this.DEBUG&&e&&console.log(`token has been refreshed`)}async _onAuthSuccess(){this._checkId!==null&&(clearInterval(this._checkId),this._checkId=null),this._checkId=setInterval(this._checkTokeHasExpired.bind(this),this.CHECK_INTERVAL*1e3),this._onChanged()}async _onAuthLogout(){this._checkId!==null&&(clearInterval(this._checkId),this._checkId=null),this._onChanged()}async _init(){let e=(await import(`./shared/keycloak.Bd_Y67Ve.js`)).default;this._keycloak=new e({url:this._baseURL,realm:this._realm,clientId:this._clientId}),this._keycloak.onTokenExpired=this._onTokenExpired.bind(this),this._keycloak.onAuthRefreshSuccess=this._onChanged.bind(this),this._keycloak.onAuthRefreshError=this._onChanged.bind(this),this._keycloak.onAuthLogout=this._onAuthLogout.bind(this),this._keycloak.onAuthSuccess=this._onAuthSuccess.bind(this),this._keycloak.onAuthError=this._onChanged.bind(this),this._keycloak.onReady=this._onReady.bind(this);let t={};t.pkceMethod=`S256`,this.DEBUG&&(t.enableLogging=!0),t.checkLoginIframe=this._checkLoginIframe,this._silentCheckSsoUri?(t.onLoad=`check-sso`,t.silentCheckSsoRedirectUri=I(this._silentCheckSsoUri),await F(5e3,this._keycloak.init(t)).catch(()=>{console.log(`Login timed out`),this._onChanged()})):await this._keycloak.init(t)}async _ensureInit(){return this._initPromise===null&&(this._initPromise=this._init()),this._initPromise}isLoggingIn(){let e=window.location.href;return e.search(`[&#]state=`)>=0&&e.search(`[&#]session_state=`)>=0}async login(e){await this._ensureInit(),e||={};let t=e.lang||`en`,n=e.scope||``;this._keycloak.authenticated||await this._keycloak.login({locale:t,scope:n,idpHint:this._idpHint})}async tryLogin(){await this._ensureInit()}async localLogout(){this._keycloak.clearToken()}async logout(){await this._ensureInit(),this._keycloak.logout()}};const R=Object.freeze({UNKNOWN:`unknown`,LOGGING_IN:`logging-in`,LOGGED_IN:`logged-in`,LOGGING_OUT:`logging-out`,LOGGED_OUT:`logged-out`});var z=class extends f(m,P){constructor(){super(),this.forceLogin=!1,this.token=``,this.subject=``,this.name=``,this.tryLogin=!1,this.entryPointUrl=``,this._user=null,this._userId=``,this._authenticated=!1,this._loginStatus=R.UNKNOWN,this.requestedLoginStatus=R.UNKNOWN,this.keycloakUrl=null,this.realm=null,this.clientId=null,this.silentCheckSsoRedirectUri=null,this.noCheckLoginIframe=!1,this.scope=null,this.idpHint=``,this._onKCChanged=this._onKCChanged.bind(this),window.playwright&&this.setAttribute(`data-testid`,`dbp-auth-keycloak`)}update(e){e.forEach((e,t)=>{switch(t){case`requestedLoginStatus`:{console.log(`requested-login-status changed`,this.requestedLoginStatus);let e=this.requestedLoginStatus;switch(this.requestedLoginStatus=R.UNKNOWN,e){case R.LOGGED_IN:this._kcwrapper.login({lang:this.lang,scope:this.scope||``});break;case R.LOGGED_OUT:this._loginStatus===R.LOGGED_IN&&this._setLoginStatus(R.LOGGING_OUT),this._kcwrapper.logout(),this._loginStatus===R.LOGGING_OUT&&this._setLoginStatus(R.LOGGED_IN);break}break}}}),super.update(e)}async _fetchUser(e,t){let n=y(this.entryPointUrl,`/frontend/users/${encodeURIComponent(e)}`),r=await fetch(n,{headers:{Authorization:`Bearer `+t}});if(!r.ok)throw r;return{roles:(await r.json()).roles??[]}}async _onKCChanged(e){let t=e.detail;if(this._authenticated=t.authenticated,t.authenticated){if(t.subject!==this.subject){this._loginStatus===R.LOGGED_IN&&(this._setLoginStatus(R.LOGGING_OUT),this._setLoggedOut());let e=t.idTokenParsed.preferred_username;this._userId=e;let n;try{n=await this._fetchUser(e,t.token)}catch(e){console.error(e),n={roles:[]}}e===this._userId&&(this._user=n)}let e=this.token!==t.token;this.token=t.token,this.name=t.idTokenParsed.name,this.subject=t.subject,this._user!==null&&this._setLoginStatus(R.LOGGED_IN,e)}else this._loginStatus===R.LOGGED_IN&&this._setLoginStatus(R.LOGGING_OUT),this._setLoggedOut()}_setLoggedOut(){this.name=``,this.token=``,this.subject=``,this._userId=``,this._user=null,this._setLoginStatus(R.LOGGED_OUT)}sendSetPropertyEvents(){let e={"login-status":this._loginStatus,subject:this.subject,token:this.token,"user-full-name":this.name,"user-id":this._userId,"person-id":this._userId,person:this._user,_roles:this._user?this._user.roles:[]};this.sendSetPropertyEvent(`auth`,e)}_setLoginStatus(e,t){this._loginStatus===e&&!t||(this._loginStatus=e,this.sendSetPropertyEvents())}static get properties(){return{...super.properties,lang:{type:String},forceLogin:{type:Boolean,attribute:`force-login`},tryLogin:{type:Boolean,attribute:`try-login`},entryPointUrl:{type:String,attribute:`entry-point-url`},name:{type:String,attribute:!1},token:{type:String,attribute:!1},subject:{type:String,attribute:!1},_userId:{type:String,attribute:!1},_user:{type:Object,attribute:!1},_loginStatus:{type:String,attribute:!1},keycloakUrl:{type:String,attribute:`url`},realm:{type:String},clientId:{type:String,attribute:`client-id`},silentCheckSsoRedirectUri:{type:String,attribute:`silent-check-sso-redirect-uri`},scope:{type:String},idpHint:{type:String,attribute:`idp-hint`},requestedLoginStatus:{type:String,attribute:`requested-login-status`},noCheckLoginIframe:{type:Boolean,attribute:`no-check-login-iframe`}}}connectedCallback(){if(super.connectedCallback(),!this.keycloakUrl)throw Error(`url not set`);if(!this.realm)throw Error(`realm not set`);if(!this.clientId)throw Error(`client-id not set`);this._kcwrapper=new L(this.keycloakUrl,this.realm,this.clientId,this.silentCheckSsoRedirectUri,!this.noCheckLoginIframe,this.idpHint),this._kcwrapper.addEventListener(`changed`,this._onKCChanged),(async()=>{try{this.forceLogin||this._kcwrapper.isLoggingIn()?(this._setLoginStatus(R.LOGGING_IN),await this._kcwrapper.login({lang:this.lang,scope:this.scope||``})):this.tryLogin?(this._setLoginStatus(R.LOGGING_IN),await this._kcwrapper.tryLogin(),this._authenticated||this._setLoginStatus(R.LOGGED_OUT)):this._setLoginStatus(R.LOGGED_OUT)}catch(e){throw this._setLoginStatus(R.LOGGED_OUT),T({summary:this._i18n.t(`login-failed`),type:`danger`,timeout:5}),e}})()}disconnectedCallback(){this._kcwrapper.close(),this._kcwrapper.removeEventListener(`changed`,this._onKCChanged),super.disconnectedCallback()}},B=class extends u(f(t(m),O)){constructor(){super(),this.closeDropdown=this.closeDropdown.bind(this),this.onWindowResize=this.onWindowResize.bind(this)}static get scopedElements(){return{"dbp-icon":o}}onWindowResize(){this.updateDropdownWidth()}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.onWindowResize),document.addEventListener(`click`,this.closeDropdown)}disconnectedCallback(){window.removeEventListener(`resize`,this.onWindowResize),document.removeEventListener(`click`,this.closeDropdown),super.disconnectedCallback()}updateDropdownWidth(){let e=this.shadowRoot.querySelector(`div.dropdown-menu`);if(!e)return;let t=this.getBoundingClientRect(),n=window.innerWidth-t.left;e.setAttribute(`style`,`width: ${n-20}px`)}onLoginClicked(e){this.sendSetPropertyEvent(`requested-login-status`,R.LOGGED_IN),e.preventDefault()}onLogoutClicked(e){this.sendSetPropertyEvent(`requested-login-status`,R.LOGGED_OUT)}static get styles(){return c` ${_()} :host { display: inline-block; } a { color: var(--dbp-content); fill: var(--dbp-content); cursor: pointer; text-decoration: none; display: block; } input::-moz-focus-inner { border: 0; } :focus-visible { outline: none !important; outline-width: 0 !important; box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: 0px 0px 4px 2px var(--dbp-primary); } .dropdown.is-active .dropdown-menu, .dropdown.is-hoverable:hover .dropdown-menu { display: block; } .dropdown-menu { display: none; min-width: 5em; max-width: 25em; position: absolute; z-index: 20; border: var(--dbp-border); border-radius: 0px; overflow: hidden; background-color: var(--dbp-background); } .dropdown-content { padding-bottom: 0.5rem; padding-top: 0.5rem; } .menu a { /*padding: 0.3em;*/ font-weight: 400; color: var(--dbp-content); display: block; text-decoration: none; } .menu a:hover { color: var(--dbp-hover-color, var(--dbp-content)); background-color: var(--dbp-hover-background-color); } .menu a.selected { color: var(--dbp-on-secondary-surface); background-color: var(--dbp-secondary-surface); } .dropdown-item { color: var(--dbp-muted); display: block; font-size: 0.875rem; line-height: 1.5; padding: 0.375rem 1rem; margin-left: 0.5em; margin-right: 0.5em; padding-left: 0.5em; padding-right: 0.5em; position: relative; } .dropdown { cursor: pointer; } a.dropdown-item { width: initial !important; } .main-button { min-width: 150px; } .menu-icon { height: 1em; width: 1em; vertical-align: -0.1rem; } .login-box svg { width: 1.1em; height: 1.1em; display: flex; } .login-button { padding: 0.3em 0.4em; transition: background-color 0.15s, color 0.15s; } .login-button:hover { color: var(--dbp-hover-color, var(--dbp-content)); background-color: var(--dbp-hover-background-color); cursor: pointer; transition: none; } .login-box { display: flex; align-items: center; } .login-box:hover svg path { fill: var(--dbp-hover-color); } .login-box .label { padding-left: 0.2em; } .dropdown-trigger { display: flex; align-items: center; } .dropdown-trigger .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-right: 0.5em; } `}setChevron(e){let t=this.shadowRoot.querySelector(`#menu-chevron-icon`);t!==null&&(t.name=e)}onDropdownClick(e){e.stopPropagation(),e.currentTarget.classList.toggle(`is-active`),this.setChevron(e.currentTarget.classList.contains(`is-active`)?`chevron-up`:`chevron-down`),this.updateDropdownWidth()}closeDropdown(){this.shadowRoot.querySelectorAll(`.dropdown`).forEach(function(e){e.classList.remove(`is-active`)}),this.setChevron(`chevron-down`)}renderLoggedIn(){let e=this._i18n;return i` <div class="dropdown" @click="${this.onDropdownClick}"> <a href="#"> <div class="dropdown-trigger login-button"> <div class="name">${this.auth[`user-full-name`]}</div> <dbp-icon class="menu-icon" name="chevron-down" id="menu-chevron-icon"></dbp-icon> </div> </a> <div class="dropdown-menu" id="dropdown-menu2" role="menu"> <div class="dropdown-content" @blur="${this.closeDropdown}"> <div class="menu"> <a href="#" @click="${this.onLogoutClicked}" class="dropdown-item"> ${e.t(`logout`)} </a> </div> </div> </div> </div> `}renderLoggedOut(){let e=this._i18n;return i` <a href="#" @click="${this.onLoginClicked}"> <div class="login-box login-button"> <div class="icon" aria-hidden="true">${v(` <svg viewBox="0 0 100 100" y="0px" x="0px" id="icon" role="img" version="1.1"> <g id="g6"> <path style="stroke-width:1.33417916" id="path2" d="m 42.943908,38.894934 5.885859,6.967885 H 5.4215537 c -1.8393311,0 -3.4334181,1.741972 -3.4334181,4.064599 0,2.322628 1.4714649,4.064599 3.4334181,4.064599 H 48.829767 L 42.943908,60.9599 c -1.348843,1.596808 -1.348843,4.064599 0,5.661406 1.348843,1.596808 3.433418,1.596808 4.782261,0 L 61.705085,49.927418 47.726169,33.378693 c -1.348843,-1.596806 -3.433418,-1.596806 -4.782261,0 -1.348843,1.596807 -1.348843,4.064599 0,5.516241 z" /> <path id="path4" d="m 50,2.3007812 c -18.777325,0 -35.049449,10.9124408 -42.8261719,26.7246098 H 13.390625 C 20.672112,16.348362 34.336876,7.8007812 50,7.8007812 73.3,7.8007812 92.300781,26.7 92.300781,50 92.300781,73.3 73.3,92.300781 50,92.300781 c -15.673389,0 -29.345175,-8.60579 -36.623047,-21.326172 H 7.1640625 C 14.942553,86.8272 31.242598,97.800781 50.099609,97.800781 76.399609,97.800781 97.900391,76.4 97.900391,50 97.800391,23.7 76.3,2.3007812 50,2.3007812 Z" /> </g> </svg> `)}</div> <div class="label">${e.t(`login`)}</div> </div> </a> `}render(){return i` <div class="authbox"> ${this.isLoggedIn()?this.renderLoggedIn():this.renderLoggedOut()} </div> `}},V={"add-notification":`Benachrichtigung hinzufügen`,"open-dialog":`Dialog öffnen`,send:`Senden`},H={"add-notification":`Add Notification`,"open-dialog":`Open Dialog`,send:`Send`};function U(){return l({en:H,de:V},`de`,`en`)}var W=class extends f(h,U){constructor(){super(),this.notificationBlock=null,this.notifications={},this.targetNotificationId=null}static get properties(){return{...super.properties,inline:{type:Boolean,attribute:`inline`}}}connectedCallback(){super.connectedCallback(),window.addEventListener(`dbp-notification-send`,e=>{let t=e;if(t.detail===void 0||(this.targetNotificationId=t.detail.targetNotificationId===void 0?null:t.detail.targetNotificationId,this.targetNotificationId&&this.targetNotificationId!==this.id)||!this.targetNotificationId&&this.id!==`dbp-notification`)return;this.notificationBlock=this._(`#notification-container`);let n=`notification-${r()}`;this.notifications[n]={},this.notifications[n].id=n,this.notifications[n].messageSelector=`#${n}`;let i=t.detail.type===void 0?`info`:t.detail.type,a=t.detail.body===void 0?``:t.detail.body,o=t.detail.summary===void 0?``:t.detail.summary,s=t.detail.timeout===void 0?0:t.detail.timeout,c=t.detail.icon===void 0?``:t.detail.icon,l=c===``?``:`<dbp-icon name="${c}"></dbp-icon>`,u=o===``?``:`<h3>${o}</h3>`,d=t.detail.replaceId===void 0?null:t.detail.replaceId;if(d)for(let e in this.notifications)this.notifications[e].replaceId===d&&this.removeMessageById(this.notifications[e]);this.notifications[n].replaceId=d;let f=s>0?`<div class="progress-container"><div class="progress" style="--dbp-progress-timeout: ${s}s;"></div></div>`:``,p=s>0?`has-progress-bar`:`no-progress-bar`,m=document.createElement(`div`);m.id=n,m.classList.add(`notification`,`enter-animation`,`is-${i}`,p),m.innerHTML=` <button id="${n}-button" class="delete"></button> ${u} ${l} ${a} ${f} `,this.notificationBlock.appendChild(m),this.notificationBlock.querySelector(`#${n}-button`).addEventListener(`click`,()=>this.removeMessageById(this.notifications[n])),s>0&&(this.notifications[n].progressTimeout=setTimeout(()=>{this.removeMessageById(this.notifications[n])},s*1e3)),e.preventDefault()})}disconnectedCallback(){super.disconnectedCallback();for(let e of Object.values(this.notifications))clearTimeout(e.progressTimeout)}removeMessageById(e,t=!1){let n=e.messageSelector,r=this._(n);if(r){let n=t?0:500;r.classList.add(`is-removing`),setTimeout(()=>{this.notificationBlock.removeChild(r);let e=new CustomEvent(`dbp-notification-close`,{detail:{targetNotificationId:this.targetNotificationId},bubbles:!0,composed:!0});this.dispatchEvent(e)},n),clearTimeout(this.notifications[e.id].progressTimeout),delete this.notifications[e.id]}}removeAllNotifications(){for(let e of Object.values(this.notifications))this.removeMessageById(e,!0)}static get styles(){return c` ${_()} ${w()} ${C()} .notification-container { position: fixed; top: 0; max-width: 500px; margin: 0.75em auto; left: 0; right: 0; z-index: 1000; padding: 0; } :host([inline]) .notification-container { top: 0; left: 0; right: 0; max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; } :host([inline]) .notification-container--inside { margin-top: 60px; } :host([inline]) .notification:not(:last-child) { /* margin-bottom: 1rem; */ } .notification h3 { font: inherit; font-weight: bold; margin-bottom: 3px; } .delete, .modal-close { -moz-appearance: none; -webkit-appearance: none; background-color: rgba(10, 10, 10, 0.2); border: none; border-radius: 290486px; cursor: pointer; pointer-events: auto; display: inline-block; flex-grow: 0; flex-shrink: 0; font-size: 0; height: 20px; max-height: 20px; max-width: 20px; min-height: 20px; min-width: 20px; outline: 0; position: relative; vertical-align: top; width: 20px; } .delete::before, .modal-close::before, .delete::after, .modal-close::after { background-color: var(--dbp-background); color: var(--dbp-content); content: ''; display: block; left: 50%; position: absolute; top: 50%; -webkit-transform: translateX(-50%) translateY(-50%) rotate(45deg); transform: translateX(-50%) translateY(-50%) rotate(45deg); -webkit-transform-origin: center center; transform-origin: center center; } .delete::before, .modal-close::before { height: 2px; width: 50%; } .delete::after, .modal-close::after { height: 50%; width: 2px; } .delete:hover, .modal-close:hover, .delete:focus, .modal-close:focus { background-color: rgba(10, 10, 10, 0.3); } .delete:active, .modal-close:active { background-color: rgba(10, 10, 10, 0.4); } `}render(){return i` <div class="columns"> <div class="column notification-container" id="notification-container"></div> </div> `}},G={"color-mode":`Farbmodus ändern`,"demo-title":`Theme Switcher Demo`,intro:`Mit dem Theme-Switcher können Sie zwischen unterschiedlichen Farb-Themes umschalten.`},K={"color-mode":`Change color mode`,"demo-title":`Theme Switcher Demo`,intro:`With the theme-switcher you can switch between multiple themes.`};function ne(){return l({en:K,de:G},`de`,`en`)}var re=class extends f(t(m),ne){constructor(){super(),this.themes=[],this.boundCloseAdditionalMenuHandler=this.hideModeMenu.bind(this),this.detectBrowserDarkMode=!1,this.darkModeClass=`dark-theme`,this.langDir=``,this.dropdownRight=!1,this.darkModeThemeOverride=null}static get properties(){return{...super.properties,themes:{type:Array,attribute:`themes`},darkModeThemeOverride:{type:String,attribute:`dark-mode-theme-override`},dropdownRight:{type:Boolean,attribute:`dropdown-right`},langDir:{type:String,attribute:`lang-dir`}}}static get scopedElements(){return{"dbp-icon":o}}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.darkModeThemeOverride===null?this.detectBrowserDarkMode=!0:this.darkModeThemeOverride===``?this.detectBrowserDarkMode=!1:(this.detectBrowserDarkMode=!0,this.darkModeClass=this.darkModeThemeOverride),this.loadTheme(`light-theme`),this.detectInitialMode()}),this.langDir&&e(this._i18n,this)}detectInitialMode(){let e=localStorage.getItem(`prefered-color-mode`);if(e){let t=this.themes.find(t=>t.class===e);t&&this.loadTheme(t.class);return}if(this.detectBrowserDarkMode&&window.matchMedia(`(prefers-color-scheme: dark)`).matches){let e=this.themes.find(e=>e.class===this.darkModeClass);e&&this.loadTheme(e.class)}}toggleModeMenu(){let e=this.shadowRoot.querySelector(`.mode-button`);if(!e)return;e.classList.contains(`active`)?e.classList.remove(`active`):e.classList.add(`active`);let t=this.shadowRoot.querySelector(`ul.extended-menu`),n=this.shadowRoot.querySelector(`.mode-button`);t===null||n===null||(t.classList.toggle(`hidden`),t.classList.contains(`hidden`)?document.removeEventListener(`click`,this.boundCloseAdditionalMenuHandler):(document.addEventListener(`click`,this.boundCloseAdditionalMenuHandler),this.initateOpenAdditionalMenu=!0))}hideModeMenu(){if(this.initateOpenAdditionalMenu){this.initateOpenAdditionalMenu=!1;return}let e=this.shadowRoot.querySelector(`ul.extended-menu`);e&&!e.classList.contains(`hidden`)&&this.toggleModeMenu()}loadTheme(e){let t=this.shadowRoot.querySelector(`.button-`+e),n=this.shadowRoot.querySelectorAll(`.button-theme`),r=this.shadowRoot.host.getRootNode({composed:!0}).body;t===null||n.length===0||r===null||(n.forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`),r.classList.contains(e)||(this.themes.forEach(e=>{r.classList.remove(e.class)}),r.classList.add(e)))}saveTheme(e){let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=window.matchMedia(`(prefers-color-scheme: light)`);e===`light-theme`&&n.matches||e===this.darkModeClass&&t.matches?localStorage.removeItem(`prefered-color-mode`):localStorage.setItem(`prefered-color-mode`,e)}static get styles(){return c` ${_()} ${w()} ${d()} mode-button, button.button { border: none; } .active, .extended-menu li a.active dbp-icon { color: var(--dbp-accent); } .active { font-weight: bolder; } a:hover:not(.active), .extended-menu li a:hover:not(.active) { color: var(--dbp-hover-color, var(--dbp-content)); background-color: var(--dbp-hover-background-color); transition: none; } a { padding: 0.3em; display: inline-block; text-decoration: none; transition: background-color 0.15s, color 0.15s; color: var(--dbp-content); } .extended-menu { list-style: none; border: var(--dbp-border); position: absolute; background-color: var(--dbp-background); z-index: 1000; border-radius: var(--dbp-border-radius); } .extended-menu li { text-align: left; min-width: 160px; } .extended-menu li a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 12px 15px; width: 100%; box-sizing: border-box; text-align: left; color: var(--dbp-content); background: none; display: block; } .icon { margin-right: 10px; } #theme-menu { position: relative; } .ul-right { right: 0px; } `}render(){let e=this._i18n;return i` <div id="theme-menu" class="${p({hidden:this.themes.length<=1})}"> <a href="#" class="mode-button" title="${e.t(`color-mode`)}" @click="${e=>{this.toggleModeMenu(),e.preventDefault()}}"> <dbp-icon name="contrast"></dbp-icon> </a> <ul class="extended-menu hidden ${p({"ul-right":this.dropdownRight})}"> ${this.themes.map(e=>i` <li class="" id="${e.class}"> <a href="#" class="button-theme button-${e.class}" @click="${t=>{this.loadTheme(e.class),this.saveTheme(e.class),t.preventDefault()}}" title="${e.name}"> <dbp-icon class="icon" name="${e.icon}"></dbp-icon> ${e.name} </a> </li> `)} </ul> </div> `}},ie=class extends m{constructor(){super(),this._observer=null,this._dark=!1}static get properties(){return{...super.properties,_dark:{type:Boolean}}}static get styles(){return c` .hidden { display: none; } `}connectedCallback(){super.connectedCallback(),this._observer=new MutationObserver(()=>{this._dark=document.body.classList.contains(`dark-theme`)}),this._observer.observe(document.body,{attributes:!0,attributeFilter:[`class`]})}disconnectedCallback(){this._observer.disconnect(),this._observer=null,super.disconnectedCallback()}render(){return i` <slot class="${p({hidden:this._dark})}" name="light"></slot> <slot class="${p({hidden:!this._dark})}" name="dark"></slot> `}}; /*! Path-to-RegExp | MIT License | https://github.com/pillarjs/path-to-regexp */ const q=e=>e,ae=/^[$_\p{ID_Start}]$/u,J=/^[$\u200c\u200d\p{ID_Continue}]$/u,Y=`https://git.new/pathToRegexpError`,oe={"{":`{`,"}":`}`,"(":`(`,")":`)`,"[":`[`,"]":`]`,"+":`+`,"?":`?`,"!":`!`};function se(e){return e.replace(/[{}()\[\]+?!:*]/g,`\\$&`)}function X(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,`\\$&`)}function*ce(e){let t=[...e],n=0;function r(){let e=``;if(ae.test(t[++n]))for(e+=t[n];J.test(t[++n]);)e+=t[n];else if(t[n]===`"`){let r=n;for(;n<t.length;){if(t[++n]===`"`){n++,r=0;break}t[n]===`\\`?e+=t[++n]:e+=t[n]}if(r)throw TypeError(`Unterminated quote at ${r}: ${Y}`)}if(!e)throw TypeError(`Missing parameter name at ${n}: ${Y}`);return e}for(;n<t.length;){let e=t[n],i=oe[e];if(i)yield{type:i,index:n++,value:e};else if(e===`\\`)yield{type:`ESCAPED`,index:n++,value:t[n++]};else if(e===`:`){let e=r();yield{type:`PARAM`,index:n,value:e}}else if(e===`*`){let e=r();yield{type:`WILDCARD`,index:n,value:e}}else yield{type:`CHAR`,index:n,value:t[n++]}}return{type:`END`,index:n,value:``}}var le=class{constructor(e){this.tokens=e}peek(){return this._peek||=this.tokens.next().value,this._peek}tryConsume(e){let t=this.peek();if(t.type===e)return this._peek=void 0,t.value}consume(e){let t=this.tryConsume(e);if(t!==void 0)return t;let{type:n,index:r}=this.peek();throw TypeError(`Unexpected ${n} at ${r}, expected ${e}: ${Y}`)}text(){let e=``,t;for(;t=this.tryConsume(`CHAR`)||this.tryConsume(`ESCAPED`);)e+=t;return e}},Z=class{constructor(e){this.tokens=e}};function Q(e,t={}){let{encodePath:n=q}=t,r=new le(ce(e));function i(e){let t=[];for(;;){let a=r.text();a&&t.push({type:`text`,value:n(a)});let o=r.tryConsume(`PARAM`);if(o){t.push({type:`param`,name:o});continue}let s=r.tryConsume(`WILDCARD`);if(s){t.push({type:`wildcard`,name:s});continue}if(r.tryConsume(`{`)){t.push({type:`group`,tokens:i(`}`)});continue}return r.consume(e),t}}return new Z(i(`END`))}function ue(e,t={}){let{encode:n=encodeURIComponent,delimiter:r=`/`}=t,i=de((e instanceof Z?e:Q(e,t)).tokens,r,n);return function(e={}){let[t,...n]=i(e);if(n.length)throw TypeError(`Missing parameters: ${n.join(`, `)}`);return t}}function de(e,t,n){let r=e.map(e=>fe(e,t,n));return e=>{let t=[``];for(let n of r){let[r,...i]=n(e);t[0]+=r,t.push(...i)}return t}}function fe(e,t,n){if(e.type===`text`)return()=>[e.value];if(e.type===`group`){let r=de(e.tokens,t,n);return e=>{let[t,...n]=r(e);return n.length?[``]:[t]}}let r=n||q;return e.type===`wildcard`&&n!==!1?n=>{let i=n[e.name];if(i==null)return[``,e.name];if(!Array.isArray(i)||i.length===0)throw TypeError(`Expected "${e.name}" to be a non-empty array`);return[i.map((t,n)=>{if(typeof t!=`string`)throw TypeError(`Expected "${e.name}/${n}" to be a string`);return r(t)}).join(t)]}:t=>{let n=t[e.name];if(n==null)return[``,e.name];if(typeof n!=`string`)throw TypeError(`Expected "${e.name}" to be a string`);return[r(n)]}}function pe(e,t={}){let{decode:n=decodeURIComponent,delimiter:r=`/`}=t,{regexp:i,keys:a}=me(e,t),o=a.map(e=>n===!1?q:e.type===`param`?n:e=>e.split(r).map(n));return function(e){let t=i.exec(e);if(!t)return!1;let n=t[0],r=Object.create(null);for(let e=1;e<t.length;e++){if(t[e]===void 0)continue;let n=a[e-1],i=o[e-1];r[n.name]=i(t[e])}return{path:n,params:r}}}function me(e,t={}){let{delimiter:n=`/`,end:r=!0,sensitive:i=!1,trailing:a=!0}=t,o=[],s=[],c=i?``:`i`,l=(Array.isArray(e)?e:[e]).map(e=>e instanceof Z?e:Q(e,t));for(let{tokens:e}of l)for(let t of $(e,0,[])){let e=he(t,n,o);s.push(e)}let u=`^(?:${s.join(`|`)})`;return a&&(u+=`(?:${X(n)}$)?`),u+=r?`$`:`(?=${X(n)}|$)`,{regexp:new RegExp(u,c),keys:o}}function*$(e,t,n){if(t===e.length)return yield n;let r=e[t];if(r.type===`group`){let i=n.slice();for(let n of $(r.tokens,0,i))yield*$(e,t+1,n)}else n.push(r);yield*$(e,t+1,n)}function he(e,t,n){let r=``,i=``,a=!0;for(let o=0;o<e.length;o++){let s=e[o];if(s.type===`text`){r+=X(s.value),i+=s.value,a||=s.value.includes(t);continue}if(s.type===`param`||s.type===`wildcard`){if(!a&&!i)throw TypeError(`Missing text after "${s.name}": ${Y}`);s.type===`param`?r+=`(${ge(t,a?``:i)}+)`:r+=`([\\s\\S]+)`,n.push(s),i=``,a=!1;continue}}return r}function ge(e,t){return t.length<2?e.length<2?`[^${X(e+t)}]`:`(?:(?!${X(e)})[^${X(t)}])`:e.length<2?`(?:(?!${X(t)})[^${X(e)}])`:`(?:(?!${X(t)}|${X(e)})[\\s\\S])`}function _e(e){return e.tokens.map(function e(t,n,r){if(t.type===`text`)return se(t.value);if(t.type===`group`)return`{${t.tokens.map(e).join(``)}}`;let i=ve(t.name)&&ye(r[n+1])?t.name:JSON.stringify(t.name);if(t.type===`param`)return`:${i}`;if(t.type==