@pod-os/elements 0.30.2-rc.8724051.0 → 0.30.2-rc.ca6f577.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.
@@ -16,7 +16,7 @@ import{d as t,r as e,h as n,H as i,e as s,f as o,w as r,i as a,j as c,k as l}fro
16
16
  */const ee=t=>{const e=D();const n=D();const i=u(t);const s=i.querySelector(".toast-wrapper");n.addElement(s).fromTo("opacity",.99,0);return e.easing("cubic-bezier(.36,.66,.04,1)").duration(300).addAnimation(n)};
17
17
  /*!
18
18
  * (C) Ionic http://ionicframework.com - MIT License
19
- */const ne=(t,e,n)=>{const i=u(t).querySelector(".toast-wrapper");const s=t.clientHeight;const o=i.getBoundingClientRect();let r=0;const a=.5;const c=t.position==="middle"?.5:0;const l=t.position==="top"?-1:1;const d=Gt(s,o.height);const h=[{offset:0,transform:`translateY(-${d+o.height}px)`},{offset:.5,transform:`translateY(0px)`},{offset:1,transform:`translateY(${d+o.height}px)`}];const f=D("toast-swipe-to-dismiss-animation").addElement(i).duration(100);switch(t.position){case"middle":r=s+o.height;f.keyframes(h);f.progressStart(true,.5);break;case"top":r=o.bottom;f.keyframes([{offset:0,transform:`translateY(${e.top})`},{offset:1,transform:"translateY(-100%)"}]);f.progressStart(true,0);break;case"bottom":default:r=s-o.top;f.keyframes([{offset:0,transform:`translateY(${e.bottom})`},{offset:1,transform:"translateY(100%)"}]);f.progressStart(true,0);break}const p=t=>t*l/r;const m=t=>{const e=c+p(t.deltaY);f.progressStep(e)};const b=e=>{const s=e.velocityY;const o=(e.deltaY+s*1e3)/r*l;g.enable(false);let c=true;let u=1;let m=0;let b=0;if(t.position==="middle"){c=o>=a/2||o<=-a/2;u=1;m=0;const t=i.getBoundingClientRect();const n=t.top-d;const s=`${n}px`;const r=e.deltaY<=0?-1:1;const l=(d+t.height)*r;const h=c?`${l}px`:"0px";const p=[{offset:0,transform:`translateY(${s})`},{offset:1,transform:`translateY(${h})`}];f.keyframes(p);b=l-n}else{c=o>=a;u=c?1:0;m=p(e.deltaY);const t=c?1-m:m;b=t*r}const w=Math.min(Math.abs(b)/Math.abs(s),200);f.onFinish((()=>{if(c){n();f.destroy()}else{if(t.position==="middle"){f.keyframes(h).progressStart(true,.5)}else{f.progressStart(true,0)}g.enable(true)}}),{oneTimeCallback:true}).progressEnd(u,m,w)};const g=j({el:i,gestureName:"toast-swipe-to-dismiss",gesturePriority:x,direction:"y",onMove:m,onEnd:b});return g};const ie=":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-50, #f2f2f2);--border-radius:14px;--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-850, #262626);--max-width:700px;--max-height:478px;--start:10px;--end:10px;font-size:clamp(14px, 0.875rem, 43.4px)}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;z-index:10}@supports (backdrop-filter: blur(0)){:host(.toast-translucent) .toast-wrapper{background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);backdrop-filter:saturate(180%) blur(20px)}:host(.ion-color.toast-translucent) .toast-wrapper{background:rgba(var(--ion-color-base-rgb), 0.8)}}.toast-wrapper.toast-middle{opacity:0.01}.toast-content{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:15px;padding-bottom:15px}.toast-header{margin-bottom:2px;font-weight:500}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;min-height:44px;transition:background-color, opacity 100ms linear;border:0;background-color:transparent;font-family:var(--ion-font-family);font-size:clamp(17px, 1.0625rem, 21.998px);font-weight:500;overflow:hidden}.toast-button.ion-activated{opacity:0.4}@media (any-hover: hover){.toast-button:hover{opacity:0.6}}";const se=ie;const oe=":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-800, #333333);--border-radius:4px;--box-shadow:0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-50, #f2f2f2);--max-width:700px;--start:8px;--end:8px;font-size:0.875rem}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;opacity:0.01;z-index:10}.toast-content{-webkit-padding-start:16px;padding-inline-start:16px;-webkit-padding-end:16px;padding-inline-end:16px;padding-top:14px;padding-bottom:14px}.toast-header{margin-bottom:2px;font-weight:500;line-height:1.25rem}.toast-message{line-height:1.25rem}.toast-layout-baseline .toast-button-group-start{-webkit-margin-start:8px;margin-inline-start:8px}.toast-layout-stacked .toast-button-group-start{-webkit-margin-end:8px;margin-inline-end:8px;margin-top:8px}.toast-layout-baseline .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px}.toast-layout-stacked .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px;margin-bottom:8px}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;position:relative;background-color:transparent;font-family:var(--ion-font-family);font-size:0.875rem;font-weight:500;letter-spacing:0.84px;text-transform:uppercase;overflow:hidden}.toast-button-cancel{color:var(--ion-color-step-100, #e6e6e6)}.toast-button-icon-only{border-radius:50%;-webkit-padding-start:9px;padding-inline-start:9px;-webkit-padding-end:9px;padding-inline-end:9px;padding-top:9px;padding-bottom:9px;width:36px;height:36px}@media (any-hover: hover){.toast-button:hover{background-color:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.08)}.toast-button-cancel:hover{background-color:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.08)}}";const re=oe;const ae=class{constructor(t){e(this,t);this.didPresent=a(this,"ionToastDidPresent",7);this.willPresent=a(this,"ionToastWillPresent",7);this.willDismiss=a(this,"ionToastWillDismiss",7);this.didDismiss=a(this,"ionToastDidDismiss",7);this.didPresentShorthand=a(this,"didPresent",7);this.willPresentShorthand=a(this,"willPresent",7);this.willDismissShorthand=a(this,"willDismiss",7);this.didDismissShorthand=a(this,"didDismiss",7);this.delegateController=S(this);this.lockController=v();this.triggerController=_();this.customHTMLEnabled=b.get("innerHTMLTemplatesEnabled",w);this.presented=false;this.dispatchCancelHandler=t=>{const e=t.detail.role;if(E(e)){const t=this.getButtons().find((t=>t.role==="cancel"));this.callButtonHandler(t)}};this.createSwipeGesture=t=>{const e=this.gesture=ne(this.el,t,(()=>{this.dismiss(undefined,I)}));e.enable(true)};this.destroySwipeGesture=()=>{const{gesture:t}=this;if(t===undefined){return}t.destroy();this.gesture=undefined};this.prefersSwipeGesture=()=>{const{swipeGesture:t}=this;return t==="vertical"};this.revealContentToScreenReader=false;this.overlayIndex=undefined;this.delegate=undefined;this.hasController=false;this.color=undefined;this.enterAnimation=undefined;this.leaveAnimation=undefined;this.cssClass=undefined;this.duration=b.getNumber("toastDuration",0);this.header=undefined;this.layout="baseline";this.message=undefined;this.keyboardClose=false;this.position="bottom";this.positionAnchor=undefined;this.buttons=undefined;this.translucent=false;this.animated=true;this.icon=undefined;this.htmlAttributes=undefined;this.swipeGesture=undefined;this.isOpen=false;this.trigger=undefined}swipeGestureChanged(){this.destroySwipeGesture();if(this.presented&&this.prefersSwipeGesture()){this.createSwipeGesture(this.lastPresentedPosition)}}onIsOpenChange(t,e){if(t===true&&e===false){this.present()}else if(t===false&&e===true){this.dismiss()}}triggerChanged(){const{trigger:t,el:e,triggerController:n}=this;if(t){n.addClickListener(e,t)}}connectedCallback(){A(this.el);this.triggerChanged()}disconnectedCallback(){this.triggerController.removeClickListener()}componentWillLoad(){T(this.el)}componentDidLoad(){if(this.isOpen===true){h((()=>this.present()))}this.triggerChanged()}async present(){const t=await this.lockController.lock();await this.delegateController.attachViewToDom();const{el:e,position:n}=this;const i=this.getAnchorElement();const s=Yt(n,i,g(this),e);this.lastPresentedPosition=s;await z(this,"toastEnter",Zt,te,{position:n,top:s.top,bottom:s.bottom});this.revealContentToScreenReader=true;if(this.duration>0){this.durationTimeout=setTimeout((()=>this.dismiss(undefined,"timeout")),this.duration)}if(this.prefersSwipeGesture()){this.createSwipeGesture(s)}t()}async dismiss(t,e){var n,i;const s=await this.lockController.lock();const{durationTimeout:o,position:r,lastPresentedPosition:a}=this;if(o){clearTimeout(o)}const c=await C(this,t,e,"toastLeave",Qt,ee,{position:r,top:(n=a===null||a===void 0?void 0:a.top)!==null&&n!==void 0?n:"",bottom:(i=a===null||a===void 0?void 0:a.bottom)!==null&&i!==void 0?i:""});if(c){this.delegateController.removeViewFromDom();this.revealContentToScreenReader=false}this.lastPresentedPosition=undefined;this.destroySwipeGesture();s();return c}onDidDismiss(){return $(this.el,"ionToastDidDismiss")}onWillDismiss(){return $(this.el,"ionToastWillDismiss")}getButtons(){const t=this.buttons?this.buttons.map((t=>typeof t==="string"?{text:t}:t)):[];return t}getAnchorElement(){const{position:t,positionAnchor:e,el:n}=this;if(e===undefined){return}if(t==="middle"&&e!==undefined){k('The positionAnchor property is ignored when using position="middle".',this.el);return undefined}if(typeof e==="string"){const t=document.getElementById(e);if(t===null){k(`An anchor element with an ID of "${e}" was not found in the DOM.`,n);return undefined}return t}if(e instanceof HTMLElement){return e}k("Invalid positionAnchor value:",e,n);return undefined}async buttonClick(t){const e=t.role;if(E(e)){return this.dismiss(undefined,e)}const n=await this.callButtonHandler(t);if(n){return this.dismiss(undefined,e)}return Promise.resolve()}async callButtonHandler(t){if(t===null||t===void 0?void 0:t.handler){try{const e=await P(t.handler);if(e===false){return false}}catch(t){console.error(t)}}return true}renderButtons(t,e){if(t.length===0){return}const i=g(this);const s={"toast-button-group":true,[`toast-button-group-${e}`]:true};return n("div",{class:s},t.map((t=>n("button",Object.assign({},t.htmlAttributes,{type:"button",class:ce(t),tabIndex:0,onClick:()=>this.buttonClick(t),part:le(t)}),n("div",{class:"toast-button-inner"},t.icon&&n("ion-icon",{"aria-hidden":"true",icon:t.icon,slot:t.text===undefined?"icon-only":undefined,class:"toast-button-icon"}),t.text),i==="md"&&n("ion-ripple-effect",{type:t.icon!==undefined&&t.text===undefined?"unbounded":"bounded"})))))}renderToastMessage(t,e=null){const{customHTMLEnabled:i,message:s}=this;if(i){return n("div",{key:t,"aria-hidden":e,class:"toast-message",part:"message",innerHTML:y(s)})}return n("div",{key:t,"aria-hidden":e,class:"toast-message",part:"message"},s)}renderHeader(t,e=null){return n("div",{key:t,class:"toast-header","aria-hidden":e,part:"header"},this.header)}render(){const{layout:t,el:e,revealContentToScreenReader:s,header:o,message:r}=this;const a=this.getButtons();const c=a.filter((t=>t.side==="start"));const l=a.filter((t=>t.side!=="start"));const d=g(this);const u={"toast-wrapper":true,[`toast-${this.position}`]:true,[`toast-layout-${t}`]:true};if(t==="stacked"&&c.length>0&&l.length>0){k("This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.",e)}return n(i,Object.assign({key:"23803334fb668f6ce7044d3a321cb84bc753bd16",tabindex:"-1"},this.htmlAttributes,{style:{zIndex:`${6e4+this.overlayIndex}`},class:f(this.color,Object.assign(Object.assign({[d]:true},m(this.cssClass)),{"overlay-hidden":true,"toast-translucent":this.translucent})),onIonToastWillDismiss:this.dispatchCancelHandler}),n("div",{key:"7cd7138ba079fccf97f318b91e9986491ab4214d",class:u},n("div",{key:"93b78fa64e24435adeb77a04c1d1d53d2f093864",class:"toast-container",part:"container"},this.renderButtons(c,"start"),this.icon!==undefined&&n("ion-icon",{key:"9a3c71b164ebcfba2540acb7568beffa76b62f47",class:"toast-icon",part:"icon",icon:this.icon,lazy:false,"aria-hidden":"true"}),n("div",{key:"feb9268102d844f1314205f7440de7066cf0620e",class:"toast-content",role:"status","aria-atomic":"true","aria-live":"polite"},!s&&o!==undefined&&this.renderHeader("oldHeader","true"),!s&&r!==undefined&&this.renderToastMessage("oldMessage","true"),s&&o!==undefined&&this.renderHeader("header"),s&&r!==undefined&&this.renderToastMessage("header")),this.renderButtons(l,"end"))))}get el(){return s(this)}static get watchers(){return{swipeGesture:["swipeGestureChanged"],isOpen:["onIsOpenChange"],trigger:["triggerChanged"]}}};const ce=t=>Object.assign({"toast-button":true,"toast-button-icon-only":t.icon!==undefined&&t.text===undefined,[`toast-button-${t.role}`]:t.role!==undefined,"ion-focusable":true,"ion-activatable":true},m(t.cssClass));const le=t=>E(t.role)?"button cancel":"button";ae.style={ios:se,md:re};const de=":host{font-family:var(--font-sans);display:block}button#new{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;width:var(--size-10);height:var(--size-10);background-color:var(--pos-primary-color);color:var(--pos-primary-text-color);font-size:var(--scale-6);border-radius:var(--radius-xs)}button#new:hover,button#new:focus{outline:none;filter:brightness(110%);box-shadow:var(--shadow-sm)}pos-new-thing-form{margin:var(--scale-3)}";const ue=de;const he=class{constructor(t){e(this,t)}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"6142a141ef03ca93a362a6b00ebe8d515c3a677a"},n("button",{key:"72ecf353cd3a7d2d68f9ef28eb1bbe7fdb88b700",id:"new",title:"Add a new thing",onClick:()=>this.openDialog()},n("ion-icon",{key:"bd05d75c42c10de6df519575787fc66eafb22930",name:"add-circle-outline"})),n("pos-dialog",{key:"23cf0118149704dfca16758970e4f4658e87e946",ref:t=>this.dialog=t},n("span",{key:"5af7b7f618cc20684c39134b5ea295400e651cb6",slot:"title"},"Add a new thing"),n("pos-new-thing-form",{key:"895496c2f6ede3c8677d9d918e0b13582090baed",slot:"content",referenceUri:this.referenceUri})))}};he.style=ue;const fe=localStorage.getItem("settings");const pe=fe?JSON.parse(fe):{offlineCache:false};const me=W(pe);be();ge();function be(){me.on("set",(()=>{const t=JSON.stringify(me.state);localStorage.setItem("settings",t)}))}function ge(){window.addEventListener("storage",(t=>{if(t.key==="settings"&&t.newValue){const e=JSON.parse(t.newValue);me.state.offlineCache=e.offlineCache}}))}const we=(t,e)=>e.some((e=>t instanceof e));let ye;let ve;function ke(){return ye||(ye=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xe(){return ve||(ve=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Se=new WeakMap;const _e=new WeakMap;const Ee=new WeakMap;function Ae(t){const e=new Promise(((e,n)=>{const i=()=>{t.removeEventListener("success",s);t.removeEventListener("error",o)};const s=()=>{e(Ie(t.result));i()};const o=()=>{n(t.error);i()};t.addEventListener("success",s);t.addEventListener("error",o)}));Ee.set(e,t);return e}function Te(t){if(Se.has(t))return;const e=new Promise(((e,n)=>{const i=()=>{t.removeEventListener("complete",s);t.removeEventListener("error",o);t.removeEventListener("abort",o)};const s=()=>{e();i()};const o=()=>{n(t.error||new DOMException("AbortError","AbortError"));i()};t.addEventListener("complete",s);t.addEventListener("error",o);t.addEventListener("abort",o)}));Se.set(t,e)}let ze={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Se.get(t);if(e==="store"){return n.objectStoreNames[1]?undefined:n.objectStore(n.objectStoreNames[0])}}return Ie(t[e])},set(t,e,n){t[e]=n;return true},has(t,e){if(t instanceof IDBTransaction&&(e==="done"||e==="store")){return true}return e in t}};function Ce(t){ze=t(ze)}function $e(t){if(xe().includes(t)){return function(...e){t.apply(Re(this),e);return Ie(this.request)}}return function(...e){return Ie(t.apply(Re(this),e))}}function Pe(t){if(typeof t==="function")return $e(t);if(t instanceof IDBTransaction)Te(t);if(we(t,ke()))return new Proxy(t,ze);return t}function Ie(t){if(t instanceof IDBRequest)return Ae(t);if(_e.has(t))return _e.get(t);const e=Pe(t);if(e!==t){_e.set(t,e);Ee.set(e,t)}return e}const Re=t=>Ee.get(t);function De(t,e,{blocked:n,upgrade:i,blocking:s,terminated:o}={}){const r=indexedDB.open(t,e);const a=Ie(r);if(i){r.addEventListener("upgradeneeded",(t=>{i(Ie(r.result),t.oldVersion,t.newVersion,Ie(r.transaction),t)}))}if(n){r.addEventListener("blocked",(t=>n(t.oldVersion,t.newVersion,t)))}a.then((t=>{if(o)t.addEventListener("close",(()=>o()));if(s){t.addEventListener("versionchange",(t=>s(t.oldVersion,t.newVersion,t)))}})).catch((()=>{}));return a}const Oe=["get","getKey","getAll","getAllKeys","count"];const je=["put","add","delete","clear"];const We=new Map;function Le(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e==="string")){return}if(We.get(e))return We.get(e);const n=e.replace(/FromIndex$/,"");const i=e!==n;const s=je.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(s||Oe.includes(n))){return}const o=async function(t,...e){const o=this.transaction(t,s?"readwrite":"readonly");let r=o.store;if(i)r=r.index(e.shift());return(await Promise.all([r[n](...e),s&&o.done]))[0]};We.set(e,o);return o}Ce((t=>({...t,get:(e,n,i)=>Le(e,n)||t.get(e,n,i),has:(e,n)=>!!Le(e,n)||t.has(e,n)})));const Me=["continue","continuePrimaryKey","advance"];const He={};const Ue=new WeakMap;const Je=new WeakMap;const Ne={get(t,e){if(!Me.includes(e))return t[e];let n=He[e];if(!n){n=He[e]=function(...t){Ue.set(this,Je.get(this)[e](...t))}}return n}};async function*Ke(...t){let e=this;if(!(e instanceof IDBCursor)){e=await e.openCursor(...t)}if(!e)return;e=e;const n=new Proxy(e,Ne);Je.set(n,e);Ee.set(n,Re(e));while(e){yield n;e=await(Ue.get(n)||e.continue());Ue.delete(n)}}function Be(t,e){return e===Symbol.asyncIterator&&we(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&we(t,[IDBIndex,IDBObjectStore])}Ce((t=>({...t,get(e,n,i){if(Be(e,n))return Ke;return t.get(e,n,i)},has(e,n){return Be(e,n)||t.has(e,n)}})));class Fe{constructor(){this.dbPromise=De("OfflineCacheDB",1,{upgrade(t){if(!t.objectStoreNames.contains("documents")){const e=t.createObjectStore("documents",{keyPath:"url"});e.createIndex("url-revision",["url","revision"])}}})}async clear(){const t=await this.dbPromise;return t.clear("documents")}async get(t){const e=await this.dbPromise;return await e.get("documents",t)}async put(t){const e=await this.dbPromise;const n=await e.getFromIndex("documents","url-revision",[t.url,t.revision]);if(n){return}await e.put("documents",t)}}class Xe{isOnline(){return navigator.onLine}}const Ve=(t,e)=>new H({session:t,offlineCache:e.offlineCache?new Fe:new U,onlineStatus:new Xe});class Ye extends N{constructor(t){super();this._value=t}get value(){return this.getValue()}_subscribe(t){const e=super._subscribe(t);!e.closed&&t.next(this._value);return e}getValue(){const{hasError:t,thrownError:e,_value:n}=this;if(t){throw e}this._throwIfClosed();return n}next(t){super.next(this._value=t)}}var qe=crypto;const Ge=t=>t instanceof CryptoKey;const Ze=async(t,e)=>{const n=`SHA-${t.slice(-3)}`;return new Uint8Array(await qe.subtle.digest(n,e))};var Qe=Ze;const tn=new TextEncoder;const en=new TextDecoder;function nn(...t){const e=t.reduce(((t,{length:e})=>t+e),0);const n=new Uint8Array(e);let i=0;for(const e of t){n.set(e,i);i+=e.length}return n}const sn=t=>{let e=t;if(typeof e==="string"){e=tn.encode(e)}const n=32768;const i=[];for(let t=0;t<e.length;t+=n){i.push(String.fromCharCode.apply(null,e.subarray(t,t+n)))}return btoa(i.join(""))};const on=t=>sn(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");const rn=t=>{const e=atob(t);const n=new Uint8Array(e.length);for(let t=0;t<e.length;t++){n[t]=e.charCodeAt(t)}return n};const an=t=>{let e=t;if(e instanceof Uint8Array){e=en.decode(e)}e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return rn(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class cn extends Error{constructor(t,e){super(t,e);this.code="ERR_JOSE_GENERIC";this.name=this.constructor.name;Error.captureStackTrace?.(this,this.constructor)}}cn.code="ERR_JOSE_GENERIC";class ln extends cn{constructor(t,e,n="unspecified",i="unspecified"){super(t,{cause:{claim:n,reason:i,payload:e}});this.code="ERR_JWT_CLAIM_VALIDATION_FAILED";this.claim=n;this.reason=i;this.payload=e}}ln.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class dn extends cn{constructor(t,e,n="unspecified",i="unspecified"){super(t,{cause:{claim:n,reason:i,payload:e}});this.code="ERR_JWT_EXPIRED";this.claim=n;this.reason=i;this.payload=e}}dn.code="ERR_JWT_EXPIRED";class un extends cn{constructor(){super(...arguments);this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}un.code="ERR_JOSE_ALG_NOT_ALLOWED";class hn extends cn{constructor(){super(...arguments);this.code="ERR_JOSE_NOT_SUPPORTED"}}hn.code="ERR_JOSE_NOT_SUPPORTED";class fn extends cn{constructor(t="decryption operation failed",e){super(t,e);this.code="ERR_JWE_DECRYPTION_FAILED"}}fn.code="ERR_JWE_DECRYPTION_FAILED";class pn extends cn{constructor(){super(...arguments);this.code="ERR_JWE_INVALID"}}pn.code="ERR_JWE_INVALID";class mn extends cn{constructor(){super(...arguments);this.code="ERR_JWS_INVALID"}}mn.code="ERR_JWS_INVALID";class bn extends cn{constructor(){super(...arguments);this.code="ERR_JWT_INVALID"}}bn.code="ERR_JWT_INVALID";class gn extends cn{constructor(){super(...arguments);this.code="ERR_JWK_INVALID"}}gn.code="ERR_JWK_INVALID";class wn extends cn{constructor(){super(...arguments);this.code="ERR_JWKS_INVALID"}}wn.code="ERR_JWKS_INVALID";class yn extends cn{constructor(t="no applicable key found in the JSON Web Key Set",e){super(t,e);this.code="ERR_JWKS_NO_MATCHING_KEY"}}yn.code="ERR_JWKS_NO_MATCHING_KEY";class vn extends cn{constructor(t="multiple matching keys found in the JSON Web Key Set",e){super(t,e);this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}vn.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class kn extends cn{constructor(t="request timed out",e){super(t,e);this.code="ERR_JWKS_TIMEOUT"}}kn.code="ERR_JWKS_TIMEOUT";class xn extends cn{constructor(t="signature verification failed",e){super(t,e);this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}xn.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Sn(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function _n(t,e){return t.name===e}function En(t){return parseInt(t.name.slice(4),10)}function An(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Tn(t,e){if(e.length&&!e.some((e=>t.usages.includes(e)))){let t="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const n=e.pop();t+=`one of ${e.join(", ")}, or ${n}.`}else if(e.length===2){t+=`one of ${e[0]} or ${e[1]}.`}else{t+=`${e[0]}.`}throw new TypeError(t)}}function zn(t,e,...n){switch(e){case"HS256":case"HS384":case"HS512":{if(!_n(t.algorithm,"HMAC"))throw Sn("HMAC");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!_n(t.algorithm,"RSASSA-PKCS1-v1_5"))throw Sn("RSASSA-PKCS1-v1_5");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!_n(t.algorithm,"RSA-PSS"))throw Sn("RSA-PSS");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448"){throw Sn("Ed25519 or Ed448")}break}case"Ed25519":{if(!_n(t.algorithm,"Ed25519"))throw Sn("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!_n(t.algorithm,"ECDSA"))throw Sn("ECDSA");const n=An(e);const i=t.algorithm.namedCurve;if(i!==n)throw Sn(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Tn(t,n)}function Cn(t,e,...n){n=n.filter(Boolean);if(n.length>2){const e=n.pop();t+=`one of type ${n.join(", ")}, or ${e}.`}else if(n.length===2){t+=`one of type ${n[0]} or ${n[1]}.`}else{t+=`of type ${n[0]}.`}if(e==null){t+=` Received ${e}`}else if(typeof e==="function"&&e.name){t+=` Received function ${e.name}`}else if(typeof e==="object"&&e!=null){if(e.constructor?.name){t+=` Received an instance of ${e.constructor.name}`}}return t}var $n=(t,...e)=>Cn("Key must be ",t,...e);function Pn(t,e,...n){return Cn(`Key for the ${t} algorithm must be `,e,...n)}var In=t=>{if(Ge(t)){return true}return t?.[Symbol.toStringTag]==="KeyObject"};const Rn=["CryptoKey"];const Dn=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1){return true}let n;for(const t of e){const e=Object.keys(t);if(!n||n.size===0){n=new Set(e);continue}for(const t of e){if(n.has(t)){return false}n.add(t)}}return true};var On=Dn;function jn(t){return typeof t==="object"&&t!==null}function Wn(t){if(!jn(t)||Object.prototype.toString.call(t)!=="[object Object]"){return false}if(Object.getPrototypeOf(t)===null){return true}let e=t;while(Object.getPrototypeOf(e)!==null){e=Object.getPrototypeOf(e)}return Object.getPrototypeOf(t)===e}var Ln=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:n}=e.algorithm;if(typeof n!=="number"||n<2048){throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}};function Mn(t){return Wn(t)&&typeof t.kty==="string"}function Hn(t){return t.kty!=="oct"&&typeof t.d==="string"}function Un(t){return t.kty!=="oct"&&typeof t.d==="undefined"}function Jn(t){return Mn(t)&&t.kty==="oct"&&typeof t.k==="string"}function Nn(t){let e;let n;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`};n=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`};n=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`};n=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"};n=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"};n=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"};n=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv};n=t.d?["deriveBits"]:[];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"Ed25519":e={name:"Ed25519"};n=t.d?["sign"]:["verify"];break;case"EdDSA":e={name:t.crv};n=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv};n=t.d?["deriveBits"]:[];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new hn('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:n}}const Kn=async t=>{if(!t.alg){throw new TypeError('"alg" argument is required when "jwk.alg" is not present')}const{algorithm:e,keyUsages:n}=Nn(t);const i=[e,t.ext??false,t.key_ops??n];const s={...t};delete s.alg;delete s.use;return qe.subtle.importKey("jwk",s,...i)};var Bn=Kn;const Fn=t=>an(t);let Xn;let Vn;const Yn=t=>t?.[Symbol.toStringTag]==="KeyObject";const qn=async(t,e,n,i,s=false)=>{let o=t.get(e);if(o?.[i]){return o[i]}const r=await Bn({...n,alg:i});if(s)Object.freeze(e);if(!o){t.set(e,{[i]:r})}else{o[i]=r}return r};const Gn=(t,e)=>{if(Yn(t)){let n=t.export({format:"jwk"});delete n.d;delete n.dp;delete n.dq;delete n.p;delete n.q;delete n.qi;if(n.k){return Fn(n.k)}Vn||(Vn=new WeakMap);return qn(Vn,t,n,e)}if(Mn(t)){if(t.k)return an(t.k);Vn||(Vn=new WeakMap);const n=qn(Vn,t,t,e,true);return n}return t};const Zn=(t,e)=>{if(Yn(t)){let n=t.export({format:"jwk"});if(n.k){return Fn(n.k)}Xn||(Xn=new WeakMap);return qn(Xn,t,n,e)}if(Mn(t)){if(t.k)return an(t.k);Xn||(Xn=new WeakMap);const n=qn(Xn,t,t,e,true);return n}return t};var Qn={normalizePublicKey:Gn,normalizePrivateKey:Zn};async function ti(t,e){if(!Wn(t)){throw new TypeError("JWK must be an object")}e||(e=t.alg);switch(t.kty){case"oct":if(typeof t.k!=="string"||!t.k){throw new TypeError('missing "k" (Key Value) Parameter value')}return an(t.k);case"RSA":if("oth"in t&&t.oth!==undefined){throw new hn('RSA JWK "oth" (Other Primes Info) Parameter value is not supported')}case"EC":case"OKP":return Bn({...t,alg:e});default:throw new hn('Unsupported "kty" (Key Type) Parameter value')}}const ei=t=>t?.[Symbol.toStringTag];const ni=(t,e,n)=>{if(e.use!==undefined&&e.use!=="sig"){throw new TypeError("Invalid key for this operation, when present its use must be sig")}if(e.key_ops!==undefined&&e.key_ops.includes?.(n)!==true){throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${n}`)}if(e.alg!==undefined&&e.alg!==t){throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`)}return true};const ii=(t,e,n,i)=>{if(e instanceof Uint8Array)return;if(i&&Mn(e)){if(Jn(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!In(e)){throw new TypeError(Pn(t,e,...Rn,"Uint8Array",i?"JSON Web Key":null))}if(e.type!=="secret"){throw new TypeError(`${ei(e)} instances for symmetric algorithms must be of type "secret"`)}};const si=(t,e,n,i)=>{if(i&&Mn(e)){switch(n){case"sign":if(Hn(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for this operation be a private JWK`);case"verify":if(Un(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for this operation be a public JWK`)}}if(!In(e)){throw new TypeError(Pn(t,e,...Rn,i?"JSON Web Key":null))}if(e.type==="secret"){throw new TypeError(`${ei(e)} instances for asymmetric algorithms must not be of type "secret"`)}if(n==="sign"&&e.type==="public"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm signing must be of type "private"`)}if(n==="decrypt"&&e.type==="public"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm decryption must be of type "private"`)}if(e.algorithm&&n==="verify"&&e.type==="private"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm verifying must be of type "public"`)}if(e.algorithm&&n==="encrypt"&&e.type==="private"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm encryption must be of type "public"`)}};function oi(t,e,n,i){const s=e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e);if(s){ii(e,n,i,t)}else{si(e,n,i,t)}}oi.bind(undefined,false);const ri=oi.bind(undefined,true);function ai(t,e,n,i,s){if(s.crit!==undefined&&i?.crit===undefined){throw new t('"crit" (Critical) Header Parameter MUST be integrity protected')}if(!i||i.crit===undefined){return new Set}if(!Array.isArray(i.crit)||i.crit.length===0||i.crit.some((t=>typeof t!=="string"||t.length===0))){throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present')}let o;if(n!==undefined){o=new Map([...Object.entries(n),...e.entries()])}else{o=e}for(const e of i.crit){if(!o.has(e)){throw new hn(`Extension Header Parameter "${e}" is not recognized`)}if(s[e]===undefined){throw new t(`Extension Header Parameter "${e}" is missing`)}if(o.get(e)&&i[e]===undefined){throw new t(`Extension Header Parameter "${e}" MUST be integrity protected`)}}return new Set(i.crit)}const ci=(t,e)=>{if(e!==undefined&&(!Array.isArray(e)||e.some((t=>typeof t!=="string")))){throw new TypeError(`"${t}" option must be an array of strings`)}if(!e){return undefined}return new Set(e)};var li=ci;const di=async t=>{if(t instanceof Uint8Array){return{kty:"oct",k:on(t)}}if(!Ge(t)){throw new TypeError($n(t,...Rn,"Uint8Array"))}if(!t.extractable){throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK")}const{ext:e,key_ops:n,alg:i,use:s,...o}=await qe.subtle.exportKey("jwk",t);return o};var ui=di;async function hi(t){return ui(t)}function fi(t,e){const n=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:t.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new hn(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function pi(t,e,n){if(n==="sign"){e=await Qn.normalizePrivateKey(e,t)}if(n==="verify"){e=await Qn.normalizePublicKey(e,t)}if(Ge(e)){zn(e,t,n);return e}if(e instanceof Uint8Array){if(!t.startsWith("HS")){throw new TypeError($n(e,...Rn))}return qe.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},false,[n])}throw new TypeError($n(e,...Rn,"Uint8Array","JSON Web Key"))}const mi=async(t,e,n,i)=>{const s=await pi(t,e,"verify");Ln(t,s);const o=fi(t,s.algorithm);try{return await qe.subtle.verify(o,s,n,i)}catch{return false}};var bi=mi;async function gi(t,e,n){if(!Wn(t)){throw new mn("Flattened JWS must be an object")}if(t.protected===undefined&&t.header===undefined){throw new mn('Flattened JWS must have either of the "protected" or "header" members')}if(t.protected!==undefined&&typeof t.protected!=="string"){throw new mn("JWS Protected Header incorrect type")}if(t.payload===undefined){throw new mn("JWS Payload missing")}if(typeof t.signature!=="string"){throw new mn("JWS Signature missing or incorrect type")}if(t.header!==undefined&&!Wn(t.header)){throw new mn("JWS Unprotected Header incorrect type")}let i={};if(t.protected){try{const e=an(t.protected);i=JSON.parse(en.decode(e))}catch{throw new mn("JWS Protected Header is invalid")}}if(!On(i,t.header)){throw new mn("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const s={...i,...t.header};const o=ai(mn,new Map([["b64",true]]),n?.crit,i,s);let r=true;if(o.has("b64")){r=i.b64;if(typeof r!=="boolean"){throw new mn('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:a}=s;if(typeof a!=="string"||!a){throw new mn('JWS "alg" (Algorithm) Header Parameter missing or invalid')}const c=n&&li("algorithms",n.algorithms);if(c&&!c.has(a)){throw new un('"alg" (Algorithm) Header Parameter value not allowed')}if(r){if(typeof t.payload!=="string"){throw new mn("JWS Payload must be a string")}}else if(typeof t.payload!=="string"&&!(t.payload instanceof Uint8Array)){throw new mn("JWS Payload must be a string or an Uint8Array instance")}let l=false;if(typeof e==="function"){e=await e(i,t);l=true;ri(a,e,"verify");if(Mn(e)){e=await ti(e,a)}}else{ri(a,e,"verify")}const d=nn(tn.encode(t.protected??""),tn.encode("."),typeof t.payload==="string"?tn.encode(t.payload):t.payload);let u;try{u=an(t.signature)}catch{throw new mn("Failed to base64url decode the signature")}const h=await bi(a,e,u,d);if(!h){throw new xn}let f;if(r){try{f=an(t.payload)}catch{throw new mn("Failed to base64url decode the payload")}}else if(typeof t.payload==="string"){f=tn.encode(t.payload)}else{f=t.payload}const p={payload:f};if(t.protected!==undefined){p.protectedHeader=i}if(t.header!==undefined){p.unprotectedHeader=t.header}if(l){return{...p,key:e}}return p}async function wi(t,e,n){if(t instanceof Uint8Array){t=en.decode(t)}if(typeof t!=="string"){throw new mn("Compact JWS must be a string or Uint8Array")}const{0:i,1:s,2:o,length:r}=t.split(".");if(r!==3){throw new mn("Invalid Compact JWS")}const a=await gi({payload:s,protected:i,signature:o},e,n);const c={payload:a.payload,protectedHeader:a.protectedHeader};if(typeof e==="function"){return{...c,key:a.key}}return c}var yi=t=>Math.floor(t.getTime()/1e3);const vi=60;const ki=vi*60;const xi=ki*24;const Si=xi*7;const _i=xi*365.25;const Ei=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;var Ai=t=>{const e=Ei.exec(t);if(!e||e[4]&&e[1]){throw new TypeError("Invalid time period format")}const n=parseFloat(e[2]);const i=e[3].toLowerCase();let s;switch(i){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(n*vi);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(n*ki);break;case"day":case"days":case"d":s=Math.round(n*xi);break;case"week":case"weeks":case"w":s=Math.round(n*Si);break;default:s=Math.round(n*_i);break}if(e[1]==="-"||e[4]==="ago"){return-s}return s};const Ti=t=>t.toLowerCase().replace(/^application\//,"");const zi=(t,e)=>{if(typeof t==="string"){return e.includes(t)}if(Array.isArray(t)){return e.some(Set.prototype.has.bind(new Set(t)))}return false};var Ci=(t,e,n={})=>{let i;try{i=JSON.parse(en.decode(e))}catch{}if(!Wn(i)){throw new bn("JWT Claims Set must be a top-level JSON object")}const{typ:s}=n;if(s&&(typeof t.typ!=="string"||Ti(t.typ)!==Ti(s))){throw new ln('unexpected "typ" JWT header value',i,"typ","check_failed")}const{requiredClaims:o=[],issuer:r,subject:a,audience:c,maxTokenAge:l}=n;const d=[...o];if(l!==undefined)d.push("iat");if(c!==undefined)d.push("aud");if(a!==undefined)d.push("sub");if(r!==undefined)d.push("iss");for(const t of new Set(d.reverse())){if(!(t in i)){throw new ln(`missing required "${t}" claim`,i,t,"missing")}}if(r&&!(Array.isArray(r)?r:[r]).includes(i.iss)){throw new ln('unexpected "iss" claim value',i,"iss","check_failed")}if(a&&i.sub!==a){throw new ln('unexpected "sub" claim value',i,"sub","check_failed")}if(c&&!zi(i.aud,typeof c==="string"?[c]:c)){throw new ln('unexpected "aud" claim value',i,"aud","check_failed")}let u;switch(typeof n.clockTolerance){case"string":u=Ai(n.clockTolerance);break;case"number":u=n.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:h}=n;const f=yi(h||new Date);if((i.iat!==undefined||l)&&typeof i.iat!=="number"){throw new ln('"iat" claim must be a number',i,"iat","invalid")}if(i.nbf!==undefined){if(typeof i.nbf!=="number"){throw new ln('"nbf" claim must be a number',i,"nbf","invalid")}if(i.nbf>f+u){throw new ln('"nbf" claim timestamp check failed',i,"nbf","check_failed")}}if(i.exp!==undefined){if(typeof i.exp!=="number"){throw new ln('"exp" claim must be a number',i,"exp","invalid")}if(i.exp<=f-u){throw new dn('"exp" claim timestamp check failed',i,"exp","check_failed")}}if(l){const t=f-i.iat;const e=typeof l==="number"?l:Ai(l);if(t-u>e){throw new dn('"iat" claim timestamp check failed (too far in the past)',i,"iat","check_failed")}if(t<0-u){throw new ln('"iat" claim timestamp check failed (it should be in the past)',i,"iat","check_failed")}}return i};async function $i(t,e,n){const i=await wi(t,e,n);if(i.protectedHeader.crit?.includes("b64")&&i.protectedHeader.b64===false){throw new bn("JWTs MUST NOT use unencoded payload")}const s=Ci(i.protectedHeader,i.payload,n);const o={payload:s,protectedHeader:i.protectedHeader};if(typeof e==="function"){return{...o,key:i.key}}return o}const Pi=async(t,e,n)=>{const i=await pi(t,e,"sign");Ln(t,i);const s=await qe.subtle.sign(fi(t,i.algorithm),i,n);return new Uint8Array(s)};var Ii=Pi;class Ri{constructor(t){if(!(t instanceof Uint8Array)){throw new TypeError("payload must be an instance of Uint8Array")}this._payload=t}setProtectedHeader(t){if(this._protectedHeader){throw new TypeError("setProtectedHeader can only be called once")}this._protectedHeader=t;return this}setUnprotectedHeader(t){if(this._unprotectedHeader){throw new TypeError("setUnprotectedHeader can only be called once")}this._unprotectedHeader=t;return this}async sign(t,e){if(!this._protectedHeader&&!this._unprotectedHeader){throw new mn("either setProtectedHeader or setUnprotectedHeader must be called before #sign()")}if(!On(this._protectedHeader,this._unprotectedHeader)){throw new mn("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const n={...this._protectedHeader,...this._unprotectedHeader};const i=ai(mn,new Map([["b64",true]]),e?.crit,this._protectedHeader,n);let s=true;if(i.has("b64")){s=this._protectedHeader.b64;if(typeof s!=="boolean"){throw new mn('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:o}=n;if(typeof o!=="string"||!o){throw new mn('JWS "alg" (Algorithm) Header Parameter missing or invalid')}ri(o,t,"sign");let r=this._payload;if(s){r=tn.encode(on(r))}let a;if(this._protectedHeader){a=tn.encode(on(JSON.stringify(this._protectedHeader)))}else{a=tn.encode("")}const c=nn(a,tn.encode("."),r);const l=await Ii(o,t,c);const d={signature:on(l),payload:""};if(s){d.payload=en.decode(r)}if(this._unprotectedHeader){d.header=this._unprotectedHeader}if(this._protectedHeader){d.protected=en.decode(a)}return d}}class Di{constructor(t){this._flattened=new Ri(t)}setProtectedHeader(t){this._flattened.setProtectedHeader(t);return this}async sign(t,e){const n=await this._flattened.sign(t,e);if(n.payload===undefined){throw new TypeError("use the flattened module for creating JWS with b64: false")}return`${n.protected}.${n.payload}.${n.signature}`}}function Oi(t,e){if(!Number.isFinite(e)){throw new TypeError(`Invalid ${t} input`)}return e}class ji{constructor(t={}){if(!Wn(t)){throw new TypeError("JWT Claims Set MUST be an object")}this._payload=t}setIssuer(t){this._payload={...this._payload,iss:t};return this}setSubject(t){this._payload={...this._payload,sub:t};return this}setAudience(t){this._payload={...this._payload,aud:t};return this}setJti(t){this._payload={...this._payload,jti:t};return this}setNotBefore(t){if(typeof t==="number"){this._payload={...this._payload,nbf:Oi("setNotBefore",t)}}else if(t instanceof Date){this._payload={...this._payload,nbf:Oi("setNotBefore",yi(t))}}else{this._payload={...this._payload,nbf:yi(new Date)+Ai(t)}}return this}setExpirationTime(t){if(typeof t==="number"){this._payload={...this._payload,exp:Oi("setExpirationTime",t)}}else if(t instanceof Date){this._payload={...this._payload,exp:Oi("setExpirationTime",yi(t))}}else{this._payload={...this._payload,exp:yi(new Date)+Ai(t)}}return this}setIssuedAt(t){if(typeof t==="undefined"){this._payload={...this._payload,iat:yi(new Date)}}else if(t instanceof Date){this._payload={...this._payload,iat:Oi("setIssuedAt",yi(t))}}else if(typeof t==="string"){this._payload={...this._payload,iat:Oi("setIssuedAt",yi(new Date)+Ai(t))}}else{this._payload={...this._payload,iat:Oi("setIssuedAt",t)}}return this}}class Wi extends ji{setProtectedHeader(t){this._protectedHeader=t;return this}async sign(t,e){const n=new Di(tn.encode(JSON.stringify(this._payload)));n.setProtectedHeader(this._protectedHeader);if(Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===false){throw new bn("JWTs MUST NOT use unencoded payload")}return n.sign(t,e)}}const Li=(t,e)=>{if(typeof t!=="string"||!t){throw new gn(`${e} missing or invalid`)}};async function Mi(t,e){if(!Wn(t)){throw new TypeError("JWK must be an object")}e??(e="sha256");if(e!=="sha256"&&e!=="sha384"&&e!=="sha512"){throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"')}let n;switch(t.kty){case"EC":Li(t.crv,'"crv" (Curve) Parameter');Li(t.x,'"x" (X Coordinate) Parameter');Li(t.y,'"y" (Y Coordinate) Parameter');n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":Li(t.crv,'"crv" (Subtype of Key Pair) Parameter');Li(t.x,'"x" (Public Key) Parameter');n={crv:t.crv,kty:t.kty,x:t.x};break;case"RSA":Li(t.e,'"e" (Exponent) Parameter');Li(t.n,'"n" (Modulus) Parameter');n={e:t.e,kty:t.kty,n:t.n};break;case"oct":Li(t.k,'"k" (Key Value) Parameter');n={k:t.k,kty:t.kty};break;default:throw new hn('"kty" (Key Type) Parameter missing or unsupported')}const i=tn.encode(JSON.stringify(n));return on(await Qe(e,i))}function Hi(t){switch(typeof t==="string"&&t.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new hn('Unsupported "alg" value for a JSON Web Key Set')}}function Ui(t){return t&&typeof t==="object"&&Array.isArray(t.keys)&&t.keys.every(Ji)}function Ji(t){return Wn(t)}function Ni(t){if(typeof structuredClone==="function"){return structuredClone(t)}return JSON.parse(JSON.stringify(t))}class Ki{constructor(t){this._cached=new WeakMap;if(!Ui(t)){throw new wn("JSON Web Key Set malformed")}this._jwks=Ni(t)}async getKey(t,e){const{alg:n,kid:i}={...t,...e?.header};const s=Hi(n);const o=this._jwks.keys.filter((t=>{let e=s===t.kty;if(e&&typeof i==="string"){e=i===t.kid}if(e&&typeof t.alg==="string"){e=n===t.alg}if(e&&typeof t.use==="string"){e=t.use==="sig"}if(e&&Array.isArray(t.key_ops)){e=t.key_ops.includes("verify")}if(e){switch(n){case"ES256":e=t.crv==="P-256";break;case"ES256K":e=t.crv==="secp256k1";break;case"ES384":e=t.crv==="P-384";break;case"ES512":e=t.crv==="P-521";break;case"Ed25519":e=t.crv==="Ed25519";break;case"EdDSA":e=t.crv==="Ed25519"||t.crv==="Ed448";break}}return e}));const{0:r,length:a}=o;if(a===0){throw new yn}if(a!==1){const t=new vn;const{_cached:e}=this;t[Symbol.asyncIterator]=async function*(){for(const t of o){try{yield await Bi(e,t,n)}catch{}}};throw t}return Bi(this._cached,r,n)}}async function Bi(t,e,n){const i=t.get(e)||t.set(e,{}).get(e);if(i[n]===undefined){const t=await ti({...e,ext:true},n);if(t instanceof Uint8Array||t.type!=="public"){throw new wn("JSON Web Key Set members must be public keys")}i[n]=t}return i[n]}function Fi(t){const e=new Ki(t);const n=async(t,n)=>e.getKey(t,n);Object.defineProperties(n,{jwks:{value:()=>Ni(e._jwks),enumerable:true,configurable:false,writable:false}});return n}const Xi=async(t,e,n)=>{let i;let s;let o=false;if(typeof AbortController==="function"){i=new AbortController;s=setTimeout((()=>{o=true;i.abort()}),e)}const r=await fetch(t.href,{signal:i?i.signal:undefined,redirect:"manual",headers:n.headers}).catch((t=>{if(o)throw new kn;throw t}));if(s!==undefined)clearTimeout(s);if(r.status!==200){throw new cn("Expected 200 OK from the JSON Web Key Set HTTP response")}try{return await r.json()}catch{throw new cn("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var Vi=Xi;function Yi(){return typeof WebSocketPair!=="undefined"||typeof navigator!=="undefined"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime!=="undefined"&&EdgeRuntime==="vercel"}let qi;if(typeof navigator==="undefined"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){const t="jose";const e="v5.10.0";qi=`${t}/${e}`}const Gi=Symbol();function Zi(t,e){if(typeof t!=="object"||t===null){return false}if(!("uat"in t)||typeof t.uat!=="number"||Date.now()-t.uat>=e){return false}if(!("jwks"in t)||!Wn(t.jwks)||!Array.isArray(t.jwks.keys)||!Array.prototype.every.call(t.jwks.keys,Wn)){return false}return true}class Qi{constructor(t,e){if(!(t instanceof URL)){throw new TypeError("url must be an instance of URL")}this._url=new URL(t.href);this._options={agent:e?.agent,headers:e?.headers};this._timeoutDuration=typeof e?.timeoutDuration==="number"?e?.timeoutDuration:5e3;this._cooldownDuration=typeof e?.cooldownDuration==="number"?e?.cooldownDuration:3e4;this._cacheMaxAge=typeof e?.cacheMaxAge==="number"?e?.cacheMaxAge:6e5;if(e?.[Gi]!==undefined){this._cache=e?.[Gi];if(Zi(e?.[Gi],this._cacheMaxAge)){this._jwksTimestamp=this._cache.uat;this._local=Fi(this._cache.jwks)}}}coolingDown(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:false}fresh(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:false}async getKey(t,e){if(!this._local||!this.fresh()){await this.reload()}try{return await this._local(t,e)}catch(n){if(n instanceof yn){if(this.coolingDown()===false){await this.reload();return this._local(t,e)}}throw n}}async reload(){if(this._pendingFetch&&Yi()){this._pendingFetch=undefined}const t=new Headers(this._options.headers);if(qi&&!t.has("User-Agent")){t.set("User-Agent",qi);this._options.headers=Object.fromEntries(t.entries())}this._pendingFetch||(this._pendingFetch=Vi(this._url,this._timeoutDuration,this._options).then((t=>{this._local=Fi(t);if(this._cache){this._cache.uat=Date.now();this._cache.jwks=t}this._jwksTimestamp=Date.now();this._pendingFetch=undefined})).catch((t=>{this._pendingFetch=undefined;throw t})));await this._pendingFetch}}function ts(t,e){const n=new Qi(t,e);const i=async(t,e)=>n.getKey(t,e);Object.defineProperties(i,{coolingDown:{get:()=>n.coolingDown(),enumerable:true,configurable:false},fresh:{get:()=>n.fresh(),enumerable:true,configurable:false},reload:{value:()=>n.reload(),enumerable:true,configurable:false,writable:false},reloading:{get:()=>!!n._pendingFetch,enumerable:true,configurable:false},jwks:{value:()=>n._local?.jwks(),enumerable:true,configurable:false,writable:false}});return i}const es=an;function ns(t){if(typeof t!=="string")throw new bn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new bn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new bn("Invalid JWT");if(!e)throw new bn("JWTs must contain a payload");let i;try{i=es(e)}catch{throw new bn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(en.decode(i))}catch{throw new bn("Failed to parse the decoded payload as JSON")}if(!Wn(s))throw new bn("Invalid JWT Claims Set");return s}function is(t){const e=t?.modulusLength??2048;if(typeof e!=="number"||e<2048){throw new hn("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used")}return e}async function ss(t,e){let n;let i;switch(t){case"PS256":case"PS384":case"PS512":n={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["sign","verify"];break;case"RS256":case"RS384":case"RS512":n={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":n={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":n={name:"ECDSA",namedCurve:"P-256"};i=["sign","verify"];break;case"ES384":n={name:"ECDSA",namedCurve:"P-384"};i=["sign","verify"];break;case"ES512":n={name:"ECDSA",namedCurve:"P-521"};i=["sign","verify"];break;case"Ed25519":n={name:"Ed25519"};i=["sign","verify"];break;case"EdDSA":{i=["sign","verify"];const t=e?.crv??"Ed25519";switch(t){case"Ed25519":case"Ed448":n={name:t};break;default:throw new hn("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{i=["deriveKey","deriveBits"];const t=e?.crv??"P-256";switch(t){case"P-256":case"P-384":case"P-521":{n={name:"ECDH",namedCurve:t};break}case"X25519":case"X448":n={name:t};break;default:throw new hn("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return qe.subtle.generateKey(n,e?.extractable??false,i)}async function os(t,e){return ss(t,e)}const rs=async(t,e)=>{const n={...e,grant_types:["authorization_code","refresh_token"],id_token_signed_response_alg:"ES256",token_endpoint_auth_method:"none",application_type:"web",subject_type:"public"};return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})};class as{dbName;storeName;dbVersion;db=null;constructor(t="soidc",e="session",n=1){this.dbName=t;this.storeName=e;this.dbVersion=n}async init(){return new Promise(((t,e)=>{const n=indexedDB.open(this.dbName,this.dbVersion);n.onerror=t=>{e(new Error(`Database error: ${t.target.error}`))};n.onsuccess=e=>{this.db=e.target.result;t(this)};n.onupgradeneeded=t=>{const e=t.target.result;if(!e.objectStoreNames.contains(this.storeName)){e.createObjectStore(this.storeName)}}}))}async setItem(t,e){if(!this.db){await this.init()}return new Promise(((n,i)=>{const s=this.db.transaction(this.storeName,"readwrite");s.oncomplete=()=>{n()};s.onerror=e=>{i(new Error(`Transaction error for setItem(${t},...): ${e.target.error}`))};s.onabort=e=>{i(new Error(`Transaction aborted for setItem(${t},...): ${e.target.error}`))};const o=s.objectStore(this.storeName);o.put(e,t)}))}async getItem(t){if(!this.db){await this.init()}return new Promise(((e,n)=>{const i=this.db.transaction(this.storeName,"readonly");i.onerror=e=>{n(new Error(`Transaction error for getItem(${t}): ${e.target.error}`))};i.onabort=e=>{n(new Error(`Transaction aborted for getItem(${t}): ${e.target.error}`))};const s=i.objectStore(this.storeName);const o=s.get(t);o.onsuccess=()=>{e(o.result||null)}}))}async deleteItem(t){if(!this.db){await this.init()}return new Promise(((e,n)=>{const i=this.db.transaction(this.storeName,"readwrite");i.oncomplete=()=>{e()};i.onerror=e=>{n(new Error(`Transaction error for deleteItem(${t}): ${e.target.error}`))};i.onabort=e=>{n(new Error(`Transaction aborted for deleteItem(${t}): ${e.target.error}`))};const s=i.objectStore(this.storeName);s.delete(t)}))}async clear(){if(!this.db){await this.init()}return new Promise(((t,e)=>{const n=this.db.transaction(this.storeName,"readwrite");n.oncomplete=()=>{t()};n.onerror=t=>{e(new Error(`Transaction error for clear(): ${t.target.error}`))};n.onabort=t=>{e(new Error(`Transaction aborted for clear(): ${t.target.error}`))};const i=n.objectStore(this.storeName);i.clear()}))}close(){if(this.db){this.db.close();this.db=null}}}const cs=async(t,e,n)=>{const i=new URL(e);const s=i.origin+i.pathname+i.search;const o=new URL(t).origin;const r=await fetch(`${o}/.well-known/openid-configuration`).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const a=r["issuer"];const c=t=>t.endsWith("/")?t.slice(0,-1):t;if(c(t)!==c(a)){throw new Error("RFC 9207 - iss != idp - "+a+" != "+t)}sessionStorage.setItem("idp",a);sessionStorage.setItem("token_endpoint",r["token_endpoint"]);sessionStorage.setItem("jwks_uri",r["jwks_uri"]);let l=n?.client_id;if(!l){const t=r["registration_endpoint"];const e=await rs(t,n??{redirect_uris:[s]}).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));l=e["client_id"];sessionStorage.setItem("client_id",l)}const{pkce_code_verifier:d,pkce_code_challenge:u}=await ls();sessionStorage.setItem("pkce_code_verifier",d);const h=window.crypto.randomUUID();sessionStorage.setItem("csrf_token",h);const f=r["authorization_endpoint"]+`?response_type=code`+`&redirect_uri=${encodeURIComponent(s)}`+`&scope=openid offline_access webid`+`&client_id=${encodeURIComponent(l)}`+`&code_challenge_method=S256`+`&code_challenge=${u}`+`&state=${h}`+`&prompt=consent`;window.location.href=f};const ls=async()=>{const t=window.crypto.randomUUID()+"-"+window.crypto.randomUUID();const e=new Uint8Array(await window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t)));const n=btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return{pkce_code_verifier:t,pkce_code_challenge:n}};const ds=async t=>{const e=new URL(window.location.href);const n=e.searchParams.get("code");if(n===null){return{clientDetails:t}}const i=sessionStorage.getItem("idp");if(i===null||e.searchParams.get("iss")!=i){throw new Error("RFC 9207 - iss != idp - "+e.searchParams.get("iss")+" != "+i)}if(e.searchParams.get("state")!=sessionStorage.getItem("csrf_token")){throw new Error("RFC 6749 - state != csrf_token - "+e.searchParams.get("state")+" != "+sessionStorage.getItem("csrf_token"))}e.searchParams.delete("iss");e.searchParams.delete("state");e.searchParams.delete("code");window.history.pushState({},document.title,e.toString());const s=sessionStorage.getItem("pkce_code_verifier");if(s===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: pkce_code_verifier")}const o=t?.client_id||sessionStorage.getItem("client_id");if(!o){throw new Error("Access Token Request preparation - Could not find in sessionStorage: client_id (dynamic registration)")}const r=sessionStorage.getItem("token_endpoint");if(r===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: token_endpoint")}const a=await os("ES256");const c=await us(n,s,e.toString(),o,r,a).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const l=c["access_token"];const d=sessionStorage.getItem("jwks_uri");if(d===null){throw new Error("Access Token validation preparation - Could not find in sessionStorage: jwks_uri")}const u=ts(new URL(d));const{payload:h}=await $i(l,u,{issuer:i,audience:"solid"});const f=await Mi(await hi(a.publicKey));if(h["cnf"]["jkt"]!=f){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+h["cnf"]["jkt"]+" != "+f)}if(h["client_id"]!=o){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+h["client_id"]+" != "+o)}const p={...c,dpop_key_pair:a};const m={idp:i,jwks_uri:d,token_endpoint:r};if(!t)t={redirect_uris:[window.location.href]};t.client_id=o;const b=await(new as).init();await Promise.all([b.setItem("idp",i),b.setItem("jwks_uri",d),b.setItem("token_endpoint",r),b.setItem("client_id",o),b.setItem("dpop_keypair",a),b.setItem("refresh_token",c["refresh_token"])]);b.close();sessionStorage.removeItem("csrf_token");sessionStorage.removeItem("pkce_code_verifier");sessionStorage.removeItem("idp");sessionStorage.removeItem("jwks_uri");sessionStorage.removeItem("token_endpoint");sessionStorage.removeItem("client_id");return{clientDetails:t,idpDetails:m,tokenDetails:p}};const us=async(t,e,n,i,s,o)=>{const r=await hi(o.publicKey);r.alg="ES256";const a=await new Wi({htu:s,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:r}).sign(o.privateKey);return fetch(s,{method:"POST",headers:{dpop:a,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:n,client_id:i})})};const hs=async()=>{const t=await(new as).init();const e=await t.getItem("client_id");const n=await t.getItem("token_endpoint");const i=await t.getItem("dpop_keypair");const s=await t.getItem("refresh_token");if(e===null||n===null||i===null||s===null){throw new Error("Could not refresh tokens: details missing from database.")}const o=await fs(s,e,n,i).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const r=o["access_token"];const a=await t.getItem("idp");if(a===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: idp")}const c=await t.getItem("jwks_uri");if(c===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: jwks_uri")}const l=ts(new URL(c));const{payload:d}=await $i(r,l,{issuer:a,audience:"solid"});const u=await Mi(await hi(i.publicKey));if(d["cnf"]["jkt"]!=u){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+d["cnf"]["jkt"]+" != "+u)}if(d["client_id"]!=e){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+d["client_id"]+" != "+e)}await t.setItem("refresh_token",o["refresh_token"]);t.close();return{...o,dpop_key_pair:i}};const fs=async(t,e,n,i)=>{const s=await hi(i.publicKey);s.alg="ES256";const o=await new Wi({htu:n,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:s}).sign(i.privateKey);return fetch(n,{method:"POST",headers:{dpop:o,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t,client_id:e})})};class ps{sessionInformation;isActive_=false;webId_=undefined;currentAth_=undefined;tokenRefreshTimeout;sessionDeactivateTimeout;onSessionExpirationWarning;constructor(t,e){this.sessionInformation={clientDetails:t};this.onSessionExpirationWarning=e?.onSessionExpirationWarning}async login(t,e){await cs(t,e,this.sessionInformation.clientDetails)}async logout(){if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=undefined;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=undefined;this.sessionInformation.idpDetails=undefined;this.sessionInformation.tokenDetails=undefined;this.isActive_=false;this.webId_=undefined;if(this.sessionInformation.clientDetails?.client_id)try{new URL(this.sessionInformation.clientDetails.client_id)}catch(t){this.sessionInformation.clientDetails.client_id=undefined}const t=await(new as).init();await t.clear();t.close()}async handleRedirectFromLogin(){const t=await ds(this.sessionInformation.clientDetails);if(!t.tokenDetails){return}this.sessionInformation=t;await this.setSessionDetails()}async restore(){await hs().then((t=>{this.sessionInformation.tokenDetails=t;return this.setSessionDetails()})).catch((t=>{}))}async createSignedDPoPToken(t){if(!this.sessionInformation.tokenDetails||!this.currentAth_){throw new Error("Session not established.")}t.ath=this.currentAth_;const e=await hi(this.sessionInformation.tokenDetails.dpop_key_pair.publicKey);return new Wi(t).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:e}).sign(this.sessionInformation.tokenDetails.dpop_key_pair.privateKey)}async authFetch(t,e,n){let i;let s;let o;if(t instanceof Request){i=new URL(t.url);s=e?.method||t?.method||"GET";o=new Headers(t.headers)}else{e=e||{};i=new URL(t.toString());s=e.method||"GET";o=e.headers?new Headers(e.headers):new Headers}if(this.sessionInformation.tokenDetails){n=n??{htu:`${i.origin}${i.pathname}`,htm:s.toUpperCase()};const t=await this.createSignedDPoPToken(n);o.set("dpop",t);o.set("authorization",`DPoP ${this.sessionInformation.tokenDetails.access_token}`)}if(t instanceof Request){return fetch(new Request(t,{...e,headers:o}))}return fetch(i,{...e,headers:o})}get isActive(){return this.isActive_}get webId(){return this.webId_}async setSessionDetails(){if(!this.sessionInformation.tokenDetails?.access_token){this.logout()}this.currentAth_=await this.computeAth(this.sessionInformation.tokenDetails.access_token);this.webId_=ns(this.sessionInformation.tokenDetails.access_token)["webid"];this.isActive_=this.webId!==undefined;this.setSessionDeactivateTimeout();this.setTokenRefreshTimeout()}setSessionDeactivateTimeout(){const t=5;const e=(this.sessionInformation.tokenDetails.expires_in-t)*1e3;if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=setTimeout((()=>this.logout()),e)}setTokenRefreshTimeout(){const t=95;const e=(this.sessionInformation.tokenDetails.expires_in-t)*1e3;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=setTimeout((async()=>{const t=await hs().catch((t=>{if(this.onSessionExpirationWarning)this.onSessionExpirationWarning();return undefined}));if(!t){return}this.sessionInformation.tokenDetails=t;this.setSessionDeactivateTimeout();this.setTokenRefreshTimeout()}),e)}async computeAth(t){const e=new TextEncoder;const n=e.encode(t);const i=await crypto.subtle.digest("SHA-256",n);const s=Array.from(new Uint8Array(i));const o=btoa(String.fromCharCode(...s));const r=o.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return r}}class ms{get authenticatedFetch(){return this._authenticatedFetch}constructor(){this.onSessionRestoreCallback=()=>{};this.sessionInfo$=new Ye({isLoggedIn:false,webId:undefined});this.session=new ps;this._authenticatedFetch=this.session.authFetch.bind(this.session)}async handleIncomingRedirect(t=false){await this.session.handleRedirectFromLogin();if(t){await this.session.restore();if(this.session.isActive){this.onSessionRestoreCallback(window.location.href)}}this.sessionInfo$.next({isLoggedIn:this.session.isActive,webId:this.session.webId})}async login(t){return this.session.login(t,window.location.href)}async logout(){await this.session.logout();this.sessionInfo$.next({isLoggedIn:false,webId:undefined})}observeSession(){return this.sessionInfo$}onSessionRestore(t){this.onSessionRestoreCallback=t}}const bs=class{constructor(t){e(this,t);this.sessionRestoredEmitter=a(this,"pod-os:session-restored",7);this.podOsLoadedEmitter=a(this,"pod-os:loaded",7);this.restorePreviousSession=false;this.disconnected$=new N;this.loading=true}async componentWillLoad(){const t=new ms;this.unsubscribeSettings=me.on("set",(()=>{this.os=Ve(t,me.state)}));this.os=Ve(t,me.state);t.onSessionRestore((t=>{this.sessionRestoredEmitter.emit({url:t})}));try{await t.handleIncomingRedirect(this.restorePreviousSession)}catch(t){console.error(t)}this.os.observeSession().pipe(K(this.disconnected$)).subscribe((async t=>{L.state.webId=t.webId;if(t.isLoggedIn){const e=await this.os.fetchProfile(t.webId);L.state.profile=e}L.state.isLoggedIn=t.isLoggedIn;this.loading=false}));this.podOsLoadedEmitter.emit({os:this.os,authenticatedFetch:t.authenticatedFetch})}disconnectedCallback(){this.unsubscribeSettings();this.disconnected$.next();this.disconnected$.unsubscribe()}async initializeOs(t){t.stopPropagation();t.detail(this.os)}async loadModule(t){t.stopPropagation();if(t.detail.module==="contacts"){const e=await this.os.loadContactsModule();t.detail.receiver(e)}else{throw Error(`Unknown module "${t.detail.module}"`)}}render(){return this.loading?n("ion-progress-bar",{type:"indeterminate"}):n("slot",null)}};const gs="pos-router {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\npos-navigation {\n max-width: var(--width-lg);\n margin: 0;\n min-width: var(--size-32);\n flex-shrink: 1; /* Ensure navigation can shrink */\n}\n\npos-add-new-thing,\npos-login {\n flex: 0 1 auto;\n flex-shrink: 0; /* Ensure those items don't shrink */\n}\n\nheader,\nfooter {\n display: flex;\n gap: var(--size-1);\n height: auto;\n justify-content: center;\n align-items: center;\n padding: var(--size-1);\n}\n\nfooter svg {\n width: var(--size-5);\n height: var(--size-5);\n}\n\nfooter {\n font-size: var(--scale-fluid-000);\n\n .settings {\n padding: 0 var(--size-1);\n text-decoration: none;\n background-color: var(--pos-background-color);\n border: 1px solid var(--pos-secondary-border-color);\n color: var(--pos-secondary-border-color);\n border-radius: var(--radius-xs);\n\n &:hover {\n background-color: var(--pos-secondary-border-color);\n color: var(--pos-background-color);\n }\n }\n}\n\nheader {\n flex-wrap: nowrap;\n padding: var(--size-1) var(--size-8);\n}\n\nmain {\n flex: 1;\n max-height: 100vh;\n overflow: auto;\n}\n\n@media (max-width: 640px) {\n header {\n padding: var(--size-1);\n justify-content: space-between;\n }\n footer {\n display: none;\n }\n}\n";const ws=gs;const ys=class{constructor(t){e(this,t);this.restorePreviousSession=false;this.mode="standalone";this.uri=""}render(){return n(i,{key:"08b186d2f354d6c07df02707eb4ada81aef7dec3"},n("pos-app",{key:"54c372343e916ab5d77584381b3965c925ae0cd0",restorePreviousSession:this.restorePreviousSession},n("pos-error-toast",{key:"ab63e18121ca16670f81da141219a782dde0694b"},n("pos-router",{key:"69b6f3bf8ce3720c6c39cdb4be69e640e27ccc5b",mode:this.mode,"onPod-os:route-changed":t=>this.uri=t.detail},n("header",{key:"5cd3412caf13b6d99da517ae7e6f5877234e65d7"},n("pos-add-new-thing",{key:"9b83b3cf03b7038303975386176df539b35ff547",referenceUri:this.uri}),n("pos-navigation",{key:"26bfed9b1c8dd1be018babc6ef40ae42808a5c42",uri:this.uri==="pod-os:dashboard"?"":this.uri}),n("pos-login",{key:"e29f18dcde866d8ac1e317fcd7b71ef584e69034"},n("pos-user-menu",{key:"be796f0914649eb4e8525a9d8acdfd535626303c",webId:L.state.webId,slot:"if-logged-in"}))),n("main",{key:"f99dfb2d43e949528bc767b94801c99bf04a7eea"},this.mainContent()),n("footer",{key:"64744d1246356fa00da9c6b561785e2b794a7907"},n(vs,{key:"a648f7f88e12c79348bda33152f2759d2b93e738"}),n("span",{key:"f22e2f9904ba517fc2e579a05018704b5ade6302"},"PodOS Browser"))))))}mainContent(){if(this.uri===""){return null}if(this.uri.startsWith("pod-os:")){return n("pos-internal-router",{uri:this.uri})}return n("pos-resource",{key:this.uri,uri:this.uri},n("pos-type-router",null))}};const vs=()=>n("svg",{viewBox:"0 0 400 400",xmlns:"http://www.w3.org/2000/svg"},n("path",{d:"M50 350 L50 100 L200 50 L350 100 L350 350 Z",style:{fill:"#008BF8",stroke:"#008BF8","stroke-width":"70"},"stroke-linejoin":"round"}),n("path",{d:"M100 300 L100 150 L200 120 L300 150 L300 300 L130 300 L130 370 L100 370Z",style:{fill:"white",stroke:"white","stroke-width":"45"},"stroke-linejoin":"round"}),n("path",{d:"M150 250 L150 200 L200 180 L250 200 L250 250 Z",style:{fill:"#DC0073",stroke:"#DC0073","stroke-width":"20"},"stroke-linejoin":"round"}));ys.style=ws;const ks=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const xs=ks;const Ss=class{constructor(t){e(this,t)}render(){return n(i,{key:"18dc165b7be1c796136804a2ba7643b2a6fffc73"},n("pos-getting-started",{key:"e3f7a22641e4c24168a36f96463515cd1a89ca5e"}),n("pos-example-resources",{key:"1044dd873049118e165ff6d38449c85695f63a50"}))}};Ss.style=xs;const _s=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Es=_s;const As=class{constructor(t){e(this,t)}render(){return n("pos-setting-offline-cache",{key:"f065206f6291089773a19045243f04b6ce35eeb9"})}};As.style=Es;const Ts=class{constructor(t){e(this,t);this.subscribeResource=a(this,"pod-os:resource",7);this.receiveResource=t=>{this.resource=t}}componentWillLoad(){at(this)}render(){return this.resource?this.resource.description():null}};const zs="dialog{background-color:var(--pos-background-color);color:var(--pos-normal-text-color);border:none;border-radius:var(--radius-md);box-shadow:var(--shadow-md);max-width:var(--width-xs);animation:slideIn 0.2s ease-out}dialog::backdrop{background:rgba(0, 0, 0, 0.5);backdrop-filter:var(--blur-sm);animation:fadeIn 0.2s ease-out}@media (prefers-color-scheme: dark){dialog::backdrop{background:rgb(100, 100, 100, 0.5)}}dialog header>:first-child{flex-grow:1;font-weight:var(--weight-light);font-size:var(--scale-2);font-family:var(--font-sans);margin:0}dialog header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;gap:var(--scale-0);border-bottom-style:inset;padding:0 0 var(--scale-0) 0}dialog>:last-child{display:block;margin-top:var(--scale-3)}button#close{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;background:none;font-size:var(--scale-3);color:var(--color-grey-500)}button#close:hover{color:var(--pos-secondary-border-color)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}";const Cs=zs;const $s=class{constructor(t){e(this,t)}async showModal(){this.dialog.showModal()}async close(){this.dialog.close()}render(){return n(i,{key:"4e570e7fb1942fab0f4056d17a28c67a7abfee19"},n("dialog",{key:"c2282c2ac11c236672ee4848019dacb59ff6b1ef",ref:t=>this.dialog=t},n("header",{key:"ca58f3372a078235d931e60b6a7979e5006010c5"},n("slot",{key:"2e63b07551e537491d86bae21c80c235ce5ca0db",name:"title"}),n("button",{key:"a3afd2ab3624f98799976de5d4b86c86360bd2af",tabindex:-1,id:"close",title:"Close",onClick:()=>this.close()},n("ion-icon",{key:"9f7fccd041dab2f0f224a13fdcb7b7254f090740",name:"close-outline"}))),n("slot",{key:"5e5b4e385c7000ece9ced84d5ba6f5b45a990e33",name:"content"})))}};$s.style=Cs;const Ps=class{constructor(t){e(this,t)}async unhandledRejection(t){t.stopPropagation();console.error("unhandled promise rejection",t);await this.showToast(t.reason.toString())}async catchError(t){t.stopPropagation();console.error(t.detail);await this.showToast(t.detail.message)}async showToast(t){const e=await R.create({message:t,duration:1e4,position:"top",color:"danger",buttons:[{text:"Dismiss",role:"cancel"}]});await e.present()}render(){return n(i,{key:"323aca8226bb81061d9edf6db10ba6fcfa69fa21"},n("ion-toast",{key:"e8bcbfb1d06594a25a27beb87da97f47c32067b1",trigger:"never",message:"Workarround to preload ion-toast and ion-ripple-effect to be able to show errors while offline",duration:0},n("ion-ripple-effect",{key:"273603931e206584a1bf3b98751d92daec0465cf"})),n("slot",{key:"6cee55328058d883459a4c89edd63a0dfac9aa7e"}))}};const Is=":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.links{display:flex;flex-direction:column;gap:var(--size-3);max-width:80vw}";const Rs=Is;const Ds=class{constructor(t){e(this,t)}render(){return n(i,{key:"42e8ecc30fa26eb7750efff9a65048bb42b4c71d"},n("div",{key:"1df80385f1f6c44f7fe4255ecb93f6183df61727"},n("h2",{key:"9b249d38f00d1b00863226799bdcd13e4f78a4a9"},"Try these... 💡"),n("p",{key:"c33157b085b1ad3397e38bf5f4b1c601b0e40b6a"},"No idea where to start? Try these example resources, and follow your nose 👃"),n("div",{key:"f0f35cc2ec1f7fbf8a306e718e1f2aaffcbe84e0",class:"links"},n("pos-rich-link",{key:"999b7dc0aa587b1964838820f17a02257b051c0e",uri:"https://pod-os.solidcommunity.net/profile/card#me"}),n("pos-rich-link",{key:"67ca02160d0bdaa73bcfb188fcf40b058a584bf8",uri:"https://angelo.veltens.org/profile/card#me"}),n("pos-rich-link",{key:"800829fb68c96b0caa0ad2372b02e08b7842b704",uri:"https://angelo.veltens.org/public/bookmarks"}),n("pos-rich-link",{key:"680e29b8bf0437d6adba15052339b91ffd41b9a4",uri:"https://solidos.solidcommunity.net/profile/card#me"}))))}};Ds.style=Rs;const Os=":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.question{font-weight:var(--weight-semibold)}a{font-weight:var(--weight-bold);color:var(--pos-primary-color)}button.login{background:none;color:var(--pos-primary-color);display:inline;text-decoration:underline;border:none;padding:0;margin:0;cursor:pointer;font-size:unset}";const js=Os;const Ws=class{constructor(t){e(this,t);this.login=a(this,"pod-os:login",7)}render(){return n(i,{key:"23a14b5ee10d585cc8cf3166ce041072b68cabb2"},n("div",{key:"964e46223d77516aaed40c7c55371716cfccf40a"},n("h2",{key:"5eaf56d6b0751d8511632d05570a05d5deba88c0"},"Getting started 🚀"),n("p",{key:"f41d858112a0337bcf2be9a39986cacac6921210"},"🔎 Enter a URL into the above navigation bar to browse through the web of data. "),n("p",{key:"8d40de32d86b871343687b402122b0dcc843daf9"},"🔐"," ",n("button",{key:"225091e03c1cf175362dc9530cf1eb5238e50d65",class:"login",onClick:()=>this.login.emit()},"Sign in")," ","to access private resources on your Solid Pod or those of your friends or coworkers.")),n("div",{key:"92924f3a67ac70cd333932f0658f9f73dd7474c9"},n("p",{key:"365d7c78aee4bb9396ac7d55c42c9e26b47fe87a",class:"question"},"New to Solid?"),n("p",{key:"42190c0f401faff3cf43fe8f3c69f4afc380f819"},n("a",{key:"d7de0d55a657c8a54a389efc50aa89bc4d48c5e6",href:"https://solidproject.org/for-developers#hosted-pod-services"},"Get a Pod →"))),n("div",{key:"8ad728231a1f2af613a462982af6bf129956ab1c"},n("p",{key:"c960fa49ff9789fe881cadc4f37d315c7727115a",class:"question"},"Want to dig deeper into PodOS?"),n("p",{key:"7991e91dbfdfc0447a2e08850e3634086f3f12ee"},n("a",{key:"a35d336eb2ca5947e66abb9e37526ee035c0a700",href:"http://pod-os.org"},"Learn more →"))))}};Ws.style=js;const Ls=":host{display:flex;background-size:cover;background-repeat:no-repeat;background-position:center;border-radius:inherit}img,ion-skeleton-text,div.error{border-radius:var(--border-radius);width:var(--width);height:var(--height);max-width:var(--max-width);max-height:var(--max-height);object-fit:var(--object-fit)}img{backdrop-filter:var(--blur-xl)}.error{display:flex;opacity:0.8;background:repeating-linear-gradient(-45deg, rgba(150, 0, 0, 0.1), rgba(150, 0, 0, 0.1) 10px, #fff 5px, #fff 25px);flex-direction:column;border:1px solid red;color:black;align-items:center;justify-content:center;word-break:break-all;padding:1rem;box-sizing:border-box}.error ion-icon{color:#282828;--ionicon-stroke-width:calc(var(--width) / 5);font-size:calc(var(--width) / 2)}a.error{text-decoration:none;width:var(--width);height:var(--height)}.code{font-weight:bold;font-size:calc(var(--width) / 8)}.text{font-size:calc(var(--width) / 20)}";const Ms=Ls;const Hs=class{constructor(t){e(this,t);this.initializeOsEmitter=a(this,"pod-os:init",7);this.resourceLoadedEmitter=a(this,"pod-os:resource-loaded",7);this.blurredBackground=false;this.loading=true;this.setOs=async t=>{this.os=t}}componentWillLoad(){L.onChange("isLoggedIn",(()=>this.fetchBlob()));this.initializeOsEmitter.emit(this.setOs)}async fetchBlob(){try{this.loading=true;this.imageError=null;this.networkError=null;this.brokenFile=null;const t=await this.os.files().fetchFile(this.src);this.resourceLoadedEmitter.emit(this.src);if(t.blob()){this.dataUri=URL.createObjectURL(t.blob())}else{this.brokenFile=t}}catch(t){this.networkError=t}finally{this.loading=false}}onImageError(t){this.networkError=null;this.imageError=t}render(){if(this.loading){return n("ion-skeleton-text",{animated:true})}if(this.networkError){return n("img",{alt:this.alt,src:this.src,onError:t=>this.onImageError(t)})}if(this.brokenFile){return n(M,{file:this.brokenFile})}if(this.imageError){return n("div",{class:"error"},n("a",{href:this.src},this.src))}return n(i,{style:{backgroundImage:this.blurredBackground?`url('${this.dataUri}')`:null}},n("img",{src:this.dataUri,alt:this.alt}))}static get watchers(){return{os:["fetchBlob"],src:["fetchBlob"]}}};Hs.style=Ms;const Us=class{constructor(t){e(this,t);this.uri="pod-os:dashboard"}render(){return this.uri==="pod-os:settings"?n("pos-app-settings",null):n("pos-app-dashboard",null)}};const Js=class{constructor(t){e(this,t);this.subscribeResource=a(this,"pod-os:resource",7);this.receiveResource=t=>{this.resource=t}}componentWillLoad(){at(this)}render(){return this.resource?this.resource.label():null}};const Ns=".container{display:flex;align-items:center;gap:var(--size-2)}.user-data{align-items:center;display:inline-flex;gap:10px}.user-data pos-picture{--width:40px;--height:40px;--border-radius:50%}pos-login-form{margin:var(--size-2)}dialog{margin-top:var(--size-10)}button#login,button#logout{outline:none;font-weight:var(--weight-bold);letter-spacing:var(--letter-xl);border:none;box-sizing:border-box;border-radius:var(--radius-xs);padding:var(--size-2);box-shadow:var(--shadow-sm);color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}button#login:focus-within,button#logout:focus-within{outline:var(--pos-input-focus-outline)}button#login:focus,button#login:hover,button#logout:focus,button#logout:hover{filter:brightness(110%);box-shadow:var(--shadow-md)}";const Ks=Ns;const Bs=class{constructor(t){e(this,t);this.initializeOsEmitter=a(this,"pod-os:init",7);this.customLoggedInComponent=false;this.setOs=async t=>{this.os=t}}componentWillLoad(){this.customLoggedInComponent=!!this.host.querySelector('[slot="if-logged-in"]');this.initializeOsEmitter.emit(this.setOs)}login(t){const e=t.detail;this.os.login(e)}logout(){this.os.logout()}onLogin(){this.openDialog()}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"8f9cbfdf5a4024b197771ecff10208ee39ab39da"},n("div",{key:"9d63ca7862e6ef22be30d6388d9e9a8061b5081e",class:"container"},!L.state.isLoggedIn?n("button",{id:"login",onClick:()=>this.openDialog()},"Login"):this.loggedInComponents()),n("pos-dialog",{key:"0e5847b6fdd0aebac9e0bbbb2d47698bf0737b22",ref:t=>this.dialog=t},n("span",{key:"d5f2d6df1406e079cbc50106c01a0aa1ea7d07dd",slot:"title"},"Sign in to your Pod"),n("pos-login-form",{key:"369326cb176faf50d5e8d6d1b636b3d7798cd0d3","onPod-os:idp-url-selected":t=>this.login(t),slot:"content"})))}loggedInComponents(){return this.customLoggedInComponent?n("slot",{name:"if-logged-in"}):this.defaultLoggedInComponents()}defaultLoggedInComponents(){return[n("pos-resource",{uri:L.state.webId},n("span",{class:"user-data"},n("pos-picture",null),n("pos-label",null))),n("button",{id:"logout",onClick:()=>this.logout()},"Logout")]}get host(){return s(this)}};Bs.style=Ks;const Fs=":host{display:block;margin:0}form{display:flex;flex-direction:column;gap:var(--size-4)}input{outline:var(--pos-input-outline);padding:var(--scale-000);border:none;border-radius:var(--radius-xs);width:var(--size-full);box-sizing:border-box;background:var(--pos-input-background-color);color:var(--pos-normal-text-color)}input:focus-within{outline:var(--pos-input-focus-outline)}input#login{outline:none;box-shadow:var(--shadow-sm);cursor:pointer;color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}input#login:disabled{cursor:default;color:var(--pos-disabled-text-color);background-color:var(--pos-disabled-color);box-shadow:none}input#login:hover:not(:disabled),input#login:focus{filter:brightness(110%);box-shadow:var(--shadow-md)}";const Xs=Fs;const Vs=class{constructor(t){e(this,t);this.idpUrlSelected=a(this,"pod-os:idp-url-selected",7);this.idpUrl="";this.canSubmit=false}validate(){this.canSubmit=Boolean(this.idpUrl)}render(){return n("form",{key:"8504357a8c80ea64a4673ccbf73c1ca870b4a244",method:"dialog",onSubmit:()=>this.handleSubmit()},n("label",{key:"d53473ff19f1ba89d3c70294eac925a2b3ef6baf",htmlFor:"idpUrl"},"Please enter your Identity Provider"),n("input",{key:"311a6c2e10e8c4b5d1d6d6fb49173b4c170da4f5",id:"idpUrl",type:"url",value:this.idpUrl,required:true,onInput:t=>this.handleChange(t),list:"suggestedIssuers",placeholder:"Type to search..."}),n("datalist",{key:"b9d4555ff8cc1cb8328171d51f6fb26163de6747",id:"suggestedIssuers"},n("option",{key:"b5beeb77c2def2f8773fc20324f92b91fd487169",value:"https://solidcommunity.net/"},"solidcommunity.net"),n("option",{key:"49979b609e9340bfda3be7b8f1614451a9d767eb",value:"https://solidweb.me/"},"solidweb.me"),n("option",{key:"a898a1b9e967fdf1a3cd1290d3fdec330294aa7d",value:"https://login.inrupt.com"},"Inrupt PodSpaces"),n("option",{key:"cc87c94deb800b066d545c002786aa6af8ea630b",value:"https://trinpod.us"},"trinpod.us"),n("option",{key:"2f4705747451be8b0e1e831897ae9044239b1c74",value:"https://trinpod.eu"},"trinpod.eu"),n("option",{key:"aaad788c5f3f9103a095be51e9db843e0dcad272",value:"https://solid.redpencil.io/"},"redpencil.io"),n("option",{key:"49cf185d7eedc8781ff37e2fe39bcee0c4894f40",value:"https://teamid.live/"},"teamid.live")),n("input",{key:"7ddd76b1600d05e8585e895fb9ac7821c8648375",id:"login",type:"submit",value:"Login",disabled:!this.canSubmit}))}handleChange(t){this.validate();this.idpUrl=t.target.value}async handleSubmit(){this.idpUrlSelected.emit(this.idpUrl)}static get delegatesFocus(){return true}static get watchers(){return{idpUrl:["validate"]}}};Vs.style=Xs;var Ys=B`
19
+ */const ne=(t,e,n)=>{const i=u(t).querySelector(".toast-wrapper");const s=t.clientHeight;const o=i.getBoundingClientRect();let r=0;const a=.5;const c=t.position==="middle"?.5:0;const l=t.position==="top"?-1:1;const d=Gt(s,o.height);const h=[{offset:0,transform:`translateY(-${d+o.height}px)`},{offset:.5,transform:`translateY(0px)`},{offset:1,transform:`translateY(${d+o.height}px)`}];const f=D("toast-swipe-to-dismiss-animation").addElement(i).duration(100);switch(t.position){case"middle":r=s+o.height;f.keyframes(h);f.progressStart(true,.5);break;case"top":r=o.bottom;f.keyframes([{offset:0,transform:`translateY(${e.top})`},{offset:1,transform:"translateY(-100%)"}]);f.progressStart(true,0);break;case"bottom":default:r=s-o.top;f.keyframes([{offset:0,transform:`translateY(${e.bottom})`},{offset:1,transform:"translateY(100%)"}]);f.progressStart(true,0);break}const p=t=>t*l/r;const m=t=>{const e=c+p(t.deltaY);f.progressStep(e)};const b=e=>{const s=e.velocityY;const o=(e.deltaY+s*1e3)/r*l;g.enable(false);let c=true;let u=1;let m=0;let b=0;if(t.position==="middle"){c=o>=a/2||o<=-a/2;u=1;m=0;const t=i.getBoundingClientRect();const n=t.top-d;const s=`${n}px`;const r=e.deltaY<=0?-1:1;const l=(d+t.height)*r;const h=c?`${l}px`:"0px";const p=[{offset:0,transform:`translateY(${s})`},{offset:1,transform:`translateY(${h})`}];f.keyframes(p);b=l-n}else{c=o>=a;u=c?1:0;m=p(e.deltaY);const t=c?1-m:m;b=t*r}const w=Math.min(Math.abs(b)/Math.abs(s),200);f.onFinish((()=>{if(c){n();f.destroy()}else{if(t.position==="middle"){f.keyframes(h).progressStart(true,.5)}else{f.progressStart(true,0)}g.enable(true)}}),{oneTimeCallback:true}).progressEnd(u,m,w)};const g=j({el:i,gestureName:"toast-swipe-to-dismiss",gesturePriority:x,direction:"y",onMove:m,onEnd:b});return g};const ie=":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-50, #f2f2f2);--border-radius:14px;--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-850, #262626);--max-width:700px;--max-height:478px;--start:10px;--end:10px;font-size:clamp(14px, 0.875rem, 43.4px)}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;z-index:10}@supports (backdrop-filter: blur(0)){:host(.toast-translucent) .toast-wrapper{background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);backdrop-filter:saturate(180%) blur(20px)}:host(.ion-color.toast-translucent) .toast-wrapper{background:rgba(var(--ion-color-base-rgb), 0.8)}}.toast-wrapper.toast-middle{opacity:0.01}.toast-content{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:15px;padding-bottom:15px}.toast-header{margin-bottom:2px;font-weight:500}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;min-height:44px;transition:background-color, opacity 100ms linear;border:0;background-color:transparent;font-family:var(--ion-font-family);font-size:clamp(17px, 1.0625rem, 21.998px);font-weight:500;overflow:hidden}.toast-button.ion-activated{opacity:0.4}@media (any-hover: hover){.toast-button:hover{opacity:0.6}}";const se=ie;const oe=":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-800, #333333);--border-radius:4px;--box-shadow:0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-50, #f2f2f2);--max-width:700px;--start:8px;--end:8px;font-size:0.875rem}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;opacity:0.01;z-index:10}.toast-content{-webkit-padding-start:16px;padding-inline-start:16px;-webkit-padding-end:16px;padding-inline-end:16px;padding-top:14px;padding-bottom:14px}.toast-header{margin-bottom:2px;font-weight:500;line-height:1.25rem}.toast-message{line-height:1.25rem}.toast-layout-baseline .toast-button-group-start{-webkit-margin-start:8px;margin-inline-start:8px}.toast-layout-stacked .toast-button-group-start{-webkit-margin-end:8px;margin-inline-end:8px;margin-top:8px}.toast-layout-baseline .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px}.toast-layout-stacked .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px;margin-bottom:8px}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;position:relative;background-color:transparent;font-family:var(--ion-font-family);font-size:0.875rem;font-weight:500;letter-spacing:0.84px;text-transform:uppercase;overflow:hidden}.toast-button-cancel{color:var(--ion-color-step-100, #e6e6e6)}.toast-button-icon-only{border-radius:50%;-webkit-padding-start:9px;padding-inline-start:9px;-webkit-padding-end:9px;padding-inline-end:9px;padding-top:9px;padding-bottom:9px;width:36px;height:36px}@media (any-hover: hover){.toast-button:hover{background-color:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.08)}.toast-button-cancel:hover{background-color:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.08)}}";const re=oe;const ae=class{constructor(t){e(this,t);this.didPresent=a(this,"ionToastDidPresent",7);this.willPresent=a(this,"ionToastWillPresent",7);this.willDismiss=a(this,"ionToastWillDismiss",7);this.didDismiss=a(this,"ionToastDidDismiss",7);this.didPresentShorthand=a(this,"didPresent",7);this.willPresentShorthand=a(this,"willPresent",7);this.willDismissShorthand=a(this,"willDismiss",7);this.didDismissShorthand=a(this,"didDismiss",7);this.delegateController=S(this);this.lockController=v();this.triggerController=_();this.customHTMLEnabled=b.get("innerHTMLTemplatesEnabled",w);this.presented=false;this.dispatchCancelHandler=t=>{const e=t.detail.role;if(E(e)){const t=this.getButtons().find((t=>t.role==="cancel"));this.callButtonHandler(t)}};this.createSwipeGesture=t=>{const e=this.gesture=ne(this.el,t,(()=>{this.dismiss(undefined,I)}));e.enable(true)};this.destroySwipeGesture=()=>{const{gesture:t}=this;if(t===undefined){return}t.destroy();this.gesture=undefined};this.prefersSwipeGesture=()=>{const{swipeGesture:t}=this;return t==="vertical"};this.revealContentToScreenReader=false;this.overlayIndex=undefined;this.delegate=undefined;this.hasController=false;this.color=undefined;this.enterAnimation=undefined;this.leaveAnimation=undefined;this.cssClass=undefined;this.duration=b.getNumber("toastDuration",0);this.header=undefined;this.layout="baseline";this.message=undefined;this.keyboardClose=false;this.position="bottom";this.positionAnchor=undefined;this.buttons=undefined;this.translucent=false;this.animated=true;this.icon=undefined;this.htmlAttributes=undefined;this.swipeGesture=undefined;this.isOpen=false;this.trigger=undefined}swipeGestureChanged(){this.destroySwipeGesture();if(this.presented&&this.prefersSwipeGesture()){this.createSwipeGesture(this.lastPresentedPosition)}}onIsOpenChange(t,e){if(t===true&&e===false){this.present()}else if(t===false&&e===true){this.dismiss()}}triggerChanged(){const{trigger:t,el:e,triggerController:n}=this;if(t){n.addClickListener(e,t)}}connectedCallback(){A(this.el);this.triggerChanged()}disconnectedCallback(){this.triggerController.removeClickListener()}componentWillLoad(){T(this.el)}componentDidLoad(){if(this.isOpen===true){h((()=>this.present()))}this.triggerChanged()}async present(){const t=await this.lockController.lock();await this.delegateController.attachViewToDom();const{el:e,position:n}=this;const i=this.getAnchorElement();const s=Yt(n,i,g(this),e);this.lastPresentedPosition=s;await z(this,"toastEnter",Zt,te,{position:n,top:s.top,bottom:s.bottom});this.revealContentToScreenReader=true;if(this.duration>0){this.durationTimeout=setTimeout((()=>this.dismiss(undefined,"timeout")),this.duration)}if(this.prefersSwipeGesture()){this.createSwipeGesture(s)}t()}async dismiss(t,e){var n,i;const s=await this.lockController.lock();const{durationTimeout:o,position:r,lastPresentedPosition:a}=this;if(o){clearTimeout(o)}const c=await C(this,t,e,"toastLeave",Qt,ee,{position:r,top:(n=a===null||a===void 0?void 0:a.top)!==null&&n!==void 0?n:"",bottom:(i=a===null||a===void 0?void 0:a.bottom)!==null&&i!==void 0?i:""});if(c){this.delegateController.removeViewFromDom();this.revealContentToScreenReader=false}this.lastPresentedPosition=undefined;this.destroySwipeGesture();s();return c}onDidDismiss(){return $(this.el,"ionToastDidDismiss")}onWillDismiss(){return $(this.el,"ionToastWillDismiss")}getButtons(){const t=this.buttons?this.buttons.map((t=>typeof t==="string"?{text:t}:t)):[];return t}getAnchorElement(){const{position:t,positionAnchor:e,el:n}=this;if(e===undefined){return}if(t==="middle"&&e!==undefined){k('The positionAnchor property is ignored when using position="middle".',this.el);return undefined}if(typeof e==="string"){const t=document.getElementById(e);if(t===null){k(`An anchor element with an ID of "${e}" was not found in the DOM.`,n);return undefined}return t}if(e instanceof HTMLElement){return e}k("Invalid positionAnchor value:",e,n);return undefined}async buttonClick(t){const e=t.role;if(E(e)){return this.dismiss(undefined,e)}const n=await this.callButtonHandler(t);if(n){return this.dismiss(undefined,e)}return Promise.resolve()}async callButtonHandler(t){if(t===null||t===void 0?void 0:t.handler){try{const e=await P(t.handler);if(e===false){return false}}catch(t){console.error(t)}}return true}renderButtons(t,e){if(t.length===0){return}const i=g(this);const s={"toast-button-group":true,[`toast-button-group-${e}`]:true};return n("div",{class:s},t.map((t=>n("button",Object.assign({},t.htmlAttributes,{type:"button",class:ce(t),tabIndex:0,onClick:()=>this.buttonClick(t),part:le(t)}),n("div",{class:"toast-button-inner"},t.icon&&n("ion-icon",{"aria-hidden":"true",icon:t.icon,slot:t.text===undefined?"icon-only":undefined,class:"toast-button-icon"}),t.text),i==="md"&&n("ion-ripple-effect",{type:t.icon!==undefined&&t.text===undefined?"unbounded":"bounded"})))))}renderToastMessage(t,e=null){const{customHTMLEnabled:i,message:s}=this;if(i){return n("div",{key:t,"aria-hidden":e,class:"toast-message",part:"message",innerHTML:y(s)})}return n("div",{key:t,"aria-hidden":e,class:"toast-message",part:"message"},s)}renderHeader(t,e=null){return n("div",{key:t,class:"toast-header","aria-hidden":e,part:"header"},this.header)}render(){const{layout:t,el:e,revealContentToScreenReader:s,header:o,message:r}=this;const a=this.getButtons();const c=a.filter((t=>t.side==="start"));const l=a.filter((t=>t.side!=="start"));const d=g(this);const u={"toast-wrapper":true,[`toast-${this.position}`]:true,[`toast-layout-${t}`]:true};if(t==="stacked"&&c.length>0&&l.length>0){k("This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.",e)}return n(i,Object.assign({key:"23803334fb668f6ce7044d3a321cb84bc753bd16",tabindex:"-1"},this.htmlAttributes,{style:{zIndex:`${6e4+this.overlayIndex}`},class:f(this.color,Object.assign(Object.assign({[d]:true},m(this.cssClass)),{"overlay-hidden":true,"toast-translucent":this.translucent})),onIonToastWillDismiss:this.dispatchCancelHandler}),n("div",{key:"7cd7138ba079fccf97f318b91e9986491ab4214d",class:u},n("div",{key:"93b78fa64e24435adeb77a04c1d1d53d2f093864",class:"toast-container",part:"container"},this.renderButtons(c,"start"),this.icon!==undefined&&n("ion-icon",{key:"9a3c71b164ebcfba2540acb7568beffa76b62f47",class:"toast-icon",part:"icon",icon:this.icon,lazy:false,"aria-hidden":"true"}),n("div",{key:"feb9268102d844f1314205f7440de7066cf0620e",class:"toast-content",role:"status","aria-atomic":"true","aria-live":"polite"},!s&&o!==undefined&&this.renderHeader("oldHeader","true"),!s&&r!==undefined&&this.renderToastMessage("oldMessage","true"),s&&o!==undefined&&this.renderHeader("header"),s&&r!==undefined&&this.renderToastMessage("header")),this.renderButtons(l,"end"))))}get el(){return s(this)}static get watchers(){return{swipeGesture:["swipeGestureChanged"],isOpen:["onIsOpenChange"],trigger:["triggerChanged"]}}};const ce=t=>Object.assign({"toast-button":true,"toast-button-icon-only":t.icon!==undefined&&t.text===undefined,[`toast-button-${t.role}`]:t.role!==undefined,"ion-focusable":true,"ion-activatable":true},m(t.cssClass));const le=t=>E(t.role)?"button cancel":"button";ae.style={ios:se,md:re};const de=":host{font-family:var(--font-sans);display:block}button#new{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;width:var(--size-10);height:var(--size-10);background-color:var(--pos-primary-color);color:var(--pos-primary-text-color);font-size:var(--scale-6);border-radius:var(--radius-xs)}button#new:hover,button#new:focus{outline:none;filter:brightness(110%);box-shadow:var(--shadow-sm)}pos-new-thing-form{margin:var(--scale-3)}";const ue=de;const he=class{constructor(t){e(this,t)}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"6142a141ef03ca93a362a6b00ebe8d515c3a677a"},n("button",{key:"72ecf353cd3a7d2d68f9ef28eb1bbe7fdb88b700",id:"new",title:"Add a new thing",onClick:()=>this.openDialog()},n("ion-icon",{key:"bd05d75c42c10de6df519575787fc66eafb22930",name:"add-circle-outline"})),n("pos-dialog",{key:"23cf0118149704dfca16758970e4f4658e87e946",ref:t=>this.dialog=t},n("span",{key:"5af7b7f618cc20684c39134b5ea295400e651cb6",slot:"title"},"Add a new thing"),n("pos-new-thing-form",{key:"895496c2f6ede3c8677d9d918e0b13582090baed",slot:"content",referenceUri:this.referenceUri})))}};he.style=ue;const fe=localStorage.getItem("settings");const pe=fe?JSON.parse(fe):{offlineCache:false};const me=W(pe);be();ge();function be(){me.on("set",(()=>{const t=JSON.stringify(me.state);localStorage.setItem("settings",t)}))}function ge(){window.addEventListener("storage",(t=>{if(t.key==="settings"&&t.newValue){const e=JSON.parse(t.newValue);me.state.offlineCache=e.offlineCache}}))}const we=(t,e)=>e.some((e=>t instanceof e));let ye;let ve;function ke(){return ye||(ye=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xe(){return ve||(ve=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Se=new WeakMap;const _e=new WeakMap;const Ee=new WeakMap;function Ae(t){const e=new Promise(((e,n)=>{const i=()=>{t.removeEventListener("success",s);t.removeEventListener("error",o)};const s=()=>{e(Ie(t.result));i()};const o=()=>{n(t.error);i()};t.addEventListener("success",s);t.addEventListener("error",o)}));Ee.set(e,t);return e}function Te(t){if(Se.has(t))return;const e=new Promise(((e,n)=>{const i=()=>{t.removeEventListener("complete",s);t.removeEventListener("error",o);t.removeEventListener("abort",o)};const s=()=>{e();i()};const o=()=>{n(t.error||new DOMException("AbortError","AbortError"));i()};t.addEventListener("complete",s);t.addEventListener("error",o);t.addEventListener("abort",o)}));Se.set(t,e)}let ze={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Se.get(t);if(e==="store"){return n.objectStoreNames[1]?undefined:n.objectStore(n.objectStoreNames[0])}}return Ie(t[e])},set(t,e,n){t[e]=n;return true},has(t,e){if(t instanceof IDBTransaction&&(e==="done"||e==="store")){return true}return e in t}};function Ce(t){ze=t(ze)}function $e(t){if(xe().includes(t)){return function(...e){t.apply(Re(this),e);return Ie(this.request)}}return function(...e){return Ie(t.apply(Re(this),e))}}function Pe(t){if(typeof t==="function")return $e(t);if(t instanceof IDBTransaction)Te(t);if(we(t,ke()))return new Proxy(t,ze);return t}function Ie(t){if(t instanceof IDBRequest)return Ae(t);if(_e.has(t))return _e.get(t);const e=Pe(t);if(e!==t){_e.set(t,e);Ee.set(e,t)}return e}const Re=t=>Ee.get(t);function De(t,e,{blocked:n,upgrade:i,blocking:s,terminated:o}={}){const r=indexedDB.open(t,e);const a=Ie(r);if(i){r.addEventListener("upgradeneeded",(t=>{i(Ie(r.result),t.oldVersion,t.newVersion,Ie(r.transaction),t)}))}if(n){r.addEventListener("blocked",(t=>n(t.oldVersion,t.newVersion,t)))}a.then((t=>{if(o)t.addEventListener("close",(()=>o()));if(s){t.addEventListener("versionchange",(t=>s(t.oldVersion,t.newVersion,t)))}})).catch((()=>{}));return a}const Oe=["get","getKey","getAll","getAllKeys","count"];const je=["put","add","delete","clear"];const We=new Map;function Le(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e==="string")){return}if(We.get(e))return We.get(e);const n=e.replace(/FromIndex$/,"");const i=e!==n;const s=je.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(s||Oe.includes(n))){return}const o=async function(t,...e){const o=this.transaction(t,s?"readwrite":"readonly");let r=o.store;if(i)r=r.index(e.shift());return(await Promise.all([r[n](...e),s&&o.done]))[0]};We.set(e,o);return o}Ce((t=>({...t,get:(e,n,i)=>Le(e,n)||t.get(e,n,i),has:(e,n)=>!!Le(e,n)||t.has(e,n)})));const Me=["continue","continuePrimaryKey","advance"];const He={};const Ue=new WeakMap;const Je=new WeakMap;const Ne={get(t,e){if(!Me.includes(e))return t[e];let n=He[e];if(!n){n=He[e]=function(...t){Ue.set(this,Je.get(this)[e](...t))}}return n}};async function*Ke(...t){let e=this;if(!(e instanceof IDBCursor)){e=await e.openCursor(...t)}if(!e)return;e=e;const n=new Proxy(e,Ne);Je.set(n,e);Ee.set(n,Re(e));while(e){yield n;e=await(Ue.get(n)||e.continue());Ue.delete(n)}}function Be(t,e){return e===Symbol.asyncIterator&&we(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&we(t,[IDBIndex,IDBObjectStore])}Ce((t=>({...t,get(e,n,i){if(Be(e,n))return Ke;return t.get(e,n,i)},has(e,n){return Be(e,n)||t.has(e,n)}})));class Fe{constructor(){this.dbPromise=De("OfflineCacheDB",1,{upgrade(t){if(!t.objectStoreNames.contains("documents")){const e=t.createObjectStore("documents",{keyPath:"url"});e.createIndex("url-revision",["url","revision"])}}})}async clear(){const t=await this.dbPromise;return t.clear("documents")}async get(t){const e=await this.dbPromise;return await e.get("documents",t)}async put(t){const e=await this.dbPromise;const n=await e.getFromIndex("documents","url-revision",[t.url,t.revision]);if(n){return}await e.put("documents",t)}}class Xe{isOnline(){return navigator.onLine}}const Ve=(t,e)=>new H({session:t,offlineCache:e.offlineCache?new Fe:new U,onlineStatus:new Xe});class Ye extends N{constructor(t){super();this._value=t}get value(){return this.getValue()}_subscribe(t){const e=super._subscribe(t);!e.closed&&t.next(this._value);return e}getValue(){const{hasError:t,thrownError:e,_value:n}=this;if(t){throw e}this._throwIfClosed();return n}next(t){super.next(this._value=t)}}var qe=crypto;const Ge=t=>t instanceof CryptoKey;const Ze=async(t,e)=>{const n=`SHA-${t.slice(-3)}`;return new Uint8Array(await qe.subtle.digest(n,e))};var Qe=Ze;const tn=new TextEncoder;const en=new TextDecoder;function nn(...t){const e=t.reduce(((t,{length:e})=>t+e),0);const n=new Uint8Array(e);let i=0;for(const e of t){n.set(e,i);i+=e.length}return n}const sn=t=>{let e=t;if(typeof e==="string"){e=tn.encode(e)}const n=32768;const i=[];for(let t=0;t<e.length;t+=n){i.push(String.fromCharCode.apply(null,e.subarray(t,t+n)))}return btoa(i.join(""))};const on=t=>sn(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");const rn=t=>{const e=atob(t);const n=new Uint8Array(e.length);for(let t=0;t<e.length;t++){n[t]=e.charCodeAt(t)}return n};const an=t=>{let e=t;if(e instanceof Uint8Array){e=en.decode(e)}e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return rn(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class cn extends Error{constructor(t,e){super(t,e);this.code="ERR_JOSE_GENERIC";this.name=this.constructor.name;Error.captureStackTrace?.(this,this.constructor)}}cn.code="ERR_JOSE_GENERIC";class ln extends cn{constructor(t,e,n="unspecified",i="unspecified"){super(t,{cause:{claim:n,reason:i,payload:e}});this.code="ERR_JWT_CLAIM_VALIDATION_FAILED";this.claim=n;this.reason=i;this.payload=e}}ln.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class dn extends cn{constructor(t,e,n="unspecified",i="unspecified"){super(t,{cause:{claim:n,reason:i,payload:e}});this.code="ERR_JWT_EXPIRED";this.claim=n;this.reason=i;this.payload=e}}dn.code="ERR_JWT_EXPIRED";class un extends cn{constructor(){super(...arguments);this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}un.code="ERR_JOSE_ALG_NOT_ALLOWED";class hn extends cn{constructor(){super(...arguments);this.code="ERR_JOSE_NOT_SUPPORTED"}}hn.code="ERR_JOSE_NOT_SUPPORTED";class fn extends cn{constructor(t="decryption operation failed",e){super(t,e);this.code="ERR_JWE_DECRYPTION_FAILED"}}fn.code="ERR_JWE_DECRYPTION_FAILED";class pn extends cn{constructor(){super(...arguments);this.code="ERR_JWE_INVALID"}}pn.code="ERR_JWE_INVALID";class mn extends cn{constructor(){super(...arguments);this.code="ERR_JWS_INVALID"}}mn.code="ERR_JWS_INVALID";class bn extends cn{constructor(){super(...arguments);this.code="ERR_JWT_INVALID"}}bn.code="ERR_JWT_INVALID";class gn extends cn{constructor(){super(...arguments);this.code="ERR_JWK_INVALID"}}gn.code="ERR_JWK_INVALID";class wn extends cn{constructor(){super(...arguments);this.code="ERR_JWKS_INVALID"}}wn.code="ERR_JWKS_INVALID";class yn extends cn{constructor(t="no applicable key found in the JSON Web Key Set",e){super(t,e);this.code="ERR_JWKS_NO_MATCHING_KEY"}}yn.code="ERR_JWKS_NO_MATCHING_KEY";class vn extends cn{constructor(t="multiple matching keys found in the JSON Web Key Set",e){super(t,e);this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}vn.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class kn extends cn{constructor(t="request timed out",e){super(t,e);this.code="ERR_JWKS_TIMEOUT"}}kn.code="ERR_JWKS_TIMEOUT";class xn extends cn{constructor(t="signature verification failed",e){super(t,e);this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}xn.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Sn(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function _n(t,e){return t.name===e}function En(t){return parseInt(t.name.slice(4),10)}function An(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Tn(t,e){if(e.length&&!e.some((e=>t.usages.includes(e)))){let t="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const n=e.pop();t+=`one of ${e.join(", ")}, or ${n}.`}else if(e.length===2){t+=`one of ${e[0]} or ${e[1]}.`}else{t+=`${e[0]}.`}throw new TypeError(t)}}function zn(t,e,...n){switch(e){case"HS256":case"HS384":case"HS512":{if(!_n(t.algorithm,"HMAC"))throw Sn("HMAC");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!_n(t.algorithm,"RSASSA-PKCS1-v1_5"))throw Sn("RSASSA-PKCS1-v1_5");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!_n(t.algorithm,"RSA-PSS"))throw Sn("RSA-PSS");const n=parseInt(e.slice(2),10);const i=En(t.algorithm.hash);if(i!==n)throw Sn(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448"){throw Sn("Ed25519 or Ed448")}break}case"Ed25519":{if(!_n(t.algorithm,"Ed25519"))throw Sn("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!_n(t.algorithm,"ECDSA"))throw Sn("ECDSA");const n=An(e);const i=t.algorithm.namedCurve;if(i!==n)throw Sn(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Tn(t,n)}function Cn(t,e,...n){n=n.filter(Boolean);if(n.length>2){const e=n.pop();t+=`one of type ${n.join(", ")}, or ${e}.`}else if(n.length===2){t+=`one of type ${n[0]} or ${n[1]}.`}else{t+=`of type ${n[0]}.`}if(e==null){t+=` Received ${e}`}else if(typeof e==="function"&&e.name){t+=` Received function ${e.name}`}else if(typeof e==="object"&&e!=null){if(e.constructor?.name){t+=` Received an instance of ${e.constructor.name}`}}return t}var $n=(t,...e)=>Cn("Key must be ",t,...e);function Pn(t,e,...n){return Cn(`Key for the ${t} algorithm must be `,e,...n)}var In=t=>{if(Ge(t)){return true}return t?.[Symbol.toStringTag]==="KeyObject"};const Rn=["CryptoKey"];const Dn=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1){return true}let n;for(const t of e){const e=Object.keys(t);if(!n||n.size===0){n=new Set(e);continue}for(const t of e){if(n.has(t)){return false}n.add(t)}}return true};var On=Dn;function jn(t){return typeof t==="object"&&t!==null}function Wn(t){if(!jn(t)||Object.prototype.toString.call(t)!=="[object Object]"){return false}if(Object.getPrototypeOf(t)===null){return true}let e=t;while(Object.getPrototypeOf(e)!==null){e=Object.getPrototypeOf(e)}return Object.getPrototypeOf(t)===e}var Ln=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:n}=e.algorithm;if(typeof n!=="number"||n<2048){throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}};function Mn(t){return Wn(t)&&typeof t.kty==="string"}function Hn(t){return t.kty!=="oct"&&typeof t.d==="string"}function Un(t){return t.kty!=="oct"&&typeof t.d==="undefined"}function Jn(t){return Mn(t)&&t.kty==="oct"&&typeof t.k==="string"}function Nn(t){let e;let n;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`};n=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`};n=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`};n=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"};n=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"};n=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"};n=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv};n=t.d?["deriveBits"]:[];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"Ed25519":e={name:"Ed25519"};n=t.d?["sign"]:["verify"];break;case"EdDSA":e={name:t.crv};n=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv};n=t.d?["deriveBits"]:[];break;default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new hn('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:n}}const Kn=async t=>{if(!t.alg){throw new TypeError('"alg" argument is required when "jwk.alg" is not present')}const{algorithm:e,keyUsages:n}=Nn(t);const i=[e,t.ext??false,t.key_ops??n];const s={...t};delete s.alg;delete s.use;return qe.subtle.importKey("jwk",s,...i)};var Bn=Kn;const Fn=t=>an(t);let Xn;let Vn;const Yn=t=>t?.[Symbol.toStringTag]==="KeyObject";const qn=async(t,e,n,i,s=false)=>{let o=t.get(e);if(o?.[i]){return o[i]}const r=await Bn({...n,alg:i});if(s)Object.freeze(e);if(!o){t.set(e,{[i]:r})}else{o[i]=r}return r};const Gn=(t,e)=>{if(Yn(t)){let n=t.export({format:"jwk"});delete n.d;delete n.dp;delete n.dq;delete n.p;delete n.q;delete n.qi;if(n.k){return Fn(n.k)}Vn||(Vn=new WeakMap);return qn(Vn,t,n,e)}if(Mn(t)){if(t.k)return an(t.k);Vn||(Vn=new WeakMap);const n=qn(Vn,t,t,e,true);return n}return t};const Zn=(t,e)=>{if(Yn(t)){let n=t.export({format:"jwk"});if(n.k){return Fn(n.k)}Xn||(Xn=new WeakMap);return qn(Xn,t,n,e)}if(Mn(t)){if(t.k)return an(t.k);Xn||(Xn=new WeakMap);const n=qn(Xn,t,t,e,true);return n}return t};var Qn={normalizePublicKey:Gn,normalizePrivateKey:Zn};async function ti(t,e){if(!Wn(t)){throw new TypeError("JWK must be an object")}e||(e=t.alg);switch(t.kty){case"oct":if(typeof t.k!=="string"||!t.k){throw new TypeError('missing "k" (Key Value) Parameter value')}return an(t.k);case"RSA":if("oth"in t&&t.oth!==undefined){throw new hn('RSA JWK "oth" (Other Primes Info) Parameter value is not supported')}case"EC":case"OKP":return Bn({...t,alg:e});default:throw new hn('Unsupported "kty" (Key Type) Parameter value')}}const ei=t=>t?.[Symbol.toStringTag];const ni=(t,e,n)=>{if(e.use!==undefined&&e.use!=="sig"){throw new TypeError("Invalid key for this operation, when present its use must be sig")}if(e.key_ops!==undefined&&e.key_ops.includes?.(n)!==true){throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${n}`)}if(e.alg!==undefined&&e.alg!==t){throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`)}return true};const ii=(t,e,n,i)=>{if(e instanceof Uint8Array)return;if(i&&Mn(e)){if(Jn(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!In(e)){throw new TypeError(Pn(t,e,...Rn,"Uint8Array",i?"JSON Web Key":null))}if(e.type!=="secret"){throw new TypeError(`${ei(e)} instances for symmetric algorithms must be of type "secret"`)}};const si=(t,e,n,i)=>{if(i&&Mn(e)){switch(n){case"sign":if(Hn(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for this operation be a private JWK`);case"verify":if(Un(e)&&ni(t,e,n))return;throw new TypeError(`JSON Web Key for this operation be a public JWK`)}}if(!In(e)){throw new TypeError(Pn(t,e,...Rn,i?"JSON Web Key":null))}if(e.type==="secret"){throw new TypeError(`${ei(e)} instances for asymmetric algorithms must not be of type "secret"`)}if(n==="sign"&&e.type==="public"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm signing must be of type "private"`)}if(n==="decrypt"&&e.type==="public"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm decryption must be of type "private"`)}if(e.algorithm&&n==="verify"&&e.type==="private"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm verifying must be of type "public"`)}if(e.algorithm&&n==="encrypt"&&e.type==="private"){throw new TypeError(`${ei(e)} instances for asymmetric algorithm encryption must be of type "public"`)}};function oi(t,e,n,i){const s=e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e);if(s){ii(e,n,i,t)}else{si(e,n,i,t)}}oi.bind(undefined,false);const ri=oi.bind(undefined,true);function ai(t,e,n,i,s){if(s.crit!==undefined&&i?.crit===undefined){throw new t('"crit" (Critical) Header Parameter MUST be integrity protected')}if(!i||i.crit===undefined){return new Set}if(!Array.isArray(i.crit)||i.crit.length===0||i.crit.some((t=>typeof t!=="string"||t.length===0))){throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present')}let o;if(n!==undefined){o=new Map([...Object.entries(n),...e.entries()])}else{o=e}for(const e of i.crit){if(!o.has(e)){throw new hn(`Extension Header Parameter "${e}" is not recognized`)}if(s[e]===undefined){throw new t(`Extension Header Parameter "${e}" is missing`)}if(o.get(e)&&i[e]===undefined){throw new t(`Extension Header Parameter "${e}" MUST be integrity protected`)}}return new Set(i.crit)}const ci=(t,e)=>{if(e!==undefined&&(!Array.isArray(e)||e.some((t=>typeof t!=="string")))){throw new TypeError(`"${t}" option must be an array of strings`)}if(!e){return undefined}return new Set(e)};var li=ci;const di=async t=>{if(t instanceof Uint8Array){return{kty:"oct",k:on(t)}}if(!Ge(t)){throw new TypeError($n(t,...Rn,"Uint8Array"))}if(!t.extractable){throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK")}const{ext:e,key_ops:n,alg:i,use:s,...o}=await qe.subtle.exportKey("jwk",t);return o};var ui=di;async function hi(t){return ui(t)}function fi(t,e){const n=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:t.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new hn(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function pi(t,e,n){if(n==="sign"){e=await Qn.normalizePrivateKey(e,t)}if(n==="verify"){e=await Qn.normalizePublicKey(e,t)}if(Ge(e)){zn(e,t,n);return e}if(e instanceof Uint8Array){if(!t.startsWith("HS")){throw new TypeError($n(e,...Rn))}return qe.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},false,[n])}throw new TypeError($n(e,...Rn,"Uint8Array","JSON Web Key"))}const mi=async(t,e,n,i)=>{const s=await pi(t,e,"verify");Ln(t,s);const o=fi(t,s.algorithm);try{return await qe.subtle.verify(o,s,n,i)}catch{return false}};var bi=mi;async function gi(t,e,n){if(!Wn(t)){throw new mn("Flattened JWS must be an object")}if(t.protected===undefined&&t.header===undefined){throw new mn('Flattened JWS must have either of the "protected" or "header" members')}if(t.protected!==undefined&&typeof t.protected!=="string"){throw new mn("JWS Protected Header incorrect type")}if(t.payload===undefined){throw new mn("JWS Payload missing")}if(typeof t.signature!=="string"){throw new mn("JWS Signature missing or incorrect type")}if(t.header!==undefined&&!Wn(t.header)){throw new mn("JWS Unprotected Header incorrect type")}let i={};if(t.protected){try{const e=an(t.protected);i=JSON.parse(en.decode(e))}catch{throw new mn("JWS Protected Header is invalid")}}if(!On(i,t.header)){throw new mn("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const s={...i,...t.header};const o=ai(mn,new Map([["b64",true]]),n?.crit,i,s);let r=true;if(o.has("b64")){r=i.b64;if(typeof r!=="boolean"){throw new mn('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:a}=s;if(typeof a!=="string"||!a){throw new mn('JWS "alg" (Algorithm) Header Parameter missing or invalid')}const c=n&&li("algorithms",n.algorithms);if(c&&!c.has(a)){throw new un('"alg" (Algorithm) Header Parameter value not allowed')}if(r){if(typeof t.payload!=="string"){throw new mn("JWS Payload must be a string")}}else if(typeof t.payload!=="string"&&!(t.payload instanceof Uint8Array)){throw new mn("JWS Payload must be a string or an Uint8Array instance")}let l=false;if(typeof e==="function"){e=await e(i,t);l=true;ri(a,e,"verify");if(Mn(e)){e=await ti(e,a)}}else{ri(a,e,"verify")}const d=nn(tn.encode(t.protected??""),tn.encode("."),typeof t.payload==="string"?tn.encode(t.payload):t.payload);let u;try{u=an(t.signature)}catch{throw new mn("Failed to base64url decode the signature")}const h=await bi(a,e,u,d);if(!h){throw new xn}let f;if(r){try{f=an(t.payload)}catch{throw new mn("Failed to base64url decode the payload")}}else if(typeof t.payload==="string"){f=tn.encode(t.payload)}else{f=t.payload}const p={payload:f};if(t.protected!==undefined){p.protectedHeader=i}if(t.header!==undefined){p.unprotectedHeader=t.header}if(l){return{...p,key:e}}return p}async function wi(t,e,n){if(t instanceof Uint8Array){t=en.decode(t)}if(typeof t!=="string"){throw new mn("Compact JWS must be a string or Uint8Array")}const{0:i,1:s,2:o,length:r}=t.split(".");if(r!==3){throw new mn("Invalid Compact JWS")}const a=await gi({payload:s,protected:i,signature:o},e,n);const c={payload:a.payload,protectedHeader:a.protectedHeader};if(typeof e==="function"){return{...c,key:a.key}}return c}var yi=t=>Math.floor(t.getTime()/1e3);const vi=60;const ki=vi*60;const xi=ki*24;const Si=xi*7;const _i=xi*365.25;const Ei=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;var Ai=t=>{const e=Ei.exec(t);if(!e||e[4]&&e[1]){throw new TypeError("Invalid time period format")}const n=parseFloat(e[2]);const i=e[3].toLowerCase();let s;switch(i){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(n*vi);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(n*ki);break;case"day":case"days":case"d":s=Math.round(n*xi);break;case"week":case"weeks":case"w":s=Math.round(n*Si);break;default:s=Math.round(n*_i);break}if(e[1]==="-"||e[4]==="ago"){return-s}return s};const Ti=t=>t.toLowerCase().replace(/^application\//,"");const zi=(t,e)=>{if(typeof t==="string"){return e.includes(t)}if(Array.isArray(t)){return e.some(Set.prototype.has.bind(new Set(t)))}return false};var Ci=(t,e,n={})=>{let i;try{i=JSON.parse(en.decode(e))}catch{}if(!Wn(i)){throw new bn("JWT Claims Set must be a top-level JSON object")}const{typ:s}=n;if(s&&(typeof t.typ!=="string"||Ti(t.typ)!==Ti(s))){throw new ln('unexpected "typ" JWT header value',i,"typ","check_failed")}const{requiredClaims:o=[],issuer:r,subject:a,audience:c,maxTokenAge:l}=n;const d=[...o];if(l!==undefined)d.push("iat");if(c!==undefined)d.push("aud");if(a!==undefined)d.push("sub");if(r!==undefined)d.push("iss");for(const t of new Set(d.reverse())){if(!(t in i)){throw new ln(`missing required "${t}" claim`,i,t,"missing")}}if(r&&!(Array.isArray(r)?r:[r]).includes(i.iss)){throw new ln('unexpected "iss" claim value',i,"iss","check_failed")}if(a&&i.sub!==a){throw new ln('unexpected "sub" claim value',i,"sub","check_failed")}if(c&&!zi(i.aud,typeof c==="string"?[c]:c)){throw new ln('unexpected "aud" claim value',i,"aud","check_failed")}let u;switch(typeof n.clockTolerance){case"string":u=Ai(n.clockTolerance);break;case"number":u=n.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:h}=n;const f=yi(h||new Date);if((i.iat!==undefined||l)&&typeof i.iat!=="number"){throw new ln('"iat" claim must be a number',i,"iat","invalid")}if(i.nbf!==undefined){if(typeof i.nbf!=="number"){throw new ln('"nbf" claim must be a number',i,"nbf","invalid")}if(i.nbf>f+u){throw new ln('"nbf" claim timestamp check failed',i,"nbf","check_failed")}}if(i.exp!==undefined){if(typeof i.exp!=="number"){throw new ln('"exp" claim must be a number',i,"exp","invalid")}if(i.exp<=f-u){throw new dn('"exp" claim timestamp check failed',i,"exp","check_failed")}}if(l){const t=f-i.iat;const e=typeof l==="number"?l:Ai(l);if(t-u>e){throw new dn('"iat" claim timestamp check failed (too far in the past)',i,"iat","check_failed")}if(t<0-u){throw new ln('"iat" claim timestamp check failed (it should be in the past)',i,"iat","check_failed")}}return i};async function $i(t,e,n){const i=await wi(t,e,n);if(i.protectedHeader.crit?.includes("b64")&&i.protectedHeader.b64===false){throw new bn("JWTs MUST NOT use unencoded payload")}const s=Ci(i.protectedHeader,i.payload,n);const o={payload:s,protectedHeader:i.protectedHeader};if(typeof e==="function"){return{...o,key:i.key}}return o}const Pi=async(t,e,n)=>{const i=await pi(t,e,"sign");Ln(t,i);const s=await qe.subtle.sign(fi(t,i.algorithm),i,n);return new Uint8Array(s)};var Ii=Pi;class Ri{constructor(t){if(!(t instanceof Uint8Array)){throw new TypeError("payload must be an instance of Uint8Array")}this._payload=t}setProtectedHeader(t){if(this._protectedHeader){throw new TypeError("setProtectedHeader can only be called once")}this._protectedHeader=t;return this}setUnprotectedHeader(t){if(this._unprotectedHeader){throw new TypeError("setUnprotectedHeader can only be called once")}this._unprotectedHeader=t;return this}async sign(t,e){if(!this._protectedHeader&&!this._unprotectedHeader){throw new mn("either setProtectedHeader or setUnprotectedHeader must be called before #sign()")}if(!On(this._protectedHeader,this._unprotectedHeader)){throw new mn("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const n={...this._protectedHeader,...this._unprotectedHeader};const i=ai(mn,new Map([["b64",true]]),e?.crit,this._protectedHeader,n);let s=true;if(i.has("b64")){s=this._protectedHeader.b64;if(typeof s!=="boolean"){throw new mn('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:o}=n;if(typeof o!=="string"||!o){throw new mn('JWS "alg" (Algorithm) Header Parameter missing or invalid')}ri(o,t,"sign");let r=this._payload;if(s){r=tn.encode(on(r))}let a;if(this._protectedHeader){a=tn.encode(on(JSON.stringify(this._protectedHeader)))}else{a=tn.encode("")}const c=nn(a,tn.encode("."),r);const l=await Ii(o,t,c);const d={signature:on(l),payload:""};if(s){d.payload=en.decode(r)}if(this._unprotectedHeader){d.header=this._unprotectedHeader}if(this._protectedHeader){d.protected=en.decode(a)}return d}}class Di{constructor(t){this._flattened=new Ri(t)}setProtectedHeader(t){this._flattened.setProtectedHeader(t);return this}async sign(t,e){const n=await this._flattened.sign(t,e);if(n.payload===undefined){throw new TypeError("use the flattened module for creating JWS with b64: false")}return`${n.protected}.${n.payload}.${n.signature}`}}function Oi(t,e){if(!Number.isFinite(e)){throw new TypeError(`Invalid ${t} input`)}return e}class ji{constructor(t={}){if(!Wn(t)){throw new TypeError("JWT Claims Set MUST be an object")}this._payload=t}setIssuer(t){this._payload={...this._payload,iss:t};return this}setSubject(t){this._payload={...this._payload,sub:t};return this}setAudience(t){this._payload={...this._payload,aud:t};return this}setJti(t){this._payload={...this._payload,jti:t};return this}setNotBefore(t){if(typeof t==="number"){this._payload={...this._payload,nbf:Oi("setNotBefore",t)}}else if(t instanceof Date){this._payload={...this._payload,nbf:Oi("setNotBefore",yi(t))}}else{this._payload={...this._payload,nbf:yi(new Date)+Ai(t)}}return this}setExpirationTime(t){if(typeof t==="number"){this._payload={...this._payload,exp:Oi("setExpirationTime",t)}}else if(t instanceof Date){this._payload={...this._payload,exp:Oi("setExpirationTime",yi(t))}}else{this._payload={...this._payload,exp:yi(new Date)+Ai(t)}}return this}setIssuedAt(t){if(typeof t==="undefined"){this._payload={...this._payload,iat:yi(new Date)}}else if(t instanceof Date){this._payload={...this._payload,iat:Oi("setIssuedAt",yi(t))}}else if(typeof t==="string"){this._payload={...this._payload,iat:Oi("setIssuedAt",yi(new Date)+Ai(t))}}else{this._payload={...this._payload,iat:Oi("setIssuedAt",t)}}return this}}class Wi extends ji{setProtectedHeader(t){this._protectedHeader=t;return this}async sign(t,e){const n=new Di(tn.encode(JSON.stringify(this._payload)));n.setProtectedHeader(this._protectedHeader);if(Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===false){throw new bn("JWTs MUST NOT use unencoded payload")}return n.sign(t,e)}}const Li=(t,e)=>{if(typeof t!=="string"||!t){throw new gn(`${e} missing or invalid`)}};async function Mi(t,e){if(!Wn(t)){throw new TypeError("JWK must be an object")}e??(e="sha256");if(e!=="sha256"&&e!=="sha384"&&e!=="sha512"){throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"')}let n;switch(t.kty){case"EC":Li(t.crv,'"crv" (Curve) Parameter');Li(t.x,'"x" (X Coordinate) Parameter');Li(t.y,'"y" (Y Coordinate) Parameter');n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":Li(t.crv,'"crv" (Subtype of Key Pair) Parameter');Li(t.x,'"x" (Public Key) Parameter');n={crv:t.crv,kty:t.kty,x:t.x};break;case"RSA":Li(t.e,'"e" (Exponent) Parameter');Li(t.n,'"n" (Modulus) Parameter');n={e:t.e,kty:t.kty,n:t.n};break;case"oct":Li(t.k,'"k" (Key Value) Parameter');n={k:t.k,kty:t.kty};break;default:throw new hn('"kty" (Key Type) Parameter missing or unsupported')}const i=tn.encode(JSON.stringify(n));return on(await Qe(e,i))}function Hi(t){switch(typeof t==="string"&&t.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new hn('Unsupported "alg" value for a JSON Web Key Set')}}function Ui(t){return t&&typeof t==="object"&&Array.isArray(t.keys)&&t.keys.every(Ji)}function Ji(t){return Wn(t)}function Ni(t){if(typeof structuredClone==="function"){return structuredClone(t)}return JSON.parse(JSON.stringify(t))}class Ki{constructor(t){this._cached=new WeakMap;if(!Ui(t)){throw new wn("JSON Web Key Set malformed")}this._jwks=Ni(t)}async getKey(t,e){const{alg:n,kid:i}={...t,...e?.header};const s=Hi(n);const o=this._jwks.keys.filter((t=>{let e=s===t.kty;if(e&&typeof i==="string"){e=i===t.kid}if(e&&typeof t.alg==="string"){e=n===t.alg}if(e&&typeof t.use==="string"){e=t.use==="sig"}if(e&&Array.isArray(t.key_ops)){e=t.key_ops.includes("verify")}if(e){switch(n){case"ES256":e=t.crv==="P-256";break;case"ES256K":e=t.crv==="secp256k1";break;case"ES384":e=t.crv==="P-384";break;case"ES512":e=t.crv==="P-521";break;case"Ed25519":e=t.crv==="Ed25519";break;case"EdDSA":e=t.crv==="Ed25519"||t.crv==="Ed448";break}}return e}));const{0:r,length:a}=o;if(a===0){throw new yn}if(a!==1){const t=new vn;const{_cached:e}=this;t[Symbol.asyncIterator]=async function*(){for(const t of o){try{yield await Bi(e,t,n)}catch{}}};throw t}return Bi(this._cached,r,n)}}async function Bi(t,e,n){const i=t.get(e)||t.set(e,{}).get(e);if(i[n]===undefined){const t=await ti({...e,ext:true},n);if(t instanceof Uint8Array||t.type!=="public"){throw new wn("JSON Web Key Set members must be public keys")}i[n]=t}return i[n]}function Fi(t){const e=new Ki(t);const n=async(t,n)=>e.getKey(t,n);Object.defineProperties(n,{jwks:{value:()=>Ni(e._jwks),enumerable:true,configurable:false,writable:false}});return n}const Xi=async(t,e,n)=>{let i;let s;let o=false;if(typeof AbortController==="function"){i=new AbortController;s=setTimeout((()=>{o=true;i.abort()}),e)}const r=await fetch(t.href,{signal:i?i.signal:undefined,redirect:"manual",headers:n.headers}).catch((t=>{if(o)throw new kn;throw t}));if(s!==undefined)clearTimeout(s);if(r.status!==200){throw new cn("Expected 200 OK from the JSON Web Key Set HTTP response")}try{return await r.json()}catch{throw new cn("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var Vi=Xi;function Yi(){return typeof WebSocketPair!=="undefined"||typeof navigator!=="undefined"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime!=="undefined"&&EdgeRuntime==="vercel"}let qi;if(typeof navigator==="undefined"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){const t="jose";const e="v5.10.0";qi=`${t}/${e}`}const Gi=Symbol();function Zi(t,e){if(typeof t!=="object"||t===null){return false}if(!("uat"in t)||typeof t.uat!=="number"||Date.now()-t.uat>=e){return false}if(!("jwks"in t)||!Wn(t.jwks)||!Array.isArray(t.jwks.keys)||!Array.prototype.every.call(t.jwks.keys,Wn)){return false}return true}class Qi{constructor(t,e){if(!(t instanceof URL)){throw new TypeError("url must be an instance of URL")}this._url=new URL(t.href);this._options={agent:e?.agent,headers:e?.headers};this._timeoutDuration=typeof e?.timeoutDuration==="number"?e?.timeoutDuration:5e3;this._cooldownDuration=typeof e?.cooldownDuration==="number"?e?.cooldownDuration:3e4;this._cacheMaxAge=typeof e?.cacheMaxAge==="number"?e?.cacheMaxAge:6e5;if(e?.[Gi]!==undefined){this._cache=e?.[Gi];if(Zi(e?.[Gi],this._cacheMaxAge)){this._jwksTimestamp=this._cache.uat;this._local=Fi(this._cache.jwks)}}}coolingDown(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:false}fresh(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:false}async getKey(t,e){if(!this._local||!this.fresh()){await this.reload()}try{return await this._local(t,e)}catch(n){if(n instanceof yn){if(this.coolingDown()===false){await this.reload();return this._local(t,e)}}throw n}}async reload(){if(this._pendingFetch&&Yi()){this._pendingFetch=undefined}const t=new Headers(this._options.headers);if(qi&&!t.has("User-Agent")){t.set("User-Agent",qi);this._options.headers=Object.fromEntries(t.entries())}this._pendingFetch||(this._pendingFetch=Vi(this._url,this._timeoutDuration,this._options).then((t=>{this._local=Fi(t);if(this._cache){this._cache.uat=Date.now();this._cache.jwks=t}this._jwksTimestamp=Date.now();this._pendingFetch=undefined})).catch((t=>{this._pendingFetch=undefined;throw t})));await this._pendingFetch}}function ts(t,e){const n=new Qi(t,e);const i=async(t,e)=>n.getKey(t,e);Object.defineProperties(i,{coolingDown:{get:()=>n.coolingDown(),enumerable:true,configurable:false},fresh:{get:()=>n.fresh(),enumerable:true,configurable:false},reload:{value:()=>n.reload(),enumerable:true,configurable:false,writable:false},reloading:{get:()=>!!n._pendingFetch,enumerable:true,configurable:false},jwks:{value:()=>n._local?.jwks(),enumerable:true,configurable:false,writable:false}});return i}const es=an;function ns(t){if(typeof t!=="string")throw new bn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new bn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new bn("Invalid JWT");if(!e)throw new bn("JWTs must contain a payload");let i;try{i=es(e)}catch{throw new bn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(en.decode(i))}catch{throw new bn("Failed to parse the decoded payload as JSON")}if(!Wn(s))throw new bn("Invalid JWT Claims Set");return s}function is(t){const e=t?.modulusLength??2048;if(typeof e!=="number"||e<2048){throw new hn("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used")}return e}async function ss(t,e){let n;let i;switch(t){case"PS256":case"PS384":case"PS512":n={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["sign","verify"];break;case"RS256":case"RS384":case"RS512":n={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":n={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:is(e)};i=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":n={name:"ECDSA",namedCurve:"P-256"};i=["sign","verify"];break;case"ES384":n={name:"ECDSA",namedCurve:"P-384"};i=["sign","verify"];break;case"ES512":n={name:"ECDSA",namedCurve:"P-521"};i=["sign","verify"];break;case"Ed25519":n={name:"Ed25519"};i=["sign","verify"];break;case"EdDSA":{i=["sign","verify"];const t=e?.crv??"Ed25519";switch(t){case"Ed25519":case"Ed448":n={name:t};break;default:throw new hn("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{i=["deriveKey","deriveBits"];const t=e?.crv??"P-256";switch(t){case"P-256":case"P-384":case"P-521":{n={name:"ECDH",namedCurve:t};break}case"X25519":case"X448":n={name:t};break;default:throw new hn("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new hn('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return qe.subtle.generateKey(n,e?.extractable??false,i)}async function os(t,e){return ss(t,e)}const rs=async(t,e)=>{const n={...e,grant_types:["authorization_code","refresh_token"],id_token_signed_response_alg:"ES256",token_endpoint_auth_method:"none",application_type:"web",subject_type:"public"};return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})};class as{dbName;storeName;dbVersion;db=null;constructor(t="soidc",e="session",n=1){this.dbName=t;this.storeName=e;this.dbVersion=n}async init(){return new Promise(((t,e)=>{const n=indexedDB.open(this.dbName,this.dbVersion);n.onerror=t=>{e(new Error(`Database error: ${t.target.error}`))};n.onsuccess=e=>{this.db=e.target.result;t(this)};n.onupgradeneeded=t=>{const e=t.target.result;if(!e.objectStoreNames.contains(this.storeName)){e.createObjectStore(this.storeName)}}}))}async setItem(t,e){if(!this.db){await this.init()}return new Promise(((n,i)=>{const s=this.db.transaction(this.storeName,"readwrite");s.oncomplete=()=>{n()};s.onerror=e=>{i(new Error(`Transaction error for setItem(${t},...): ${e.target.error}`))};s.onabort=e=>{i(new Error(`Transaction aborted for setItem(${t},...): ${e.target.error}`))};const o=s.objectStore(this.storeName);o.put(e,t)}))}async getItem(t){if(!this.db){await this.init()}return new Promise(((e,n)=>{const i=this.db.transaction(this.storeName,"readonly");i.onerror=e=>{n(new Error(`Transaction error for getItem(${t}): ${e.target.error}`))};i.onabort=e=>{n(new Error(`Transaction aborted for getItem(${t}): ${e.target.error}`))};const s=i.objectStore(this.storeName);const o=s.get(t);o.onsuccess=()=>{e(o.result||null)}}))}async deleteItem(t){if(!this.db){await this.init()}return new Promise(((e,n)=>{const i=this.db.transaction(this.storeName,"readwrite");i.oncomplete=()=>{e()};i.onerror=e=>{n(new Error(`Transaction error for deleteItem(${t}): ${e.target.error}`))};i.onabort=e=>{n(new Error(`Transaction aborted for deleteItem(${t}): ${e.target.error}`))};const s=i.objectStore(this.storeName);s.delete(t)}))}async clear(){if(!this.db){await this.init()}return new Promise(((t,e)=>{const n=this.db.transaction(this.storeName,"readwrite");n.oncomplete=()=>{t()};n.onerror=t=>{e(new Error(`Transaction error for clear(): ${t.target.error}`))};n.onabort=t=>{e(new Error(`Transaction aborted for clear(): ${t.target.error}`))};const i=n.objectStore(this.storeName);i.clear()}))}close(){if(this.db){this.db.close();this.db=null}}}const cs=async(t,e,n)=>{const i=new URL(e);const s=i.origin+i.pathname+i.search;const o=new URL(t).origin;const r=await fetch(`${o}/.well-known/openid-configuration`).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const a=r["issuer"];const c=t=>t.endsWith("/")?t.slice(0,-1):t;if(c(t)!==c(a)){throw new Error("RFC 9207 - iss != idp - "+a+" != "+t)}sessionStorage.setItem("idp",a);sessionStorage.setItem("token_endpoint",r["token_endpoint"]);sessionStorage.setItem("jwks_uri",r["jwks_uri"]);let l=n?.client_id;if(!l){const t=r["registration_endpoint"];const e=await rs(t,n??{redirect_uris:[s]}).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));l=e["client_id"];sessionStorage.setItem("client_id",l)}const{pkce_code_verifier:d,pkce_code_challenge:u}=await ls();sessionStorage.setItem("pkce_code_verifier",d);const h=window.crypto.randomUUID();sessionStorage.setItem("csrf_token",h);const f=r["authorization_endpoint"]+`?response_type=code`+`&redirect_uri=${encodeURIComponent(s)}`+`&scope=openid offline_access webid`+`&client_id=${encodeURIComponent(l)}`+`&code_challenge_method=S256`+`&code_challenge=${u}`+`&state=${h}`+`&prompt=consent`;window.location.href=f};const ls=async()=>{const t=window.crypto.randomUUID()+"-"+window.crypto.randomUUID();const e=new Uint8Array(await window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t)));const n=btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return{pkce_code_verifier:t,pkce_code_challenge:n}};const ds=async t=>{const e=new URL(window.location.href);const n=e.searchParams.get("code");if(n===null){return{clientDetails:t}}const i=sessionStorage.getItem("idp");if(i===null||e.searchParams.get("iss")!=i){throw new Error("RFC 9207 - iss != idp - "+e.searchParams.get("iss")+" != "+i)}if(e.searchParams.get("state")!=sessionStorage.getItem("csrf_token")){throw new Error("RFC 6749 - state != csrf_token - "+e.searchParams.get("state")+" != "+sessionStorage.getItem("csrf_token"))}e.searchParams.delete("iss");e.searchParams.delete("state");e.searchParams.delete("code");window.history.pushState({},document.title,e.toString());const s=sessionStorage.getItem("pkce_code_verifier");if(s===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: pkce_code_verifier")}const o=t?.client_id||sessionStorage.getItem("client_id");if(!o){throw new Error("Access Token Request preparation - Could not find in sessionStorage: client_id (dynamic registration)")}const r=sessionStorage.getItem("token_endpoint");if(r===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: token_endpoint")}const a=await os("ES256");const c=await us(n,s,e.toString(),o,r,a).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const l=c["access_token"];const d=sessionStorage.getItem("jwks_uri");if(d===null){throw new Error("Access Token validation preparation - Could not find in sessionStorage: jwks_uri")}const u=ts(new URL(d));const{payload:h}=await $i(l,u,{issuer:i,audience:"solid"});const f=await Mi(await hi(a.publicKey));if(h["cnf"]["jkt"]!=f){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+h["cnf"]["jkt"]+" != "+f)}if(h["client_id"]!=o){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+h["client_id"]+" != "+o)}const p={...c,dpop_key_pair:a};const m={idp:i,jwks_uri:d,token_endpoint:r};if(!t)t={redirect_uris:[window.location.href]};t.client_id=o;const b=await(new as).init();await Promise.all([b.setItem("idp",i),b.setItem("jwks_uri",d),b.setItem("token_endpoint",r),b.setItem("client_id",o),b.setItem("dpop_keypair",a),b.setItem("refresh_token",c["refresh_token"])]);b.close();sessionStorage.removeItem("csrf_token");sessionStorage.removeItem("pkce_code_verifier");sessionStorage.removeItem("idp");sessionStorage.removeItem("jwks_uri");sessionStorage.removeItem("token_endpoint");sessionStorage.removeItem("client_id");return{clientDetails:t,idpDetails:m,tokenDetails:p}};const us=async(t,e,n,i,s,o)=>{const r=await hi(o.publicKey);r.alg="ES256";const a=await new Wi({htu:s,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:r}).sign(o.privateKey);return fetch(s,{method:"POST",headers:{dpop:a,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:n,client_id:i})})};const hs=async()=>{const t=await(new as).init();const e=await t.getItem("client_id");const n=await t.getItem("token_endpoint");const i=await t.getItem("dpop_keypair");const s=await t.getItem("refresh_token");if(e===null||n===null||i===null||s===null){throw new Error("Could not refresh tokens: details missing from database.")}const o=await fs(s,e,n,i).then((t=>{if(!t.ok){throw new Error(`HTTP error! Status: ${t.status}`)}return t.json()}));const r=o["access_token"];const a=await t.getItem("idp");if(a===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: idp")}const c=await t.getItem("jwks_uri");if(c===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: jwks_uri")}const l=ts(new URL(c));const{payload:d}=await $i(r,l,{issuer:a,audience:"solid"});const u=await Mi(await hi(i.publicKey));if(d["cnf"]["jkt"]!=u){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+d["cnf"]["jkt"]+" != "+u)}if(d["client_id"]!=e){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+d["client_id"]+" != "+e)}await t.setItem("refresh_token",o["refresh_token"]);t.close();return{...o,dpop_key_pair:i}};const fs=async(t,e,n,i)=>{const s=await hi(i.publicKey);s.alg="ES256";const o=await new Wi({htu:n,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:s}).sign(i.privateKey);return fetch(n,{method:"POST",headers:{dpop:o,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t,client_id:e})})};class ps{sessionInformation;isActive_=false;webId_=undefined;currentAth_=undefined;tokenRefreshTimeout;sessionDeactivateTimeout;onSessionExpirationWarning;constructor(t,e){this.sessionInformation={clientDetails:t};this.onSessionExpirationWarning=e?.onSessionExpirationWarning}async login(t,e){await cs(t,e,this.sessionInformation.clientDetails)}async logout(){if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=undefined;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=undefined;this.sessionInformation.idpDetails=undefined;this.sessionInformation.tokenDetails=undefined;this.isActive_=false;this.webId_=undefined;if(this.sessionInformation.clientDetails?.client_id)try{new URL(this.sessionInformation.clientDetails.client_id)}catch(t){this.sessionInformation.clientDetails.client_id=undefined}const t=await(new as).init();await t.clear();t.close()}async handleRedirectFromLogin(){const t=await ds(this.sessionInformation.clientDetails);if(!t.tokenDetails){return}this.sessionInformation=t;await this.setSessionDetails()}async restore(){await hs().then((t=>{this.sessionInformation.tokenDetails=t;return this.setSessionDetails()})).catch((t=>{}))}async createSignedDPoPToken(t){if(!this.sessionInformation.tokenDetails||!this.currentAth_){throw new Error("Session not established.")}t.ath=this.currentAth_;const e=await hi(this.sessionInformation.tokenDetails.dpop_key_pair.publicKey);return new Wi(t).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:e}).sign(this.sessionInformation.tokenDetails.dpop_key_pair.privateKey)}async authFetch(t,e,n){let i;let s;let o;if(t instanceof Request){i=new URL(t.url);s=e?.method||t?.method||"GET";o=new Headers(t.headers)}else{e=e||{};i=new URL(t.toString());s=e.method||"GET";o=e.headers?new Headers(e.headers):new Headers}if(this.sessionInformation.tokenDetails){n=n??{htu:`${i.origin}${i.pathname}`,htm:s.toUpperCase()};const t=await this.createSignedDPoPToken(n);o.set("dpop",t);o.set("authorization",`DPoP ${this.sessionInformation.tokenDetails.access_token}`)}if(t instanceof Request){return fetch(new Request(t,{...e,headers:o}))}return fetch(i,{...e,headers:o})}get isActive(){return this.isActive_}get webId(){return this.webId_}async setSessionDetails(){if(!this.sessionInformation.tokenDetails?.access_token){this.logout()}this.currentAth_=await this.computeAth(this.sessionInformation.tokenDetails.access_token);this.webId_=ns(this.sessionInformation.tokenDetails.access_token)["webid"];this.isActive_=this.webId!==undefined;this.setSessionDeactivateTimeout();this.setTokenRefreshTimeout()}setSessionDeactivateTimeout(){const t=5;const e=(this.sessionInformation.tokenDetails.expires_in-t)*1e3;if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=setTimeout((()=>this.logout()),e)}setTokenRefreshTimeout(){const t=95;const e=(this.sessionInformation.tokenDetails.expires_in-t)*1e3;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=setTimeout((async()=>{const t=await hs().catch((t=>{if(this.onSessionExpirationWarning)this.onSessionExpirationWarning();return undefined}));if(!t){return}this.sessionInformation.tokenDetails=t;this.setSessionDetails()}),e)}async computeAth(t){const e=new TextEncoder;const n=e.encode(t);const i=await crypto.subtle.digest("SHA-256",n);const s=Array.from(new Uint8Array(i));const o=btoa(String.fromCharCode(...s));const r=o.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return r}}class ms{get authenticatedFetch(){return this._authenticatedFetch}constructor(){this.onSessionRestoreCallback=()=>{};this.sessionInfo$=new Ye({isLoggedIn:false,webId:undefined});this.session=new ps;this._authenticatedFetch=this.session.authFetch.bind(this.session)}async handleIncomingRedirect(t=false){await this.session.handleRedirectFromLogin();if(t){await this.session.restore();if(this.session.isActive){this.onSessionRestoreCallback(window.location.href)}}this.sessionInfo$.next({isLoggedIn:this.session.isActive,webId:this.session.webId})}async login(t){return this.session.login(t,window.location.href)}async logout(){await this.session.logout();this.sessionInfo$.next({isLoggedIn:false,webId:undefined})}observeSession(){return this.sessionInfo$}onSessionRestore(t){this.onSessionRestoreCallback=t}}const bs=class{constructor(t){e(this,t);this.sessionRestoredEmitter=a(this,"pod-os:session-restored",7);this.podOsLoadedEmitter=a(this,"pod-os:loaded",7);this.restorePreviousSession=false;this.disconnected$=new N;this.loading=true}async componentWillLoad(){const t=new ms;this.unsubscribeSettings=me.on("set",(()=>{this.os=Ve(t,me.state)}));this.os=Ve(t,me.state);t.onSessionRestore((t=>{this.sessionRestoredEmitter.emit({url:t})}));try{await t.handleIncomingRedirect(this.restorePreviousSession)}catch(t){console.error(t)}this.os.observeSession().pipe(K(this.disconnected$)).subscribe((async t=>{L.state.webId=t.webId;if(t.isLoggedIn){const e=await this.os.fetchProfile(t.webId);L.state.profile=e}L.state.isLoggedIn=t.isLoggedIn;this.loading=false}));this.podOsLoadedEmitter.emit({os:this.os,authenticatedFetch:t.authenticatedFetch})}disconnectedCallback(){this.unsubscribeSettings();this.disconnected$.next();this.disconnected$.unsubscribe()}async initializeOs(t){t.stopPropagation();t.detail(this.os)}async loadModule(t){t.stopPropagation();if(t.detail.module==="contacts"){const e=await this.os.loadContactsModule();t.detail.receiver(e)}else{throw Error(`Unknown module "${t.detail.module}"`)}}render(){return this.loading?n("ion-progress-bar",{type:"indeterminate"}):n("slot",null)}};const gs="pos-router {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\npos-navigation {\n max-width: var(--width-lg);\n margin: 0;\n min-width: var(--size-32);\n flex-shrink: 1; /* Ensure navigation can shrink */\n}\n\npos-add-new-thing,\npos-login {\n flex: 0 1 auto;\n flex-shrink: 0; /* Ensure those items don't shrink */\n}\n\nheader,\nfooter {\n display: flex;\n gap: var(--size-1);\n height: auto;\n justify-content: center;\n align-items: center;\n padding: var(--size-1);\n}\n\nfooter svg {\n width: var(--size-5);\n height: var(--size-5);\n}\n\nfooter {\n font-size: var(--scale-fluid-000);\n\n .settings {\n padding: 0 var(--size-1);\n text-decoration: none;\n background-color: var(--pos-background-color);\n border: 1px solid var(--pos-secondary-border-color);\n color: var(--pos-secondary-border-color);\n border-radius: var(--radius-xs);\n\n &:hover {\n background-color: var(--pos-secondary-border-color);\n color: var(--pos-background-color);\n }\n }\n}\n\nheader {\n flex-wrap: nowrap;\n padding: var(--size-1) var(--size-8);\n}\n\nmain {\n flex: 1;\n max-height: 100vh;\n overflow: auto;\n}\n\n@media (max-width: 640px) {\n header {\n padding: var(--size-1);\n justify-content: space-between;\n }\n footer {\n display: none;\n }\n}\n";const ws=gs;const ys=class{constructor(t){e(this,t);this.restorePreviousSession=false;this.mode="standalone";this.uri=""}render(){return n(i,{key:"08b186d2f354d6c07df02707eb4ada81aef7dec3"},n("pos-app",{key:"54c372343e916ab5d77584381b3965c925ae0cd0",restorePreviousSession:this.restorePreviousSession},n("pos-error-toast",{key:"ab63e18121ca16670f81da141219a782dde0694b"},n("pos-router",{key:"69b6f3bf8ce3720c6c39cdb4be69e640e27ccc5b",mode:this.mode,"onPod-os:route-changed":t=>this.uri=t.detail},n("header",{key:"5cd3412caf13b6d99da517ae7e6f5877234e65d7"},n("pos-add-new-thing",{key:"9b83b3cf03b7038303975386176df539b35ff547",referenceUri:this.uri}),n("pos-navigation",{key:"26bfed9b1c8dd1be018babc6ef40ae42808a5c42",uri:this.uri==="pod-os:dashboard"?"":this.uri}),n("pos-login",{key:"e29f18dcde866d8ac1e317fcd7b71ef584e69034"},n("pos-user-menu",{key:"be796f0914649eb4e8525a9d8acdfd535626303c",webId:L.state.webId,slot:"if-logged-in"}))),n("main",{key:"f99dfb2d43e949528bc767b94801c99bf04a7eea"},this.mainContent()),n("footer",{key:"64744d1246356fa00da9c6b561785e2b794a7907"},n(vs,{key:"a648f7f88e12c79348bda33152f2759d2b93e738"}),n("span",{key:"f22e2f9904ba517fc2e579a05018704b5ade6302"},"PodOS Browser"))))))}mainContent(){if(this.uri===""){return null}if(this.uri.startsWith("pod-os:")){return n("pos-internal-router",{uri:this.uri})}return n("pos-resource",{key:this.uri,uri:this.uri},n("pos-type-router",null))}};const vs=()=>n("svg",{viewBox:"0 0 400 400",xmlns:"http://www.w3.org/2000/svg"},n("path",{d:"M50 350 L50 100 L200 50 L350 100 L350 350 Z",style:{fill:"#008BF8",stroke:"#008BF8","stroke-width":"70"},"stroke-linejoin":"round"}),n("path",{d:"M100 300 L100 150 L200 120 L300 150 L300 300 L130 300 L130 370 L100 370Z",style:{fill:"white",stroke:"white","stroke-width":"45"},"stroke-linejoin":"round"}),n("path",{d:"M150 250 L150 200 L200 180 L250 200 L250 250 Z",style:{fill:"#DC0073",stroke:"#DC0073","stroke-width":"20"},"stroke-linejoin":"round"}));ys.style=ws;const ks=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const xs=ks;const Ss=class{constructor(t){e(this,t)}render(){return n(i,{key:"18dc165b7be1c796136804a2ba7643b2a6fffc73"},n("pos-getting-started",{key:"e3f7a22641e4c24168a36f96463515cd1a89ca5e"}),n("pos-example-resources",{key:"1044dd873049118e165ff6d38449c85695f63a50"}))}};Ss.style=xs;const _s=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Es=_s;const As=class{constructor(t){e(this,t)}render(){return n("pos-setting-offline-cache",{key:"f065206f6291089773a19045243f04b6ce35eeb9"})}};As.style=Es;const Ts=class{constructor(t){e(this,t);this.subscribeResource=a(this,"pod-os:resource",7);this.receiveResource=t=>{this.resource=t}}componentWillLoad(){at(this)}render(){return this.resource?this.resource.description():null}};const zs="dialog{background-color:var(--pos-background-color);color:var(--pos-normal-text-color);border:none;border-radius:var(--radius-md);box-shadow:var(--shadow-md);max-width:var(--width-xs);animation:slideIn 0.2s ease-out}dialog::backdrop{background:rgba(0, 0, 0, 0.5);backdrop-filter:var(--blur-sm);animation:fadeIn 0.2s ease-out}@media (prefers-color-scheme: dark){dialog::backdrop{background:rgb(100, 100, 100, 0.5)}}dialog header>:first-child{flex-grow:1;font-weight:var(--weight-light);font-size:var(--scale-2);font-family:var(--font-sans);margin:0}dialog header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;gap:var(--scale-0);border-bottom-style:inset;padding:0 0 var(--scale-0) 0}dialog>:last-child{display:block;margin-top:var(--scale-3)}button#close{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;background:none;font-size:var(--scale-3);color:var(--color-grey-500)}button#close:hover{color:var(--pos-secondary-border-color)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}";const Cs=zs;const $s=class{constructor(t){e(this,t)}async showModal(){this.dialog.showModal()}async close(){this.dialog.close()}render(){return n(i,{key:"4e570e7fb1942fab0f4056d17a28c67a7abfee19"},n("dialog",{key:"c2282c2ac11c236672ee4848019dacb59ff6b1ef",ref:t=>this.dialog=t},n("header",{key:"ca58f3372a078235d931e60b6a7979e5006010c5"},n("slot",{key:"2e63b07551e537491d86bae21c80c235ce5ca0db",name:"title"}),n("button",{key:"a3afd2ab3624f98799976de5d4b86c86360bd2af",tabindex:-1,id:"close",title:"Close",onClick:()=>this.close()},n("ion-icon",{key:"9f7fccd041dab2f0f224a13fdcb7b7254f090740",name:"close-outline"}))),n("slot",{key:"5e5b4e385c7000ece9ced84d5ba6f5b45a990e33",name:"content"})))}};$s.style=Cs;const Ps=class{constructor(t){e(this,t)}async unhandledRejection(t){t.stopPropagation();console.error("unhandled promise rejection",t);await this.showToast(t.reason.toString())}async catchError(t){t.stopPropagation();console.error(t.detail);await this.showToast(t.detail.message)}async showToast(t){const e=await R.create({message:t,duration:1e4,position:"top",color:"danger",buttons:[{text:"Dismiss",role:"cancel"}]});await e.present()}render(){return n(i,{key:"323aca8226bb81061d9edf6db10ba6fcfa69fa21"},n("ion-toast",{key:"e8bcbfb1d06594a25a27beb87da97f47c32067b1",trigger:"never",message:"Workarround to preload ion-toast and ion-ripple-effect to be able to show errors while offline",duration:0},n("ion-ripple-effect",{key:"273603931e206584a1bf3b98751d92daec0465cf"})),n("slot",{key:"6cee55328058d883459a4c89edd63a0dfac9aa7e"}))}};const Is=":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.links{display:flex;flex-direction:column;gap:var(--size-3);max-width:80vw}";const Rs=Is;const Ds=class{constructor(t){e(this,t)}render(){return n(i,{key:"42e8ecc30fa26eb7750efff9a65048bb42b4c71d"},n("div",{key:"1df80385f1f6c44f7fe4255ecb93f6183df61727"},n("h2",{key:"9b249d38f00d1b00863226799bdcd13e4f78a4a9"},"Try these... 💡"),n("p",{key:"c33157b085b1ad3397e38bf5f4b1c601b0e40b6a"},"No idea where to start? Try these example resources, and follow your nose 👃"),n("div",{key:"f0f35cc2ec1f7fbf8a306e718e1f2aaffcbe84e0",class:"links"},n("pos-rich-link",{key:"999b7dc0aa587b1964838820f17a02257b051c0e",uri:"https://pod-os.solidcommunity.net/profile/card#me"}),n("pos-rich-link",{key:"67ca02160d0bdaa73bcfb188fcf40b058a584bf8",uri:"https://angelo.veltens.org/profile/card#me"}),n("pos-rich-link",{key:"800829fb68c96b0caa0ad2372b02e08b7842b704",uri:"https://angelo.veltens.org/public/bookmarks"}),n("pos-rich-link",{key:"680e29b8bf0437d6adba15052339b91ffd41b9a4",uri:"https://solidos.solidcommunity.net/profile/card#me"}))))}};Ds.style=Rs;const Os=":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.question{font-weight:var(--weight-semibold)}a{font-weight:var(--weight-bold);color:var(--pos-primary-color)}button.login{background:none;color:var(--pos-primary-color);display:inline;text-decoration:underline;border:none;padding:0;margin:0;cursor:pointer;font-size:unset}";const js=Os;const Ws=class{constructor(t){e(this,t);this.login=a(this,"pod-os:login",7)}render(){return n(i,{key:"23a14b5ee10d585cc8cf3166ce041072b68cabb2"},n("div",{key:"964e46223d77516aaed40c7c55371716cfccf40a"},n("h2",{key:"5eaf56d6b0751d8511632d05570a05d5deba88c0"},"Getting started 🚀"),n("p",{key:"f41d858112a0337bcf2be9a39986cacac6921210"},"🔎 Enter a URL into the above navigation bar to browse through the web of data. "),n("p",{key:"8d40de32d86b871343687b402122b0dcc843daf9"},"🔐"," ",n("button",{key:"225091e03c1cf175362dc9530cf1eb5238e50d65",class:"login",onClick:()=>this.login.emit()},"Sign in")," ","to access private resources on your Solid Pod or those of your friends or coworkers.")),n("div",{key:"92924f3a67ac70cd333932f0658f9f73dd7474c9"},n("p",{key:"365d7c78aee4bb9396ac7d55c42c9e26b47fe87a",class:"question"},"New to Solid?"),n("p",{key:"42190c0f401faff3cf43fe8f3c69f4afc380f819"},n("a",{key:"d7de0d55a657c8a54a389efc50aa89bc4d48c5e6",href:"https://solidproject.org/for-developers#hosted-pod-services"},"Get a Pod →"))),n("div",{key:"8ad728231a1f2af613a462982af6bf129956ab1c"},n("p",{key:"c960fa49ff9789fe881cadc4f37d315c7727115a",class:"question"},"Want to dig deeper into PodOS?"),n("p",{key:"7991e91dbfdfc0447a2e08850e3634086f3f12ee"},n("a",{key:"a35d336eb2ca5947e66abb9e37526ee035c0a700",href:"http://pod-os.org"},"Learn more →"))))}};Ws.style=js;const Ls=":host{display:flex;background-size:cover;background-repeat:no-repeat;background-position:center;border-radius:inherit}img,ion-skeleton-text,div.error{border-radius:var(--border-radius);width:var(--width);height:var(--height);max-width:var(--max-width);max-height:var(--max-height);object-fit:var(--object-fit)}img{backdrop-filter:var(--blur-xl)}.error{display:flex;opacity:0.8;background:repeating-linear-gradient(-45deg, rgba(150, 0, 0, 0.1), rgba(150, 0, 0, 0.1) 10px, #fff 5px, #fff 25px);flex-direction:column;border:1px solid red;color:black;align-items:center;justify-content:center;word-break:break-all;padding:1rem;box-sizing:border-box}.error ion-icon{color:#282828;--ionicon-stroke-width:calc(var(--width) / 5);font-size:calc(var(--width) / 2)}a.error{text-decoration:none;width:var(--width);height:var(--height)}.code{font-weight:bold;font-size:calc(var(--width) / 8)}.text{font-size:calc(var(--width) / 20)}";const Ms=Ls;const Hs=class{constructor(t){e(this,t);this.initializeOsEmitter=a(this,"pod-os:init",7);this.resourceLoadedEmitter=a(this,"pod-os:resource-loaded",7);this.blurredBackground=false;this.loading=true;this.setOs=async t=>{this.os=t}}componentWillLoad(){L.onChange("isLoggedIn",(()=>this.fetchBlob()));this.initializeOsEmitter.emit(this.setOs)}async fetchBlob(){try{this.loading=true;this.imageError=null;this.networkError=null;this.brokenFile=null;const t=await this.os.files().fetchFile(this.src);this.resourceLoadedEmitter.emit(this.src);if(t.blob()){this.dataUri=URL.createObjectURL(t.blob())}else{this.brokenFile=t}}catch(t){this.networkError=t}finally{this.loading=false}}onImageError(t){this.networkError=null;this.imageError=t}render(){if(this.loading){return n("ion-skeleton-text",{animated:true})}if(this.networkError){return n("img",{alt:this.alt,src:this.src,onError:t=>this.onImageError(t)})}if(this.brokenFile){return n(M,{file:this.brokenFile})}if(this.imageError){return n("div",{class:"error"},n("a",{href:this.src},this.src))}return n(i,{style:{backgroundImage:this.blurredBackground?`url('${this.dataUri}')`:null}},n("img",{src:this.dataUri,alt:this.alt}))}static get watchers(){return{os:["fetchBlob"],src:["fetchBlob"]}}};Hs.style=Ms;const Us=class{constructor(t){e(this,t);this.uri="pod-os:dashboard"}render(){return this.uri==="pod-os:settings"?n("pos-app-settings",null):n("pos-app-dashboard",null)}};const Js=class{constructor(t){e(this,t);this.subscribeResource=a(this,"pod-os:resource",7);this.receiveResource=t=>{this.resource=t}}componentWillLoad(){at(this)}render(){return this.resource?this.resource.label():null}};const Ns=".container{display:flex;align-items:center;gap:var(--size-2)}.user-data{align-items:center;display:inline-flex;gap:10px}.user-data pos-picture{--width:40px;--height:40px;--border-radius:50%}pos-login-form{margin:var(--size-2)}dialog{margin-top:var(--size-10)}button#login,button#logout{outline:none;font-weight:var(--weight-bold);letter-spacing:var(--letter-xl);border:none;box-sizing:border-box;border-radius:var(--radius-xs);padding:var(--size-2);box-shadow:var(--shadow-sm);color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}button#login:focus-within,button#logout:focus-within{outline:var(--pos-input-focus-outline)}button#login:focus,button#login:hover,button#logout:focus,button#logout:hover{filter:brightness(110%);box-shadow:var(--shadow-md)}";const Ks=Ns;const Bs=class{constructor(t){e(this,t);this.initializeOsEmitter=a(this,"pod-os:init",7);this.customLoggedInComponent=false;this.setOs=async t=>{this.os=t}}componentWillLoad(){this.customLoggedInComponent=!!this.host.querySelector('[slot="if-logged-in"]');this.initializeOsEmitter.emit(this.setOs)}login(t){const e=t.detail;this.os.login(e)}logout(){this.os.logout()}onLogin(){this.openDialog()}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"8f9cbfdf5a4024b197771ecff10208ee39ab39da"},n("div",{key:"9d63ca7862e6ef22be30d6388d9e9a8061b5081e",class:"container"},!L.state.isLoggedIn?n("button",{id:"login",onClick:()=>this.openDialog()},"Login"):this.loggedInComponents()),n("pos-dialog",{key:"0e5847b6fdd0aebac9e0bbbb2d47698bf0737b22",ref:t=>this.dialog=t},n("span",{key:"d5f2d6df1406e079cbc50106c01a0aa1ea7d07dd",slot:"title"},"Sign in to your Pod"),n("pos-login-form",{key:"369326cb176faf50d5e8d6d1b636b3d7798cd0d3","onPod-os:idp-url-selected":t=>this.login(t),slot:"content"})))}loggedInComponents(){return this.customLoggedInComponent?n("slot",{name:"if-logged-in"}):this.defaultLoggedInComponents()}defaultLoggedInComponents(){return[n("pos-resource",{uri:L.state.webId},n("span",{class:"user-data"},n("pos-picture",null),n("pos-label",null))),n("button",{id:"logout",onClick:()=>this.logout()},"Logout")]}get host(){return s(this)}};Bs.style=Ks;const Fs=":host{display:block;margin:0}form{display:flex;flex-direction:column;gap:var(--size-4)}input{outline:var(--pos-input-outline);padding:var(--scale-000);border:none;border-radius:var(--radius-xs);width:var(--size-full);box-sizing:border-box;background:var(--pos-input-background-color);color:var(--pos-normal-text-color)}input:focus-within{outline:var(--pos-input-focus-outline)}input#login{outline:none;box-shadow:var(--shadow-sm);cursor:pointer;color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}input#login:disabled{cursor:default;color:var(--pos-disabled-text-color);background-color:var(--pos-disabled-color);box-shadow:none}input#login:hover:not(:disabled),input#login:focus{filter:brightness(110%);box-shadow:var(--shadow-md)}";const Xs=Fs;const Vs=class{constructor(t){e(this,t);this.idpUrlSelected=a(this,"pod-os:idp-url-selected",7);this.idpUrl="";this.canSubmit=false}validate(){this.canSubmit=Boolean(this.idpUrl)}render(){return n("form",{key:"8504357a8c80ea64a4673ccbf73c1ca870b4a244",method:"dialog",onSubmit:()=>this.handleSubmit()},n("label",{key:"d53473ff19f1ba89d3c70294eac925a2b3ef6baf",htmlFor:"idpUrl"},"Please enter your Identity Provider"),n("input",{key:"311a6c2e10e8c4b5d1d6d6fb49173b4c170da4f5",id:"idpUrl",type:"url",value:this.idpUrl,required:true,onInput:t=>this.handleChange(t),list:"suggestedIssuers",placeholder:"Type to search..."}),n("datalist",{key:"b9d4555ff8cc1cb8328171d51f6fb26163de6747",id:"suggestedIssuers"},n("option",{key:"b5beeb77c2def2f8773fc20324f92b91fd487169",value:"https://solidcommunity.net/"},"solidcommunity.net"),n("option",{key:"49979b609e9340bfda3be7b8f1614451a9d767eb",value:"https://solidweb.me/"},"solidweb.me"),n("option",{key:"a898a1b9e967fdf1a3cd1290d3fdec330294aa7d",value:"https://login.inrupt.com"},"Inrupt PodSpaces"),n("option",{key:"cc87c94deb800b066d545c002786aa6af8ea630b",value:"https://trinpod.us"},"trinpod.us"),n("option",{key:"2f4705747451be8b0e1e831897ae9044239b1c74",value:"https://trinpod.eu"},"trinpod.eu"),n("option",{key:"aaad788c5f3f9103a095be51e9db843e0dcad272",value:"https://solid.redpencil.io/"},"redpencil.io"),n("option",{key:"49cf185d7eedc8781ff37e2fe39bcee0c4894f40",value:"https://teamid.live/"},"teamid.live")),n("input",{key:"7ddd76b1600d05e8585e895fb9ac7821c8648375",id:"login",type:"submit",value:"Login",disabled:!this.canSubmit}))}handleChange(t){this.validate();this.idpUrl=t.target.value}async handleSubmit(){this.idpUrlSelected.emit(this.idpUrl)}static get delegatesFocus(){return true}static get watchers(){return{idpUrl:["validate"]}}};Vs.style=Xs;var Ys=B`
20
20
  :host {
21
21
  display: inline-block;
22
22
  }
@@ -585,4 +585,4 @@ import{d as t,r as e,h as n,H as i,e as s,f as o,w as r,i as a,j as c,k as l}fro
585
585
  margin: 0 var(--spacing);
586
586
  }
587
587
  `;var xl=class extends q{constructor(){super(...arguments);this.vertical=false}connectedCallback(){super.connectedCallback();this.setAttribute("role","separator")}handleVerticalChange(){this.setAttribute("aria-orientation",this.vertical?"vertical":"horizontal")}};xl.styles=[V,kl];Y([tt({type:Boolean,reflect:true})],xl.prototype,"vertical",2);Y([nt("vertical")],xl.prototype,"handleVerticalChange",1);xl.define("sl-divider");const Sl="button {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n margin: 0;\n border: none;\n background: none;\n cursor: pointer;\n border-radius: 50%;\n pos-picture {\n --width: 40px;\n --height: 40px;\n --border-radius: 50%;\n }\n sl-avatar {\n --size: 40px;\n }\n}\n\nsl-dropdown {\n display: block;\n}\n";const _l=Sl;const El=class{constructor(t){e(this,t);this.logout=a(this,"pod-os:logout",7);this.link=a(this,"pod-os:link",7)}onSelect(t){const{value:e}=t.detail.item;if(e==="logout"){this.logout.emit()}else if(e==="profile"){this.link.emit(this.webId)}else if(e==="dashboard"){this.link.emit("pod-os:dashboard")}else if(e==="settings"){this.link.emit("pod-os:settings")}}render(){if(!this.webId)return null;return n("pos-resource",{uri:this.webId},n("sl-dropdown",null,n("button",{slot:"trigger","aria-label":"User menu"},n("pos-picture",null,n("sl-avatar",null))),n("sl-menu",null,n("sl-menu-item",{value:"dashboard"},"Dashboard"),n("sl-menu-item",{value:"profile"},n("pos-label",null)),n("sl-menu-item",{value:"settings"},"Settings"),n("sl-divider",null),n("sl-menu-item",{value:"logout"},"Logout"))))}};El.style=_l;export{$t as ion_icon,Wt as ion_progress_bar,Jt as ion_ripple_effect,Vt as ion_skeleton_text,ae as ion_toast,he as pos_add_new_thing,bs as pos_app,ys as pos_app_browser,Ss as pos_app_dashboard,As as pos_app_settings,Ts as pos_description,$s as pos_dialog,Ps as pos_error_toast,Ds as pos_example_resources,Ws as pos_getting_started,Hs as pos_image,Us as pos_internal_router,Js as pos_label,Bs as pos_login,Vs as pos_login_form,wc as pos_make_findable,Sc as pos_navigation,Ac as pos_navigation_bar,Cc as pos_new_thing_form,Ic as pos_picture,Oc as pos_resource,Lc as pos_rich_link,Qc as pos_router,nl as pos_select_term,ol as pos_setting_offline_cache,cl as pos_tool_select,wl as pos_type_router,El as pos_user_menu};
588
- //# sourceMappingURL=p-411c85a4.entry.js.map
588
+ //# sourceMappingURL=p-c9ba983f.entry.js.map