nostr-comments 0.4.0 → 0.6.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.
@@ -1,96 +1,154 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");n.id="nostr-comments-styles",n.appendChild(document.createTextNode(':where(.nostr-comments){--nc-bg: #ffffff;--nc-text: #1f2937;--nc-primary: #319cfc;--nc-error: #dc2626;--nc-success: #16a34a;--nc-bg-secondary: color-mix(in srgb, var(--nc-text) 4%, var(--nc-bg));--nc-bg-hover: color-mix(in srgb, var(--nc-text) 6%, var(--nc-bg));--nc-border: color-mix(in srgb, var(--nc-text) 18%, var(--nc-bg));--nc-text-secondary: color-mix(in srgb, var(--nc-text) 60%, var(--nc-bg));--nc-text-muted: color-mix(in srgb, var(--nc-text) 40%, var(--nc-bg));--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, black);--nc-primary-light: color-mix(in srgb, var(--nc-primary) 8%, var(--nc-bg));--nc-error-light: color-mix(in srgb, var(--nc-error) 6%, var(--nc-bg));--nc-success-light: color-mix(in srgb, var(--nc-success) 12%, var(--nc-bg));--nc-space-xs: 3px;--nc-space-sm: 6px;--nc-space-md: 10px;--nc-space-lg: 14px;--nc-space-xl: 20px;--nc-radius-sm: 6px;--nc-radius-md: 8px;--nc-radius-lg: 10px;--nc-radius-xl: 16px;--nc-radius-full: 9999px;--nc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;--nc-font-size-xs: 11px;--nc-font-size-sm: 12px;--nc-font-size-md: 13px;--nc-font-size-lg: 15px;--nc-avatar-radius: 50%;--nc-shadow-sm: 0 1px 3px rgba(0, 0, 0, .04);--nc-shadow-md: 0 4px 12px rgba(0, 0, 0, .06);--nc-shadow-lg: 0 12px 32px rgba(0, 0, 0, .12);--nc-transition: .2s ease-out}:where(.nostr-comments[data-theme=dark]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}@media(prefers-color-scheme:dark){:where(.nostr-comments[data-theme=auto]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}}.nostr-comments:not([data-headless=true]){font-family:var(--nc-font-family);font-size:var(--nc-font-size-md);color:var(--nc-text);line-height:1.5}.nostr-comments:not([data-headless=true]) *{box-sizing:border-box}.nostr-comments:not([data-headless=true]) .nc-header{margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-title{font-size:var(--nc-font-size-lg);font-weight:600;margin:0;display:flex;align-items:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-count{font-weight:400;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-editor{margin-bottom:var(--nc-space-xl)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary-light);border-radius:var(--nc-radius-md);margin-bottom:var(--nc-space-md);font-size:var(--nc-font-size-sm);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-label{font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-content{color:var(--nc-text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply{margin-left:auto;background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs) var(--nc-space-sm);border-radius:var(--nc-radius-sm);transition:background var(--nc-transition);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-editor__main{display:flex;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__input-wrapper{flex:1}.nostr-comments:not([data-headless=true]) .nc-editor__textarea{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:color-mix(in srgb,var(--nc-bg) 60%,transparent);color:var(--nc-text);font-family:inherit;font-size:var(--nc-font-size-md);resize:vertical;min-height:96px;transition:border-color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea::placeholder{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-editor__actions{display:flex;justify-content:flex-end;margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__submit{padding:var(--nc-space-sm) var(--nc-space-xl);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-list{display:flex;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-loading,.nostr-comments:not([data-headless=true]) .nc-empty,.nostr-comments:not([data-headless=true]) .nc-error{text-align:center;padding:var(--nc-space-xl);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-loading{display:flex;align-items:center;justify-content:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-loading__spinner{width:16px;height:16px;border:1.5px solid var(--nc-border);border-top-color:var(--nc-primary);border-radius:50%;animation:nc-spin .8s linear infinite}@keyframes nc-spin{to{transform:rotate(360deg)}}.nostr-comments:not([data-headless=true]) .nc-error__retry{margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);cursor:pointer;color:var(--nc-text);transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-error__retry:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-comment{padding-top:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-comment:first-child{padding-top:0}.nostr-comments:not([data-headless=true]) .nc-comment__main{display:flex;align-items:flex-start;gap:var(--nc-space-md);position:relative}.nostr-comments:not([data-headless=true]) .nc-comment__vline{position:absolute;left:20px;top:48px;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__content{flex:1;min-width:0;padding-top:2px}.nostr-comments:not([data-headless=true]) .nc-comment__header{margin-bottom:var(--nc-space-xs);display:flex}.nostr-comments:not([data-headless=true]) .nc-comment__author{font-weight:500;color:var(--nc-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-comment__text{margin:0;color:var(--nc-text);white-space:pre-wrap;word-wrap:break-word}.nostr-comments:not([data-headless=true]) .nc-comment__actions{display:flex;align-items:center;gap:var(--nc-space-md);margin-top:var(--nc-space-xs);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-comment__time{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:0;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn:hover{color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-comment__child-wrapper{position:relative;padding-left:50px}.nostr-comments:not([data-headless=true]) .nc-comment__connector{position:absolute;left:20px;top:0;width:26px;height:32px;border-left:1.5px solid var(--nc-border);border-bottom:1.5px solid var(--nc-border);border-bottom-left-radius:var(--nc-radius-xl)}.nostr-comments:not([data-headless=true]) .nc-comment__connector-line{position:absolute;left:20px;top:0;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview{display:flex;align-items:center;gap:var(--nc-space-xs);padding:var(--nc-space-xs) var(--nc-space-sm);margin-bottom:var(--nc-space-xs);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-sm);border-left:2px solid var(--nc-primary);font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);overflow:hidden;width:fit-content;max-width:100%}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-load-more{display:block;width:100%;padding:var(--nc-space-md);margin-top:var(--nc-space-lg);background:transparent;border:none;color:var(--nc-text-muted);font-size:var(--nc-font-size-sm);cursor:pointer;transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-load-more:hover:not(:disabled){color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-load-more:disabled{cursor:wait}.nostr-comments:not([data-headless=true]) .nc-avatar-link{flex-shrink:0;text-decoration:none;margin-top:4px}.nostr-comments:not([data-headless=true]) .nc-avatar-link:hover{opacity:.8}.nostr-comments:not([data-headless=true]) .nc-avatar{flex-shrink:0;border-radius:var(--nc-avatar-radius, 50%);object-fit:cover;aspect-ratio:1 / 1}.nostr-comments:not([data-headless=true]) .nc-username{color:inherit;text-decoration:none}.nostr-comments:not([data-headless=true]) .nc-username:hover{text-decoration:underline}.nostr-comments:not([data-headless=true]) .nc-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:9999;padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal{background:var(--nc-bg);border-radius:var(--nc-radius-xl);width:100%;max-width:400px;max-height:90vh;overflow-y:auto;box-shadow:var(--nc-shadow-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__header{display:flex;align-items:center;padding:var(--nc-space-lg);border-bottom:1px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-modal__header h3{margin:0;font-size:var(--nc-font-size-lg);font-weight:600;flex:1}.nostr-comments:not([data-headless=true]) .nc-modal__back{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;transition:background var(--nc-transition);margin-right:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-modal__back:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__close{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;margin-left:auto;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-modal__close:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__body{padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__description{margin:0 0 var(--nc-space-lg);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-options{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-login-option{display:flex;gap:var(--nc-space-md);padding:var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);text-align:left;cursor:pointer;transition:border-color var(--nc-transition),background var(--nc-transition);width:100%}.nostr-comments:not([data-headless=true]) .nc-login-option:hover:not(:disabled):not(.nc-login-option--disabled){border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-login-option--disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker{cursor:default;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker .nc-login-option__icon{display:none}.nostr-comments:not([data-headless=true]) .nc-login-option__icon{flex-shrink:0;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%}.nostr-comments:not([data-headless=true]) .nc-login-option__icon--success{background:var(--nc-success-light);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-login-option__content h4{margin:0 0 var(--nc-space-xs);font-size:var(--nc-font-size-md);font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-login-option__content p{margin:0;font-size:var(--nc-font-size-sm);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-option__hint{margin-top:var(--nc-space-sm)!important;color:var(--nc-text-muted)!important;font-style:italic}.nostr-comments:not([data-headless=true]) .nc-login-option__error{margin-top:var(--nc-space-sm)!important;color:var(--nc-error)!important}.nostr-comments:not([data-headless=true]) .nc-login-option__warning{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-error-light);border-radius:var(--nc-radius-sm);color:var(--nc-error)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-bunker-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit{padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-temp-nsec{margin-top:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);overflow:hidden}.nostr-comments:not([data-headless=true]) .nc-temp-nsec__code{display:block;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-login-option__compatibility{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-primary-light);border-radius:var(--nc-radius-sm);color:var(--nc-primary)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-temp-actions{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn{flex:1;display:flex;align-items:center;justify-content:center;gap:var(--nc-space-xs);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);color:var(--nc-text);cursor:pointer;font-size:var(--nc-font-size-sm);transition:background var(--nc-transition),border-color var(--nc-transition),color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success:hover{background:var(--nc-success-light)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue{width:100%;margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);border:none;border-radius:var(--nc-radius-md);color:#fff;cursor:pointer;font-weight:500;transition:background var(--nc-transition),opacity var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue:hover{background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue--muted{opacity:.6}.nostr-comments:not([data-headless=true]) .nc-import-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-import-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-import-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit{padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-sm);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-import-form__back{margin-top:var(--nc-space-md);padding:var(--nc-space-sm);background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__back:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view{display:flex;flex-direction:column;align-items:center;text-align:center;padding:var(--nc-space-xl) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon{width:52px;height:52px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon--success{width:36px;height:36px;background:var(--nc-success-light);color:var(--nc-success);margin-bottom:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__title{margin:0 0 var(--nc-space-sm);font-size:var(--nc-font-size-lg);font-weight:600;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view__desc{margin:0 0 var(--nc-space-xl);color:var(--nc-text-secondary);max-width:320px}.nostr-comments:not([data-headless=true]) .nc-temp-view--created{padding:var(--nc-space-lg) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__header{display:flex;align-items:center;gap:var(--nc-space-md);margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__header .nc-temp-view__title{margin:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-section{width:100%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-box{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-code{flex:1;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;text-align:left;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-actions{display:flex;gap:var(--nc-space-xs);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:50%;color:var(--nc-text-secondary);cursor:pointer;transition:all var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn:hover{border-color:var(--nc-primary);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-hint{margin:var(--nc-space-sm) 0 0;font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);text-align:left}.nostr-comments:not([data-headless=true]) .nc-temp-view__form{width:100%;max-width:320px;display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm);text-align:center}.nostr-comments:not([data-headless=true]) .nc-temp-view__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input::placeholder{font-family:var(--nc-font-family)}.nostr-comments:not([data-headless=true]) .nc-temp-view__error{margin:0;color:var(--nc-error);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit{width:100%;padding:var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;font-size:var(--nc-font-size-md);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-logged-in{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__user{display:flex;align-items:center;gap:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__info{display:flex;flex-direction:column;gap:var(--nc-space-xs)}.nostr-comments:not([data-headless=true]) .nc-logged-in__name{font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-logged-in__type{font-size:var(--nc-font-size-sm);color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-logged-in__temp-backup{display:flex;flex-direction:column;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout{margin-top:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-error-light);border:1px solid var(--nc-error);border-radius:var(--nc-radius-md);color:var(--nc-error);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout:hover{background:var(--nc-error);color:#fff}')),document.head.appendChild(n)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
- (function(M,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],b):(M=typeof globalThis<"u"?globalThis:M||self,b(M.NostrComments={},M.jsxRuntime,M.React))})(this,(function(M,b,z){"use strict";var sg=Object.defineProperty;var ig=(M,b,z)=>b in M?sg(M,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):M[b]=z;var g=(M,b,z)=>ig(M,typeof b!="symbol"?b+"":b,z);class Wt{constructor(){g(this,"cachedPubKey")}static isAvailable(){return typeof window<"u"&&!!window.nostr}async getPublicKey(){if(!window.nostr)throw new Error("NIP-07 extension not available");return this.cachedPubKey||(this.cachedPubKey=await window.nostr.getPublicKey()),this.cachedPubKey}async signEvent(e){if(!window.nostr)throw new Error("NIP-07 extension not available");return window.nostr.signEvent(e)}}function Mo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Ko(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Kc(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mo(t.outputLen),Mo(t.blockLen)}function Zt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Hc(t,e){Ko(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const qn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ho=t=>t instanceof Uint8Array,Vn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ee=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function zc(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function jn(t){if(typeof t=="string"&&(t=zc(t)),!Ho(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function qc(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Ho(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let zo=class{clone(){return this._cloneInto()}};function Vc(t){const e=r=>t().update(jn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function qo(t=32){if(qn&&typeof qn.getRandomValues=="function")return qn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function jc(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+l,a,r)}let Fc=class extends zo{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Vn(this.buffer)}update(e){Zt(this);const{view:n,buffer:r,blockLen:o}=this;e=jn(e);const s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=Vn(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zt(this),Hc(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;jc(r,o-8,BigInt(this.length*8),s),this.process(r,0);const a=Vn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%n&&e.buffer.set(r),e}};const Wc=(t,e,n)=>t&e^~t&n,Zc=(t,e,n)=>t&e^t&n^e&n,Jc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ze=new Uint32Array(64);let Gc=class extends Fc{constructor(){super(64,32,8,!1),this.A=He[0]|0,this.B=He[1]|0,this.C=He[2]|0,this.D=He[3]|0,this.E=He[4]|0,this.F=He[5]|0,this.G=He[6]|0,this.H=He[7]|0}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)ze[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=ze[u-15],f=ze[u-2],m=Ee(p,7)^Ee(p,18)^p>>>3,h=Ee(f,17)^Ee(f,19)^f>>>10;ze[u]=h+ze[u-7]+m+ze[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=Ee(a,6)^Ee(a,11)^Ee(a,25),f=d+p+Wc(a,c,l)+Jc[u]+ze[u]|0,h=(Ee(r,2)^Ee(r,13)^Ee(r,22))+Zc(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){ze.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Fn=Vc(()=>new Gc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const Yc=BigInt(1),Xc=BigInt(2),Jt=t=>t instanceof Uint8Array,Qc=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ft(t){if(!Jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Qc[t[n]];return e}function Wn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function It(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}function ie(t){return Wn(ft(t))}function Zn(t){if(!Jt(t))throw new Error("Uint8Array expected");return Wn(ft(Uint8Array.from(t).reverse()))}function qe(t,e){return It(t.toString(16).padStart(e*2,"0"))}function Jn(t,e){return qe(t,e).reverse()}function te(t,e,n){let r;if(typeof e=="string")try{r=It(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function tt(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}const Gn=t=>(Xc<<BigInt(t-1))-Yc,Yn=t=>new Uint8Array(t),Vo=t=>Uint8Array.from(t);function jo(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Yn(t),o=Yn(t),s=0;const i=()=>{r.fill(1),o.fill(0),s=0},a=(...u)=>n(o,r,...u),c=(u=Yn())=>{o=a(Vo([0]),u),r=a(),u.length!==0&&(o=a(Vo([1]),u),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const p=[];for(;u<e;){r=a();const f=r.slice();p.push(f),u+=r.length}return tt(...p)};return(u,p)=>{i(),c(u);let f;for(;!(f=p(l()));)c();return i(),f}}const el={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function $t(t,e,n={}){const r=(o,s,i)=>{const a=el[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const c=t[o];if(!(i&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(const[o,s]of Object.entries(e))r(o,s,!1);for(const[o,s]of Object.entries(n))r(o,s,!0);return t}const tl=Object.freeze(Object.defineProperty({__proto__:null,bitMask:Gn,bytesToHex:ft,bytesToNumberBE:ie,bytesToNumberLE:Zn,concatBytes:tt,createHmacDrbg:jo,ensureBytes:te,hexToBytes:It,hexToNumber:Wn,numberToBytesBE:qe,numberToBytesLE:Jn,validateObject:$t},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Q=BigInt(0),G=BigInt(1),nt=BigInt(2),nl=BigInt(3),Xn=BigInt(4),Fo=BigInt(5),Wo=BigInt(8);BigInt(9),BigInt(16);function ee(t,e){const n=t%e;return n>=Q?n:e+n}function rl(t,e,n){if(n<=Q||e<Q)throw new Error("Expected power/modulo > 0");if(n===G)return Q;let r=G;for(;e>Q;)e&G&&(r=r*t%n),t=t*t%n,e>>=G;return r}function he(t,e,n){let r=t;for(;e-- >Q;)r*=r,r%=n;return r}function Qn(t,e){if(t===Q||e<=Q)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ee(t,e),r=e,o=Q,s=G;for(;n!==Q;){const a=r/n,c=r%n,l=o-s*a;r=n,n=c,o=s,s=l}if(r!==G)throw new Error("invert: does not exist");return ee(o,e)}function ol(t){const e=(t-G)/nt;let n,r,o;for(n=t-G,r=0;n%nt===Q;n/=nt,r++);for(o=nt;o<t&&rl(o,e,t)!==t-G;o++);if(r===1){const i=(t+G)/Xn;return function(c,l){const d=c.pow(l,i);if(!c.eql(c.sqr(d),l))throw new Error("Cannot find square root");return d}}const s=(n+G)/nt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,d=a.pow(a.mul(a.ONE,o),n),u=a.pow(c,s),p=a.pow(c,n);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let f=1;for(let h=a.sqr(p);f<l&&!a.eql(h,a.ONE);f++)h=a.sqr(h);const m=a.pow(d,G<<BigInt(l-f-1));d=a.sqr(m),u=a.mul(u,m),p=a.mul(p,d),l=f}return u}}function sl(t){if(t%Xn===nl){const e=(t+G)/Xn;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(t%Wo===Fo){const e=(t-Fo)/Wo;return function(r,o){const s=r.mul(o,nt),i=r.pow(s,e),a=r.mul(o,i),c=r.mul(r.mul(a,nt),i),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return ol(t)}const il=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function al(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=il.reduce((r,o)=>(r[o]="function",r),e);return $t(t,n)}function cl(t,e,n){if(n<Q)throw new Error("Expected power > 0");if(n===Q)return t.ONE;if(n===G)return e;let r=t.ONE,o=e;for(;n>Q;)n&G&&(r=t.mul(r,o)),o=t.sqr(o),n>>=G;return r}function ll(t,e){const n=new Array(e.length),r=e.reduce((s,i,a)=>t.is0(i)?s:(n[a]=s,t.mul(s,i)),t.ONE),o=t.inv(r);return e.reduceRight((s,i,a)=>t.is0(i)?s:(n[a]=t.mul(s,n[a]),t.mul(s,i)),o),n}function Zo(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ul(t,e,n=!1,r={}){if(t<=Q)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:s}=Zo(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=sl(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:s,MASK:Gn(o),ZERO:Q,ONE:G,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Q<=c&&c<t},is0:c=>c===Q,isOdd:c=>(c&G)===G,neg:c=>ee(-c,t),eql:(c,l)=>c===l,sqr:c=>ee(c*c,t),add:(c,l)=>ee(c+l,t),sub:(c,l)=>ee(c-l,t),mul:(c,l)=>ee(c*l,t),pow:(c,l)=>cl(a,c,l),div:(c,l)=>ee(c*Qn(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Qn(c,t),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>ll(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>n?Jn(c,s):qe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return n?Zn(c):ie(c)}});return Object.freeze(a)}function Jo(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Go(t){const e=Jo(t);return e+Math.ceil(e/2)}function dl(t,e,n=!1){const r=t.length,o=Jo(e),s=Go(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const i=n?ie(t):Zn(t),a=ee(i,e-G)+G;return n?Jn(a,o):qe(a,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hl=BigInt(0),er=BigInt(1);function fl(t,e){const n=(o,s)=>{const i=s.negate();return o?i:s},r=o=>{const s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:n,unsafeLadder(o,s){let i=t.ZERO,a=o;for(;s>hl;)s&er&&(i=i.add(a)),a=a.double(),s>>=er;return i},precomputeWindow(o,s){const{windows:i,windowSize:a}=r(s),c=[];let l=o,d=l;for(let u=0;u<i;u++){d=l,c.push(d);for(let p=1;p<a;p++)d=d.add(l),c.push(d);l=d.double()}return c},wNAF(o,s,i){const{windows:a,windowSize:c}=r(o);let l=t.ZERO,d=t.BASE;const u=BigInt(2**o-1),p=2**o,f=BigInt(o);for(let m=0;m<a;m++){const h=m*c;let y=Number(i&u);i>>=f,y>c&&(y-=p,i+=er);const v=h,x=h+Math.abs(y)-1,S=m%2!==0,U=y<0;y===0?d=d.add(n(S,s[v])):l=l.add(n(U,s[x]))}return{p:l,f:d}},wNAFCached(o,s,i,a){const c=o._WINDOW_SIZE||1;let l=s.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&s.set(o,a(l))),this.wNAF(c,l,i)}}}function Yo(t){return al(t.Fp),$t(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Zo(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pl(t){const e=Yo(t);$t(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=e;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:ml,hexToBytes:gl}=tl,rt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=rt;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ml(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=rt,n=typeof t=="string"?gl(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:s}=rt._parseInt(n.subarray(2)),{d:i,l:a}=rt._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const d=l.toString(16);return d.length&1?`0${d}`:d},r=e(n(t.s)),o=e(n(t.r)),s=r.length/2,i=o.length/2,a=n(s),c=n(i);return`30${n(i+s+4)}02${c}${o}02${a}${r}`}},Be=BigInt(0),fe=BigInt(1);BigInt(2);const Xo=BigInt(3);BigInt(4);function yl(t){const e=pl(t),{Fp:n}=e,r=e.toBytes||((m,h,y)=>{const v=h.toAffine();return tt(Uint8Array.from([4]),n.toBytes(v.x),n.toBytes(v.y))}),o=e.fromBytes||(m=>{const h=m.subarray(1),y=n.fromBytes(h.subarray(0,n.BYTES)),v=n.fromBytes(h.subarray(n.BYTES,2*n.BYTES));return{x:y,y:v}});function s(m){const{a:h,b:y}=e,v=n.sqr(m),x=n.mul(v,m);return n.add(n.add(x,n.mul(m,h)),y)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(m){return typeof m=="bigint"&&Be<m&&m<e.n}function a(m){if(!i(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){const{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:v,n:x}=e;if(h&&typeof m!="bigint"){if(m instanceof Uint8Array&&(m=ft(m)),typeof m!="string"||!h.includes(m.length))throw new Error("Invalid key");m=m.padStart(y*2,"0")}let S;try{S=typeof m=="bigint"?m:ie(te("private key",m,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof m}`)}return v&&(S=ee(S,x)),a(S),S}const l=new Map;function d(m){if(!(m instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(h,y,v){if(this.px=h,this.py=y,this.pz=v,h==null||!n.isValid(h))throw new Error("x required");if(y==null||!n.isValid(y))throw new Error("y required");if(v==null||!n.isValid(v))throw new Error("z required")}static fromAffine(h){const{x:y,y:v}=h||{};if(!h||!n.isValid(y)||!n.isValid(v))throw new Error("invalid affine point");if(h instanceof u)throw new Error("projective point not allowed");const x=S=>n.eql(S,n.ZERO);return x(y)&&x(v)?u.ZERO:new u(y,v,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){const y=n.invertBatch(h.map(v=>v.pz));return h.map((v,x)=>v.toAffine(y[x])).map(u.fromAffine)}static fromHex(h){const y=u.fromAffine(o(te("pointHex",h)));return y.assertValidity(),y}static fromPrivateKey(h){return u.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:h,y}=this.toAffine();if(!n.isValid(h)||!n.isValid(y))throw new Error("bad point: x or y not FE");const v=n.sqr(y),x=s(h);if(!n.eql(v,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:h}=this.toAffine();if(n.isOdd)return!n.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){d(h);const{px:y,py:v,pz:x}=this,{px:S,py:U,pz:K}=h,_=n.eql(n.mul(y,K),n.mul(S,x)),N=n.eql(n.mul(v,K),n.mul(U,x));return _&&N}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:h,b:y}=e,v=n.mul(y,Xo),{px:x,py:S,pz:U}=this;let K=n.ZERO,_=n.ZERO,N=n.ZERO,L=n.mul(x,x),H=n.mul(S,S),T=n.mul(U,U),O=n.mul(x,S);return O=n.add(O,O),N=n.mul(x,U),N=n.add(N,N),K=n.mul(h,N),_=n.mul(v,T),_=n.add(K,_),K=n.sub(H,_),_=n.add(H,_),_=n.mul(K,_),K=n.mul(O,K),N=n.mul(v,N),T=n.mul(h,T),O=n.sub(L,T),O=n.mul(h,O),O=n.add(O,N),N=n.add(L,L),L=n.add(N,L),L=n.add(L,T),L=n.mul(L,O),_=n.add(_,L),T=n.mul(S,U),T=n.add(T,T),L=n.mul(T,O),K=n.sub(K,L),N=n.mul(T,H),N=n.add(N,N),N=n.add(N,N),new u(K,_,N)}add(h){d(h);const{px:y,py:v,pz:x}=this,{px:S,py:U,pz:K}=h;let _=n.ZERO,N=n.ZERO,L=n.ZERO;const H=e.a,T=n.mul(e.b,Xo);let O=n.mul(y,S),D=n.mul(v,U),R=n.mul(x,K),k=n.add(y,v),w=n.add(S,U);k=n.mul(k,w),w=n.add(O,D),k=n.sub(k,w),w=n.add(y,x);let E=n.add(S,K);return w=n.mul(w,E),E=n.add(O,R),w=n.sub(w,E),E=n.add(v,x),_=n.add(U,K),E=n.mul(E,_),_=n.add(D,R),E=n.sub(E,_),L=n.mul(H,w),_=n.mul(T,R),L=n.add(_,L),_=n.sub(D,L),L=n.add(D,L),N=n.mul(_,L),D=n.add(O,O),D=n.add(D,O),R=n.mul(H,R),w=n.mul(T,w),D=n.add(D,R),R=n.sub(O,R),R=n.mul(H,R),w=n.add(w,R),O=n.mul(D,w),N=n.add(N,O),O=n.mul(E,w),_=n.mul(k,_),_=n.sub(_,O),O=n.mul(k,D),L=n.mul(E,L),L=n.add(L,O),new u(_,N,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(u.ZERO)}wNAF(h){return f.wNAFCached(this,l,h,y=>{const v=n.invertBatch(y.map(x=>x.pz));return y.map((x,S)=>x.toAffine(v[S])).map(u.fromAffine)})}multiplyUnsafe(h){const y=u.ZERO;if(h===Be)return y;if(a(h),h===fe)return this;const{endo:v}=e;if(!v)return f.unsafeLadder(this,h);let{k1neg:x,k1:S,k2neg:U,k2:K}=v.splitScalar(h),_=y,N=y,L=this;for(;S>Be||K>Be;)S&fe&&(_=_.add(L)),K&fe&&(N=N.add(L)),L=L.double(),S>>=fe,K>>=fe;return x&&(_=_.negate()),U&&(N=N.negate()),N=new u(n.mul(N.px,v.beta),N.py,N.pz),_.add(N)}multiply(h){a(h);let y=h,v,x;const{endo:S}=e;if(S){const{k1neg:U,k1:K,k2neg:_,k2:N}=S.splitScalar(y);let{p:L,f:H}=this.wNAF(K),{p:T,f:O}=this.wNAF(N);L=f.constTimeNegate(U,L),T=f.constTimeNegate(_,T),T=new u(n.mul(T.px,S.beta),T.py,T.pz),v=L.add(T),x=H.add(O)}else{const{p:U,f:K}=this.wNAF(y);v=U,x=K}return u.normalizeZ([v,x])[0]}multiplyAndAddUnsafe(h,y,v){const x=u.BASE,S=(K,_)=>_===Be||_===fe||!K.equals(x)?K.multiplyUnsafe(_):K.multiply(_),U=S(this,y).add(S(h,v));return U.is0()?void 0:U}toAffine(h){const{px:y,py:v,pz:x}=this,S=this.is0();h==null&&(h=S?n.ONE:n.inv(x));const U=n.mul(y,h),K=n.mul(v,h),_=n.mul(x,h);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:U,y:K}}isTorsionFree(){const{h,isTorsionFree:y}=e;if(h===fe)return!0;if(y)return y(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h,clearCofactor:y}=e;return h===fe?this:y?y(u,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),r(u,this,h)}toHex(h=!0){return ft(this.toRawBytes(h))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const p=e.nBitLength,f=fl(u,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function bl(t){const e=Yo(t);return $t(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function wl(t){const e=bl(t),{Fp:n,n:r}=e,o=n.BYTES+1,s=2*n.BYTES+1;function i(w){return Be<w&&w<n.ORDER}function a(w){return ee(w,r)}function c(w){return Qn(w,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:u,isWithinCurveOrder:p}=yl({...e,toBytes(w,E,A){const I=E.toAffine(),C=n.toBytes(I.x),$=tt;return A?$(Uint8Array.from([E.hasEvenY()?2:3]),C):$(Uint8Array.from([4]),C,n.toBytes(I.y))},fromBytes(w){const E=w.length,A=w[0],I=w.subarray(1);if(E===o&&(A===2||A===3)){const C=ie(I);if(!i(C))throw new Error("Point is not on curve");const $=u(C);let B=n.sqrt($);const P=(B&fe)===fe;return(A&1)===1!==P&&(B=n.neg(B)),{x:C,y:B}}else if(E===s&&A===4){const C=n.fromBytes(I.subarray(0,n.BYTES)),$=n.fromBytes(I.subarray(n.BYTES,2*n.BYTES));return{x:C,y:$}}else throw new Error(`Point of length ${E} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),f=w=>ft(qe(w,e.nByteLength));function m(w){const E=r>>fe;return w>E}function h(w){return m(w)?a(-w):w}const y=(w,E,A)=>ie(w.slice(E,A));class v{constructor(E,A,I){this.r=E,this.s=A,this.recovery=I,this.assertValidity()}static fromCompact(E){const A=e.nByteLength;return E=te("compactSignature",E,A*2),new v(y(E,0,A),y(E,A,2*A))}static fromDER(E){const{r:A,s:I}=rt.toSig(te("DER",E));return new v(A,I)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new v(this.r,this.s,E)}recoverPublicKey(E){const{r:A,s:I,recovery:C}=this,$=N(te("msgHash",E));if(C==null||![0,1,2,3].includes(C))throw new Error("recovery id invalid");const B=C===2||C===3?A+e.n:A;if(B>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=(C&1)===0?"02":"03",q=l.fromHex(P+f(B)),V=c(B),W=a(-$*V),F=a(I*V),X=l.BASE.multiplyAndAddUnsafe(q,W,F);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const x={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=Go(e.n);return dl(e.randomBytes(w),e.n)},precompute(w=8,E=l.BASE){return E._setWindowSize(w),E.multiply(BigInt(3)),E}};function S(w,E=!0){return l.fromPrivateKey(w).toRawBytes(E)}function U(w){const E=w instanceof Uint8Array,A=typeof w=="string",I=(E||A)&&w.length;return E?I===o||I===s:A?I===2*o||I===2*s:w instanceof l}function K(w,E,A=!0){if(U(w))throw new Error("first arg must be private key");if(!U(E))throw new Error("second arg must be public key");return l.fromHex(E).multiply(d(w)).toRawBytes(A)}const _=e.bits2int||function(w){const E=ie(w),A=w.length*8-e.nBitLength;return A>0?E>>BigInt(A):E},N=e.bits2int_modN||function(w){return a(_(w))},L=Gn(e.nBitLength);function H(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(Be<=w&&w<L))throw new Error(`bigint expected < 2^${e.nBitLength}`);return qe(w,e.nByteLength)}function T(w,E,A=O){if(["recovered","canonical"].some(ue=>ue in A))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:C}=e;let{lowS:$,prehash:B,extraEntropy:P}=A;$==null&&($=!0),w=te("msgHash",w),B&&(w=te("prehashed msgHash",I(w)));const q=N(w),V=d(E),W=[H(V),H(q)];if(P!=null){const ue=P===!0?C(n.BYTES):P;W.push(te("extraEntropy",ue))}const F=tt(...W),X=q;function se(ue){const J=_(ue);if(!p(J))return;const de=c(J),Bt=l.BASE.multiply(J).toAffine(),ve=a(Bt.x);if(ve===Be)return;const Lt=a(de*a(X+ve*V));if(Lt===Be)return;let Dc=(Bt.x===ve?0:2)|Number(Bt.y&fe),Mc=Lt;return $&&m(Lt)&&(Mc=h(Lt),Dc^=1),new v(ve,Mc,Dc)}return{seed:F,k2sig:se}}const O={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function R(w,E,A=O){const{seed:I,k2sig:C}=T(w,E,A),$=e;return jo($.hash.outputLen,$.nByteLength,$.hmac)(I,C)}l.BASE._setWindowSize(8);function k(w,E,A,I=D){var Bt;const C=w;if(E=te("msgHash",E),A=te("publicKey",A),"strict"in I)throw new Error("options.strict was renamed to lowS");const{lowS:$,prehash:B}=I;let P,q;try{if(typeof C=="string"||C instanceof Uint8Array)try{P=v.fromDER(C)}catch(ve){if(!(ve instanceof rt.Err))throw ve;P=v.fromCompact(C)}else if(typeof C=="object"&&typeof C.r=="bigint"&&typeof C.s=="bigint"){const{r:ve,s:Lt}=C;P=new v(ve,Lt)}else throw new Error("PARSE");q=l.fromHex(A)}catch(ve){if(ve.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if($&&P.hasHighS())return!1;B&&(E=e.hash(E));const{r:V,s:W}=P,F=N(E),X=c(W),se=a(F*X),ue=a(V*X),J=(Bt=l.BASE.multiplyAndAddUnsafe(q,se,ue))==null?void 0:Bt.toAffine();return J?a(J.x)===V:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:K,sign:R,verify:k,ProjectivePoint:l,Signature:v,utils:x}}let Qo=class extends zo{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Kc(e);const r=jn(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return Zt(this),this.iHash.update(e),this}digestInto(e){Zt(this),Ko(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const es=(t,e,n)=>new Qo(t,e).update(n).digest();es.create=(t,e)=>new Qo(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vl(t){return{hash:t,hmac:(e,...n)=>es(t,e,qc(...n)),randomBytes:qo}}function El(t,e){const n=r=>wl({...t,...vl(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ts=BigInt(1),Xt=BigInt(2),ns=(t,e)=>(t+e/Xt)/e;function rs(t){const e=Gt,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,d=l*l*t%e,u=he(d,n,e)*d%e,p=he(u,n,e)*d%e,f=he(p,Xt,e)*l%e,m=he(f,o,e)*f%e,h=he(m,s,e)*m%e,y=he(h,a,e)*h%e,v=he(y,c,e)*y%e,x=he(v,a,e)*h%e,S=he(x,n,e)*d%e,U=he(S,i,e)*m%e,K=he(U,r,e)*l%e,_=he(K,Xt,e);if(!tr.eql(tr.sqr(_),t))throw new Error("Cannot find square root");return _}const tr=ul(Gt,void 0,void 0,{sqrt:rs}),ot=El({a:BigInt(0),b:BigInt(7),Fp:tr,n:Yt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Yt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ts*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,i=BigInt("0x100000000000000000000000000000000"),a=ns(s*t,e),c=ns(-r*t,e);let l=ee(t-a*n-c*o,e),d=ee(-a*r-c*s,e);const u=l>i,p=d>i;if(u&&(l=e-l),p&&(d=e-d),l>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:p,k2:d}}}},Fn),Qt=BigInt(0),os=t=>typeof t=="bigint"&&Qt<t&&t<Gt,xl=t=>typeof t=="bigint"&&Qt<t&&t<Yt,ss={};function en(t,...e){let n=ss[t];if(n===void 0){const r=Fn(Uint8Array.from(t,o=>o.charCodeAt(0)));n=tt(r,r),ss[t]=n}return Fn(tt(n,...e))}const nr=t=>t.toRawBytes(!0).slice(1),rr=t=>qe(t,32),or=t=>ee(t,Gt),Tt=t=>ee(t,Yt),sr=ot.ProjectivePoint,kl=(t,e,n)=>sr.BASE.multiplyAndAddUnsafe(t,e,n);function ir(t){let e=ot.utils.normPrivateKeyToScalar(t),n=sr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Tt(-e),bytes:nr(n)}}function is(t){if(!os(t))throw new Error("bad x: need 0 < x < p");const e=or(t*t),n=or(e*t+BigInt(7));let r=rs(n);r%Xt!==Qt&&(r=or(-r));const o=new sr(t,r,ts);return o.assertValidity(),o}function as(...t){return Tt(ie(en("BIP0340/challenge",...t)))}function _l(t){return ir(t).bytes}function Al(t,e,n=qo(32)){const r=te("message",t),{bytes:o,scalar:s}=ir(e),i=te("auxRand",n,32),a=rr(s^ie(en("BIP0340/aux",i))),c=en("BIP0340/nonce",a,o,r),l=Tt(ie(c));if(l===Qt)throw new Error("sign failed: k is zero");const{bytes:d,scalar:u}=ir(l),p=as(d,o,r),f=new Uint8Array(64);if(f.set(d,0),f.set(rr(Tt(u+p*s)),32),!cs(f,r,o))throw new Error("sign: Invalid signature produced");return f}function cs(t,e,n){const r=te("signature",t,64),o=te("message",e),s=te("publicKey",n,32);try{const i=is(ie(s)),a=ie(r.subarray(0,32));if(!os(a))return!1;const c=ie(r.subarray(32,64));if(!xl(c))return!1;const l=as(rr(a),nr(i),o),d=kl(i,c,Tt(-l));return!(!d||!d.hasEvenY()||d.toAffine().x!==a)}catch{return!1}}const xe={getPublicKey:_l,sign:Al,verify:cs,utils:{randomPrivateKey:ot.utils.randomPrivateKey,lift_x:is,pointToBytes:nr,numberToBytesBE:qe,bytesToNumberBE:ie,taggedHash:en,mod:ee}},ar=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cr=t=>t instanceof Uint8Array,lr=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ke=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const Sl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Y(t){if(!cr(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Sl[t[n]];return e}function st(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}function Nl(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Pt(t){if(typeof t=="string"&&(t=Nl(t)),!cr(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function it(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!cr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class ls{clone(){return this._cloneInto()}}function us(t){const e=r=>t().update(Pt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ur(t=32){if(ar&&typeof ar.getRandomValues=="function")return ar.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function dr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Cl(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function ds(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Bl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");dr(t.outputLen),dr(t.blockLen)}function Ll(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Il(t,e){ds(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const _e={number:dr,bool:Cl,bytes:ds,hash:Bl,exists:Ll,output:Il};function $l(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+l,a,r)}class Tl extends ls{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=lr(this.buffer)}update(e){_e.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=Pt(e);const s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=lr(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_e.exists(this),_e.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;$l(r,o-8,BigInt(this.length*8),s),this.process(r,0);const a=lr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%n&&e.buffer.set(r),e}}const Pl=(t,e,n)=>t&e^~t&n,Ul=(t,e,n)=>t&e^t&n^e&n,Ol=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ve=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),je=new Uint32Array(64);class hs extends Tl{constructor(){super(64,32,8,!1),this.A=Ve[0]|0,this.B=Ve[1]|0,this.C=Ve[2]|0,this.D=Ve[3]|0,this.E=Ve[4]|0,this.F=Ve[5]|0,this.G=Ve[6]|0,this.H=Ve[7]|0}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)je[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=je[u-15],f=je[u-2],m=ke(p,7)^ke(p,18)^p>>>3,h=ke(f,17)^ke(f,19)^f>>>10;je[u]=h+je[u-7]+m+je[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=ke(a,6)^ke(a,11)^ke(a,25),f=d+p+Pl(a,c,l)+Ol[u]+je[u]|0,h=(ke(r,2)^ke(r,13)^ke(r,22))+Ul(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Rl extends hs{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const me=us(()=>new hs);us(()=>new Rl);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Le(...t){const e=(o,s)=>i=>o(s(i)),n=Array.from(t).reverse().reduce((o,s)=>o?e(o,s.encode):s.encode,void 0),r=t.reduce((o,s)=>o?e(o,s.decode):s.decode,void 0);return{encode:n,decode:r}}function Ie(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(pt(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function $e(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function tn(t,e="="){if(pt(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function fs(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function ps(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const o=[],s=Array.from(t);for(s.forEach(i=>{if(pt(i),i<0||i>=e)throw new Error(`Wrong integer: ${i}`)});;){let i=0,a=!0;for(let c=r;c<s.length;c++){const l=s[c],d=e*i+l;if(!Number.isSafeInteger(d)||e*i/e!==i||d-l!==e*i)throw new Error("convertRadix: carry overflow");if(i=d%n,s[c]=Math.floor(d/n),!Number.isSafeInteger(s[c])||s[c]*n+i!==d)throw new Error("convertRadix: carry overflow");if(a)s[c]?a=!1:r=c;else continue}if(o.push(i),a)break}for(let i=0;i<t.length-1&&t[i]===0;i++)o.push(0);return o.reverse()}const ms=(t,e)=>e?ms(e,t%e):t,nn=(t,e)=>t+(e-ms(t,e));function hr(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(nn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${nn(e,n)}`);let o=0,s=0;const i=2**n-1,a=[];for(const c of t){if(pt(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(o=o<<e|c,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)a.push((o>>s-n&i)>>>0);o&=2**s-1}if(o=o<<n-s&i,!r&&s>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function Dl(t){return pt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return ps(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(ps(e,t,2**8))}}}function Fe(t,e=!1){if(pt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(nn(8,t)>32||nn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return hr(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(hr(n,t,8,e))}}}function gs(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ml=Le(Fe(4),Ie("0123456789ABCDEF"),$e("")),Kl=Le(Fe(5),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tn(5),$e(""));Le(Fe(5),Ie("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tn(5),$e("")),Le(Fe(5),Ie("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),$e(""),fs(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const ge=Le(Fe(6),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tn(6),$e("")),Hl=Le(Fe(6),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tn(6),$e("")),fr=t=>Le(Dl(58),Ie(t),$e("")),pr=fr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");fr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),fr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ys=[0,2,3,5,6,7,9,10,11],zl={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=pr.encode(r).padStart(ys[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=ys.indexOf(r.length),s=pr.decode(r);for(let i=0;i<s.length-o;i++)if(s[i]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(s.slice(s.length-o)))}return Uint8Array.from(e)}},mr=Le(Ie("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),$e("")),bs=[996825010,642813549,513874426,1027748829,705979059];function Ut(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<bs.length;r++)(e>>r&1)===1&&(n^=bs[r]);return n}function ws(t,e,n=1){const r=t.length;let o=1;for(let s=0;s<r;s++){const i=t.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${t})`);o=Ut(o)^i>>5}o=Ut(o);for(let s=0;s<r;s++)o=Ut(o)^t.charCodeAt(s)&31;for(let s of e)o=Ut(o)^s;for(let s=0;s<6;s++)o=Ut(o);return o^=n,mr.encode(hr([o%2**30],30,5,!1))}function vs(t){const e=t==="bech32"?1:734539939,n=Fe(5),r=n.decode,o=n.encode,s=gs(r);function i(d,u,p=90){if(typeof d!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof d}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const f=d.length+7+u.length;if(p!==!1&&f>p)throw new TypeError(`Length ${f} exceeds limit ${p}`);return d=d.toLowerCase(),`${d}1${mr.encode(u)}${ws(d,u,e)}`}function a(d,u=90){if(typeof d!="string")throw new Error(`bech32.decode input should be string, not ${typeof d}`);if(d.length<8||u!==!1&&d.length>u)throw new TypeError(`Wrong string length: ${d.length} (${d}). Expected (8..${u})`);const p=d.toLowerCase();if(d!==p&&d!==d.toUpperCase())throw new Error("String must be lowercase or uppercase");d=p;const f=d.lastIndexOf("1");if(f===0||f===-1)throw new Error('Letter "1" must be present between prefix and data only');const m=d.slice(0,f),h=d.slice(f+1);if(h.length<6)throw new Error("Data must be at least 6 characters long");const y=mr.decode(h).slice(0,-6),v=ws(m,y,e);if(!h.endsWith(v))throw new Error(`Invalid checksum in ${d}: expected "${v}"`);return{prefix:m,words:y}}const c=gs(a);function l(d){const{prefix:u,words:p}=a(d,!1);return{prefix:u,words:p,bytes:r(p)}}return{encode:i,decode:a,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const mt=vs("bech32");vs("bech32m");const ql={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Vl=Le(Fe(4),Ie("0123456789abcdef"),$e(""),fs(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));`${Object.keys({utf8:ql,hex:Vl,base16:Ml,base32:Kl,base64:ge,base64url:Hl,base58:pr,base58xmr:zl}).join(", ")}`;function gr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Es(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function jl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ae(t,...e){if(!jl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const ne=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const Fl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gt(t){Ae(t);let e="";for(let n=0;n<t.length;n++)e+=Fl[t[n]];return e}const Te={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function xs(t){if(t>=Te._0&&t<=Te._9)return t-Te._0;if(t>=Te._A&&t<=Te._F)return t-(Te._A-10);if(t>=Te._a&&t<=Te._f)return t-(Te._a-10)}function ks(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=xs(t.charCodeAt(s)),a=xs(t.charCodeAt(s+1));if(i===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[o]=i*16+a}return r}function Wl(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function _s(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Zl=(t,e)=>(Object.assign(e,t),e),We=16,Jl=283;function yr(t){return t<<1^Jl&-(t>>7)}function yt(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=yr(t);return n}const br=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=yr(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return e})(),Gl=br.map((t,e)=>br.indexOf(e)),Yl=t=>t<<24|t>>>8,wr=t=>t<<8|t>>>24;function As(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,d)=>e(t[d])),r=n.map(wr),o=r.map(wr),s=o.map(wr),i=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let d=0;d<256;d++){const u=l*256+d;i[u]=n[l]^r[d],a[u]=o[l]^s[d],c[u]=t[l]<<8|t[d]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:o,T3:s,T01:i,T23:a}}const vr=As(br,t=>yt(t,3)<<24|t<<16|t<<8|yt(t,2)),Ss=As(Gl,t=>yt(t,11)<<24|yt(t,13)<<16|yt(t,9)<<8|yt(t,14)),Xl=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=yr(n))t[e]=n;return t})();function Ns(t){Ae(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=vr,r=ne(t),o=r.length,s=a=>Se(n,a,a,a,a),i=new Uint32Array(e+28);i.set(r);for(let a=o;a<i.length;a++){let c=i[a-1];a%o===0?c=s(Yl(c))^Xl[a/o-1]:o>6&&a%o===4&&(c=s(c)),i[a]=i[a-o]^c}return i}function Ql(t){const e=Ns(t),n=e.slice(),r=e.length,{sbox2:o}=vr,{T0:s,T1:i,T2:a,T3:c}=Ss;for(let l=0;l<r;l+=4)for(let d=0;d<4;d++)n[l+d]=e[r-l-4+d];e.fill(0);for(let l=4;l<r-4;l++){const d=n[l],u=Se(o,d,d,d,d);n[l]=s[u&255]^i[u>>>8&255]^a[u>>>16&255]^c[u>>>24]}return n}function Ze(t,e,n,r,o,s){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|s>>>24&255]}function Se(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function Cs(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=vr;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let m=0;m<l;m++){const h=t[c++]^Ze(i,a,e,n,r,o),y=t[c++]^Ze(i,a,n,r,o,e),v=t[c++]^Ze(i,a,r,o,e,n),x=t[c++]^Ze(i,a,o,e,n,r);e=h,n=y,r=v,o=x}const d=t[c++]^Se(s,e,n,r,o),u=t[c++]^Se(s,n,r,o,e),p=t[c++]^Se(s,r,o,e,n),f=t[c++]^Se(s,o,e,n,r);return{s0:d,s1:u,s2:p,s3:f}}function eu(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=Ss;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let m=0;m<l;m++){const h=t[c++]^Ze(i,a,e,o,r,n),y=t[c++]^Ze(i,a,n,e,o,r),v=t[c++]^Ze(i,a,r,n,e,o),x=t[c++]^Ze(i,a,o,r,n,e);e=h,n=y,r=v,o=x}const d=t[c++]^Se(s,e,o,r,n),u=t[c++]^Se(s,n,e,o,r),p=t[c++]^Se(s,r,n,e,o),f=t[c++]^Se(s,o,r,n,e);return{s0:d,s1:u,s2:p,s3:f}}function Bs(t,e){if(!e)return new Uint8Array(t);if(Ae(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}function tu(t){if(Ae(t),t.length%We!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${We}`)}function nu(t,e,n){let r=t.length;const o=r%We;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=ne(t);if(e){let c=We-o;c||(c=We),r=r+c}const i=Bs(r,n),a=ne(i);return{b:s,o:a,out:i}}function ru(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let s=0;s<r;s++)if(t[n-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function ou(t){const e=new Uint8Array(16),n=ne(e);e.set(t);const r=We-t.length;for(let o=We-r;o<We;o++)e[o]=r;return n}const Ls=Zl({blockSize:16,nonceLength:16},function(e,n,r={}){Ae(e),Ae(n,16);const o=!r.disablePadding;return{encrypt:(s,i)=>{const a=Ns(e),{b:c,o:l,out:d}=nu(s,o,i),u=ne(n);let p=u[0],f=u[1],m=u[2],h=u[3],y=0;for(;y+4<=c.length;)p^=c[y+0],f^=c[y+1],m^=c[y+2],h^=c[y+3],{s0:p,s1:f,s2:m,s3:h}=Cs(a,p,f,m,h),l[y++]=p,l[y++]=f,l[y++]=m,l[y++]=h;if(o){const v=ou(s.subarray(y*4));p^=v[0],f^=v[1],m^=v[2],h^=v[3],{s0:p,s1:f,s2:m,s3:h}=Cs(a,p,f,m,h),l[y++]=p,l[y++]=f,l[y++]=m,l[y++]=h}return a.fill(0),d},decrypt:(s,i)=>{tu(s);const a=Ql(e),c=ne(n),l=Bs(s.length,i),d=ne(s),u=ne(l);let p=c[0],f=c[1],m=c[2],h=c[3];for(let y=0;y+4<=d.length;){const v=p,x=f,S=m,U=h;p=d[y+0],f=d[y+1],m=d[y+2],h=d[y+3];const{s0:K,s1:_,s2:N,s3:L}=eu(a,p,f,m,h);u[y++]=K^v,u[y++]=_^x,u[y++]=N^S,u[y++]=L^U}return a.fill(0),ru(l,o)}}}),Is=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),su=Is("expand 16-byte k"),iu=Is("expand 32-byte k"),au=ne(su),$s=ne(iu);$s.slice();function j(t,e){return t<<e|t>>>32-e}function Er(t){return t.byteOffset%4===0}const rn=64,cu=16,Ts=2**32-1,Ps=new Uint32Array;function lu(t,e,n,r,o,s,i,a){const c=o.length,l=new Uint8Array(rn),d=ne(l),u=Er(o)&&Er(s),p=u?ne(o):Ps,f=u?ne(s):Ps;for(let m=0;m<c;i++){if(t(e,n,r,d,i,a),i>=Ts)throw new Error("arx: counter overflow");const h=Math.min(rn,c-m);if(u&&h===rn){const y=m/4;if(m%4!==0)throw new Error("arx: invalid block position");for(let v=0,x;v<cu;v++)x=y+v,f[x]=p[x]^d[v];m+=rn;continue}for(let y=0,v;y<h;y++)v=m+y,s[v]=o[v]^l[y];m+=h}}function uu(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=Wl({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return gr(o),gr(i),Es(s),Es(n),(a,c,l,d,u=0)=>{Ae(a),Ae(c),Ae(l);const p=l.length;if(d||(d=new Uint8Array(p)),Ae(d),gr(u),u<0||u>=Ts)throw new Error("arx: counter overflow");if(d.length<p)throw new Error(`arx: output (${d.length}) is shorter than data (${p})`);const f=[];let m=a.length,h,y;if(m===32)h=a.slice(),f.push(h),y=$s;else if(m===16&&n)h=new Uint8Array(32),h.set(a),h.set(a,16),y=au,f.push(h);else throw new Error(`arx: invalid 32-byte key, got length=${m}`);Er(c)||(c=c.slice(),f.push(c));const v=ne(h);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(y,v,ne(c.subarray(0,16)),v),c=c.subarray(16)}const x=16-o;if(x!==c.length)throw new Error(`arx: nonce must be ${x} or 16 bytes`);if(x!==12){const U=new Uint8Array(12);U.set(c,s?0:12-c.length),c=U,f.push(c)}const S=ne(c);for(lu(t,y,v,S,l,d,u,i);f.length>0;)f.pop().fill(0);return d}}function du(t,e,n,r,o,s=20){let i=t[0],a=t[1],c=t[2],l=t[3],d=e[0],u=e[1],p=e[2],f=e[3],m=e[4],h=e[5],y=e[6],v=e[7],x=o,S=n[0],U=n[1],K=n[2],_=i,N=a,L=c,H=l,T=d,O=u,D=p,R=f,k=m,w=h,E=y,A=v,I=x,C=S,$=U,B=K;for(let q=0;q<s;q+=2)_=_+T|0,I=j(I^_,16),k=k+I|0,T=j(T^k,12),_=_+T|0,I=j(I^_,8),k=k+I|0,T=j(T^k,7),N=N+O|0,C=j(C^N,16),w=w+C|0,O=j(O^w,12),N=N+O|0,C=j(C^N,8),w=w+C|0,O=j(O^w,7),L=L+D|0,$=j($^L,16),E=E+$|0,D=j(D^E,12),L=L+D|0,$=j($^L,8),E=E+$|0,D=j(D^E,7),H=H+R|0,B=j(B^H,16),A=A+B|0,R=j(R^A,12),H=H+R|0,B=j(B^H,8),A=A+B|0,R=j(R^A,7),_=_+O|0,B=j(B^_,16),E=E+B|0,O=j(O^E,12),_=_+O|0,B=j(B^_,8),E=E+B|0,O=j(O^E,7),N=N+D|0,I=j(I^N,16),A=A+I|0,D=j(D^A,12),N=N+D|0,I=j(I^N,8),A=A+I|0,D=j(D^A,7),L=L+R|0,C=j(C^L,16),k=k+C|0,R=j(R^k,12),L=L+R|0,C=j(C^L,8),k=k+C|0,R=j(R^k,7),H=H+T|0,$=j($^H,16),w=w+$|0,T=j(T^w,12),H=H+T|0,$=j($^H,8),w=w+$|0,T=j(T^w,7);let P=0;r[P++]=i+_|0,r[P++]=a+N|0,r[P++]=c+L|0,r[P++]=l+H|0,r[P++]=d+T|0,r[P++]=u+O|0,r[P++]=p+D|0,r[P++]=f+R|0,r[P++]=m+k|0,r[P++]=h+w|0,r[P++]=y+E|0,r[P++]=v+A|0,r[P++]=x+I|0,r[P++]=S+C|0,r[P++]=U+$|0,r[P++]=K+B|0}const on=uu(du,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Us extends ls{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,_e.hash(e);const r=Pt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return _e.exists(this),this.iHash.update(e),this}digestInto(e){_e.exists(this),_e.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ot=(t,e,n)=>new Us(t,e).update(n).digest();Ot.create=(t,e)=>new Us(t,e);function Os(t,e,n){return _e.hash(t),Ot(t,Pt(n),Pt(e))}const xr=new Uint8Array([0]),Rs=new Uint8Array;function Ds(t,e,n,r=32){if(_e.hash(t),_e.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);n===void 0&&(n=Rs);const s=new Uint8Array(o*t.outputLen),i=Ot.create(t,e),a=i._cloneInto(),c=new Uint8Array(i.outputLen);for(let l=0;l<o;l++)xr[0]=l+1,a.update(l===0?Rs:c).update(n).update(xr).digestInto(c),s.set(c,t.outputLen*l),i._cloneInto(a);return i.destroy(),a.destroy(),c.fill(0),xr.fill(0),s.slice(0,r)}var hu=Object.defineProperty,Z=(t,e)=>{for(var n in e)hu(t,n,{get:e[n],enumerable:!0})},bt=Symbol("verified"),fu=t=>t instanceof Object;function kr(t){if(!fu(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}var pu={};Z(pu,{Queue:()=>bu,QueueNode:()=>Ms,binarySearch:()=>_r,bytesToHex:()=>Y,hexToBytes:()=>st,insertEventIntoAscendingList:()=>yu,insertEventIntoDescendingList:()=>gu,normalizeURL:()=>mu,utf8Decoder:()=>Pe,utf8Encoder:()=>ye});var Pe=new TextDecoder("utf-8"),ye=new TextEncoder;function mu(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}function gu(t,e){const[n,r]=_r(t,o=>e.id===o.id?0:e.created_at===o.created_at?-1:o.created_at-e.created_at);return r||t.splice(n,0,e),t}function yu(t,e){const[n,r]=_r(t,o=>e.id===o.id?0:e.created_at===o.created_at?-1:e.created_at-o.created_at);return r||t.splice(n,0,e),t}function _r(t,e){let n=0,r=t.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),s=e(t[o]);if(s===0)return[o,!0];s<0?r=o-1:n=o+1}return[n,!1]}var Ms=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},bu=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Ms(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},wu=class{generateSecretKey(){return xe.utils.randomPrivateKey()}getPublicKey(e){return Y(xe.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(xe.getPublicKey(n)),r.id=sn(r),r.sig=Y(xe.sign(sn(r),n)),r[bt]=!0,r}verifyEvent(e){if(typeof e[bt]=="boolean")return e[bt];const n=sn(e);if(n!==e.id)return e[bt]=!1,!1;try{const r=xe.verify(e.sig,n,e.pubkey);return e[bt]=r,r}catch{return e[bt]=!1,!1}}};function vu(t){if(!kr(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function sn(t){let e=me(ye.encode(vu(t)));return Y(e)}var an=new wu,Ar=an.generateSecretKey,cn=an.getPublicKey,be=an.finalizeEvent,Sr=an.verifyEvent,Eu={};Z(Eu,{Application:()=>Td,BadgeAward:()=>Bu,BadgeDefinition:()=>Sd,BlockedRelaysList:()=>cd,BlossomServerList:()=>md,BookmarkList:()=>sd,Bookmarksets:()=>kd,Calendar:()=>Kd,CalendarEventRSVP:()=>Hd,ChannelCreation:()=>js,ChannelHideMessage:()=>Zs,ChannelMessage:()=>Ws,ChannelMetadata:()=>Fs,ChannelMuteUser:()=>Js,ChatMessage:()=>Lu,ClassifiedListing:()=>Od,ClientAuth:()=>Ys,Comment:()=>Mu,CommunitiesList:()=>id,CommunityDefinition:()=>jd,CommunityPostApproval:()=>Wu,Contacts:()=>Su,CreateOrUpdateProduct:()=>Bd,CreateOrUpdateStall:()=>Cd,Curationsets:()=>_d,Date:()=>Dd,DirectMessageRelaysList:()=>fd,DraftClassifiedListing:()=>Rd,DraftLong:()=>Id,Emojisets:()=>$d,EncryptedDirectMessage:()=>Nu,EventDeletion:()=>Cu,FavoriteRelays:()=>ud,FileMessage:()=>$u,FileMetadata:()=>Du,FileServerPreference:()=>pd,Followsets:()=>vd,ForumThread:()=>Iu,GenericRepost:()=>Ir,Genericlists:()=>Ed,GiftWrap:()=>Gs,GroupMetadata:()=>Fd,HTTPAuth:()=>$r,Handlerinformation:()=>Vd,Handlerrecommendation:()=>qd,Highlights:()=>ed,InterestsList:()=>dd,Interestsets:()=>Nd,JobFeedback:()=>Gu,JobRequest:()=>Zu,JobResult:()=>Ju,Label:()=>Fu,LightningPubRPC:()=>yd,LiveChatMessage:()=>Ku,LiveEvent:()=>Pd,LongFormArticle:()=>Ld,Metadata:()=>_u,Mutelist:()=>nd,NWCWalletInfo:()=>gd,NWCWalletRequest:()=>Xs,NWCWalletResponse:()=>bd,NormalVideo:()=>Pu,NostrConnect:()=>wd,OpenTimestamps:()=>Ou,Photo:()=>Tu,Pinlist:()=>rd,Poll:()=>Ru,PollResponse:()=>td,PrivateDirectMessage:()=>Vs,ProblemTracker:()=>qu,ProfileBadges:()=>Ad,PublicChatsList:()=>ad,Reaction:()=>Lr,RecommendRelay:()=>Au,RelayList:()=>od,RelayReview:()=>zd,Relaysets:()=>xd,Report:()=>Vu,Reporting:()=>ju,Repost:()=>Br,Seal:()=>qs,SearchRelaysList:()=>ld,ShortTextNote:()=>zs,ShortVideo:()=>Uu,Time:()=>Md,UserEmojiList:()=>hd,UserStatuses:()=>Ud,Voice:()=>Hu,VoiceComment:()=>zu,Zap:()=>Qu,ZapGoal:()=>Yu,ZapRequest:()=>Xu,classifyKind:()=>xu,isAddressableKind:()=>Cr,isEphemeralKind:()=>Hs,isKind:()=>ku,isRegularKind:()=>Ks,isReplaceableKind:()=>Nr});function Ks(t){return t<1e4&&t!==0&&t!==3}function Nr(t){return t===0||t===3||1e4<=t&&t<2e4}function Hs(t){return 2e4<=t&&t<3e4}function Cr(t){return 3e4<=t&&t<4e4}function xu(t){return Ks(t)?"regular":Nr(t)?"replaceable":Hs(t)?"ephemeral":Cr(t)?"parameterized":"unknown"}function ku(t,e){const n=e instanceof Array?e:[e];return kr(t)&&n.includes(t.kind)||!1}var _u=0,zs=1,Au=2,Su=3,Nu=4,Cu=5,Br=6,Lr=7,Bu=8,Lu=9,Iu=11,qs=13,Vs=14,$u=15,Ir=16,Tu=20,Pu=21,Uu=22,js=40,Fs=41,Ws=42,Zs=43,Js=44,Ou=1040,Gs=1059,Ru=1068,Du=1063,Mu=1111,Ku=1311,Hu=1222,zu=1244,qu=1971,Vu=1984,ju=1984,Fu=1985,Wu=4550,Zu=5999,Ju=6999,Gu=7e3,Yu=9041,Xu=9734,Qu=9735,ed=9802,td=1018,nd=1e4,rd=10001,od=10002,sd=10003,id=10004,ad=10005,cd=10006,ld=10007,ud=10012,dd=10015,hd=10030,fd=10050,pd=10096,md=10063,gd=13194,yd=21e3,Ys=22242,Xs=23194,bd=23195,wd=24133,$r=27235,vd=3e4,Ed=30001,xd=30002,kd=30003,_d=30004,Ad=30008,Sd=30009,Nd=30015,Cd=30017,Bd=30018,Ld=30023,Id=30024,$d=30030,Td=30078,Pd=30311,Ud=30315,Od=30402,Rd=30403,Dd=31922,Md=31923,Kd=31924,Hd=31925,zd=31987,qd=31989,Vd=31990,jd=34550,Fd=39e3,Wd={};Z(Wd,{getHex64:()=>Tr,getInt:()=>Qs,getSubscriptionId:()=>Zd,matchEventId:()=>Jd,matchEventKind:()=>Yd,matchEventPubkey:()=>Gd});function Tr(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function Qs(t,e){let n=e.length,r=t.indexOf(`"${e}":`)+n+3,o=t.slice(r),s=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,s),10)}function Zd(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function Jd(t,e){return e===Tr(t,"id")}function Gd(t,e){return e===Tr(t,"pubkey")}function Yd(t,e){return e===Qs(t,"kind")}var Xd={};Z(Xd,{makeAuthEvent:()=>Qd});function Qd(t,e){return{kind:Ys,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}var eh;try{eh=WebSocket}catch{}var th;try{th=WebSocket}catch{}var wt={};Z(wt,{BECH32_REGEX:()=>ei,Bech32MaxSize:()=>Pr,NostrTypeGuard:()=>nh,decode:()=>ln,decodeNostrURI:()=>oh,encodeBytes:()=>dn,naddrEncode:()=>uh,neventEncode:()=>lh,noteEncode:()=>ah,nprofileEncode:()=>ch,npubEncode:()=>ih,nsecEncode:()=>sh});var nh={isNProfile:t=>/^nprofile1[a-z\d]+$/.test(t||""),isNEvent:t=>/^nevent1[a-z\d]+$/.test(t||""),isNAddr:t=>/^naddr1[a-z\d]+$/.test(t||""),isNSec:t=>/^nsec1[a-z\d]{58}$/.test(t||""),isNPub:t=>/^npub1[a-z\d]{58}$/.test(t||""),isNote:t=>/^note1[a-z\d]+$/.test(t||""),isNcryptsec:t=>/^ncryptsec1[a-z\d]+$/.test(t||"")},Pr=5e3,ei=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function rh(t){const e=new Uint8Array(4);return e[0]=t>>24&255,e[1]=t>>16&255,e[2]=t>>8&255,e[3]=t&255,e}function oh(t){try{return t.startsWith("nostr:")&&(t=t.substring(6)),ln(t)}catch{return{type:"invalid",data:null}}}function ln(t){var o,s,i,a,c,l,d;let{prefix:e,words:n}=mt.decode(t,Pr),r=new Uint8Array(mt.fromWords(n));switch(e){case"nprofile":{let u=Ur(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Y(u[0][0]),relays:u[1]?u[1].map(p=>Pe.decode(p)):[]}}}case"nevent":{let u=Ur(r);if(!((s=u[0])!=null&&s[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(u[3]&&u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Y(u[0][0]),relays:u[1]?u[1].map(p=>Pe.decode(p)):[],author:(i=u[2])!=null&&i[0]?Y(u[2][0]):void 0,kind:(a=u[3])!=null&&a[0]?parseInt(Y(u[3][0]),16):void 0}}}case"naddr":{let u=Ur(r);if(!((c=u[0])!=null&&c[0]))throw new Error("missing TLV 0 for naddr");if(!((l=u[2])!=null&&l[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((d=u[3])!=null&&d[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Pe.decode(u[0][0]),pubkey:Y(u[2][0]),kind:parseInt(Y(u[3][0]),16),relays:u[1]?u[1].map(p=>Pe.decode(p)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:Y(r)};default:throw new Error(`unknown prefix ${e}`)}}function Ur(t){let e={},n=t;for(;n.length>0;){let r=n[0],o=n[1],s=n.slice(2,2+o);if(n=n.slice(2+o),s.length<o)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(s)}return e}function sh(t){return dn("nsec",t)}function ih(t){return dn("npub",st(t))}function ah(t){return dn("note",st(t))}function un(t,e){let n=mt.toWords(e);return mt.encode(t,n,Pr)}function dn(t,e){return un(t,e)}function ch(t){let e=Or({0:[st(t.pubkey)],1:(t.relays||[]).map(n=>ye.encode(n))});return un("nprofile",e)}function lh(t){let e;t.kind!==void 0&&(e=rh(t.kind));let n=Or({0:[st(t.id)],1:(t.relays||[]).map(r=>ye.encode(r)),2:t.author?[st(t.author)]:[],3:e?[new Uint8Array(e)]:[]});return un("nevent",n)}function uh(t){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,t.kind,!1);let n=Or({0:[ye.encode(t.identifier)],1:(t.relays||[]).map(r=>ye.encode(r)),2:[st(t.pubkey)],3:[new Uint8Array(e)]});return un("naddr",n)}function Or(t){let e=[];return Object.entries(t).reverse().forEach(([n,r])=>{r.forEach(o=>{let s=new Uint8Array(o.length+2);s.set([parseInt(n)],0),s.set([o.length],1),s.set(o,2),e.push(s)})}),it(...e)}var dh={};Z(dh,{decrypt:()=>hh,encrypt:()=>ti});function ti(t,e,n){const r=t instanceof Uint8Array?Y(t):t,o=ot.getSharedSecret(r,"02"+e),s=ni(o);let i=Uint8Array.from(ur(16)),a=ye.encode(n),c=Ls(s,i).encrypt(a),l=ge.encode(new Uint8Array(c)),d=ge.encode(new Uint8Array(i.buffer));return`${l}?iv=${d}`}function hh(t,e,n){const r=t instanceof Uint8Array?Y(t):t;let[o,s]=n.split("?iv="),i=ot.getSharedSecret(r,"02"+e),a=ni(i),c=ge.decode(s),l=ge.decode(o),d=Ls(a,c).decrypt(l);return Pe.decode(d)}function ni(t){return t.slice(1,33)}var fh={};Z(fh,{NIP05_REGEX:()=>Rr,isNip05:()=>ph,isValid:()=>yh,queryProfile:()=>ri,searchDomain:()=>gh,useFetchImplementation:()=>mh});var Rr=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,ph=t=>Rr.test(t||""),hn;try{hn=fetch}catch{}function mh(t){hn=t}async function gh(t,e=""){try{const n=`https://${t}/.well-known/nostr.json?name=${e}`,r=await hn(n,{redirect:"manual"});if(r.status!==200)throw Error("Wrong response code");return(await r.json()).names}catch{return{}}}async function ri(t){var o;const e=t.match(Rr);if(!e)return null;const[,n="_",r]=e;try{const s=`https://${r}/.well-known/nostr.json?name=${n}`,i=await hn(s,{redirect:"manual"});if(i.status!==200)throw Error("Wrong response code");const a=await i.json(),c=a.names[n];return c?{pubkey:c,relays:(o=a.relays)==null?void 0:o[c]}:null}catch{return null}}async function yh(t,e){const n=await ri(e);return n?n.pubkey===t:!1}var bh={};Z(bh,{parse:()=>wh});function wh(t){const e={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=t.tags.length-1;o>=0;o--){const s=t.tags[o];if(s[0]==="e"&&s[1]){const[i,a,c,l,d]=s,u={id:a,relays:c?[c]:[],author:d};if(l==="root"){e.root=u;continue}if(l==="reply"){e.reply=u;continue}if(l==="mention"){e.mentions.push(u);continue}n?r=u:n=u,e.mentions.push(u);continue}if(s[0]==="q"&&s[1]){const[i,a,c]=s;e.quotes.push({id:a,relays:c?[c]:[]})}if(s[0]==="p"&&s[1]){e.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]});continue}}return e.root||(e.root=r||n||e.reply),e.reply||(e.reply=n||e.root),[e.reply,e.root].forEach(o=>{if(!o)return;let s=e.mentions.indexOf(o);if(s!==-1&&e.mentions.splice(s,1),o.author){let i=e.profiles.find(a=>a.pubkey===o.author);i&&i.relays&&(o.relays||(o.relays=[]),i.relays.forEach(a=>{var c;((c=o.relays)==null?void 0:c.indexOf(a))===-1&&o.relays.push(a)}),i.relays=o.relays)}}),e.mentions.forEach(o=>{if(o.author){let s=e.profiles.find(i=>i.pubkey===o.author);s&&s.relays&&(o.relays||(o.relays=[]),s.relays.forEach(i=>{o.relays.indexOf(i)===-1&&o.relays.push(i)}),s.relays=o.relays)}}),e}var vh={};Z(vh,{fetchRelayInformation:()=>xh,useFetchImplementation:()=>Eh});var oi;try{oi=fetch}catch{}function Eh(t){oi=t}async function xh(t){return await(await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var kh={};Z(kh,{fastEventHash:()=>ii,getPow:()=>si,minePow:()=>_h});function si(t){let e=0;for(let n=0;n<64;n+=8){const r=parseInt(t.substring(n,n+8),16);if(r===0)e+=32;else{e+=Math.clz32(r);break}}return e}function _h(t,e){let n=0;const r=t,o=["nonce",n.toString(),e.toString()];for(r.tags.push(o);;){const s=Math.floor(new Date().getTime()/1e3);if(s!==r.created_at&&(n=0,r.created_at=s),o[1]=(++n).toString(),r.id=ii(r),si(r.id)>=e)break}return r}function ii(t){return Y(me(ye.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}var Ah={};Z(Ah,{unwrapEvent:()=>Rh,unwrapManyEvents:()=>Dh,wrapEvent:()=>vi,wrapManyEvents:()=>Oh});var Sh={};Z(Sh,{createRumor:()=>gi,createSeal:()=>yi,createWrap:()=>bi,unwrapEvent:()=>zr,unwrapManyEvents:()=>wi,wrapEvent:()=>fn,wrapManyEvents:()=>Ph});var Nh={};Z(Nh,{decrypt:()=>Hr,encrypt:()=>Kr,getConversationKey:()=>Dr,v2:()=>$h});var ai=1,ci=65535;function Dr(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return Os(me,n,"nip44-v2")}function li(t,e){const n=Ds(me,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Mr(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Ch(t){if(!Number.isSafeInteger(t)||t<ai||t>ci)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}function Bh(t){const e=ye.encode(t),n=e.length,r=Ch(n),o=new Uint8Array(Mr(n)-n);return it(r,e,o)}function Lh(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<ai||e>ci||n.length!==e||t.length!==2+Mr(e))throw new Error("invalid padding");return Pe.decode(n)}function ui(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=it(n,e);return Ot(me,t,r)}function Ih(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=ge.decode(t)}catch(s){throw new Error("invalid base64: "+s.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Kr(t,e,n=ur(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=li(e,n),i=Bh(t),a=on(r,o,i),c=ui(s,a,n);return ge.encode(it(new Uint8Array([2]),n,a,c))}function Hr(t,e){const{nonce:n,ciphertext:r,mac:o}=Ih(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=li(e,n),c=ui(a,r,n);if(!_s(c,o))throw new Error("invalid MAC");const l=on(s,i,r);return Lh(l)}var $h={utils:{getConversationKey:Dr,calcPaddedLen:Mr},encrypt:Kr,decrypt:Hr},Th=2880*60,di=()=>Math.round(Date.now()/1e3),hi=()=>Math.round(di()-Math.random()*Th),fi=(t,e)=>Dr(t,e),pi=(t,e,n)=>Kr(JSON.stringify(t),fi(e,n)),mi=(t,e)=>JSON.parse(Hr(t.content,fi(e,t.pubkey)));function gi(t,e){const n={created_at:di(),content:"",tags:[],...t,pubkey:cn(e)};return n.id=sn(n),n}function yi(t,e,n){return be({kind:qs,content:pi(t,e,n),created_at:hi(),tags:[]},e)}function bi(t,e){const n=Ar();return be({kind:Gs,content:pi(t,n,e),created_at:hi(),tags:[["p",e]]},n)}function fn(t,e,n){const r=gi(t,e),o=yi(r,e,n);return bi(o,n)}function Ph(t,e,n){if(!n||n.length===0)throw new Error("At least one recipient is required.");const r=cn(e),o=[fn(t,e,r)];return n.forEach(s=>{o.push(fn(t,e,s))}),o}function zr(t,e){const n=mi(t,e);return mi(n,e)}function wi(t,e){let n=[];return t.forEach(r=>{n.push(zr(r,e))}),n.sort((r,o)=>r.created_at-o.created_at),n}function Uh(t,e,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:Vs,tags:[],content:e};return(Array.isArray(t)?t:[t]).forEach(({publicKey:i,relayUrl:a})=>{o.tags.push(a?["p",i,a]:["p",i])}),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}function vi(t,e,n,r,o){const s=Uh(e,n,r,o);return fn(s,t,e.publicKey)}function Oh(t,e,n,r,o){if(!e||e.length===0)throw new Error("At least one recipient is required.");return[{publicKey:cn(t)},...e].map(i=>vi(t,i,n,r,o))}var Rh=zr,Dh=wi,Mh={};Z(Mh,{finishRepostEvent:()=>Kh,getRepostedEvent:()=>Hh,getRepostedEventPointer:()=>Ei});function Kh(t,e,n,r){var i;let o;const s=[...t.tags??[],["e",e.id,n],["p",e.pubkey]];return e.kind===zs?o=Br:(o=Ir,s.push(["k",String(e.kind)])),be({kind:o,tags:s,content:t.content===""||(i=e.tags)!=null&&i.find(a=>a[0]==="-")?"":JSON.stringify(e),created_at:t.created_at},r)}function Ei(t){if(![Br,Ir].includes(t.kind))return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const o=t.tags[r];o.length>=2&&(o[0]==="e"&&e===void 0?e=o:o[0]==="p"&&n===void 0&&(n=o))}if(e!==void 0)return{id:e[1],relays:[e[2],n==null?void 0:n[2]].filter(r=>typeof r=="string"),author:n==null?void 0:n[1]}}function Hh(t,{skipVerification:e}={}){const n=Ei(t);if(n===void 0||t.content==="")return;let r;try{r=JSON.parse(t.content)}catch{return}if(r.id===n.id&&!(!e&&!Sr(r)))return r}var zh={};Z(zh,{NOSTR_URI_REGEX:()=>qr,parse:()=>Vh,test:()=>qh});var qr=new RegExp(`nostr:(${ei.source})`);function qh(t){return typeof t=="string"&&new RegExp(`^${qr.source}$`).test(t)}function Vh(t){const e=t.match(new RegExp(`^${qr.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:ln(e[1])}}var jh={};Z(jh,{finishReactionEvent:()=>Fh,getReactedEventPointer:()=>Wh});function Fh(t,e,n){const r=e.tags.filter(o=>o.length>=2&&(o[0]==="e"||o[0]==="p"));return be({...t,kind:Lr,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function Wh(t){if(t.kind!==Lr)return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const o=t.tags[r];o.length>=2&&(o[0]==="e"&&e===void 0?e=o:o[0]==="p"&&n===void 0&&(n=o))}if(!(e===void 0||n===void 0))return{id:e[1],relays:[e[2],n[2]].filter(r=>r!==void 0),author:n[1]}}var Zh={};Z(Zh,{parse:()=>Gh});var xi=/\W/m,ki=/[^\w\/] |[^\w\/]$|$|,| /m,Jh=42;function*Gh(t){let e=[];if(typeof t!="string"){for(let s=0;s<t.tags.length;s++){const i=t.tags[s];i[0]==="emoji"&&i.length>=3&&e.push({type:"emoji",shortcode:i[1],url:i[2]})}t=t.content}const n=t.length;let r=0,o=0;e:for(;o<n;){const s=t.indexOf(":",o),i=t.indexOf("#",o);if(s===-1&&i===-1)break e;if(s===-1||i>=0&&i<s){if(i===0||t[i-1]===" "){const a=t.slice(i+1,i+Jh).match(xi),c=a?i+1+a.index:n;yield{type:"text",text:t.slice(r,i)},yield{type:"hashtag",value:t.slice(i+1,c)},o=c,r=o;continue e}o=i+1;continue e}if(t.slice(s-5,s)==="nostr"){const a=t.slice(s+60).match(xi),c=a?s+60+a.index:n;try{let l,{data:d,type:u}=ln(t.slice(s+1,c));switch(u){case"npub":l={pubkey:d};break;case"note":l={id:d};break;case"nsec":o=c+1;continue;default:l=d}r!==s-5&&(yield{type:"text",text:t.slice(r,s-5)}),yield{type:"reference",pointer:l},o=c,r=o;continue e}catch{o=s+1;continue e}}else if(t.slice(s-5,s)==="https"||t.slice(s-4,s)==="http"){const a=t.slice(s+4).match(ki),c=a?s+4+a.index:n,l=t[s-1]==="s"?5:4;try{let d=new URL(t.slice(s-l,c));if(d.hostname.indexOf(".")===-1)throw new Error("invalid url");if(r!==s-l&&(yield{type:"text",text:t.slice(r,s-l)}),/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(d.pathname)){yield{type:"image",url:d.toString()},o=c,r=o;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(d.pathname)){yield{type:"video",url:d.toString()},o=c,r=o;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(d.pathname)){yield{type:"audio",url:d.toString()},o=c,r=o;continue e}yield{type:"url",url:d.toString()},o=c,r=o;continue e}catch{o=c+1;continue e}}else if(t.slice(s-3,s)==="wss"||t.slice(s-2,s)==="ws"){const a=t.slice(s+4).match(ki),c=a?s+4+a.index:n,l=t[s-1]==="s"?3:2;try{let d=new URL(t.slice(s-l,c));if(d.hostname.indexOf(".")===-1)throw new Error("invalid ws url");r!==s-l&&(yield{type:"text",text:t.slice(r,s-l)}),yield{type:"relay",url:d.toString()},o=c,r=o;continue e}catch{o=c+1;continue e}}else{for(let a=0;a<e.length;a++){const c=e[a];if(t[s+c.shortcode.length+1]===":"&&t.slice(s+1,s+c.shortcode.length+1)===c.shortcode){r!==s&&(yield{type:"text",text:t.slice(r,s)}),yield c,o=s+c.shortcode.length+2,r=o;continue e}}o=s+1;continue e}}r!==n&&(yield{type:"text",text:t.slice(r)})}var Yh={};Z(Yh,{channelCreateEvent:()=>Xh,channelHideMessageEvent:()=>tf,channelMessageEvent:()=>ef,channelMetadataEvent:()=>Qh,channelMuteUserEvent:()=>nf});var Xh=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:js,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},Qh=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Fs,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},ef=(t,e)=>{const n=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&n.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),be({kind:Ws,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},tf=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Zs,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},nf=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Js,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)},rf={};Z(rf,{EMOJI_SHORTCODE_REGEX:()=>_i,matchAll:()=>of,regex:()=>Vr,replaceAll:()=>sf});var _i=/:(\w+):/,Vr=()=>new RegExp(`\\B${_i.source}\\B`,"g");function*of(t){const e=t.matchAll(Vr());for(const n of e)try{const[r,o]=n;yield{shortcode:r,name:o,start:n.index,end:n.index+r.length}}catch{}}function sf(t,e){return t.replaceAll(Vr(),(n,r)=>e({shortcode:n,name:r}))}var af={};Z(af,{useFetchImplementation:()=>cf,validateGithub:()=>lf});var jr;try{jr=fetch}catch{}function cf(t){jr=t}async function lf(t,e,n){try{return await(await jr(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch{return!1}}var uf={};Z(uf,{makeNwcRequestEvent:()=>hf,parseConnectionString:()=>df});function df(t){const{host:e,pathname:n,searchParams:r}=new URL(t),o=n||e,s=r.get("relay"),i=r.get("secret");if(!o||!s||!i)throw new Error("invalid connection string");return{pubkey:o,relay:s,secret:i}}async function hf(t,e,n){const o=ti(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:n}})),s={kind:Xs,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",t]]};return be(s,e)}var ff={};Z(ff,{normalizeIdentifier:()=>pf});function pf(t){return t=t.trim().toLowerCase(),t=t.normalize("NFKC"),Array.from(t).map(e=>new RegExp("\\p{Letter}","u").test(e)||new RegExp("\\p{Number}","u").test(e)?e:"-").join("")}var mf={};Z(mf,{getSatoshisAmountFromBolt11:()=>Ef,getZapEndpoint:()=>yf,makeZapReceipt:()=>vf,makeZapRequest:()=>bf,useFetchImplementation:()=>gf,validateZapRequest:()=>wf});var Fr;try{Fr=fetch}catch{}function gf(t){Fr=t}async function yf(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(r){let[i,a]=r.split("@");e=new URL(`/.well-known/lnurlp/${i}`,`https://${a}`).toString()}else if(n){let{words:i}=mt.decode(n,1e3),a=mt.fromWords(i);e=Pe.decode(a)}else return null;let s=await(await Fr(e)).json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch{}return null}function bf(t){let e={kind:9734,created_at:Math.round(Date.now()/1e3),content:t.comment||"",tags:[["p","pubkey"in t?t.pubkey:t.event.pubkey],["amount",t.amount.toString()],["relays",...t.relays]]};if("event"in t){if(e.tags.push(["e",t.event.id]),Nr(t.event.kind)){const n=["a",`${t.event.kind}:${t.event.pubkey}:`];e.tags.push(n)}else if(Cr(t.event.kind)){let n=t.event.tags.find(([o,s])=>o==="d"&&s);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${t.event.kind}:${t.event.pubkey}:${n[1]}`];e.tags.push(r)}e.tags.push(["k",t.event.kind.toString()])}return e}function wf(t){let e;try{e=JSON.parse(t)}catch{return"Invalid zap request JSON."}if(!kr(e))return"Zap request is not a valid Nostr event.";if(!Sr(e))return"Invalid signature on zap request.";let n=e.tags.find(([s,i])=>s==="p"&&i);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=e.tags.find(([s,i])=>s==="e"&&i);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([s,i])=>s==="relays"&&i)?null:"Zap request doesn't have a 'relays' tag."}function vf({zapRequest:t,preimage:e,bolt11:n,paidAt:r}){let o=JSON.parse(t),s=o.tags.filter(([a])=>a==="e"||a==="p"||a==="a"),i={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",o.pubkey],["bolt11",n],["description",t]]};return e&&i.tags.push(["preimage",e]),i}function Ef(t){if(t.length<50)return 0;t=t.substring(0,50);const e=t.lastIndexOf("1");if(e===-1)return 0;const n=t.substring(0,e);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const o=r[r.length-1],s=o.charCodeAt(0)-48,i=s>=0&&s<=9;let a=r.length-1;if(i&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(o){case"m":return c*1e5;case"u":return c*100;case"n":return c/10;case"p":return c/1e4;default:return c*1e8}}var xf={};Z(xf,{Negentropy:()=>Si,NegentropyStorageVector:()=>Af,NegentropySync:()=>Sf});var Wr=97,vt=32,Ai=16,at={Skip:0,Fingerprint:1,IdList:2},Ue=class{constructor(t){g(this,"_raw");g(this,"length");typeof t=="number"?(this._raw=new Uint8Array(t),this.length=0):t instanceof Uint8Array?(this._raw=new Uint8Array(t),this.length=t.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(t){if(t instanceof Ue&&(t=t.unwrap()),typeof t.length!="number")throw Error("bad length");const e=t.length+this.length;if(this.capacity<e){const n=this._raw,r=Math.max(this.capacity*2,e);this._raw=new Uint8Array(r),this._raw.set(n)}this._raw.set(t,this.length),this.length+=t.length}shift(){const t=this._raw[0];return this._raw=this._raw.subarray(1),this.length--,t}shiftN(t=1){const e=this._raw.subarray(0,t);return this._raw=this._raw.subarray(t),this.length-=t,e}};function pn(t){let e=0;for(;;){if(t.length===0)throw Error("parse ends prematurely");let n=t.shift();if(e=e<<7|n&127,(n&128)===0)break}return e}function Oe(t){if(t===0)return new Ue(new Uint8Array([0]));let e=[];for(;t!==0;)e.push(t&127),t>>>=7;e.reverse();for(let n=0;n<e.length-1;n++)e[n]|=128;return new Ue(new Uint8Array(e))}function kf(t){return mn(t,1)[0]}function mn(t,e){if(t.length<e)throw Error("parse ends prematurely");return t.shiftN(e)}var _f=class{constructor(){g(this,"buf");this.setToZero()}setToZero(){this.buf=new Uint8Array(vt)}add(t){let e=0,n=0,r=new DataView(this.buf.buffer),o=new DataView(t.buffer);for(let s=0;s<8;s++){let i=s*4,a=r.getUint32(i,!0),c=o.getUint32(i,!0),l=a;l+=e,l+=c,l>4294967295&&(n=1),r.setUint32(i,l&4294967295,!0),e=n,n=0}}negate(){let t=new DataView(this.buf.buffer);for(let n=0;n<8;n++){let r=n*4;t.setUint32(r,~t.getUint32(r,!0))}let e=new Uint8Array(vt);e[0]=1,this.add(e)}getFingerprint(t){let e=new Ue;return e.extend(this.buf),e.extend(Oe(t)),me(e.unwrap()).subarray(0,Ai)}},Af=class{constructor(){g(this,"items");g(this,"sealed");this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");const n=ks(e);if(n.byteLength!==vt)throw Error("bad id size for added item");this.items.push({timestamp:t,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(Zr);for(let t=1;t<this.items.length;t++)if(Zr(this.items[t-1],this.items[t])===0)throw Error("duplicate item inserted")}unseal(){this.sealed=!1}size(){return this._checkSealed(),this.items.length}getItem(t){if(this._checkSealed(),t>=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,n){this._checkSealed(),this._checkBounds(t,e);for(let r=t;r<e&&n(this.items[r],r);++r);}findLowerBound(t,e,n){return this._checkSealed(),this._checkBounds(t,e),this._binarySearch(this.items,t,e,r=>Zr(r,n)<0)}fingerprint(t,e){let n=new _f;return n.setToZero(),this.iterate(t,e,r=>(n.add(r.id),!0)),n.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,n,r){let o=n-e;for(;o>0;){let s=e,i=Math.floor(o/2);s+=i,r(t[s])?(e=++s,o-=i+1):o=i}return e}},Si=class{constructor(t,e=6e4){g(this,"storage");g(this,"frameSizeLimit");g(this,"lastTimestampIn");g(this,"lastTimestampOut");if(e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}initiate(){let t=new Ue;return t.extend(new Uint8Array([Wr])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),gt(t.unwrap())}reconcile(t,e,n){const r=new Ue(ks(t));this.lastTimestampIn=this.lastTimestampOut=0;let o=new Ue;o.extend(new Uint8Array([Wr]));let s=kf(r);if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(s!==Wr)throw Error("unsupported negentropy protocol version requested: "+(s-96));let i=this.storage.size(),a=this._bound(0),c=0,l=!1;for(;r.length!==0;){let d=new Ue,u=()=>{l&&(l=!1,d.extend(this.encodeBound(a)),d.extend(Oe(at.Skip)))},p=this.decodeBound(r),f=pn(r),m=c,h=this.storage.findLowerBound(c,i,p);if(f===at.Skip)l=!0;else if(f===at.Fingerprint){let y=mn(r,Ai),v=this.storage.fingerprint(m,h);Ni(y,v)!==0?(u(),this.splitRange(m,h,p,d)):l=!0}else if(f===at.IdList){let y=pn(r),v={};for(let x=0;x<y;x++){let S=mn(r,vt);v[gt(S)]=S}if(l=!0,this.storage.iterate(m,h,x=>{let S=x.id;const U=gt(S);return v[U]?delete v[gt(S)]:e==null||e(U),!0}),n)for(let x of Object.values(v))n(gt(x))}else throw Error("unexpected mode");if(this.exceededFrameSizeLimit(o.length+d.length)){let y=this.storage.fingerprint(h,i);o.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),o.extend(Oe(at.Fingerprint)),o.extend(y);break}else o.extend(d);c=h,a=p}return o.length===1?null:gt(o.unwrap())}splitRange(t,e,n,r){let o=e-t,s=16;if(o<s*2)r.extend(this.encodeBound(n)),r.extend(Oe(at.IdList)),r.extend(Oe(o)),this.storage.iterate(t,e,i=>(r.extend(i.id),!0));else{let i=Math.floor(o/s),a=o%s,c=t;for(let l=0;l<s;l++){let d=i+(l<a?1:0),u=this.storage.fingerprint(c,c+d);c+=d;let p;if(c===e)p=n;else{let f,m;this.storage.iterate(c-1,c+1,(h,y)=>(y===c-1?f=h:m=h,!0)),p=this.getMinimalBound(f,m)}r.extend(this.encodeBound(p)),r.extend(Oe(at.Fingerprint)),r.extend(u)}}}exceededFrameSizeLimit(t){return t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=pn(t);return e=e===0?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),n=pn(t);if(n>vt)throw Error("bound key too long");let r=mn(t,n);return{timestamp:e,id:r}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,Oe(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,Oe(t+1)}encodeBound(t){let e=new Ue;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(Oe(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let n=0,r=e.id,o=t.id;for(let s=0;s<vt&&r[s]===o[s];s++)n++;return this._bound(e.timestamp,e.id.subarray(0,n+1))}}};function Ni(t,e){for(let n=0;n<t.byteLength;n++){if(t[n]<e[n])return-1;if(t[n]>e[n])return 1}return t.byteLength>e.byteLength?1:t.byteLength<e.byteLength?-1:0}function Zr(t,e){return t.timestamp===e.timestamp?Ni(t.id,e.id):t.timestamp-e.timestamp}var Sf=class{constructor(t,e,n,r={}){g(this,"relay");g(this,"storage");g(this,"neg");g(this,"filter");g(this,"subscription");g(this,"onhave");g(this,"onneed");this.relay=t,this.storage=e,this.neg=new Si(e),this.onhave=r.onhave,this.onneed=r.onneed,this.filter=n,this.subscription=this.relay.prepareSubscription([{}],{label:r.label||"negentropy"}),this.subscription.oncustom=o=>{var s,i,a,c;switch(o[0]){case"NEG-MSG":{o.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${o}`);try{const l=this.neg.reconcile(o[2],this.onhave,this.onneed);l?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${l}"]`):(this.close(),(s=r.onclose)==null||s.call(r))}catch(l){console.error("negentropy reconcile error:",l),(i=r==null?void 0:r.onclose)==null||i.call(r,`reconcile error: ${l}`)}break}case"NEG-CLOSE":{const l=o[2];console.warn("negentropy error:",l),(a=r.onclose)==null||a.call(r,l);break}case"NEG-ERR":(c=r.onclose)==null||c.call(r)}}}async start(){const t=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${t}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}},Nf={};Z(Nf,{getToken:()=>Cf,hashPayload:()=>Jr,unpackEventFromToken:()=>Bi,validateEvent:()=>Ui,validateEventKind:()=>Ii,validateEventMethodTag:()=>Ti,validateEventPayloadTag:()=>Pi,validateEventTimestamp:()=>Li,validateEventUrlTag:()=>$i,validateToken:()=>Bf});var Ci="Nostr ";async function Cf(t,e,n,r=!1,o){const s={kind:$r,tags:[["u",t],["method",e]],created_at:Math.round(new Date().getTime()/1e3),content:""};o&&s.tags.push(["payload",Jr(o)]);const i=await n(s);return(r?Ci:"")+ge.encode(ye.encode(JSON.stringify(i)))}async function Bf(t,e,n){const r=await Bi(t).catch(s=>{throw s});return await Ui(r,e,n).catch(s=>{throw s})}async function Bi(t){if(!t)throw new Error("Missing token");t=t.replace(Ci,"");const e=Pe.decode(ge.decode(t));if(!e||e.length===0||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}function Li(t){return t.created_at?Math.round(new Date().getTime()/1e3)-t.created_at<60:!1}function Ii(t){return t.kind===$r}function $i(t,e){const n=t.tags.find(r=>r[0]==="u");return n?n.length>0&&n[1]===e:!1}function Ti(t,e){const n=t.tags.find(r=>r[0]==="method");return n?n.length>0&&n[1].toLowerCase()===e.toLowerCase():!1}function Jr(t){const e=me(ye.encode(JSON.stringify(t)));return Y(e)}function Pi(t,e){const n=t.tags.find(o=>o[0]==="payload");if(!n)return!1;const r=Jr(e);return n.length>0&&n[1]===r}async function Ui(t,e,n,r){if(!Sr(t))throw new Error("Invalid nostr event, signature invalid");if(!Ii(t))throw new Error("Invalid nostr event, kind invalid");if(!Li(t))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!$i(t,e))throw new Error("Invalid nostr event, url tag invalid");if(!Ti(t,n))throw new Error("Invalid nostr event, method tag invalid");if(r&&typeof r=="object"&&Object.keys(r).length>0&&!Pi(t,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}class Et{constructor(e){g(this,"secretKey");g(this,"pubkey");this.secretKey=e||Ar(),this.pubkey=cn(this.secretKey)}async getPublicKey(){return this.pubkey}async signEvent(e){return be(e,this.secretKey)}getNsec(){return wt.nsecEncode(this.secretKey)}getNpub(){return wt.npubEncode(this.pubkey)}exportKeyFile(){return{nsec:this.getNsec(),npub:this.getNpub(),pubkey:this.pubkey}}downloadKeyFile(){const e=this.exportKeyFile(),n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`nostr-key-${this.pubkey.slice(0,8)}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}copyNsec(){return navigator.clipboard.writeText(this.getNsec())}static fromNsec(e){const{type:n,data:r}=wt.decode(e);if(n!=="nsec")throw new Error("Invalid nsec");return new Et(r)}}var ct=Symbol("verified"),Lf=t=>t instanceof Object;function If(t){if(!Lf(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}var $f=new TextDecoder("utf-8"),Oi=new TextEncoder;function xt(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}var Tf=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},Pf=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Tf(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},Uf=class{generateSecretKey(){return xe.utils.randomPrivateKey()}getPublicKey(e){return Y(xe.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(xe.getPublicKey(n)),r.id=Gr(r),r.sig=Y(xe.sign(Gr(r),n)),r[ct]=!0,r}verifyEvent(e){if(typeof e[ct]=="boolean")return e[ct];const n=Gr(e);if(n!==e.id)return e[ct]=!1,!1;try{const r=xe.verify(e.sig,n,e.pubkey);return e[ct]=r,r}catch{return e[ct]=!1,!1}}};function Of(t){if(!If(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Gr(t){let e=me(Oi.encode(Of(t)));return Y(e)}var gn=new Uf;gn.generateSecretKey;var Ri=gn.getPublicKey,Rf=gn.finalizeEvent,Di=gn.verifyEvent,Mi=1,Ki=65535;function Yr(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return Os(me,n,"nip44-v2")}function Hi(t,e){const n=Ds(me,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function zi(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Df(t){if(!Number.isSafeInteger(t)||t<Mi||t>Ki)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}function Mf(t){const e=Oi.encode(t),n=e.length,r=Df(n),o=new Uint8Array(zi(n)-n);return it(r,e,o)}function Kf(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Mi||e>Ki||n.length!==e||t.length!==2+zi(e))throw new Error("invalid padding");return $f.decode(n)}function qi(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=it(n,e);return Ot(me,t,r)}function Hf(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=ge.decode(t)}catch(s){throw new Error("invalid base64: "+s.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function zf(t,e,n=ur(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=Hi(e,n),i=Mf(t),a=on(r,o,i),c=qi(s,a,n);return ge.encode(it(new Uint8Array([2]),n,a,c))}function Vi(t,e){const{nonce:n,ciphertext:r,mac:o}=Hf(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=Hi(e,n),c=qi(a,r,n);if(!_s(c,o))throw new Error("invalid MAC");const l=on(s,i,r);return Kf(l)}var qf=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Vf;try{Vf=fetch}catch{}var jf=22242,Xr=24133;function Ff(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([s,i])=>s===n.slice(1)&&o.indexOf(i)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Wf(t,e){for(let n=0;n<t.length;n++)if(Ff(t[n],e))return!0;return!1}function Zf(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function Jf(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function Gf(t,e){return{kind:jf,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Yf(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}var Xf=t=>(t[ct]=!0,!0),ji=class extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}},Fi=class{constructor(e,n){g(this,"url");g(this,"_connected",!1);g(this,"onclose",null);g(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));g(this,"onauth");g(this,"baseEoseTimeout",4400);g(this,"publishTimeout",4400);g(this,"pingFrequency",29e3);g(this,"pingTimeout",2e4);g(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);g(this,"openSubs",new Map);g(this,"enablePing");g(this,"enableReconnect");g(this,"reconnectTimeoutHandle");g(this,"pingIntervalHandle");g(this,"reconnectAttempts",0);g(this,"closedIntentionally",!1);g(this,"connectionPromise");g(this,"openCountRequests",new Map);g(this,"openEventPublishes",new Map);g(this,"ws");g(this,"incomingMessageQueue",new Pf);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=xt(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket,this.enablePing=n.enablePing,this.enableReconnect=n.enableReconnect||!1}static async connect(e,n){const r=new Fi(e,n);return await r.connect(n),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},e)}handleHardClose(e){var r;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,(r=this.onclose)==null||r.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(e)}async connect(e){let n;return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((r,o)=>{e!=null&&e.timeout&&(n=setTimeout(()=>{var s;o("connection timed out"),this.connectionPromise=void 0,(s=this.onclose)==null||s.call(this),this.closeAllSubscriptions("relay connection timed out")},e.timeout)),e!=null&&e.abort&&(e.abort.onabort=o);try{this.ws=new this._WebSocket(this.url)}catch(s){clearTimeout(n),o(s);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(n),this._connected=!0;const s=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const i of this.openSubs.values()){if(i.eosed=!1,s)for(let a=0;a<i.filters.length;a++)i.lastEmitted&&(i.filters[a].since=i.lastEmitted+1);i.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),r()},this.ws.onerror=s=>{clearTimeout(n),o(s.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=s=>{clearTimeout(n),o(s.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,n)=>{if(!this.connectionPromise)return n(new Error(`no connection to ${this.url}, can't ping`));try{const r=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),r.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(r){n(r)}})}async pingpong(){var e,n,r;((e=this.ws)==null?void 0:e.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(s=>setTimeout(()=>s(!1),this.pingTimeout))])||((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Yf();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=Jf(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=Zf(e,"id"),c=(r=i.alreadyHaveEvent)==null?void 0:r.call(i,a);if((o=i.receivedEvent)==null||o.call(i,this,a),c)return}try{let i=JSON.parse(e);switch(i[0]){case"EVENT":{const a=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&Wf(a.filters,c)&&a.onevent(c),(!a.lastEmitted||a.lastEmitted<c.created_at)&&(a.lastEmitted=c.created_at);return}case"COUNT":{const a=i[1],c=i[2],l=this.openCountRequests.get(a);l&&(l.resolve(c.count),this.openCountRequests.delete(a));return}case"EOSE":{const a=this.openSubs.get(i[1]);if(!a)return;a.receivedEose();return}case"OK":{const a=i[1],c=i[2],l=i[3],d=this.openEventPublishes.get(a);d&&(clearTimeout(d.timeout),c?d.resolve(l):d.reject(new Error(l)),this.openEventPublishes.delete(a));return}case"CLOSED":{const a=i[1],c=this.openSubs.get(a);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":{this.onnotice(i[1]);return}case"AUTH":{this.challenge=i[1],this.onauth&&this.auth(this.onauth);return}default:{const a=this.openSubs.get(i[1]);(s=a==null?void 0:a.oncustom)==null||s.call(a,i);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new ji(e,this.url);this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){const n=this.challenge;if(!n)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,o)=>{try{let s=await e(Gf(this.url,n)),i=setTimeout(()=>{let a=this.openEventPublishes.get(s.id);a&&(a.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:r,reject:o,timeout:i}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(s){console.warn("subscribe auth function failed:",s)}}),this.authPromise)}async publish(e){const n=new Promise((r,o)=>{const s=setTimeout(()=>{const i=this.openEventPublishes.get(e.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:r,reject:o,timeout:s})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((s,i)=>{this.openCountRequests.set(r,{resolve:s,reject:i})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),n.abort&&(n.abort.onabort=()=>r.close(String(n.abort.reason||"<aborted>"))),r}prepareSubscription(e,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new Qf(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e,n,r;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.onclose)==null||e.call(this),((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close())}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Qf=class{constructor(e,n,r,o){g(this,"relay");g(this,"id");g(this,"lastEmitted");g(this,"closed",!1);g(this,"eosed",!1);g(this,"filters");g(this,"alreadyHaveEvent");g(this,"receivedEvent");g(this,"onevent");g(this,"oneose");g(this,"onclose");g(this,"oncustom");g(this,"eoseTimeout");g(this,"eoseTimeoutHandle");if(r.length===0)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(s=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,s)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(r){if(!(r instanceof ji))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},ep=class{constructor(e){g(this,"relays",new Map);g(this,"seenOn",new Map);g(this,"trackRelays",!1);g(this,"verifyEvent");g(this,"enablePing");g(this,"enableReconnect");g(this,"automaticallyAuth");g(this,"trustedRelayURLs",new Set);g(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,n){e=xt(e);let r=this.relays.get(e);if(r||(r=new Fi(e,{verifyEvent:this.trustedRelayURLs.has(e)?Xf:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),r.onclose=()=>{r&&!r.enableReconnect&&this.relays.delete(e)},this.relays.set(e,r)),this.automaticallyAuth){const o=this.automaticallyAuth(e);o&&(r.onauth=o)}return await r.connect({timeout:n==null?void 0:n.connectionTimeout,abort:n==null?void 0:n.abort}),r}close(e){e.map(xt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close(),this.relays.delete(n)})}subscribe(e,n,r){const o=[];for(let s=0;s<e.length;s++){const i=xt(e[s]);o.find(a=>a.url===i)||o.push({url:i,filter:n})}return this.subscribeMap(o,r)}subscribeMany(e,n,r){const o=[],s=[];for(let i=0;i<e.length;i++){const a=xt(e[i]);s.indexOf(a)===-1&&(s.push(a),o.push({url:a,filter:n}))}return this.subscribeMap(o,r)}subscribeMap(e,n){const r=new Map;for(const f of e){const{url:m,filter:h}=f;r.has(m)||r.set(m,[]),r.get(m).push(h)}const o=Array.from(r.entries()).map(([f,m])=>({url:f,filters:m}));this.trackRelays&&(n.receivedEvent=(f,m)=>{let h=this.seenOn.get(m);h||(h=new Set,this.seenOn.set(m,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var m;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((m=n.oneose)==null||m.call(n),c=()=>{}))};const l=[];let d=(f,m)=>{var h;l[f]||(c(f),l[f]=m,l.filter(y=>y).length===o.length&&((h=n.onclose)==null||h.call(n,l),d=()=>{}))};const u=f=>{var h;if((h=n.alreadyHaveEvent)!=null&&h.call(n,f))return!0;const m=s.has(f);return s.add(f),m},p=Promise.all(o.map(async({url:f,filters:m},h)=>{let y;try{y=await this.ensureRelay(f,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0,abort:n.abort})}catch(x){d(h,(x==null?void 0:x.message)||String(x));return}let v=y.subscribe(m,{...n,oneose:()=>c(h),onclose:x=>{x.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(m,{...n,oneose:()=>c(h),onclose:S=>{d(h,S)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort})}).catch(S=>{d(h,`auth was required and attempted, but failed with: ${S}`)}):d(h,x)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await p,i.forEach(m=>{m.close(f)})}}}subscribeEose(e,n,r){const o=this.subscribe(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}async querySync(e,n,r){return new Promise(async o=>{const s=[];this.subscribeEose(e,n,{...r,onevent(i){s.push(i)},onclose(i){o(s)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((s,i)=>i.created_at-s.created_at),o[0]||null}publish(e,n,r){return e.map(xt).map(async(o,s,i)=>{if(i.indexOf(o)!==s)return Promise.reject("duplicate url");let a=await this.ensureRelay(o);return a.publish(n).catch(async c=>{if(c instanceof Error&&c.message.startsWith("auth-required: ")&&(r!=null&&r.onauth))return await a.auth(r.onauth),a.publish(n);throw c}).then(c=>{if(this.trackRelays){let l=this.seenOn.get(n.id);l||(l=new Set,this.seenOn.set(n.id,l)),l.add(a)}return c})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},Wi;try{Wi=WebSocket}catch{}var tp=class extends ep{constructor(e){super({verifyEvent:Di,websocketImplementation:Wi,...e})}},Zi;try{Zi=fetch}catch{}var np=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function rp(t){let e=t.match(np);if(e)try{const n=e[1],r=new URLSearchParams(e[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return op(t)}async function op(t){const e=t.match(qf);if(!e)return null;const[n,r="_",o]=e;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,i=await(await Zi(s,{redirect:"error"})).json();let a=i.names[r],c=i.nip46[a]||[];return{pubkey:a,relays:c,secret:null}}catch{return null}}var Qr=class{constructor(e,n){g(this,"params");g(this,"pool");g(this,"subCloser");g(this,"isOpen");g(this,"serial");g(this,"idPrefix");g(this,"listeners");g(this,"waitingForAuth");g(this,"secretKey");g(this,"conversationKey");g(this,"bp");g(this,"cachedPubKey");this.params=n,this.pool=n.pool||new tp,this.secretKey=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={}}static fromBunker(e,n,r={}){if(n.relays.length===0)throw new Error("no relays specified for this bunker");const o=new Qr(e,r);return o.conversationKey=Yr(e,n.pubkey),o.bp=n,o.setupSubscription(),o}static async fromURI(e,n,r={},o=3e5){const s=new Qr(e,r),i=new URL(n),a=Ri(e);return new Promise((c,l)=>{let d=!1;const u=s.pool.subscribe(i.searchParams.getAll("relay"),{kinds:[Xr],"#p":[a],limit:0},{onevent:async p=>{try{const f=Yr(e,p.pubkey),m=Vi(p.content,f);JSON.parse(m).result===i.searchParams.get("secret")&&(u.close(),s.bp={pubkey:p.pubkey,relays:i.searchParams.getAll("relay"),secret:i.searchParams.get("secret")},s.conversationKey=Yr(e,p.pubkey),s.setupSubscription(),d=!0,await Promise.race([new Promise(y=>setTimeout(y,1e3)),s.switchRelays()]),c(s))}catch(f){console.warn("failed to process potential connection event",f)}},onclose:()=>{d||l(new Error("subscription closed before connection was established."))},maxWait:typeof o=="number"?o:void 0,abort:typeof o!="number"?o:void 0})})}setupSubscription(){const e=this.listeners,n=this.waitingForAuth,r=this.conversationKey;this.subCloser=this.pool.subscribe(this.bp.relays,{kinds:[Xr],authors:[this.bp.pubkey],"#p":[Ri(this.secretKey)],limit:0},{onevent:async o=>{const s=JSON.parse(Vi(o.content,r)),{id:i,result:a,error:c}=s;if(a==="auth_url"&&n[i]){delete n[i],this.params.onauth?this.params.onauth(c):console.warn(`nostr-tools/nip46: remote signer ${this.bp.pubkey} tried to send an "auth_url"='${c}' but there was no onauth() callback configured.`);return}let l=e[i];l&&(c?l.reject(c):a&&l.resolve(a),delete e[i])},onclose:()=>{this.subCloser=void 0}}),this.isOpen=!0}async switchRelays(){try{const e=await this.sendRequest("switch_relays",[]);let n=JSON.parse(e);if(!n||JSON.stringify(n.sort())===JSON.stringify(this.bp.relays))return!1;this.bp.relays=n;let r=this.subCloser;return setTimeout(()=>{r.close()},5e3),this.subCloser=void 0,this.setupSubscription(),!0}catch{return!1}}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(e,n){return new Promise(async(r,o)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.subCloser||this.setupSubscription(),this.serial++;const s=`${this.idPrefix}-${this.serial}`,i=zf(JSON.stringify({id:s,method:e,params:n}),this.conversationKey),a=Rf({kind:Xr,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[s]={resolve:r,reject:o},this.waitingForAuth[s]=!0,await Promise.any(this.pool.publish(this.bp.relays,a))}catch(s){o(s)}})}async ping(){let e=await this.sendRequest("ping",[]);if(e!=="pong")throw new Error(`result is not pong: ${e}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async signEvent(e){let n=await this.sendRequest("sign_event",[JSON.stringify(e)]),r=JSON.parse(n);if(Di(r))return r;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(r)}`)}async nip04Encrypt(e,n){return await this.sendRequest("nip04_encrypt",[e,n])}async nip04Decrypt(e,n){return await this.sendRequest("nip04_decrypt",[e,n])}async nip44Encrypt(e,n){return await this.sendRequest("nip44_encrypt",[e,n])}async nip44Decrypt(e,n){return await this.sendRequest("nip44_decrypt",[e,n])}};class yn{constructor(e){g(this,"signer");g(this,"cachedPubKey");this.signer=e}async connect(){await this.signer.connect()}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.signer.getPublicKey()),this.cachedPubKey}async signEvent(e){return await this.signer.signEvent(e)}async close(){await this.signer.close()}static async create(e){const n=await rp(e);if(!n)throw new Error("Invalid bunker input");const r=Qr.fromBunker(Ar(),n,{onauth:o=>{window.open(o,"_blank")}});return new yn(r)}}let Re={signer:null,signerInfo:null,loading:!1,error:null};const eo=new Set;function re(t){Re={...Re,...t},eo.forEach(e=>e())}function sp(t){return eo.add(t),()=>eo.delete(t)}function Ji(){return Re}function ip(){return Re.signer!==null}function kt(){const{signer:t,signerInfo:e,loading:n,error:r}=z.useSyncExternalStore(sp,Ji,Ji),o=z.useCallback(async()=>{if(!Wt.isAvailable()){re({error:"NIP-07 extension not found"});return}re({loading:!0,error:null});try{const u=new Wt,p=await u.getPublicKey();re({signer:u,signerInfo:{type:"nip07",pubkey:p},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),s=z.useCallback(async()=>{re({loading:!0,error:null});try{const u=new Et,p=await u.getPublicKey();re({signer:u,signerInfo:{type:"temp",pubkey:p},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),i=z.useCallback(async u=>{re({loading:!0,error:null});try{const p=Et.fromNsec(u.trim()),f=await p.getPublicKey();re({signer:p,signerInfo:{type:"temp",pubkey:f},loading:!1})}catch(p){throw re({error:p instanceof Error?p.message:"Invalid nsec",loading:!1}),p}},[]),a=z.useCallback(async u=>{re({loading:!0,error:null});try{const p=await yn.create(u);await p.connect();const f=await p.getPublicKey();re({signer:p,signerInfo:{type:"bunker",pubkey:f},loading:!1})}catch(p){re({error:p instanceof Error?p.message:"Login failed",loading:!1})}},[]),c=z.useCallback(()=>{var u;((u=Re.signerInfo)==null?void 0:u.type)==="bunker"&&Re.signer&&Re.signer.close(),re({signer:null,signerInfo:null,error:null})},[]),l=z.useCallback(()=>{re({error:null})},[]),d=z.useCallback(()=>{var u;return((u=Re.signerInfo)==null?void 0:u.type)==="temp"?Re.signer:null},[]);return{signer:t,signerInfo:e,loading:n,error:r,isLoggedIn:t!==null,loginWithNip07:o,loginWithTemp:s,loginWithNsec:i,loginWithBunker:a,logout:c,clearError:l,getTempSigner:d,isNip07Available:Wt.isAvailable()}}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ap(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function to(t,e=""){if(!Number.isSafeInteger(t)||t<0){const n=e&&`"${e}" `;throw new Error(`${n}expected integer >= 0, got ${t}`)}}function ae(t,e,n=""){const r=ap(t),o=t==null?void 0:t.length,s=e!==void 0;if(!r||s&&o!==e){const i=n&&`"${n}" `,a=s?` of length ${e}`:"",c=r?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return t}function Gi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function cp(t,e){ae(t,void 0,"digestInto() output");const n=e.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function no(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ro(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ne(t,e){return t<<32-e|t>>>e}const Yi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",lp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ce(t){if(ae(t),Yi)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=lp[t[n]];return e}const De={_0:48,_9:57,A:65,F:70,a:97,f:102};function Xi(t){if(t>=De._0&&t<=De._9)return t-De._0;if(t>=De.A&&t<=De.F)return t-(De.A-10);if(t>=De.a&&t<=De.f)return t-(De.a-10)}function lt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Yi)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=Xi(t.charCodeAt(s)),a=Xi(t.charCodeAt(s+1));if(i===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[o]=i*16+a}return r}function bn(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];ae(o),e+=o.length}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const s=t[r];n.set(s,o),o+=s.length}return n}function up(t,e={}){const n=(o,s)=>t(s).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function Qi(t=32){const e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(e==null?void 0:e.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}const dp=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function hp(t,e,n){return t&e^~t&n}function fp(t,e,n){return t&e^t&n^e&n}class pp{constructor(e,n,r,o){g(this,"blockLen");g(this,"outputLen");g(this,"padOffset");g(this,"isLE");g(this,"buffer");g(this,"view");g(this,"finished",!1);g(this,"length",0);g(this,"pos",0);g(this,"destroyed",!1);this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ro(this.buffer)}update(e){Gi(this),ae(e);const{view:n,buffer:r,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=ro(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gi(this),cp(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,no(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;r.setBigUint64(o-8,BigInt(this.length*8),s),this.process(r,0);const a=ro(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mp=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64);class gp extends pp{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)Ge[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=Ge[u-15],f=Ge[u-2],m=Ne(p,7)^Ne(p,18)^p>>>3,h=Ne(f,17)^Ne(f,19)^f>>>10;Ge[u]=h+Ge[u-7]+m+Ge[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=Ne(a,6)^Ne(a,11)^Ne(a,25),f=d+p+hp(a,c,l)+mp[u]+Ge[u]|0,h=(Ne(r,2)^Ne(r,13)^Ne(r,22))+fp(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){no(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),no(this.buffer)}}class yp extends gp{constructor(){super(32);g(this,"A",Je[0]|0);g(this,"B",Je[1]|0);g(this,"C",Je[2]|0);g(this,"D",Je[3]|0);g(this,"E",Je[4]|0);g(this,"F",Je[5]|0);g(this,"G",Je[6]|0);g(this,"H",Je[7]|0)}}const oo=up(()=>new yp,dp(1)),so=BigInt(0),io=BigInt(1);function ea(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}" `;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function bp(t){if(typeof t=="bigint"){if(!vp(t))throw new Error("positive bigint expected, got "+t)}else to(t);return t}function ta(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?so:BigInt("0x"+t)}function ao(t){return ta(ce(t))}function na(t){return ta(ce(wp(ae(t)).reverse()))}function co(t,e){to(e),t=bp(t);const n=lt(t.toString(16).padStart(e*2,"0"));if(n.length!==e)throw new Error("number too large");return n}function ra(t,e){return co(t,e).reverse()}function wp(t){return Uint8Array.from(t)}function oa(t){return Uint8Array.from(t,(e,n)=>{const r=e.charCodeAt(0);if(e.length!==1||r>127)throw new Error(`string contains non-ASCII character "${t[n]}" with code ${r} at position ${n}`);return r})}const vp=t=>typeof t=="bigint"&&so<=t;function Ep(t){let e;for(e=0;t>so;t>>=io,e+=1);return e}const sa=t=>(io<<BigInt(t))-io;function ia(t,e={},n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(s,i,a){const c=t[s];if(a&&c===void 0)return;const l=typeof c;if(l!==i||c===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${l}`)}const o=(s,i)=>Object.entries(s).forEach(([a,c])=>r(a,c,i));o(e,!1),o(n,!0)}function aa(t){const e=new WeakMap;return(n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const le=BigInt(0),oe=BigInt(1),ut=BigInt(2),ca=BigInt(3),la=BigInt(4),ua=BigInt(5),xp=BigInt(7),da=BigInt(8),kp=BigInt(9),ha=BigInt(16);function we(t,e){const n=t%e;return n>=le?n:e+n}function pe(t,e,n){let r=t;for(;e-- >le;)r*=r,r%=n;return r}function fa(t,e){if(t===le)throw new Error("invert: expected non-zero number");if(e<=le)throw new Error("invert: expected positive modulus, got "+e);let n=we(t,e),r=e,o=le,s=oe;for(;n!==le;){const a=r/n,c=r%n,l=o-s*a;r=n,n=c,o=s,s=l}if(r!==oe)throw new Error("invert: does not exist");return we(o,e)}function lo(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function pa(t,e){const n=(t.ORDER+oe)/la,r=t.pow(e,n);return lo(t,r,e),r}function _p(t,e){const n=(t.ORDER-ua)/da,r=t.mul(e,ut),o=t.pow(r,n),s=t.mul(e,o),i=t.mul(t.mul(s,ut),o),a=t.mul(s,t.sub(i,t.ONE));return lo(t,a,e),a}function Ap(t){const e=wn(t),n=ma(t),r=n(e,e.neg(e.ONE)),o=n(e,r),s=n(e,e.neg(r)),i=(t+xp)/ha;return(a,c)=>{let l=a.pow(c,i),d=a.mul(l,r);const u=a.mul(l,o),p=a.mul(l,s),f=a.eql(a.sqr(d),c),m=a.eql(a.sqr(u),c);l=a.cmov(l,d,f),d=a.cmov(p,u,m);const h=a.eql(a.sqr(d),c),y=a.cmov(l,d,h);return lo(a,y,c),y}}function ma(t){if(t<ca)throw new Error("sqrt is not defined for small field");let e=t-oe,n=0;for(;e%ut===le;)e/=ut,n++;let r=ut;const o=wn(t);for(;ya(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return pa;let s=o.pow(r,e);const i=(e+oe)/ut;return function(c,l){if(c.is0(l))return l;if(ya(c,l)!==1)throw new Error("Cannot find square root");let d=n,u=c.mul(c.ONE,s),p=c.pow(l,e),f=c.pow(l,i);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let m=1,h=c.sqr(p);for(;!c.eql(h,c.ONE);)if(m++,h=c.sqr(h),m===d)throw new Error("Cannot find square root");const y=oe<<BigInt(d-m-1),v=c.pow(u,y);d=m,u=c.sqr(v),p=c.mul(p,u),f=c.mul(f,v)}return f}}function Sp(t){return t%la===ca?pa:t%da===ua?_p:t%ha===kp?Ap(t):ma(t)}const Np=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cp(t){const e={ORDER:"bigint",BYTES:"number",BITS:"number"},n=Np.reduce((r,o)=>(r[o]="function",r),e);return ia(t,n),t}function Bp(t,e,n){if(n<le)throw new Error("invalid exponent, negatives unsupported");if(n===le)return t.ONE;if(n===oe)return e;let r=t.ONE,o=e;for(;n>le;)n&oe&&(r=t.mul(r,o)),o=t.sqr(o),n>>=oe;return r}function ga(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),o=e.reduce((i,a,c)=>t.is0(a)?i:(r[c]=i,t.mul(i,a)),t.ONE),s=t.inv(o);return e.reduceRight((i,a,c)=>t.is0(a)?i:(r[c]=t.mul(i,r[c]),t.mul(i,a)),s),r}function ya(t,e){const n=(t.ORDER-oe)/ut,r=t.pow(e,n),o=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Lp(t,e){e!==void 0&&to(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}class Ip{constructor(e,n={}){g(this,"ORDER");g(this,"BITS");g(this,"BYTES");g(this,"isLE");g(this,"ZERO",le);g(this,"ONE",oe);g(this,"_lengths");g(this,"_sqrt");g(this,"_mod");var i;if(e<=le)throw new Error("invalid field: expected ORDER > 0, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=(i=n.allowedLengths)==null?void 0:i.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:o,nByteLength:s}=Lp(e,r);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return we(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return le<=e&&e<this.ORDER}is0(e){return e===le}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&oe)===oe}neg(e){return we(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return we(e*e,this.ORDER)}add(e,n){return we(e+n,this.ORDER)}sub(e,n){return we(e-n,this.ORDER)}mul(e,n){return we(e*n,this.ORDER)}pow(e,n){return Bp(this,e,n)}div(e,n){return we(e*fa(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return fa(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=Sp(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?ra(e,this.BYTES):co(e,this.BYTES)}fromBytes(e,n=!1){ae(e);const{_lengths:r,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(r){if(!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);const l=new Uint8Array(o);l.set(e,s?0:l.length-e.length),e=l}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=s?na(e):ao(e);if(a&&(c=we(c,i)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return ga(this,e)}cmov(e,n,r){return r?n:e}}function wn(t,e={}){return new Ip(t,e)}function ba(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function $p(t){const e=ba(t);return e+Math.ceil(e/2)}function Tp(t,e,n=!1){ae(t);const r=t.length,o=ba(e),s=$p(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?na(t):ao(t),a=we(i,e-oe)+oe;return n?ra(a,o):co(a,o)}const _t=BigInt(0),dt=BigInt(1);function vn(t,e){const n=e.negate();return t?n:e}function wa(t,e){const n=ga(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function va(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function uo(t,e){va(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),o=2**t,s=sa(t),i=BigInt(t);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function Ea(t,e,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let a=Number(t&o),c=t>>i;a>r&&(a-=s,c+=dt);const l=e*r,d=l+Math.abs(a)-1,u=a===0,p=a<0,f=e%2!==0;return{nextN:c,offset:d,isZero:u,isNeg:p,isNegF:f,offsetF:l}}const ho=new WeakMap,xa=new WeakMap;function fo(t){return xa.get(t)||1}function ka(t){if(t!==_t)throw new Error("invalid wNAF")}class Pp{constructor(e,n){g(this,"BASE");g(this,"ZERO");g(this,"Fn");g(this,"bits");this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let o=e;for(;n>_t;)n&dt&&(r=r.add(o)),o=o.double(),n>>=dt;return r}precomputeWindow(e,n){const{windows:r,windowSize:o}=uo(n,this.bits),s=[];let i=e,a=i;for(let c=0;c<r;c++){a=i,s.push(a);for(let l=1;l<o;l++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=uo(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:c,offset:l,isZero:d,isNeg:u,isNegF:p,offsetF:f}=Ea(r,a,i);r=c,d?s=s.add(vn(p,n[f])):o=o.add(vn(u,n[l]))}return ka(r),{p:o,f:s}}wNAFUnsafe(e,n,r,o=this.ZERO){const s=uo(e,this.bits);for(let i=0;i<s.windows&&r!==_t;i++){const{nextN:a,offset:c,isZero:l,isNeg:d}=Ea(r,i,s);if(r=a,!l){const u=n[c];o=o.add(d?u.negate():u)}}return ka(r),o}getPrecomputes(e,n,r){let o=ho.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(o=r(o)),ho.set(n,o))),o}cached(e,n,r){const o=fo(e);return this.wNAF(o,this.getPrecomputes(o,e,r),n)}unsafe(e,n,r,o){const s=fo(e);return s===1?this._unsafeLadder(e,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),n,o)}createCache(e,n){va(n,this.bits),xa.set(e,n),ho.delete(e)}hasCache(e){return fo(e)!==1}}function Up(t,e,n,r){let o=e,s=t.ZERO,i=t.ZERO;for(;n>_t||r>_t;)n&dt&&(s=s.add(o)),r&dt&&(i=i.add(o)),o=o.double(),n>>=dt,r>>=dt;return{p1:s,p2:i}}function _a(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Cp(e),e}else return wn(t,{isLE:n})}function Op(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const l=e[c];if(!(typeof l=="bigint"&&l>_t))throw new Error(`CURVE.${c} must be positive bigint`)}const o=_a(e.p,n.Fp,r),s=_a(e.n,n.Fn,r),a=["Gx","Gy","a","b"];for(const c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function Rp(t,e){return function(r){const o=t(r);return{secretKey:o,publicKey:e(o)}}}oa("HashToScalar-");const Aa=(t,e)=>(t+(t>=0?e:-e)/Mp)/e;function Dp(t,e,n){const[[r,o],[s,i]]=e,a=Aa(i*t,n),c=Aa(-o*t,n);let l=t-a*r-c*s,d=-a*o-c*i;const u=l<Rt,p=d<Rt;u&&(l=-l),p&&(d=-d);const f=sa(Math.ceil(Ep(n)/2))+En;if(l<Rt||l>=f||d<Rt||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:u,k1:l,k2neg:p,k2:d}}const Rt=BigInt(0),En=BigInt(1),Mp=BigInt(2),xn=BigInt(3),Kp=BigInt(4);function Hp(t,e={}){const n=Op("weierstrass",t,e),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:a}=s;ia(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c}=e;if(c&&(!r.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=qp(r,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(R,k,w){const{x:E,y:A}=k.toAffine(),I=r.toBytes(E);if(ea(w,"isCompressed"),w){d();const C=!r.isOdd(A);return bn(zp(C),I)}else return bn(Uint8Array.of(4),I,r.toBytes(A))}function p(R){ae(R,void 0,"Point");const{publicKey:k,publicKeyUncompressed:w}=l,E=R.length,A=R[0],I=R.subarray(1);if(E===k&&(A===2||A===3)){const C=r.fromBytes(I);if(!r.isValid(C))throw new Error("bad point: is not on curve, wrong x");const $=h(C);let B;try{B=r.sqrt($)}catch(V){const W=V instanceof Error?": "+V.message:"";throw new Error("bad point: is not on curve, sqrt error"+W)}d();const P=r.isOdd(B);return(A&1)===1!==P&&(B=r.neg(B)),{x:C,y:B}}else if(E===w&&A===4){const C=r.BYTES,$=r.fromBytes(I.subarray(0,C)),B=r.fromBytes(I.subarray(C,C*2));if(!y($,B))throw new Error("bad point: is not on curve");return{x:$,y:B}}else throw new Error(`bad point: got length ${E}, expected compressed=${k} or uncompressed=${w}`)}const f=e.toBytes||u,m=e.fromBytes||p;function h(R){const k=r.sqr(R),w=r.mul(k,R);return r.add(r.add(w,r.mul(R,s.a)),s.b)}function y(R,k){const w=r.sqr(k),E=h(R);return r.eql(w,E)}if(!y(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const v=r.mul(r.pow(s.a,xn),Kp),x=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(v,x)))throw new Error("bad curve params: a or b");function S(R,k,w=!1){if(!r.isValid(k)||w&&r.is0(k))throw new Error(`bad point coordinate ${R}`);return k}function U(R){if(!(R instanceof H))throw new Error("Weierstrass Point expected")}function K(R){if(!c||!c.basises)throw new Error("no endo");return Dp(R,c.basises,o.ORDER)}const _=aa((R,k)=>{const{X:w,Y:E,Z:A}=R;if(r.eql(A,r.ONE))return{x:w,y:E};const I=R.is0();k==null&&(k=I?r.ONE:r.inv(A));const C=r.mul(w,k),$=r.mul(E,k),B=r.mul(A,k);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:C,y:$}}),N=aa(R=>{if(R.is0()){if(e.allowInfinityPoint&&!r.is0(R.Y))return;throw new Error("bad point: ZERO")}const{x:k,y:w}=R.toAffine();if(!r.isValid(k)||!r.isValid(w))throw new Error("bad point: x or y not field elements");if(!y(k,w))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(R,k,w,E,A){return w=new H(r.mul(w.X,R),w.Y,w.Z),k=vn(E,k),w=vn(A,w),k.add(w)}const D=class D{constructor(k,w,E){g(this,"X");g(this,"Y");g(this,"Z");this.X=S("x",k),this.Y=S("y",w,!0),this.Z=S("z",E),Object.freeze(this)}static CURVE(){return s}static fromAffine(k){const{x:w,y:E}=k||{};if(!k||!r.isValid(w)||!r.isValid(E))throw new Error("invalid affine point");if(k instanceof D)throw new Error("projective point not allowed");return r.is0(w)&&r.is0(E)?D.ZERO:new D(w,E,r.ONE)}static fromBytes(k){const w=D.fromAffine(m(ae(k,void 0,"point")));return w.assertValidity(),w}static fromHex(k){return D.fromBytes(lt(k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,w=!0){return O.createCache(this,k),w||this.multiply(xn),this}assertValidity(){N(this)}hasEvenY(){const{y:k}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(k)}equals(k){U(k);const{X:w,Y:E,Z:A}=this,{X:I,Y:C,Z:$}=k,B=r.eql(r.mul(w,$),r.mul(I,A)),P=r.eql(r.mul(E,$),r.mul(C,A));return B&&P}negate(){return new D(this.X,r.neg(this.Y),this.Z)}double(){const{a:k,b:w}=s,E=r.mul(w,xn),{X:A,Y:I,Z:C}=this;let $=r.ZERO,B=r.ZERO,P=r.ZERO,q=r.mul(A,A),V=r.mul(I,I),W=r.mul(C,C),F=r.mul(A,I);return F=r.add(F,F),P=r.mul(A,C),P=r.add(P,P),$=r.mul(k,P),B=r.mul(E,W),B=r.add($,B),$=r.sub(V,B),B=r.add(V,B),B=r.mul($,B),$=r.mul(F,$),P=r.mul(E,P),W=r.mul(k,W),F=r.sub(q,W),F=r.mul(k,F),F=r.add(F,P),P=r.add(q,q),q=r.add(P,q),q=r.add(q,W),q=r.mul(q,F),B=r.add(B,q),W=r.mul(I,C),W=r.add(W,W),q=r.mul(W,F),$=r.sub($,q),P=r.mul(W,V),P=r.add(P,P),P=r.add(P,P),new D($,B,P)}add(k){U(k);const{X:w,Y:E,Z:A}=this,{X:I,Y:C,Z:$}=k;let B=r.ZERO,P=r.ZERO,q=r.ZERO;const V=s.a,W=r.mul(s.b,xn);let F=r.mul(w,I),X=r.mul(E,C),se=r.mul(A,$),ue=r.add(w,E),J=r.add(I,C);ue=r.mul(ue,J),J=r.add(F,X),ue=r.sub(ue,J),J=r.add(w,A);let de=r.add(I,$);return J=r.mul(J,de),de=r.add(F,se),J=r.sub(J,de),de=r.add(E,A),B=r.add(C,$),de=r.mul(de,B),B=r.add(X,se),de=r.sub(de,B),q=r.mul(V,J),B=r.mul(W,se),q=r.add(B,q),B=r.sub(X,q),q=r.add(X,q),P=r.mul(B,q),X=r.add(F,F),X=r.add(X,F),se=r.mul(V,se),J=r.mul(W,J),X=r.add(X,se),se=r.sub(F,se),se=r.mul(V,se),J=r.add(J,se),F=r.mul(X,J),P=r.add(P,F),F=r.mul(de,J),B=r.mul(ue,B),B=r.sub(B,F),F=r.mul(ue,X),q=r.mul(de,q),q=r.add(q,F),new D(B,P,q)}subtract(k){return this.add(k.negate())}is0(){return this.equals(D.ZERO)}multiply(k){const{endo:w}=e;if(!o.isValidNot0(k))throw new Error("invalid scalar: out of range");let E,A;const I=C=>O.cached(this,C,$=>wa(D,$));if(w){const{k1neg:C,k1:$,k2neg:B,k2:P}=K(k),{p:q,f:V}=I($),{p:W,f:F}=I(P);A=V.add(F),E=L(w.beta,q,W,C,B)}else{const{p:C,f:$}=I(k);E=C,A=$}return wa(D,[E,A])[0]}multiplyUnsafe(k){const{endo:w}=e,E=this;if(!o.isValid(k))throw new Error("invalid scalar: out of range");if(k===Rt||E.is0())return D.ZERO;if(k===En)return E;if(O.hasCache(this))return this.multiply(k);if(w){const{k1neg:A,k1:I,k2neg:C,k2:$}=K(k),{p1:B,p2:P}=Up(D,E,I,$);return L(w.beta,B,P,A,C)}else return O.unsafe(E,k)}toAffine(k){return _(this,k)}isTorsionFree(){const{isTorsionFree:k}=e;return i===En?!0:k?k(D,this):O.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:k}=e;return i===En?this:k?k(D,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(k=!0){return ea(k,"isCompressed"),this.assertValidity(),f(D,this,k)}toHex(k=!0){return ce(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};g(D,"BASE",new D(s.Gx,s.Gy,r.ONE)),g(D,"ZERO",new D(r.ZERO,r.ONE,r.ZERO)),g(D,"Fp",r),g(D,"Fn",o);let H=D;const T=o.BITS,O=new Pp(H,e.endo?Math.ceil(T/2):T);return H.BASE.precompute(8),H}function zp(t){return Uint8Array.of(t?2:3)}function qp(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}const kn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Vp={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},jp=BigInt(0),po=BigInt(2);function Fp(t){const e=kn.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,d=l*l*t%e,u=pe(d,n,e)*d%e,p=pe(u,n,e)*d%e,f=pe(p,po,e)*l%e,m=pe(f,o,e)*f%e,h=pe(m,s,e)*m%e,y=pe(h,a,e)*h%e,v=pe(y,c,e)*y%e,x=pe(v,a,e)*h%e,S=pe(x,n,e)*d%e,U=pe(S,i,e)*m%e,K=pe(U,r,e)*l%e,_=pe(K,po,e);if(!_n.eql(_n.sqr(_),t))throw new Error("Cannot find square root");return _}const _n=wn(kn.p,{sqrt:Fp}),At=Hp(kn,{Fp:_n,endo:Vp}),Sa={};function An(t,...e){let n=Sa[t];if(n===void 0){const r=oo(oa(t));n=bn(r,r),Sa[t]=n}return oo(bn(n,...e))}const mo=t=>t.toBytes(!0).slice(1),go=t=>t%po===jp;function yo(t){const{Fn:e,BASE:n}=At,r=e.fromBytes(t),o=n.multiply(r);return{scalar:go(o.y)?r:e.neg(r),bytes:mo(o)}}function Na(t){const e=_n;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const n=e.create(t*t),r=e.create(n*t+BigInt(7));let o=e.sqrt(r);go(o)||(o=e.neg(o));const s=At.fromAffine({x:t,y:o});return s.assertValidity(),s}const Dt=ao;function Ca(...t){return At.Fn.create(Dt(An("BIP0340/challenge",...t)))}function Ba(t){return yo(t).bytes}function Wp(t,e,n=Qi(32)){const{Fn:r}=At,o=ae(t,void 0,"message"),{bytes:s,scalar:i}=yo(e),a=ae(n,32,"auxRand"),c=r.toBytes(i^Dt(An("BIP0340/aux",a))),l=An("BIP0340/nonce",c,s,o),{bytes:d,scalar:u}=yo(l),p=Ca(d,s,o),f=new Uint8Array(64);if(f.set(d,0),f.set(r.toBytes(r.create(u+p*i)),32),!La(f,o,s))throw new Error("sign: Invalid signature produced");return f}function La(t,e,n){const{Fp:r,Fn:o,BASE:s}=At,i=ae(t,64,"signature"),a=ae(e,void 0,"message"),c=ae(n,32,"publicKey");try{const l=Na(Dt(c)),d=Dt(i.subarray(0,32));if(!r.isValidNot0(d))return!1;const u=Dt(i.subarray(32,64));if(!o.isValidNot0(u))return!1;const p=Ca(o.toBytes(d),mo(l),a),f=s.multiplyUnsafe(u).add(l.multiplyUnsafe(o.neg(p))),{x:m,y:h}=f.toAffine();return!(f.is0()||!go(h)||m!==d)}catch{return!1}}const Mt=(()=>{const n=(r=Qi(48))=>Tp(r,kn.n);return{keygen:Rp(n,Ba),getPublicKey:Ba,sign:Wp,verify:La,Point:At,utils:{randomSecretKey:n,taggedHash:An,lift_x:Na,pointToBytes:mo},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),ht=Symbol("verified"),Zp=t=>t instanceof Object;function Jp(t){if(!Zp(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}const Sn=new TextDecoder("utf-8"),Gp=new TextEncoder;function Ye(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}class Yp{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}}class Xp{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Yp(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}}class Qp{generateSecretKey(){return Mt.utils.randomSecretKey()}getPublicKey(e){return ce(Mt.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ce(Mt.getPublicKey(n)),r.id=bo(r),r.sig=ce(Mt.sign(lt(bo(r)),n)),r[ht]=!0,r}verifyEvent(e){if(typeof e[ht]=="boolean")return e[ht];const n=bo(e);if(n!==e.id)return e[ht]=!1,!1;try{const r=Mt.verify(lt(e.sig),lt(n),lt(e.pubkey));return e[ht]=r,r}catch{return e[ht]=!1,!1}}}function em(t){if(!Jp(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function bo(t){let e=oo(Gp.encode(em(t)));return ce(e)}const Nn=new Qp;Nn.generateSecretKey,Nn.getPublicKey,Nn.finalizeEvent;const tm=Nn.verifyEvent,nm=22242;function rm(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([s,i])=>s===n.slice(1)&&o.indexOf(i)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function om(t,e){for(let n=0;n<t.length;n++)if(rm(t[n],e))return!0;return!1}function sm(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function im(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function am(t,e){return{kind:nm,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function cm(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}const lm=t=>(t[ht]=!0,!0);class Ia extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}}class wo{constructor(e,n){g(this,"url");g(this,"_connected",!1);g(this,"onclose",null);g(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));g(this,"onauth");g(this,"baseEoseTimeout",4400);g(this,"publishTimeout",4400);g(this,"pingFrequency",29e3);g(this,"pingTimeout",2e4);g(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);g(this,"openSubs",new Map);g(this,"enablePing");g(this,"enableReconnect");g(this,"reconnectTimeoutHandle");g(this,"pingIntervalHandle");g(this,"reconnectAttempts",0);g(this,"closedIntentionally",!1);g(this,"connectionPromise");g(this,"openCountRequests",new Map);g(this,"openEventPublishes",new Map);g(this,"ws");g(this,"incomingMessageQueue",new Xp);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=Ye(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket,this.enablePing=n.enablePing,this.enableReconnect=n.enableReconnect||!1}static async connect(e,n){const r=new wo(e,n);return await r.connect(n),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},e)}handleHardClose(e){var r;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,(r=this.onclose)==null||r.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(e)}async connect(e){let n;return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((r,o)=>{e!=null&&e.timeout&&(n=setTimeout(()=>{var s;o("connection timed out"),this.connectionPromise=void 0,(s=this.onclose)==null||s.call(this),this.closeAllSubscriptions("relay connection timed out")},e.timeout)),e!=null&&e.abort&&(e.abort.onabort=o);try{this.ws=new this._WebSocket(this.url)}catch(s){clearTimeout(n),o(s);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(n),this._connected=!0;const s=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const i of this.openSubs.values()){if(i.eosed=!1,s)for(let a=0;a<i.filters.length;a++)i.lastEmitted&&(i.filters[a].since=i.lastEmitted+1);i.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),r()},this.ws.onerror=s=>{clearTimeout(n),o(s.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=s=>{clearTimeout(n),o(s.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,n)=>{if(!this.connectionPromise)return n(new Error(`no connection to ${this.url}, can't ping`));try{const r=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),r.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(r){n(r)}})}async pingpong(){var e,n,r;((e=this.ws)==null?void 0:e.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(s=>setTimeout(()=>s(!1),this.pingTimeout))])||((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await cm();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=im(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=sm(e,"id"),c=(r=i.alreadyHaveEvent)==null?void 0:r.call(i,a);if((o=i.receivedEvent)==null||o.call(i,this,a),c)return}try{let i=JSON.parse(e);switch(i[0]){case"EVENT":{const a=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&om(a.filters,c)&&a.onevent(c),(!a.lastEmitted||a.lastEmitted<c.created_at)&&(a.lastEmitted=c.created_at);return}case"COUNT":{const a=i[1],c=i[2],l=this.openCountRequests.get(a);l&&(l.resolve(c.count),this.openCountRequests.delete(a));return}case"EOSE":{const a=this.openSubs.get(i[1]);if(!a)return;a.receivedEose();return}case"OK":{const a=i[1],c=i[2],l=i[3],d=this.openEventPublishes.get(a);d&&(clearTimeout(d.timeout),c?d.resolve(l):d.reject(new Error(l)),this.openEventPublishes.delete(a));return}case"CLOSED":{const a=i[1],c=this.openSubs.get(a);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":{this.onnotice(i[1]);return}case"AUTH":{this.challenge=i[1],this.onauth&&this.auth(this.onauth);return}default:{const a=this.openSubs.get(i[1]);(s=a==null?void 0:a.oncustom)==null||s.call(a,i);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Ia(e,this.url);this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){const n=this.challenge;if(!n)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,o)=>{try{let s=await e(am(this.url,n)),i=setTimeout(()=>{let a=this.openEventPublishes.get(s.id);a&&(a.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:r,reject:o,timeout:i}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(s){console.warn("subscribe auth function failed:",s)}}),this.authPromise)}async publish(e){const n=new Promise((r,o)=>{const s=setTimeout(()=>{const i=this.openEventPublishes.get(e.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:r,reject:o,timeout:s})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((s,i)=>{this.openCountRequests.set(r,{resolve:s,reject:i})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),n.abort&&(n.abort.onabort=()=>r.close(String(n.abort.reason||"<aborted>"))),r}prepareSubscription(e,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new um(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e,n,r;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.onclose)==null||e.call(this),((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close())}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}}class um{constructor(e,n,r,o){g(this,"relay");g(this,"id");g(this,"lastEmitted");g(this,"closed",!1);g(this,"eosed",!1);g(this,"filters");g(this,"alreadyHaveEvent");g(this,"receivedEvent");g(this,"onevent");g(this,"oneose");g(this,"onclose");g(this,"oncustom");g(this,"eoseTimeout");g(this,"eoseTimeoutHandle");if(r.length===0)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(s=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,s)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(r){if(!(r instanceof Ia))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}}class dm{constructor(e){g(this,"relays",new Map);g(this,"seenOn",new Map);g(this,"trackRelays",!1);g(this,"verifyEvent");g(this,"enablePing");g(this,"enableReconnect");g(this,"automaticallyAuth");g(this,"trustedRelayURLs",new Set);g(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,n){e=Ye(e);let r=this.relays.get(e);if(r||(r=new wo(e,{verifyEvent:this.trustedRelayURLs.has(e)?lm:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),r.onclose=()=>{r&&!r.enableReconnect&&this.relays.delete(e)},this.relays.set(e,r)),this.automaticallyAuth){const o=this.automaticallyAuth(e);o&&(r.onauth=o)}return await r.connect({timeout:n==null?void 0:n.connectionTimeout,abort:n==null?void 0:n.abort}),r}close(e){e.map(Ye).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close(),this.relays.delete(n)})}subscribe(e,n,r){const o=[];for(let s=0;s<e.length;s++){const i=Ye(e[s]);o.find(a=>a.url===i)||o.push({url:i,filter:n})}return this.subscribeMap(o,r)}subscribeMany(e,n,r){const o=[],s=[];for(let i=0;i<e.length;i++){const a=Ye(e[i]);s.indexOf(a)===-1&&(s.push(a),o.push({url:a,filter:n}))}return this.subscribeMap(o,r)}subscribeMap(e,n){const r=new Map;for(const f of e){const{url:m,filter:h}=f;r.has(m)||r.set(m,[]),r.get(m).push(h)}const o=Array.from(r.entries()).map(([f,m])=>({url:f,filters:m}));this.trackRelays&&(n.receivedEvent=(f,m)=>{let h=this.seenOn.get(m);h||(h=new Set,this.seenOn.set(m,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var m;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((m=n.oneose)==null||m.call(n),c=()=>{}))};const l=[];let d=(f,m)=>{var h;l[f]||(c(f),l[f]=m,l.filter(y=>y).length===o.length&&((h=n.onclose)==null||h.call(n,l),d=()=>{}))};const u=f=>{var h;if((h=n.alreadyHaveEvent)!=null&&h.call(n,f))return!0;const m=s.has(f);return s.add(f),m},p=Promise.all(o.map(async({url:f,filters:m},h)=>{let y;try{y=await this.ensureRelay(f,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0,abort:n.abort})}catch(x){d(h,(x==null?void 0:x.message)||String(x));return}let v=y.subscribe(m,{...n,oneose:()=>c(h),onclose:x=>{x.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(m,{...n,oneose:()=>c(h),onclose:S=>{d(h,S)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort})}).catch(S=>{d(h,`auth was required and attempted, but failed with: ${S}`)}):d(h,x)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await p,i.forEach(m=>{m.close(f)})}}}subscribeEose(e,n,r){const o=this.subscribe(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}async querySync(e,n,r){return new Promise(async o=>{const s=[];this.subscribeEose(e,n,{...r,onevent(i){s.push(i)},onclose(i){o(s)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((s,i)=>i.created_at-s.created_at),o[0]||null}publish(e,n,r){return e.map(Ye).map(async(o,s,i)=>{if(i.indexOf(o)!==s)return Promise.reject("duplicate url");let a=await this.ensureRelay(o);return a.publish(n).catch(async c=>{if(c instanceof Error&&c.message.startsWith("auth-required: ")&&(r!=null&&r.onauth))return await a.auth(r.onauth),a.publish(n);throw c}).then(c=>{if(this.trackRelays){let l=this.seenOn.get(n.id);l||(l=new Set,this.seenOn.set(n.id,l)),l.add(a)}return c})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}}var $a;try{$a=WebSocket}catch{}class hm extends dm{constructor(e){super({verifyEvent:tm,websocketImplementation:$a,...e})}}var fm=Math.pow(2,8)-1,pm=Math.pow(2,16)-1,mm=Math.pow(2,32)-1;const gm=function(t){var e=t-1;if(e<=fm)return Uint8Array;if(e<=pm)return Uint16Array;if(e<=mm)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};function Xe(t){if(this.capacity=t,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var e=gm(t);this.forward=new e(t),this.backward=new e(t),this.K=new Array(t),this.V=new Array(t),this.size=0,this.head=0,this.tail=0,this.items={}}Xe.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},Xe.prototype.splayOnTop=function(t){var e=this.head;if(this.head===t)return this;var n=this.backward[t],r=this.forward[t];return this.tail===t?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[e]=t,this.head=t,this.forward[t]=e,this},Xe.prototype.set=function(t,e){var n=this.items[t];if(typeof n<"u"){this.splayOnTop(n),this.V[n]=e;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[t]=n,this.K[n]=t,this.V[n]=e,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},Xe.prototype.setpop=function(t,e){var n=null,r=null,o=this.items[t];return typeof o<"u"?(this.splayOnTop(o),n=this.V[o],this.V[o]=e,{evicted:!1,key:t,value:n}):(this.size<this.capacity?o=this.size++:(o=this.tail,this.tail=this.backward[o],n=this.V[o],r=this.K[o],delete this.items[r]),this.items[t]=o,this.K[o]=t,this.V[o]=e,this.forward[o]=this.head,this.backward[this.head]=o,this.head=o,r?{evicted:!0,key:r,value:n}:null)},Xe.prototype.has=function(t){return t in this.items},Xe.prototype.get=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.splayOnTop(e),this.V[e]},Xe.prototype.peek=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.V[e]};class Ta{constructor(e,n){g(this,"_batchLoadFn");g(this,"_maxBatchSize");g(this,"_cacheKeyFn");g(this,"_cacheMap");g(this,"_batch");if(typeof e!="function")throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`);this._batchLoadFn=e,this._maxBatchSize=(n==null?void 0:n.maxBatchSize)||1/0,this._cacheKeyFn=n==null?void 0:n.cacheKeyFn;const r=new Xe(2e3);this._cacheMap={get:n.transformCacheHit?o=>{var s;return(s=r.get(o))==null?void 0:s.then(n.transformCacheHit)}:o=>r.get(o),set(o,s){return r.set(o,s)},delete(o){r.set(o,void 0)},clear(){r.clear()}},this._batch=null}load(e){if(e==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const n=ym(this),r=this._cacheKeyFn(e),o=this._cacheMap.get(r);if(o){const i=n.cacheHits||(n.cacheHits=[]);return new Promise(a=>{i.push(()=>{a(o)})})}n.keys.push(e);const s=new Promise((i,a)=>{n.callbacks.push({resolve:i,reject:a})});return this._cacheMap.set(r,s),s}clear(e){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);n.delete(r)}return this}}function ym(t){const e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const n={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=n,setTimeout(()=>{bm(t,n)}),n}function bm(t,e){if(e.hasDispatched=!0,e.keys.length===0){Eo(e);return}let n;try{n=t._batchLoadFn(e.keys)}catch(r){return vo(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(r)}.`))}if(!n||typeof n.then!="function")return vo(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(n)}.`));n.then(r=>{if(r.length!==e.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
2
+ (function(K,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],b):(K=typeof globalThis<"u"?globalThis:K||self,b(K.NostrComments={},K.jsxRuntime,K.React))})(this,(function(K,b,z){"use strict";var ug=Object.defineProperty;var dg=(K,b,z)=>b in K?ug(K,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):K[b]=z;var g=(K,b,z)=>dg(K,typeof b!="symbol"?b+"":b,z);class Wt{constructor(){g(this,"cachedPubKey")}static isAvailable(){return typeof window<"u"&&!!window.nostr}async getPublicKey(){if(!window.nostr)throw new Error("NIP-07 extension not available");return this.cachedPubKey||(this.cachedPubKey=await window.nostr.getPublicKey()),this.cachedPubKey}async signEvent(e){if(!window.nostr)throw new Error("NIP-07 extension not available");return window.nostr.signEvent(e)}}function Ho(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function zo(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Dc(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ho(t.outputLen),Ho(t.blockLen)}function Zt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Kc(t,e){zo(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Hn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qo=t=>t instanceof Uint8Array,zn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ee=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Hc(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function qn(t){if(typeof t=="string"&&(t=Hc(t)),!qo(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function zc(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!qo(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let Vo=class{clone(){return this._cloneInto()}};function qc(t){const e=r=>t().update(qn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function jo(t=32){if(Hn&&typeof Hn.getRandomValues=="function")return Hn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Vc(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+l,a,r)}let jc=class extends Vo{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=zn(this.buffer)}update(e){Zt(this);const{view:n,buffer:r,blockLen:o}=this;e=qn(e);const s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=zn(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zt(this),Kc(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;Vc(r,o-8,BigInt(this.length*8),s),this.process(r,0);const a=zn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%n&&e.buffer.set(r),e}};const Fc=(t,e,n)=>t&e^~t&n,Wc=(t,e,n)=>t&e^t&n^e&n,Zc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ze=new Uint32Array(64);let Jc=class extends jc{constructor(){super(64,32,8,!1),this.A=He[0]|0,this.B=He[1]|0,this.C=He[2]|0,this.D=He[3]|0,this.E=He[4]|0,this.F=He[5]|0,this.G=He[6]|0,this.H=He[7]|0}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)ze[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=ze[u-15],f=ze[u-2],m=Ee(p,7)^Ee(p,18)^p>>>3,h=Ee(f,17)^Ee(f,19)^f>>>10;ze[u]=h+ze[u-7]+m+ze[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=Ee(a,6)^Ee(a,11)^Ee(a,25),f=d+p+Fc(a,c,l)+Zc[u]+ze[u]|0,h=(Ee(r,2)^Ee(r,13)^Ee(r,22))+Wc(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){ze.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Vn=qc(()=>new Jc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const Gc=BigInt(1),Yc=BigInt(2),Jt=t=>t instanceof Uint8Array,Xc=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ft(t){if(!Jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Xc[t[n]];return e}function jn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function It(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}function ie(t){return jn(ft(t))}function Fn(t){if(!Jt(t))throw new Error("Uint8Array expected");return jn(ft(Uint8Array.from(t).reverse()))}function qe(t,e){return It(t.toString(16).padStart(e*2,"0"))}function Wn(t,e){return qe(t,e).reverse()}function te(t,e,n){let r;if(typeof e=="string")try{r=It(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function tt(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}const Zn=t=>(Yc<<BigInt(t-1))-Gc,Jn=t=>new Uint8Array(t),Fo=t=>Uint8Array.from(t);function Wo(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Jn(t),o=Jn(t),s=0;const i=()=>{r.fill(1),o.fill(0),s=0},a=(...u)=>n(o,r,...u),c=(u=Jn())=>{o=a(Fo([0]),u),r=a(),u.length!==0&&(o=a(Fo([1]),u),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const p=[];for(;u<e;){r=a();const f=r.slice();p.push(f),u+=r.length}return tt(...p)};return(u,p)=>{i(),c(u);let f;for(;!(f=p(l()));)c();return i(),f}}const Qc={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function $t(t,e,n={}){const r=(o,s,i)=>{const a=Qc[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const c=t[o];if(!(i&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(const[o,s]of Object.entries(e))r(o,s,!1);for(const[o,s]of Object.entries(n))r(o,s,!0);return t}const el=Object.freeze(Object.defineProperty({__proto__:null,bitMask:Zn,bytesToHex:ft,bytesToNumberBE:ie,bytesToNumberLE:Fn,concatBytes:tt,createHmacDrbg:Wo,ensureBytes:te,hexToBytes:It,hexToNumber:jn,numberToBytesBE:qe,numberToBytesLE:Wn,validateObject:$t},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Q=BigInt(0),G=BigInt(1),nt=BigInt(2),tl=BigInt(3),Gn=BigInt(4),Zo=BigInt(5),Jo=BigInt(8);BigInt(9),BigInt(16);function ee(t,e){const n=t%e;return n>=Q?n:e+n}function nl(t,e,n){if(n<=Q||e<Q)throw new Error("Expected power/modulo > 0");if(n===G)return Q;let r=G;for(;e>Q;)e&G&&(r=r*t%n),t=t*t%n,e>>=G;return r}function he(t,e,n){let r=t;for(;e-- >Q;)r*=r,r%=n;return r}function Yn(t,e){if(t===Q||e<=Q)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ee(t,e),r=e,o=Q,s=G;for(;n!==Q;){const a=r/n,c=r%n,l=o-s*a;r=n,n=c,o=s,s=l}if(r!==G)throw new Error("invert: does not exist");return ee(o,e)}function rl(t){const e=(t-G)/nt;let n,r,o;for(n=t-G,r=0;n%nt===Q;n/=nt,r++);for(o=nt;o<t&&nl(o,e,t)!==t-G;o++);if(r===1){const i=(t+G)/Gn;return function(c,l){const d=c.pow(l,i);if(!c.eql(c.sqr(d),l))throw new Error("Cannot find square root");return d}}const s=(n+G)/nt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,d=a.pow(a.mul(a.ONE,o),n),u=a.pow(c,s),p=a.pow(c,n);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let f=1;for(let h=a.sqr(p);f<l&&!a.eql(h,a.ONE);f++)h=a.sqr(h);const m=a.pow(d,G<<BigInt(l-f-1));d=a.sqr(m),u=a.mul(u,m),p=a.mul(p,d),l=f}return u}}function ol(t){if(t%Gn===tl){const e=(t+G)/Gn;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(t%Jo===Zo){const e=(t-Zo)/Jo;return function(r,o){const s=r.mul(o,nt),i=r.pow(s,e),a=r.mul(o,i),c=r.mul(r.mul(a,nt),i),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return rl(t)}const sl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function il(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=sl.reduce((r,o)=>(r[o]="function",r),e);return $t(t,n)}function al(t,e,n){if(n<Q)throw new Error("Expected power > 0");if(n===Q)return t.ONE;if(n===G)return e;let r=t.ONE,o=e;for(;n>Q;)n&G&&(r=t.mul(r,o)),o=t.sqr(o),n>>=G;return r}function cl(t,e){const n=new Array(e.length),r=e.reduce((s,i,a)=>t.is0(i)?s:(n[a]=s,t.mul(s,i)),t.ONE),o=t.inv(r);return e.reduceRight((s,i,a)=>t.is0(i)?s:(n[a]=t.mul(s,n[a]),t.mul(s,i)),o),n}function Go(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ll(t,e,n=!1,r={}){if(t<=Q)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:s}=Go(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=ol(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:s,MASK:Zn(o),ZERO:Q,ONE:G,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Q<=c&&c<t},is0:c=>c===Q,isOdd:c=>(c&G)===G,neg:c=>ee(-c,t),eql:(c,l)=>c===l,sqr:c=>ee(c*c,t),add:(c,l)=>ee(c+l,t),sub:(c,l)=>ee(c-l,t),mul:(c,l)=>ee(c*l,t),pow:(c,l)=>al(a,c,l),div:(c,l)=>ee(c*Yn(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Yn(c,t),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>cl(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>n?Wn(c,s):qe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return n?Fn(c):ie(c)}});return Object.freeze(a)}function Yo(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Xo(t){const e=Yo(t);return e+Math.ceil(e/2)}function ul(t,e,n=!1){const r=t.length,o=Yo(e),s=Xo(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const i=n?ie(t):Fn(t),a=ee(i,e-G)+G;return n?Wn(a,o):qe(a,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dl=BigInt(0),Xn=BigInt(1);function hl(t,e){const n=(o,s)=>{const i=s.negate();return o?i:s},r=o=>{const s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:n,unsafeLadder(o,s){let i=t.ZERO,a=o;for(;s>dl;)s&Xn&&(i=i.add(a)),a=a.double(),s>>=Xn;return i},precomputeWindow(o,s){const{windows:i,windowSize:a}=r(s),c=[];let l=o,d=l;for(let u=0;u<i;u++){d=l,c.push(d);for(let p=1;p<a;p++)d=d.add(l),c.push(d);l=d.double()}return c},wNAF(o,s,i){const{windows:a,windowSize:c}=r(o);let l=t.ZERO,d=t.BASE;const u=BigInt(2**o-1),p=2**o,f=BigInt(o);for(let m=0;m<a;m++){const h=m*c;let y=Number(i&u);i>>=f,y>c&&(y-=p,i+=Xn);const v=h,x=h+Math.abs(y)-1,S=m%2!==0,M=y<0;y===0?d=d.add(n(S,s[v])):l=l.add(n(M,s[x]))}return{p:l,f:d}},wNAFCached(o,s,i,a){const c=o._WINDOW_SIZE||1;let l=s.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&s.set(o,a(l))),this.wNAF(c,l,i)}}}function Qo(t){return il(t.Fp),$t(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Go(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function fl(t){const e=Qo(t);$t(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=e;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:pl,hexToBytes:ml}=el,rt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=rt;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:pl(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=rt,n=typeof t=="string"?ml(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:s}=rt._parseInt(n.subarray(2)),{d:i,l:a}=rt._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const d=l.toString(16);return d.length&1?`0${d}`:d},r=e(n(t.s)),o=e(n(t.r)),s=r.length/2,i=o.length/2,a=n(s),c=n(i);return`30${n(i+s+4)}02${c}${o}02${a}${r}`}},Be=BigInt(0),fe=BigInt(1);BigInt(2);const es=BigInt(3);BigInt(4);function gl(t){const e=fl(t),{Fp:n}=e,r=e.toBytes||((m,h,y)=>{const v=h.toAffine();return tt(Uint8Array.from([4]),n.toBytes(v.x),n.toBytes(v.y))}),o=e.fromBytes||(m=>{const h=m.subarray(1),y=n.fromBytes(h.subarray(0,n.BYTES)),v=n.fromBytes(h.subarray(n.BYTES,2*n.BYTES));return{x:y,y:v}});function s(m){const{a:h,b:y}=e,v=n.sqr(m),x=n.mul(v,m);return n.add(n.add(x,n.mul(m,h)),y)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(m){return typeof m=="bigint"&&Be<m&&m<e.n}function a(m){if(!i(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){const{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:v,n:x}=e;if(h&&typeof m!="bigint"){if(m instanceof Uint8Array&&(m=ft(m)),typeof m!="string"||!h.includes(m.length))throw new Error("Invalid key");m=m.padStart(y*2,"0")}let S;try{S=typeof m=="bigint"?m:ie(te("private key",m,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof m}`)}return v&&(S=ee(S,x)),a(S),S}const l=new Map;function d(m){if(!(m instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(h,y,v){if(this.px=h,this.py=y,this.pz=v,h==null||!n.isValid(h))throw new Error("x required");if(y==null||!n.isValid(y))throw new Error("y required");if(v==null||!n.isValid(v))throw new Error("z required")}static fromAffine(h){const{x:y,y:v}=h||{};if(!h||!n.isValid(y)||!n.isValid(v))throw new Error("invalid affine point");if(h instanceof u)throw new Error("projective point not allowed");const x=S=>n.eql(S,n.ZERO);return x(y)&&x(v)?u.ZERO:new u(y,v,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){const y=n.invertBatch(h.map(v=>v.pz));return h.map((v,x)=>v.toAffine(y[x])).map(u.fromAffine)}static fromHex(h){const y=u.fromAffine(o(te("pointHex",h)));return y.assertValidity(),y}static fromPrivateKey(h){return u.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:h,y}=this.toAffine();if(!n.isValid(h)||!n.isValid(y))throw new Error("bad point: x or y not FE");const v=n.sqr(y),x=s(h);if(!n.eql(v,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:h}=this.toAffine();if(n.isOdd)return!n.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){d(h);const{px:y,py:v,pz:x}=this,{px:S,py:M,pz:R}=h,_=n.eql(n.mul(y,R),n.mul(S,x)),N=n.eql(n.mul(v,R),n.mul(M,x));return _&&N}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:h,b:y}=e,v=n.mul(y,es),{px:x,py:S,pz:M}=this;let R=n.ZERO,_=n.ZERO,N=n.ZERO,L=n.mul(x,x),H=n.mul(S,S),U=n.mul(M,M),T=n.mul(x,S);return T=n.add(T,T),N=n.mul(x,M),N=n.add(N,N),R=n.mul(h,N),_=n.mul(v,U),_=n.add(R,_),R=n.sub(H,_),_=n.add(H,_),_=n.mul(R,_),R=n.mul(T,R),N=n.mul(v,N),U=n.mul(h,U),T=n.sub(L,U),T=n.mul(h,T),T=n.add(T,N),N=n.add(L,L),L=n.add(N,L),L=n.add(L,U),L=n.mul(L,T),_=n.add(_,L),U=n.mul(S,M),U=n.add(U,U),L=n.mul(U,T),R=n.sub(R,L),N=n.mul(U,H),N=n.add(N,N),N=n.add(N,N),new u(R,_,N)}add(h){d(h);const{px:y,py:v,pz:x}=this,{px:S,py:M,pz:R}=h;let _=n.ZERO,N=n.ZERO,L=n.ZERO;const H=e.a,U=n.mul(e.b,es);let T=n.mul(y,S),O=n.mul(v,M),D=n.mul(x,R),k=n.add(y,v),w=n.add(S,M);k=n.mul(k,w),w=n.add(T,O),k=n.sub(k,w),w=n.add(y,x);let E=n.add(S,R);return w=n.mul(w,E),E=n.add(T,D),w=n.sub(w,E),E=n.add(v,x),_=n.add(M,R),E=n.mul(E,_),_=n.add(O,D),E=n.sub(E,_),L=n.mul(H,w),_=n.mul(U,D),L=n.add(_,L),_=n.sub(O,L),L=n.add(O,L),N=n.mul(_,L),O=n.add(T,T),O=n.add(O,T),D=n.mul(H,D),w=n.mul(U,w),O=n.add(O,D),D=n.sub(T,D),D=n.mul(H,D),w=n.add(w,D),T=n.mul(O,w),N=n.add(N,T),T=n.mul(E,w),_=n.mul(k,_),_=n.sub(_,T),T=n.mul(k,O),L=n.mul(E,L),L=n.add(L,T),new u(_,N,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(u.ZERO)}wNAF(h){return f.wNAFCached(this,l,h,y=>{const v=n.invertBatch(y.map(x=>x.pz));return y.map((x,S)=>x.toAffine(v[S])).map(u.fromAffine)})}multiplyUnsafe(h){const y=u.ZERO;if(h===Be)return y;if(a(h),h===fe)return this;const{endo:v}=e;if(!v)return f.unsafeLadder(this,h);let{k1neg:x,k1:S,k2neg:M,k2:R}=v.splitScalar(h),_=y,N=y,L=this;for(;S>Be||R>Be;)S&fe&&(_=_.add(L)),R&fe&&(N=N.add(L)),L=L.double(),S>>=fe,R>>=fe;return x&&(_=_.negate()),M&&(N=N.negate()),N=new u(n.mul(N.px,v.beta),N.py,N.pz),_.add(N)}multiply(h){a(h);let y=h,v,x;const{endo:S}=e;if(S){const{k1neg:M,k1:R,k2neg:_,k2:N}=S.splitScalar(y);let{p:L,f:H}=this.wNAF(R),{p:U,f:T}=this.wNAF(N);L=f.constTimeNegate(M,L),U=f.constTimeNegate(_,U),U=new u(n.mul(U.px,S.beta),U.py,U.pz),v=L.add(U),x=H.add(T)}else{const{p:M,f:R}=this.wNAF(y);v=M,x=R}return u.normalizeZ([v,x])[0]}multiplyAndAddUnsafe(h,y,v){const x=u.BASE,S=(R,_)=>_===Be||_===fe||!R.equals(x)?R.multiplyUnsafe(_):R.multiply(_),M=S(this,y).add(S(h,v));return M.is0()?void 0:M}toAffine(h){const{px:y,py:v,pz:x}=this,S=this.is0();h==null&&(h=S?n.ONE:n.inv(x));const M=n.mul(y,h),R=n.mul(v,h),_=n.mul(x,h);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:M,y:R}}isTorsionFree(){const{h,isTorsionFree:y}=e;if(h===fe)return!0;if(y)return y(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h,clearCofactor:y}=e;return h===fe?this:y?y(u,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),r(u,this,h)}toHex(h=!0){return ft(this.toRawBytes(h))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const p=e.nBitLength,f=hl(u,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function yl(t){const e=Qo(t);return $t(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function bl(t){const e=yl(t),{Fp:n,n:r}=e,o=n.BYTES+1,s=2*n.BYTES+1;function i(w){return Be<w&&w<n.ORDER}function a(w){return ee(w,r)}function c(w){return Yn(w,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:u,isWithinCurveOrder:p}=gl({...e,toBytes(w,E,A){const I=E.toAffine(),C=n.toBytes(I.x),$=tt;return A?$(Uint8Array.from([E.hasEvenY()?2:3]),C):$(Uint8Array.from([4]),C,n.toBytes(I.y))},fromBytes(w){const E=w.length,A=w[0],I=w.subarray(1);if(E===o&&(A===2||A===3)){const C=ie(I);if(!i(C))throw new Error("Point is not on curve");const $=u(C);let B=n.sqrt($);const P=(B&fe)===fe;return(A&1)===1!==P&&(B=n.neg(B)),{x:C,y:B}}else if(E===s&&A===4){const C=n.fromBytes(I.subarray(0,n.BYTES)),$=n.fromBytes(I.subarray(n.BYTES,2*n.BYTES));return{x:C,y:$}}else throw new Error(`Point of length ${E} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),f=w=>ft(qe(w,e.nByteLength));function m(w){const E=r>>fe;return w>E}function h(w){return m(w)?a(-w):w}const y=(w,E,A)=>ie(w.slice(E,A));class v{constructor(E,A,I){this.r=E,this.s=A,this.recovery=I,this.assertValidity()}static fromCompact(E){const A=e.nByteLength;return E=te("compactSignature",E,A*2),new v(y(E,0,A),y(E,A,2*A))}static fromDER(E){const{r:A,s:I}=rt.toSig(te("DER",E));return new v(A,I)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new v(this.r,this.s,E)}recoverPublicKey(E){const{r:A,s:I,recovery:C}=this,$=N(te("msgHash",E));if(C==null||![0,1,2,3].includes(C))throw new Error("recovery id invalid");const B=C===2||C===3?A+e.n:A;if(B>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=(C&1)===0?"02":"03",q=l.fromHex(P+f(B)),V=c(B),W=a(-$*V),F=a(I*V),X=l.BASE.multiplyAndAddUnsafe(q,W,F);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const x={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=Xo(e.n);return ul(e.randomBytes(w),e.n)},precompute(w=8,E=l.BASE){return E._setWindowSize(w),E.multiply(BigInt(3)),E}};function S(w,E=!0){return l.fromPrivateKey(w).toRawBytes(E)}function M(w){const E=w instanceof Uint8Array,A=typeof w=="string",I=(E||A)&&w.length;return E?I===o||I===s:A?I===2*o||I===2*s:w instanceof l}function R(w,E,A=!0){if(M(w))throw new Error("first arg must be private key");if(!M(E))throw new Error("second arg must be public key");return l.fromHex(E).multiply(d(w)).toRawBytes(A)}const _=e.bits2int||function(w){const E=ie(w),A=w.length*8-e.nBitLength;return A>0?E>>BigInt(A):E},N=e.bits2int_modN||function(w){return a(_(w))},L=Zn(e.nBitLength);function H(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(Be<=w&&w<L))throw new Error(`bigint expected < 2^${e.nBitLength}`);return qe(w,e.nByteLength)}function U(w,E,A=T){if(["recovered","canonical"].some(ue=>ue in A))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:C}=e;let{lowS:$,prehash:B,extraEntropy:P}=A;$==null&&($=!0),w=te("msgHash",w),B&&(w=te("prehashed msgHash",I(w)));const q=N(w),V=d(E),W=[H(V),H(q)];if(P!=null){const ue=P===!0?C(n.BYTES):P;W.push(te("extraEntropy",ue))}const F=tt(...W),X=q;function se(ue){const J=_(ue);if(!p(J))return;const de=c(J),Bt=l.BASE.multiply(J).toAffine(),ve=a(Bt.x);if(ve===Be)return;const Lt=a(de*a(X+ve*V));if(Lt===Be)return;let Rc=(Bt.x===ve?0:2)|Number(Bt.y&fe),Mc=Lt;return $&&m(Lt)&&(Mc=h(Lt),Rc^=1),new v(ve,Mc,Rc)}return{seed:F,k2sig:se}}const T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function D(w,E,A=T){const{seed:I,k2sig:C}=U(w,E,A),$=e;return Wo($.hash.outputLen,$.nByteLength,$.hmac)(I,C)}l.BASE._setWindowSize(8);function k(w,E,A,I=O){var Bt;const C=w;if(E=te("msgHash",E),A=te("publicKey",A),"strict"in I)throw new Error("options.strict was renamed to lowS");const{lowS:$,prehash:B}=I;let P,q;try{if(typeof C=="string"||C instanceof Uint8Array)try{P=v.fromDER(C)}catch(ve){if(!(ve instanceof rt.Err))throw ve;P=v.fromCompact(C)}else if(typeof C=="object"&&typeof C.r=="bigint"&&typeof C.s=="bigint"){const{r:ve,s:Lt}=C;P=new v(ve,Lt)}else throw new Error("PARSE");q=l.fromHex(A)}catch(ve){if(ve.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if($&&P.hasHighS())return!1;B&&(E=e.hash(E));const{r:V,s:W}=P,F=N(E),X=c(W),se=a(F*X),ue=a(V*X),J=(Bt=l.BASE.multiplyAndAddUnsafe(q,se,ue))==null?void 0:Bt.toAffine();return J?a(J.x)===V:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:R,sign:D,verify:k,ProjectivePoint:l,Signature:v,utils:x}}let ts=class extends Vo{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Dc(e);const r=qn(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return Zt(this),this.iHash.update(e),this}digestInto(e){Zt(this),zo(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const ns=(t,e,n)=>new ts(t,e).update(n).digest();ns.create=(t,e)=>new ts(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wl(t){return{hash:t,hmac:(e,...n)=>ns(t,e,zc(...n)),randomBytes:jo}}function vl(t,e){const n=r=>bl({...t,...wl(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),rs=BigInt(1),Xt=BigInt(2),os=(t,e)=>(t+e/Xt)/e;function ss(t){const e=Gt,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,d=l*l*t%e,u=he(d,n,e)*d%e,p=he(u,n,e)*d%e,f=he(p,Xt,e)*l%e,m=he(f,o,e)*f%e,h=he(m,s,e)*m%e,y=he(h,a,e)*h%e,v=he(y,c,e)*y%e,x=he(v,a,e)*h%e,S=he(x,n,e)*d%e,M=he(S,i,e)*m%e,R=he(M,r,e)*l%e,_=he(R,Xt,e);if(!Qn.eql(Qn.sqr(_),t))throw new Error("Cannot find square root");return _}const Qn=ll(Gt,void 0,void 0,{sqrt:ss}),ot=vl({a:BigInt(0),b:BigInt(7),Fp:Qn,n:Yt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Yt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-rs*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,i=BigInt("0x100000000000000000000000000000000"),a=os(s*t,e),c=os(-r*t,e);let l=ee(t-a*n-c*o,e),d=ee(-a*r-c*s,e);const u=l>i,p=d>i;if(u&&(l=e-l),p&&(d=e-d),l>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:p,k2:d}}}},Vn),Qt=BigInt(0),is=t=>typeof t=="bigint"&&Qt<t&&t<Gt,El=t=>typeof t=="bigint"&&Qt<t&&t<Yt,as={};function en(t,...e){let n=as[t];if(n===void 0){const r=Vn(Uint8Array.from(t,o=>o.charCodeAt(0)));n=tt(r,r),as[t]=n}return Vn(tt(n,...e))}const er=t=>t.toRawBytes(!0).slice(1),tr=t=>qe(t,32),nr=t=>ee(t,Gt),Tt=t=>ee(t,Yt),rr=ot.ProjectivePoint,xl=(t,e,n)=>rr.BASE.multiplyAndAddUnsafe(t,e,n);function or(t){let e=ot.utils.normPrivateKeyToScalar(t),n=rr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Tt(-e),bytes:er(n)}}function cs(t){if(!is(t))throw new Error("bad x: need 0 < x < p");const e=nr(t*t),n=nr(e*t+BigInt(7));let r=ss(n);r%Xt!==Qt&&(r=nr(-r));const o=new rr(t,r,rs);return o.assertValidity(),o}function ls(...t){return Tt(ie(en("BIP0340/challenge",...t)))}function kl(t){return or(t).bytes}function _l(t,e,n=jo(32)){const r=te("message",t),{bytes:o,scalar:s}=or(e),i=te("auxRand",n,32),a=tr(s^ie(en("BIP0340/aux",i))),c=en("BIP0340/nonce",a,o,r),l=Tt(ie(c));if(l===Qt)throw new Error("sign failed: k is zero");const{bytes:d,scalar:u}=or(l),p=ls(d,o,r),f=new Uint8Array(64);if(f.set(d,0),f.set(tr(Tt(u+p*s)),32),!us(f,r,o))throw new Error("sign: Invalid signature produced");return f}function us(t,e,n){const r=te("signature",t,64),o=te("message",e),s=te("publicKey",n,32);try{const i=cs(ie(s)),a=ie(r.subarray(0,32));if(!is(a))return!1;const c=ie(r.subarray(32,64));if(!El(c))return!1;const l=ls(tr(a),er(i),o),d=xl(i,c,Tt(-l));return!(!d||!d.hasEvenY()||d.toAffine().x!==a)}catch{return!1}}const xe={getPublicKey:kl,sign:_l,verify:us,utils:{randomPrivateKey:ot.utils.randomPrivateKey,lift_x:cs,pointToBytes:er,numberToBytesBE:qe,bytesToNumberBE:ie,taggedHash:en,mod:ee}},sr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ir=t=>t instanceof Uint8Array,ar=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ke=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const Al=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Y(t){if(!ir(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Al[t[n]];return e}function st(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,s=t.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i}return n}function Sl(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Pt(t){if(typeof t=="string"&&(t=Sl(t)),!ir(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function it(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!ir(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class ds{clone(){return this._cloneInto()}}function hs(t){const e=r=>t().update(Pt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function cr(t=32){if(sr&&typeof sr.getRandomValues=="function")return sr.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function lr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Nl(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function fs(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Cl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lr(t.outputLen),lr(t.blockLen)}function Bl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ll(t,e){fs(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const _e={number:lr,bool:Nl,bytes:fs,hash:Cl,exists:Bl,output:Ll};function Il(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+l,a,r)}class $l extends ds{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ar(this.buffer)}update(e){_e.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=Pt(e);const s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=ar(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_e.exists(this),_e.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;Il(r,o-8,BigInt(this.length*8),s),this.process(r,0);const a=ar(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%n&&e.buffer.set(r),e}}const Tl=(t,e,n)=>t&e^~t&n,Pl=(t,e,n)=>t&e^t&n^e&n,Ul=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ve=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),je=new Uint32Array(64);class ps extends $l{constructor(){super(64,32,8,!1),this.A=Ve[0]|0,this.B=Ve[1]|0,this.C=Ve[2]|0,this.D=Ve[3]|0,this.E=Ve[4]|0,this.F=Ve[5]|0,this.G=Ve[6]|0,this.H=Ve[7]|0}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)je[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=je[u-15],f=je[u-2],m=ke(p,7)^ke(p,18)^p>>>3,h=ke(f,17)^ke(f,19)^f>>>10;je[u]=h+je[u-7]+m+je[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=ke(a,6)^ke(a,11)^ke(a,25),f=d+p+Tl(a,c,l)+Ul[u]+je[u]|0,h=(ke(r,2)^ke(r,13)^ke(r,22))+Pl(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Ol extends ps{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const me=hs(()=>new ps);hs(()=>new Ol);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Le(...t){const e=(o,s)=>i=>o(s(i)),n=Array.from(t).reverse().reduce((o,s)=>o?e(o,s.encode):s.encode,void 0),r=t.reduce((o,s)=>o?e(o,s.decode):s.decode,void 0);return{encode:n,decode:r}}function Ie(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(pt(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function $e(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function tn(t,e="="){if(pt(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function ms(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function gs(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const o=[],s=Array.from(t);for(s.forEach(i=>{if(pt(i),i<0||i>=e)throw new Error(`Wrong integer: ${i}`)});;){let i=0,a=!0;for(let c=r;c<s.length;c++){const l=s[c],d=e*i+l;if(!Number.isSafeInteger(d)||e*i/e!==i||d-l!==e*i)throw new Error("convertRadix: carry overflow");if(i=d%n,s[c]=Math.floor(d/n),!Number.isSafeInteger(s[c])||s[c]*n+i!==d)throw new Error("convertRadix: carry overflow");if(a)s[c]?a=!1:r=c;else continue}if(o.push(i),a)break}for(let i=0;i<t.length-1&&t[i]===0;i++)o.push(0);return o.reverse()}const ys=(t,e)=>e?ys(e,t%e):t,nn=(t,e)=>t+(e-ys(t,e));function ur(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(nn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${nn(e,n)}`);let o=0,s=0;const i=2**n-1,a=[];for(const c of t){if(pt(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(o=o<<e|c,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)a.push((o>>s-n&i)>>>0);o&=2**s-1}if(o=o<<n-s&i,!r&&s>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function Rl(t){return pt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return gs(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(gs(e,t,2**8))}}}function Fe(t,e=!1){if(pt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(nn(8,t)>32||nn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return ur(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(ur(n,t,8,e))}}}function bs(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ml=Le(Fe(4),Ie("0123456789ABCDEF"),$e("")),Dl=Le(Fe(5),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tn(5),$e(""));Le(Fe(5),Ie("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tn(5),$e("")),Le(Fe(5),Ie("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),$e(""),ms(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const ge=Le(Fe(6),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tn(6),$e("")),Kl=Le(Fe(6),Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tn(6),$e("")),dr=t=>Le(Rl(58),Ie(t),$e("")),hr=dr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");dr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),dr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ws=[0,2,3,5,6,7,9,10,11],Hl={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=hr.encode(r).padStart(ws[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=ws.indexOf(r.length),s=hr.decode(r);for(let i=0;i<s.length-o;i++)if(s[i]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(s.slice(s.length-o)))}return Uint8Array.from(e)}},fr=Le(Ie("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),$e("")),vs=[996825010,642813549,513874426,1027748829,705979059];function Ut(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<vs.length;r++)(e>>r&1)===1&&(n^=vs[r]);return n}function Es(t,e,n=1){const r=t.length;let o=1;for(let s=0;s<r;s++){const i=t.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${t})`);o=Ut(o)^i>>5}o=Ut(o);for(let s=0;s<r;s++)o=Ut(o)^t.charCodeAt(s)&31;for(let s of e)o=Ut(o)^s;for(let s=0;s<6;s++)o=Ut(o);return o^=n,fr.encode(ur([o%2**30],30,5,!1))}function xs(t){const e=t==="bech32"?1:734539939,n=Fe(5),r=n.decode,o=n.encode,s=bs(r);function i(d,u,p=90){if(typeof d!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof d}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const f=d.length+7+u.length;if(p!==!1&&f>p)throw new TypeError(`Length ${f} exceeds limit ${p}`);return d=d.toLowerCase(),`${d}1${fr.encode(u)}${Es(d,u,e)}`}function a(d,u=90){if(typeof d!="string")throw new Error(`bech32.decode input should be string, not ${typeof d}`);if(d.length<8||u!==!1&&d.length>u)throw new TypeError(`Wrong string length: ${d.length} (${d}). Expected (8..${u})`);const p=d.toLowerCase();if(d!==p&&d!==d.toUpperCase())throw new Error("String must be lowercase or uppercase");d=p;const f=d.lastIndexOf("1");if(f===0||f===-1)throw new Error('Letter "1" must be present between prefix and data only');const m=d.slice(0,f),h=d.slice(f+1);if(h.length<6)throw new Error("Data must be at least 6 characters long");const y=fr.decode(h).slice(0,-6),v=Es(m,y,e);if(!h.endsWith(v))throw new Error(`Invalid checksum in ${d}: expected "${v}"`);return{prefix:m,words:y}}const c=bs(a);function l(d){const{prefix:u,words:p}=a(d,!1);return{prefix:u,words:p,bytes:r(p)}}return{encode:i,decode:a,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const mt=xs("bech32");xs("bech32m");const zl={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},ql=Le(Fe(4),Ie("0123456789abcdef"),$e(""),ms(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));`${Object.keys({utf8:zl,hex:ql,base16:Ml,base32:Dl,base64:ge,base64url:Kl,base58:hr,base58xmr:Hl}).join(", ")}`;function pr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function ks(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Vl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ae(t,...e){if(!Vl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const ne=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const jl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gt(t){Ae(t);let e="";for(let n=0;n<t.length;n++)e+=jl[t[n]];return e}const Te={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function _s(t){if(t>=Te._0&&t<=Te._9)return t-Te._0;if(t>=Te._A&&t<=Te._F)return t-(Te._A-10);if(t>=Te._a&&t<=Te._f)return t-(Te._a-10)}function As(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=_s(t.charCodeAt(s)),a=_s(t.charCodeAt(s+1));if(i===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[o]=i*16+a}return r}function Fl(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Ss(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Wl=(t,e)=>(Object.assign(e,t),e),We=16,Zl=283;function mr(t){return t<<1^Zl&-(t>>7)}function yt(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=mr(t);return n}const gr=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=mr(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return e})(),Jl=gr.map((t,e)=>gr.indexOf(e)),Gl=t=>t<<24|t>>>8,yr=t=>t<<8|t>>>24;function Ns(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,d)=>e(t[d])),r=n.map(yr),o=r.map(yr),s=o.map(yr),i=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let d=0;d<256;d++){const u=l*256+d;i[u]=n[l]^r[d],a[u]=o[l]^s[d],c[u]=t[l]<<8|t[d]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:o,T3:s,T01:i,T23:a}}const br=Ns(gr,t=>yt(t,3)<<24|t<<16|t<<8|yt(t,2)),Cs=Ns(Jl,t=>yt(t,11)<<24|yt(t,13)<<16|yt(t,9)<<8|yt(t,14)),Yl=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=mr(n))t[e]=n;return t})();function Bs(t){Ae(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=br,r=ne(t),o=r.length,s=a=>Se(n,a,a,a,a),i=new Uint32Array(e+28);i.set(r);for(let a=o;a<i.length;a++){let c=i[a-1];a%o===0?c=s(Gl(c))^Yl[a/o-1]:o>6&&a%o===4&&(c=s(c)),i[a]=i[a-o]^c}return i}function Xl(t){const e=Bs(t),n=e.slice(),r=e.length,{sbox2:o}=br,{T0:s,T1:i,T2:a,T3:c}=Cs;for(let l=0;l<r;l+=4)for(let d=0;d<4;d++)n[l+d]=e[r-l-4+d];e.fill(0);for(let l=4;l<r-4;l++){const d=n[l],u=Se(o,d,d,d,d);n[l]=s[u&255]^i[u>>>8&255]^a[u>>>16&255]^c[u>>>24]}return n}function Ze(t,e,n,r,o,s){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|s>>>24&255]}function Se(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function Ls(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=br;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let m=0;m<l;m++){const h=t[c++]^Ze(i,a,e,n,r,o),y=t[c++]^Ze(i,a,n,r,o,e),v=t[c++]^Ze(i,a,r,o,e,n),x=t[c++]^Ze(i,a,o,e,n,r);e=h,n=y,r=v,o=x}const d=t[c++]^Se(s,e,n,r,o),u=t[c++]^Se(s,n,r,o,e),p=t[c++]^Se(s,r,o,e,n),f=t[c++]^Se(s,o,e,n,r);return{s0:d,s1:u,s2:p,s3:f}}function Ql(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=Cs;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let m=0;m<l;m++){const h=t[c++]^Ze(i,a,e,o,r,n),y=t[c++]^Ze(i,a,n,e,o,r),v=t[c++]^Ze(i,a,r,n,e,o),x=t[c++]^Ze(i,a,o,r,n,e);e=h,n=y,r=v,o=x}const d=t[c++]^Se(s,e,o,r,n),u=t[c++]^Se(s,n,e,o,r),p=t[c++]^Se(s,r,n,e,o),f=t[c++]^Se(s,o,r,n,e);return{s0:d,s1:u,s2:p,s3:f}}function Is(t,e){if(!e)return new Uint8Array(t);if(Ae(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}function eu(t){if(Ae(t),t.length%We!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${We}`)}function tu(t,e,n){let r=t.length;const o=r%We;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=ne(t);if(e){let c=We-o;c||(c=We),r=r+c}const i=Is(r,n),a=ne(i);return{b:s,o:a,out:i}}function nu(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let s=0;s<r;s++)if(t[n-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function ru(t){const e=new Uint8Array(16),n=ne(e);e.set(t);const r=We-t.length;for(let o=We-r;o<We;o++)e[o]=r;return n}const $s=Wl({blockSize:16,nonceLength:16},function(e,n,r={}){Ae(e),Ae(n,16);const o=!r.disablePadding;return{encrypt:(s,i)=>{const a=Bs(e),{b:c,o:l,out:d}=tu(s,o,i),u=ne(n);let p=u[0],f=u[1],m=u[2],h=u[3],y=0;for(;y+4<=c.length;)p^=c[y+0],f^=c[y+1],m^=c[y+2],h^=c[y+3],{s0:p,s1:f,s2:m,s3:h}=Ls(a,p,f,m,h),l[y++]=p,l[y++]=f,l[y++]=m,l[y++]=h;if(o){const v=ru(s.subarray(y*4));p^=v[0],f^=v[1],m^=v[2],h^=v[3],{s0:p,s1:f,s2:m,s3:h}=Ls(a,p,f,m,h),l[y++]=p,l[y++]=f,l[y++]=m,l[y++]=h}return a.fill(0),d},decrypt:(s,i)=>{eu(s);const a=Xl(e),c=ne(n),l=Is(s.length,i),d=ne(s),u=ne(l);let p=c[0],f=c[1],m=c[2],h=c[3];for(let y=0;y+4<=d.length;){const v=p,x=f,S=m,M=h;p=d[y+0],f=d[y+1],m=d[y+2],h=d[y+3];const{s0:R,s1:_,s2:N,s3:L}=Ql(a,p,f,m,h);u[y++]=R^v,u[y++]=_^x,u[y++]=N^S,u[y++]=L^M}return a.fill(0),nu(l,o)}}}),Ts=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),ou=Ts("expand 16-byte k"),su=Ts("expand 32-byte k"),iu=ne(ou),Ps=ne(su);Ps.slice();function j(t,e){return t<<e|t>>>32-e}function wr(t){return t.byteOffset%4===0}const rn=64,au=16,Us=2**32-1,Os=new Uint32Array;function cu(t,e,n,r,o,s,i,a){const c=o.length,l=new Uint8Array(rn),d=ne(l),u=wr(o)&&wr(s),p=u?ne(o):Os,f=u?ne(s):Os;for(let m=0;m<c;i++){if(t(e,n,r,d,i,a),i>=Us)throw new Error("arx: counter overflow");const h=Math.min(rn,c-m);if(u&&h===rn){const y=m/4;if(m%4!==0)throw new Error("arx: invalid block position");for(let v=0,x;v<au;v++)x=y+v,f[x]=p[x]^d[v];m+=rn;continue}for(let y=0,v;y<h;y++)v=m+y,s[v]=o[v]^l[y];m+=h}}function lu(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=Fl({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return pr(o),pr(i),ks(s),ks(n),(a,c,l,d,u=0)=>{Ae(a),Ae(c),Ae(l);const p=l.length;if(d||(d=new Uint8Array(p)),Ae(d),pr(u),u<0||u>=Us)throw new Error("arx: counter overflow");if(d.length<p)throw new Error(`arx: output (${d.length}) is shorter than data (${p})`);const f=[];let m=a.length,h,y;if(m===32)h=a.slice(),f.push(h),y=Ps;else if(m===16&&n)h=new Uint8Array(32),h.set(a),h.set(a,16),y=iu,f.push(h);else throw new Error(`arx: invalid 32-byte key, got length=${m}`);wr(c)||(c=c.slice(),f.push(c));const v=ne(h);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(y,v,ne(c.subarray(0,16)),v),c=c.subarray(16)}const x=16-o;if(x!==c.length)throw new Error(`arx: nonce must be ${x} or 16 bytes`);if(x!==12){const M=new Uint8Array(12);M.set(c,s?0:12-c.length),c=M,f.push(c)}const S=ne(c);for(cu(t,y,v,S,l,d,u,i);f.length>0;)f.pop().fill(0);return d}}function uu(t,e,n,r,o,s=20){let i=t[0],a=t[1],c=t[2],l=t[3],d=e[0],u=e[1],p=e[2],f=e[3],m=e[4],h=e[5],y=e[6],v=e[7],x=o,S=n[0],M=n[1],R=n[2],_=i,N=a,L=c,H=l,U=d,T=u,O=p,D=f,k=m,w=h,E=y,A=v,I=x,C=S,$=M,B=R;for(let q=0;q<s;q+=2)_=_+U|0,I=j(I^_,16),k=k+I|0,U=j(U^k,12),_=_+U|0,I=j(I^_,8),k=k+I|0,U=j(U^k,7),N=N+T|0,C=j(C^N,16),w=w+C|0,T=j(T^w,12),N=N+T|0,C=j(C^N,8),w=w+C|0,T=j(T^w,7),L=L+O|0,$=j($^L,16),E=E+$|0,O=j(O^E,12),L=L+O|0,$=j($^L,8),E=E+$|0,O=j(O^E,7),H=H+D|0,B=j(B^H,16),A=A+B|0,D=j(D^A,12),H=H+D|0,B=j(B^H,8),A=A+B|0,D=j(D^A,7),_=_+T|0,B=j(B^_,16),E=E+B|0,T=j(T^E,12),_=_+T|0,B=j(B^_,8),E=E+B|0,T=j(T^E,7),N=N+O|0,I=j(I^N,16),A=A+I|0,O=j(O^A,12),N=N+O|0,I=j(I^N,8),A=A+I|0,O=j(O^A,7),L=L+D|0,C=j(C^L,16),k=k+C|0,D=j(D^k,12),L=L+D|0,C=j(C^L,8),k=k+C|0,D=j(D^k,7),H=H+U|0,$=j($^H,16),w=w+$|0,U=j(U^w,12),H=H+U|0,$=j($^H,8),w=w+$|0,U=j(U^w,7);let P=0;r[P++]=i+_|0,r[P++]=a+N|0,r[P++]=c+L|0,r[P++]=l+H|0,r[P++]=d+U|0,r[P++]=u+T|0,r[P++]=p+O|0,r[P++]=f+D|0,r[P++]=m+k|0,r[P++]=h+w|0,r[P++]=y+E|0,r[P++]=v+A|0,r[P++]=x+I|0,r[P++]=S+C|0,r[P++]=M+$|0,r[P++]=R+B|0}const on=lu(uu,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Rs extends ds{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,_e.hash(e);const r=Pt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return _e.exists(this),this.iHash.update(e),this}digestInto(e){_e.exists(this),_e.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ot=(t,e,n)=>new Rs(t,e).update(n).digest();Ot.create=(t,e)=>new Rs(t,e);function Ms(t,e,n){return _e.hash(t),Ot(t,Pt(n),Pt(e))}const vr=new Uint8Array([0]),Ds=new Uint8Array;function Ks(t,e,n,r=32){if(_e.hash(t),_e.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);n===void 0&&(n=Ds);const s=new Uint8Array(o*t.outputLen),i=Ot.create(t,e),a=i._cloneInto(),c=new Uint8Array(i.outputLen);for(let l=0;l<o;l++)vr[0]=l+1,a.update(l===0?Ds:c).update(n).update(vr).digestInto(c),s.set(c,t.outputLen*l),i._cloneInto(a);return i.destroy(),a.destroy(),c.fill(0),vr.fill(0),s.slice(0,r)}var du=Object.defineProperty,Z=(t,e)=>{for(var n in e)du(t,n,{get:e[n],enumerable:!0})},bt=Symbol("verified"),hu=t=>t instanceof Object;function Er(t){if(!hu(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}var fu={};Z(fu,{Queue:()=>yu,QueueNode:()=>Hs,binarySearch:()=>xr,bytesToHex:()=>Y,hexToBytes:()=>st,insertEventIntoAscendingList:()=>gu,insertEventIntoDescendingList:()=>mu,normalizeURL:()=>pu,utf8Decoder:()=>Pe,utf8Encoder:()=>ye});var Pe=new TextDecoder("utf-8"),ye=new TextEncoder;function pu(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}function mu(t,e){const[n,r]=xr(t,o=>e.id===o.id?0:e.created_at===o.created_at?-1:o.created_at-e.created_at);return r||t.splice(n,0,e),t}function gu(t,e){const[n,r]=xr(t,o=>e.id===o.id?0:e.created_at===o.created_at?-1:e.created_at-o.created_at);return r||t.splice(n,0,e),t}function xr(t,e){let n=0,r=t.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),s=e(t[o]);if(s===0)return[o,!0];s<0?r=o-1:n=o+1}return[n,!1]}var Hs=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},yu=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Hs(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},bu=class{generateSecretKey(){return xe.utils.randomPrivateKey()}getPublicKey(e){return Y(xe.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(xe.getPublicKey(n)),r.id=sn(r),r.sig=Y(xe.sign(sn(r),n)),r[bt]=!0,r}verifyEvent(e){if(typeof e[bt]=="boolean")return e[bt];const n=sn(e);if(n!==e.id)return e[bt]=!1,!1;try{const r=xe.verify(e.sig,n,e.pubkey);return e[bt]=r,r}catch{return e[bt]=!1,!1}}};function wu(t){if(!Er(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function sn(t){let e=me(ye.encode(wu(t)));return Y(e)}var an=new bu,kr=an.generateSecretKey,cn=an.getPublicKey,be=an.finalizeEvent,_r=an.verifyEvent,vu={};Z(vu,{Application:()=>$d,BadgeAward:()=>Cu,BadgeDefinition:()=>Ad,BlockedRelaysList:()=>ad,BlossomServerList:()=>pd,BookmarkList:()=>od,Bookmarksets:()=>xd,Calendar:()=>Dd,CalendarEventRSVP:()=>Kd,ChannelCreation:()=>Ws,ChannelHideMessage:()=>Gs,ChannelMessage:()=>Js,ChannelMetadata:()=>Zs,ChannelMuteUser:()=>Ys,ChatMessage:()=>Bu,ClassifiedListing:()=>Ud,ClientAuth:()=>Qs,Comment:()=>Mu,CommunitiesList:()=>sd,CommunityDefinition:()=>Vd,CommunityPostApproval:()=>Fu,Contacts:()=>Au,CreateOrUpdateProduct:()=>Cd,CreateOrUpdateStall:()=>Nd,Curationsets:()=>kd,Date:()=>Rd,DirectMessageRelaysList:()=>hd,DraftClassifiedListing:()=>Od,DraftLong:()=>Ld,Emojisets:()=>Id,EncryptedDirectMessage:()=>Su,EventDeletion:()=>Nu,FavoriteRelays:()=>ld,FileMessage:()=>Iu,FileMetadata:()=>Ru,FileServerPreference:()=>fd,Followsets:()=>wd,ForumThread:()=>Lu,GenericRepost:()=>Br,Genericlists:()=>vd,GiftWrap:()=>Xs,GroupMetadata:()=>jd,HTTPAuth:()=>Lr,Handlerinformation:()=>qd,Handlerrecommendation:()=>zd,Highlights:()=>Qu,InterestsList:()=>ud,Interestsets:()=>Sd,JobFeedback:()=>Ju,JobRequest:()=>Wu,JobResult:()=>Zu,Label:()=>ju,LightningPubRPC:()=>gd,LiveChatMessage:()=>Du,LiveEvent:()=>Td,LongFormArticle:()=>Bd,Metadata:()=>ku,Mutelist:()=>td,NWCWalletInfo:()=>md,NWCWalletRequest:()=>ei,NWCWalletResponse:()=>yd,NormalVideo:()=>Tu,NostrConnect:()=>bd,OpenTimestamps:()=>Uu,Photo:()=>$u,Pinlist:()=>nd,Poll:()=>Ou,PollResponse:()=>ed,PrivateDirectMessage:()=>Fs,ProblemTracker:()=>zu,ProfileBadges:()=>_d,PublicChatsList:()=>id,Reaction:()=>Cr,RecommendRelay:()=>_u,RelayList:()=>rd,RelayReview:()=>Hd,Relaysets:()=>Ed,Report:()=>qu,Reporting:()=>Vu,Repost:()=>Nr,Seal:()=>js,SearchRelaysList:()=>cd,ShortTextNote:()=>Vs,ShortVideo:()=>Pu,Time:()=>Md,UserEmojiList:()=>dd,UserStatuses:()=>Pd,Voice:()=>Ku,VoiceComment:()=>Hu,Zap:()=>Xu,ZapGoal:()=>Gu,ZapRequest:()=>Yu,classifyKind:()=>Eu,isAddressableKind:()=>Sr,isEphemeralKind:()=>qs,isKind:()=>xu,isRegularKind:()=>zs,isReplaceableKind:()=>Ar});function zs(t){return t<1e4&&t!==0&&t!==3}function Ar(t){return t===0||t===3||1e4<=t&&t<2e4}function qs(t){return 2e4<=t&&t<3e4}function Sr(t){return 3e4<=t&&t<4e4}function Eu(t){return zs(t)?"regular":Ar(t)?"replaceable":qs(t)?"ephemeral":Sr(t)?"parameterized":"unknown"}function xu(t,e){const n=e instanceof Array?e:[e];return Er(t)&&n.includes(t.kind)||!1}var ku=0,Vs=1,_u=2,Au=3,Su=4,Nu=5,Nr=6,Cr=7,Cu=8,Bu=9,Lu=11,js=13,Fs=14,Iu=15,Br=16,$u=20,Tu=21,Pu=22,Ws=40,Zs=41,Js=42,Gs=43,Ys=44,Uu=1040,Xs=1059,Ou=1068,Ru=1063,Mu=1111,Du=1311,Ku=1222,Hu=1244,zu=1971,qu=1984,Vu=1984,ju=1985,Fu=4550,Wu=5999,Zu=6999,Ju=7e3,Gu=9041,Yu=9734,Xu=9735,Qu=9802,ed=1018,td=1e4,nd=10001,rd=10002,od=10003,sd=10004,id=10005,ad=10006,cd=10007,ld=10012,ud=10015,dd=10030,hd=10050,fd=10096,pd=10063,md=13194,gd=21e3,Qs=22242,ei=23194,yd=23195,bd=24133,Lr=27235,wd=3e4,vd=30001,Ed=30002,xd=30003,kd=30004,_d=30008,Ad=30009,Sd=30015,Nd=30017,Cd=30018,Bd=30023,Ld=30024,Id=30030,$d=30078,Td=30311,Pd=30315,Ud=30402,Od=30403,Rd=31922,Md=31923,Dd=31924,Kd=31925,Hd=31987,zd=31989,qd=31990,Vd=34550,jd=39e3,Fd={};Z(Fd,{getHex64:()=>Ir,getInt:()=>ti,getSubscriptionId:()=>Wd,matchEventId:()=>Zd,matchEventKind:()=>Gd,matchEventPubkey:()=>Jd});function Ir(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function ti(t,e){let n=e.length,r=t.indexOf(`"${e}":`)+n+3,o=t.slice(r),s=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,s),10)}function Wd(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function Zd(t,e){return e===Ir(t,"id")}function Jd(t,e){return e===Ir(t,"pubkey")}function Gd(t,e){return e===ti(t,"kind")}var Yd={};Z(Yd,{makeAuthEvent:()=>Xd});function Xd(t,e){return{kind:Qs,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}var Qd;try{Qd=WebSocket}catch{}var eh;try{eh=WebSocket}catch{}var wt={};Z(wt,{BECH32_REGEX:()=>ni,Bech32MaxSize:()=>$r,NostrTypeGuard:()=>th,decode:()=>ln,decodeNostrURI:()=>rh,encodeBytes:()=>dn,naddrEncode:()=>lh,neventEncode:()=>ch,noteEncode:()=>ih,nprofileEncode:()=>ah,npubEncode:()=>sh,nsecEncode:()=>oh});var th={isNProfile:t=>/^nprofile1[a-z\d]+$/.test(t||""),isNEvent:t=>/^nevent1[a-z\d]+$/.test(t||""),isNAddr:t=>/^naddr1[a-z\d]+$/.test(t||""),isNSec:t=>/^nsec1[a-z\d]{58}$/.test(t||""),isNPub:t=>/^npub1[a-z\d]{58}$/.test(t||""),isNote:t=>/^note1[a-z\d]+$/.test(t||""),isNcryptsec:t=>/^ncryptsec1[a-z\d]+$/.test(t||"")},$r=5e3,ni=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function nh(t){const e=new Uint8Array(4);return e[0]=t>>24&255,e[1]=t>>16&255,e[2]=t>>8&255,e[3]=t&255,e}function rh(t){try{return t.startsWith("nostr:")&&(t=t.substring(6)),ln(t)}catch{return{type:"invalid",data:null}}}function ln(t){var o,s,i,a,c,l,d;let{prefix:e,words:n}=mt.decode(t,$r),r=new Uint8Array(mt.fromWords(n));switch(e){case"nprofile":{let u=Tr(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Y(u[0][0]),relays:u[1]?u[1].map(p=>Pe.decode(p)):[]}}}case"nevent":{let u=Tr(r);if(!((s=u[0])!=null&&s[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(u[3]&&u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Y(u[0][0]),relays:u[1]?u[1].map(p=>Pe.decode(p)):[],author:(i=u[2])!=null&&i[0]?Y(u[2][0]):void 0,kind:(a=u[3])!=null&&a[0]?parseInt(Y(u[3][0]),16):void 0}}}case"naddr":{let u=Tr(r);if(!((c=u[0])!=null&&c[0]))throw new Error("missing TLV 0 for naddr");if(!((l=u[2])!=null&&l[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((d=u[3])!=null&&d[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Pe.decode(u[0][0]),pubkey:Y(u[2][0]),kind:parseInt(Y(u[3][0]),16),relays:u[1]?u[1].map(p=>Pe.decode(p)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:Y(r)};default:throw new Error(`unknown prefix ${e}`)}}function Tr(t){let e={},n=t;for(;n.length>0;){let r=n[0],o=n[1],s=n.slice(2,2+o);if(n=n.slice(2+o),s.length<o)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(s)}return e}function oh(t){return dn("nsec",t)}function sh(t){return dn("npub",st(t))}function ih(t){return dn("note",st(t))}function un(t,e){let n=mt.toWords(e);return mt.encode(t,n,$r)}function dn(t,e){return un(t,e)}function ah(t){let e=Pr({0:[st(t.pubkey)],1:(t.relays||[]).map(n=>ye.encode(n))});return un("nprofile",e)}function ch(t){let e;t.kind!==void 0&&(e=nh(t.kind));let n=Pr({0:[st(t.id)],1:(t.relays||[]).map(r=>ye.encode(r)),2:t.author?[st(t.author)]:[],3:e?[new Uint8Array(e)]:[]});return un("nevent",n)}function lh(t){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,t.kind,!1);let n=Pr({0:[ye.encode(t.identifier)],1:(t.relays||[]).map(r=>ye.encode(r)),2:[st(t.pubkey)],3:[new Uint8Array(e)]});return un("naddr",n)}function Pr(t){let e=[];return Object.entries(t).reverse().forEach(([n,r])=>{r.forEach(o=>{let s=new Uint8Array(o.length+2);s.set([parseInt(n)],0),s.set([o.length],1),s.set(o,2),e.push(s)})}),it(...e)}var uh={};Z(uh,{decrypt:()=>dh,encrypt:()=>ri});function ri(t,e,n){const r=t instanceof Uint8Array?Y(t):t,o=ot.getSharedSecret(r,"02"+e),s=oi(o);let i=Uint8Array.from(cr(16)),a=ye.encode(n),c=$s(s,i).encrypt(a),l=ge.encode(new Uint8Array(c)),d=ge.encode(new Uint8Array(i.buffer));return`${l}?iv=${d}`}function dh(t,e,n){const r=t instanceof Uint8Array?Y(t):t;let[o,s]=n.split("?iv="),i=ot.getSharedSecret(r,"02"+e),a=oi(i),c=ge.decode(s),l=ge.decode(o),d=$s(a,c).decrypt(l);return Pe.decode(d)}function oi(t){return t.slice(1,33)}var hh={};Z(hh,{NIP05_REGEX:()=>Ur,isNip05:()=>fh,isValid:()=>gh,queryProfile:()=>si,searchDomain:()=>mh,useFetchImplementation:()=>ph});var Ur=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,fh=t=>Ur.test(t||""),hn;try{hn=fetch}catch{}function ph(t){hn=t}async function mh(t,e=""){try{const n=`https://${t}/.well-known/nostr.json?name=${e}`,r=await hn(n,{redirect:"manual"});if(r.status!==200)throw Error("Wrong response code");return(await r.json()).names}catch{return{}}}async function si(t){var o;const e=t.match(Ur);if(!e)return null;const[,n="_",r]=e;try{const s=`https://${r}/.well-known/nostr.json?name=${n}`,i=await hn(s,{redirect:"manual"});if(i.status!==200)throw Error("Wrong response code");const a=await i.json(),c=a.names[n];return c?{pubkey:c,relays:(o=a.relays)==null?void 0:o[c]}:null}catch{return null}}async function gh(t,e){const n=await si(e);return n?n.pubkey===t:!1}var yh={};Z(yh,{parse:()=>bh});function bh(t){const e={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=t.tags.length-1;o>=0;o--){const s=t.tags[o];if(s[0]==="e"&&s[1]){const[i,a,c,l,d]=s,u={id:a,relays:c?[c]:[],author:d};if(l==="root"){e.root=u;continue}if(l==="reply"){e.reply=u;continue}if(l==="mention"){e.mentions.push(u);continue}n?r=u:n=u,e.mentions.push(u);continue}if(s[0]==="q"&&s[1]){const[i,a,c]=s;e.quotes.push({id:a,relays:c?[c]:[]})}if(s[0]==="p"&&s[1]){e.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]});continue}}return e.root||(e.root=r||n||e.reply),e.reply||(e.reply=n||e.root),[e.reply,e.root].forEach(o=>{if(!o)return;let s=e.mentions.indexOf(o);if(s!==-1&&e.mentions.splice(s,1),o.author){let i=e.profiles.find(a=>a.pubkey===o.author);i&&i.relays&&(o.relays||(o.relays=[]),i.relays.forEach(a=>{var c;((c=o.relays)==null?void 0:c.indexOf(a))===-1&&o.relays.push(a)}),i.relays=o.relays)}}),e.mentions.forEach(o=>{if(o.author){let s=e.profiles.find(i=>i.pubkey===o.author);s&&s.relays&&(o.relays||(o.relays=[]),s.relays.forEach(i=>{o.relays.indexOf(i)===-1&&o.relays.push(i)}),s.relays=o.relays)}}),e}var wh={};Z(wh,{fetchRelayInformation:()=>Eh,useFetchImplementation:()=>vh});var ii;try{ii=fetch}catch{}function vh(t){ii=t}async function Eh(t){return await(await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var xh={};Z(xh,{fastEventHash:()=>ci,getPow:()=>ai,minePow:()=>kh});function ai(t){let e=0;for(let n=0;n<64;n+=8){const r=parseInt(t.substring(n,n+8),16);if(r===0)e+=32;else{e+=Math.clz32(r);break}}return e}function kh(t,e){let n=0;const r=t,o=["nonce",n.toString(),e.toString()];for(r.tags.push(o);;){const s=Math.floor(new Date().getTime()/1e3);if(s!==r.created_at&&(n=0,r.created_at=s),o[1]=(++n).toString(),r.id=ci(r),ai(r.id)>=e)break}return r}function ci(t){return Y(me(ye.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}var _h={};Z(_h,{unwrapEvent:()=>Oh,unwrapManyEvents:()=>Rh,wrapEvent:()=>xi,wrapManyEvents:()=>Uh});var Ah={};Z(Ah,{createRumor:()=>bi,createSeal:()=>wi,createWrap:()=>vi,unwrapEvent:()=>Kr,unwrapManyEvents:()=>Ei,wrapEvent:()=>fn,wrapManyEvents:()=>Th});var Sh={};Z(Sh,{decrypt:()=>Dr,encrypt:()=>Mr,getConversationKey:()=>Or,v2:()=>Ih});var li=1,ui=65535;function Or(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return Ms(me,n,"nip44-v2")}function di(t,e){const n=Ks(me,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Rr(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Nh(t){if(!Number.isSafeInteger(t)||t<li||t>ui)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}function Ch(t){const e=ye.encode(t),n=e.length,r=Nh(n),o=new Uint8Array(Rr(n)-n);return it(r,e,o)}function Bh(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<li||e>ui||n.length!==e||t.length!==2+Rr(e))throw new Error("invalid padding");return Pe.decode(n)}function hi(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=it(n,e);return Ot(me,t,r)}function Lh(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=ge.decode(t)}catch(s){throw new Error("invalid base64: "+s.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Mr(t,e,n=cr(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=di(e,n),i=Ch(t),a=on(r,o,i),c=hi(s,a,n);return ge.encode(it(new Uint8Array([2]),n,a,c))}function Dr(t,e){const{nonce:n,ciphertext:r,mac:o}=Lh(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=di(e,n),c=hi(a,r,n);if(!Ss(c,o))throw new Error("invalid MAC");const l=on(s,i,r);return Bh(l)}var Ih={utils:{getConversationKey:Or,calcPaddedLen:Rr},encrypt:Mr,decrypt:Dr},$h=2880*60,fi=()=>Math.round(Date.now()/1e3),pi=()=>Math.round(fi()-Math.random()*$h),mi=(t,e)=>Or(t,e),gi=(t,e,n)=>Mr(JSON.stringify(t),mi(e,n)),yi=(t,e)=>JSON.parse(Dr(t.content,mi(e,t.pubkey)));function bi(t,e){const n={created_at:fi(),content:"",tags:[],...t,pubkey:cn(e)};return n.id=sn(n),n}function wi(t,e,n){return be({kind:js,content:gi(t,e,n),created_at:pi(),tags:[]},e)}function vi(t,e){const n=kr();return be({kind:Xs,content:gi(t,n,e),created_at:pi(),tags:[["p",e]]},n)}function fn(t,e,n){const r=bi(t,e),o=wi(r,e,n);return vi(o,n)}function Th(t,e,n){if(!n||n.length===0)throw new Error("At least one recipient is required.");const r=cn(e),o=[fn(t,e,r)];return n.forEach(s=>{o.push(fn(t,e,s))}),o}function Kr(t,e){const n=yi(t,e);return yi(n,e)}function Ei(t,e){let n=[];return t.forEach(r=>{n.push(Kr(r,e))}),n.sort((r,o)=>r.created_at-o.created_at),n}function Ph(t,e,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:Fs,tags:[],content:e};return(Array.isArray(t)?t:[t]).forEach(({publicKey:i,relayUrl:a})=>{o.tags.push(a?["p",i,a]:["p",i])}),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}function xi(t,e,n,r,o){const s=Ph(e,n,r,o);return fn(s,t,e.publicKey)}function Uh(t,e,n,r,o){if(!e||e.length===0)throw new Error("At least one recipient is required.");return[{publicKey:cn(t)},...e].map(i=>xi(t,i,n,r,o))}var Oh=Kr,Rh=Ei,Mh={};Z(Mh,{finishRepostEvent:()=>Dh,getRepostedEvent:()=>Kh,getRepostedEventPointer:()=>ki});function Dh(t,e,n,r){var i;let o;const s=[...t.tags??[],["e",e.id,n],["p",e.pubkey]];return e.kind===Vs?o=Nr:(o=Br,s.push(["k",String(e.kind)])),be({kind:o,tags:s,content:t.content===""||(i=e.tags)!=null&&i.find(a=>a[0]==="-")?"":JSON.stringify(e),created_at:t.created_at},r)}function ki(t){if(![Nr,Br].includes(t.kind))return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const o=t.tags[r];o.length>=2&&(o[0]==="e"&&e===void 0?e=o:o[0]==="p"&&n===void 0&&(n=o))}if(e!==void 0)return{id:e[1],relays:[e[2],n==null?void 0:n[2]].filter(r=>typeof r=="string"),author:n==null?void 0:n[1]}}function Kh(t,{skipVerification:e}={}){const n=ki(t);if(n===void 0||t.content==="")return;let r;try{r=JSON.parse(t.content)}catch{return}if(r.id===n.id&&!(!e&&!_r(r)))return r}var Hh={};Z(Hh,{NOSTR_URI_REGEX:()=>Hr,parse:()=>qh,test:()=>zh});var Hr=new RegExp(`nostr:(${ni.source})`);function zh(t){return typeof t=="string"&&new RegExp(`^${Hr.source}$`).test(t)}function qh(t){const e=t.match(new RegExp(`^${Hr.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:ln(e[1])}}var Vh={};Z(Vh,{finishReactionEvent:()=>jh,getReactedEventPointer:()=>Fh});function jh(t,e,n){const r=e.tags.filter(o=>o.length>=2&&(o[0]==="e"||o[0]==="p"));return be({...t,kind:Cr,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function Fh(t){if(t.kind!==Cr)return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const o=t.tags[r];o.length>=2&&(o[0]==="e"&&e===void 0?e=o:o[0]==="p"&&n===void 0&&(n=o))}if(!(e===void 0||n===void 0))return{id:e[1],relays:[e[2],n[2]].filter(r=>r!==void 0),author:n[1]}}var Wh={};Z(Wh,{parse:()=>Jh});var _i=/\W/m,Ai=/[^\w\/] |[^\w\/]$|$|,| /m,Zh=42;function*Jh(t){let e=[];if(typeof t!="string"){for(let s=0;s<t.tags.length;s++){const i=t.tags[s];i[0]==="emoji"&&i.length>=3&&e.push({type:"emoji",shortcode:i[1],url:i[2]})}t=t.content}const n=t.length;let r=0,o=0;e:for(;o<n;){const s=t.indexOf(":",o),i=t.indexOf("#",o);if(s===-1&&i===-1)break e;if(s===-1||i>=0&&i<s){if(i===0||t[i-1]===" "){const a=t.slice(i+1,i+Zh).match(_i),c=a?i+1+a.index:n;yield{type:"text",text:t.slice(r,i)},yield{type:"hashtag",value:t.slice(i+1,c)},o=c,r=o;continue e}o=i+1;continue e}if(t.slice(s-5,s)==="nostr"){const a=t.slice(s+60).match(_i),c=a?s+60+a.index:n;try{let l,{data:d,type:u}=ln(t.slice(s+1,c));switch(u){case"npub":l={pubkey:d};break;case"note":l={id:d};break;case"nsec":o=c+1;continue;default:l=d}r!==s-5&&(yield{type:"text",text:t.slice(r,s-5)}),yield{type:"reference",pointer:l},o=c,r=o;continue e}catch{o=s+1;continue e}}else if(t.slice(s-5,s)==="https"||t.slice(s-4,s)==="http"){const a=t.slice(s+4).match(Ai),c=a?s+4+a.index:n,l=t[s-1]==="s"?5:4;try{let d=new URL(t.slice(s-l,c));if(d.hostname.indexOf(".")===-1)throw new Error("invalid url");if(r!==s-l&&(yield{type:"text",text:t.slice(r,s-l)}),/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(d.pathname)){yield{type:"image",url:d.toString()},o=c,r=o;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(d.pathname)){yield{type:"video",url:d.toString()},o=c,r=o;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(d.pathname)){yield{type:"audio",url:d.toString()},o=c,r=o;continue e}yield{type:"url",url:d.toString()},o=c,r=o;continue e}catch{o=c+1;continue e}}else if(t.slice(s-3,s)==="wss"||t.slice(s-2,s)==="ws"){const a=t.slice(s+4).match(Ai),c=a?s+4+a.index:n,l=t[s-1]==="s"?3:2;try{let d=new URL(t.slice(s-l,c));if(d.hostname.indexOf(".")===-1)throw new Error("invalid ws url");r!==s-l&&(yield{type:"text",text:t.slice(r,s-l)}),yield{type:"relay",url:d.toString()},o=c,r=o;continue e}catch{o=c+1;continue e}}else{for(let a=0;a<e.length;a++){const c=e[a];if(t[s+c.shortcode.length+1]===":"&&t.slice(s+1,s+c.shortcode.length+1)===c.shortcode){r!==s&&(yield{type:"text",text:t.slice(r,s)}),yield c,o=s+c.shortcode.length+2,r=o;continue e}}o=s+1;continue e}}r!==n&&(yield{type:"text",text:t.slice(r)})}var Gh={};Z(Gh,{channelCreateEvent:()=>Yh,channelHideMessageEvent:()=>ef,channelMessageEvent:()=>Qh,channelMetadataEvent:()=>Xh,channelMuteUserEvent:()=>tf});var Yh=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Ws,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},Xh=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Zs,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},Qh=(t,e)=>{const n=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&n.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),be({kind:Js,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},ef=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Gs,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},tf=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return be({kind:Ys,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)},nf={};Z(nf,{EMOJI_SHORTCODE_REGEX:()=>Si,matchAll:()=>rf,regex:()=>zr,replaceAll:()=>of});var Si=/:(\w+):/,zr=()=>new RegExp(`\\B${Si.source}\\B`,"g");function*rf(t){const e=t.matchAll(zr());for(const n of e)try{const[r,o]=n;yield{shortcode:r,name:o,start:n.index,end:n.index+r.length}}catch{}}function of(t,e){return t.replaceAll(zr(),(n,r)=>e({shortcode:n,name:r}))}var sf={};Z(sf,{useFetchImplementation:()=>af,validateGithub:()=>cf});var qr;try{qr=fetch}catch{}function af(t){qr=t}async function cf(t,e,n){try{return await(await qr(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch{return!1}}var lf={};Z(lf,{makeNwcRequestEvent:()=>df,parseConnectionString:()=>uf});function uf(t){const{host:e,pathname:n,searchParams:r}=new URL(t),o=n||e,s=r.get("relay"),i=r.get("secret");if(!o||!s||!i)throw new Error("invalid connection string");return{pubkey:o,relay:s,secret:i}}async function df(t,e,n){const o=ri(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:n}})),s={kind:ei,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",t]]};return be(s,e)}var hf={};Z(hf,{normalizeIdentifier:()=>ff});function ff(t){return t=t.trim().toLowerCase(),t=t.normalize("NFKC"),Array.from(t).map(e=>new RegExp("\\p{Letter}","u").test(e)||new RegExp("\\p{Number}","u").test(e)?e:"-").join("")}var pf={};Z(pf,{getSatoshisAmountFromBolt11:()=>vf,getZapEndpoint:()=>gf,makeZapReceipt:()=>wf,makeZapRequest:()=>yf,useFetchImplementation:()=>mf,validateZapRequest:()=>bf});var Vr;try{Vr=fetch}catch{}function mf(t){Vr=t}async function gf(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(r){let[i,a]=r.split("@");e=new URL(`/.well-known/lnurlp/${i}`,`https://${a}`).toString()}else if(n){let{words:i}=mt.decode(n,1e3),a=mt.fromWords(i);e=Pe.decode(a)}else return null;let s=await(await Vr(e)).json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch{}return null}function yf(t){let e={kind:9734,created_at:Math.round(Date.now()/1e3),content:t.comment||"",tags:[["p","pubkey"in t?t.pubkey:t.event.pubkey],["amount",t.amount.toString()],["relays",...t.relays]]};if("event"in t){if(e.tags.push(["e",t.event.id]),Ar(t.event.kind)){const n=["a",`${t.event.kind}:${t.event.pubkey}:`];e.tags.push(n)}else if(Sr(t.event.kind)){let n=t.event.tags.find(([o,s])=>o==="d"&&s);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${t.event.kind}:${t.event.pubkey}:${n[1]}`];e.tags.push(r)}e.tags.push(["k",t.event.kind.toString()])}return e}function bf(t){let e;try{e=JSON.parse(t)}catch{return"Invalid zap request JSON."}if(!Er(e))return"Zap request is not a valid Nostr event.";if(!_r(e))return"Invalid signature on zap request.";let n=e.tags.find(([s,i])=>s==="p"&&i);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=e.tags.find(([s,i])=>s==="e"&&i);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([s,i])=>s==="relays"&&i)?null:"Zap request doesn't have a 'relays' tag."}function wf({zapRequest:t,preimage:e,bolt11:n,paidAt:r}){let o=JSON.parse(t),s=o.tags.filter(([a])=>a==="e"||a==="p"||a==="a"),i={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",o.pubkey],["bolt11",n],["description",t]]};return e&&i.tags.push(["preimage",e]),i}function vf(t){if(t.length<50)return 0;t=t.substring(0,50);const e=t.lastIndexOf("1");if(e===-1)return 0;const n=t.substring(0,e);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const o=r[r.length-1],s=o.charCodeAt(0)-48,i=s>=0&&s<=9;let a=r.length-1;if(i&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(o){case"m":return c*1e5;case"u":return c*100;case"n":return c/10;case"p":return c/1e4;default:return c*1e8}}var Ef={};Z(Ef,{Negentropy:()=>Ci,NegentropyStorageVector:()=>_f,NegentropySync:()=>Af});var jr=97,vt=32,Ni=16,at={Skip:0,Fingerprint:1,IdList:2},Ue=class{constructor(t){g(this,"_raw");g(this,"length");typeof t=="number"?(this._raw=new Uint8Array(t),this.length=0):t instanceof Uint8Array?(this._raw=new Uint8Array(t),this.length=t.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(t){if(t instanceof Ue&&(t=t.unwrap()),typeof t.length!="number")throw Error("bad length");const e=t.length+this.length;if(this.capacity<e){const n=this._raw,r=Math.max(this.capacity*2,e);this._raw=new Uint8Array(r),this._raw.set(n)}this._raw.set(t,this.length),this.length+=t.length}shift(){const t=this._raw[0];return this._raw=this._raw.subarray(1),this.length--,t}shiftN(t=1){const e=this._raw.subarray(0,t);return this._raw=this._raw.subarray(t),this.length-=t,e}};function pn(t){let e=0;for(;;){if(t.length===0)throw Error("parse ends prematurely");let n=t.shift();if(e=e<<7|n&127,(n&128)===0)break}return e}function Oe(t){if(t===0)return new Ue(new Uint8Array([0]));let e=[];for(;t!==0;)e.push(t&127),t>>>=7;e.reverse();for(let n=0;n<e.length-1;n++)e[n]|=128;return new Ue(new Uint8Array(e))}function xf(t){return mn(t,1)[0]}function mn(t,e){if(t.length<e)throw Error("parse ends prematurely");return t.shiftN(e)}var kf=class{constructor(){g(this,"buf");this.setToZero()}setToZero(){this.buf=new Uint8Array(vt)}add(t){let e=0,n=0,r=new DataView(this.buf.buffer),o=new DataView(t.buffer);for(let s=0;s<8;s++){let i=s*4,a=r.getUint32(i,!0),c=o.getUint32(i,!0),l=a;l+=e,l+=c,l>4294967295&&(n=1),r.setUint32(i,l&4294967295,!0),e=n,n=0}}negate(){let t=new DataView(this.buf.buffer);for(let n=0;n<8;n++){let r=n*4;t.setUint32(r,~t.getUint32(r,!0))}let e=new Uint8Array(vt);e[0]=1,this.add(e)}getFingerprint(t){let e=new Ue;return e.extend(this.buf),e.extend(Oe(t)),me(e.unwrap()).subarray(0,Ni)}},_f=class{constructor(){g(this,"items");g(this,"sealed");this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");const n=As(e);if(n.byteLength!==vt)throw Error("bad id size for added item");this.items.push({timestamp:t,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(Fr);for(let t=1;t<this.items.length;t++)if(Fr(this.items[t-1],this.items[t])===0)throw Error("duplicate item inserted")}unseal(){this.sealed=!1}size(){return this._checkSealed(),this.items.length}getItem(t){if(this._checkSealed(),t>=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,n){this._checkSealed(),this._checkBounds(t,e);for(let r=t;r<e&&n(this.items[r],r);++r);}findLowerBound(t,e,n){return this._checkSealed(),this._checkBounds(t,e),this._binarySearch(this.items,t,e,r=>Fr(r,n)<0)}fingerprint(t,e){let n=new kf;return n.setToZero(),this.iterate(t,e,r=>(n.add(r.id),!0)),n.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,n,r){let o=n-e;for(;o>0;){let s=e,i=Math.floor(o/2);s+=i,r(t[s])?(e=++s,o-=i+1):o=i}return e}},Ci=class{constructor(t,e=6e4){g(this,"storage");g(this,"frameSizeLimit");g(this,"lastTimestampIn");g(this,"lastTimestampOut");if(e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}initiate(){let t=new Ue;return t.extend(new Uint8Array([jr])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),gt(t.unwrap())}reconcile(t,e,n){const r=new Ue(As(t));this.lastTimestampIn=this.lastTimestampOut=0;let o=new Ue;o.extend(new Uint8Array([jr]));let s=xf(r);if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(s!==jr)throw Error("unsupported negentropy protocol version requested: "+(s-96));let i=this.storage.size(),a=this._bound(0),c=0,l=!1;for(;r.length!==0;){let d=new Ue,u=()=>{l&&(l=!1,d.extend(this.encodeBound(a)),d.extend(Oe(at.Skip)))},p=this.decodeBound(r),f=pn(r),m=c,h=this.storage.findLowerBound(c,i,p);if(f===at.Skip)l=!0;else if(f===at.Fingerprint){let y=mn(r,Ni),v=this.storage.fingerprint(m,h);Bi(y,v)!==0?(u(),this.splitRange(m,h,p,d)):l=!0}else if(f===at.IdList){let y=pn(r),v={};for(let x=0;x<y;x++){let S=mn(r,vt);v[gt(S)]=S}if(l=!0,this.storage.iterate(m,h,x=>{let S=x.id;const M=gt(S);return v[M]?delete v[gt(S)]:e==null||e(M),!0}),n)for(let x of Object.values(v))n(gt(x))}else throw Error("unexpected mode");if(this.exceededFrameSizeLimit(o.length+d.length)){let y=this.storage.fingerprint(h,i);o.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),o.extend(Oe(at.Fingerprint)),o.extend(y);break}else o.extend(d);c=h,a=p}return o.length===1?null:gt(o.unwrap())}splitRange(t,e,n,r){let o=e-t,s=16;if(o<s*2)r.extend(this.encodeBound(n)),r.extend(Oe(at.IdList)),r.extend(Oe(o)),this.storage.iterate(t,e,i=>(r.extend(i.id),!0));else{let i=Math.floor(o/s),a=o%s,c=t;for(let l=0;l<s;l++){let d=i+(l<a?1:0),u=this.storage.fingerprint(c,c+d);c+=d;let p;if(c===e)p=n;else{let f,m;this.storage.iterate(c-1,c+1,(h,y)=>(y===c-1?f=h:m=h,!0)),p=this.getMinimalBound(f,m)}r.extend(this.encodeBound(p)),r.extend(Oe(at.Fingerprint)),r.extend(u)}}}exceededFrameSizeLimit(t){return t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=pn(t);return e=e===0?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),n=pn(t);if(n>vt)throw Error("bound key too long");let r=mn(t,n);return{timestamp:e,id:r}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,Oe(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,Oe(t+1)}encodeBound(t){let e=new Ue;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(Oe(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let n=0,r=e.id,o=t.id;for(let s=0;s<vt&&r[s]===o[s];s++)n++;return this._bound(e.timestamp,e.id.subarray(0,n+1))}}};function Bi(t,e){for(let n=0;n<t.byteLength;n++){if(t[n]<e[n])return-1;if(t[n]>e[n])return 1}return t.byteLength>e.byteLength?1:t.byteLength<e.byteLength?-1:0}function Fr(t,e){return t.timestamp===e.timestamp?Bi(t.id,e.id):t.timestamp-e.timestamp}var Af=class{constructor(t,e,n,r={}){g(this,"relay");g(this,"storage");g(this,"neg");g(this,"filter");g(this,"subscription");g(this,"onhave");g(this,"onneed");this.relay=t,this.storage=e,this.neg=new Ci(e),this.onhave=r.onhave,this.onneed=r.onneed,this.filter=n,this.subscription=this.relay.prepareSubscription([{}],{label:r.label||"negentropy"}),this.subscription.oncustom=o=>{var s,i,a,c;switch(o[0]){case"NEG-MSG":{o.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${o}`);try{const l=this.neg.reconcile(o[2],this.onhave,this.onneed);l?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${l}"]`):(this.close(),(s=r.onclose)==null||s.call(r))}catch(l){console.error("negentropy reconcile error:",l),(i=r==null?void 0:r.onclose)==null||i.call(r,`reconcile error: ${l}`)}break}case"NEG-CLOSE":{const l=o[2];console.warn("negentropy error:",l),(a=r.onclose)==null||a.call(r,l);break}case"NEG-ERR":(c=r.onclose)==null||c.call(r)}}}async start(){const t=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${t}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}},Sf={};Z(Sf,{getToken:()=>Nf,hashPayload:()=>Wr,unpackEventFromToken:()=>Ii,validateEvent:()=>Ri,validateEventKind:()=>Ti,validateEventMethodTag:()=>Ui,validateEventPayloadTag:()=>Oi,validateEventTimestamp:()=>$i,validateEventUrlTag:()=>Pi,validateToken:()=>Cf});var Li="Nostr ";async function Nf(t,e,n,r=!1,o){const s={kind:Lr,tags:[["u",t],["method",e]],created_at:Math.round(new Date().getTime()/1e3),content:""};o&&s.tags.push(["payload",Wr(o)]);const i=await n(s);return(r?Li:"")+ge.encode(ye.encode(JSON.stringify(i)))}async function Cf(t,e,n){const r=await Ii(t).catch(s=>{throw s});return await Ri(r,e,n).catch(s=>{throw s})}async function Ii(t){if(!t)throw new Error("Missing token");t=t.replace(Li,"");const e=Pe.decode(ge.decode(t));if(!e||e.length===0||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}function $i(t){return t.created_at?Math.round(new Date().getTime()/1e3)-t.created_at<60:!1}function Ti(t){return t.kind===Lr}function Pi(t,e){const n=t.tags.find(r=>r[0]==="u");return n?n.length>0&&n[1]===e:!1}function Ui(t,e){const n=t.tags.find(r=>r[0]==="method");return n?n.length>0&&n[1].toLowerCase()===e.toLowerCase():!1}function Wr(t){const e=me(ye.encode(JSON.stringify(t)));return Y(e)}function Oi(t,e){const n=t.tags.find(o=>o[0]==="payload");if(!n)return!1;const r=Wr(e);return n.length>0&&n[1]===r}async function Ri(t,e,n,r){if(!_r(t))throw new Error("Invalid nostr event, signature invalid");if(!Ti(t))throw new Error("Invalid nostr event, kind invalid");if(!$i(t))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Pi(t,e))throw new Error("Invalid nostr event, url tag invalid");if(!Ui(t,n))throw new Error("Invalid nostr event, method tag invalid");if(r&&typeof r=="object"&&Object.keys(r).length>0&&!Oi(t,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}class Et{constructor(e){g(this,"secretKey");g(this,"pubkey");this.secretKey=e||kr(),this.pubkey=cn(this.secretKey)}async getPublicKey(){return this.pubkey}async signEvent(e){return be(e,this.secretKey)}getNsec(){return wt.nsecEncode(this.secretKey)}getNpub(){return wt.npubEncode(this.pubkey)}exportKeyFile(){return{nsec:this.getNsec(),npub:this.getNpub(),pubkey:this.pubkey}}downloadKeyFile(){const e=this.exportKeyFile(),n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`nostr-key-${this.pubkey.slice(0,8)}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}copyNsec(){return navigator.clipboard.writeText(this.getNsec())}static fromNsec(e){const{type:n,data:r}=wt.decode(e);if(n!=="nsec")throw new Error("Invalid nsec");return new Et(r)}}var ct=Symbol("verified"),Bf=t=>t instanceof Object;function Lf(t){if(!Bf(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}var If=new TextDecoder("utf-8"),Mi=new TextEncoder;function xt(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}var $f=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},Tf=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new $f(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},Pf=class{generateSecretKey(){return xe.utils.randomPrivateKey()}getPublicKey(e){return Y(xe.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(xe.getPublicKey(n)),r.id=Zr(r),r.sig=Y(xe.sign(Zr(r),n)),r[ct]=!0,r}verifyEvent(e){if(typeof e[ct]=="boolean")return e[ct];const n=Zr(e);if(n!==e.id)return e[ct]=!1,!1;try{const r=xe.verify(e.sig,n,e.pubkey);return e[ct]=r,r}catch{return e[ct]=!1,!1}}};function Uf(t){if(!Lf(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Zr(t){let e=me(Mi.encode(Uf(t)));return Y(e)}var gn=new Pf;gn.generateSecretKey;var Di=gn.getPublicKey,Of=gn.finalizeEvent,Ki=gn.verifyEvent,Hi=1,zi=65535;function Jr(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return Ms(me,n,"nip44-v2")}function qi(t,e){const n=Ks(me,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Vi(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Rf(t){if(!Number.isSafeInteger(t)||t<Hi||t>zi)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}function Mf(t){const e=Mi.encode(t),n=e.length,r=Rf(n),o=new Uint8Array(Vi(n)-n);return it(r,e,o)}function Df(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Hi||e>zi||n.length!==e||t.length!==2+Vi(e))throw new Error("invalid padding");return If.decode(n)}function ji(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=it(n,e);return Ot(me,t,r)}function Kf(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=ge.decode(t)}catch(s){throw new Error("invalid base64: "+s.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Hf(t,e,n=cr(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=qi(e,n),i=Mf(t),a=on(r,o,i),c=ji(s,a,n);return ge.encode(it(new Uint8Array([2]),n,a,c))}function Fi(t,e){const{nonce:n,ciphertext:r,mac:o}=Kf(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=qi(e,n),c=ji(a,r,n);if(!Ss(c,o))throw new Error("invalid MAC");const l=on(s,i,r);return Df(l)}var zf=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,qf;try{qf=fetch}catch{}var Vf=22242,Gr=24133;function jf(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([s,i])=>s===n.slice(1)&&o.indexOf(i)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Ff(t,e){for(let n=0;n<t.length;n++)if(jf(t[n],e))return!0;return!1}function Wf(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function Zf(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function Jf(t,e){return{kind:Vf,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Gf(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}var Yf=t=>(t[ct]=!0,!0),Wi=class extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}},Zi=class{constructor(e,n){g(this,"url");g(this,"_connected",!1);g(this,"onclose",null);g(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));g(this,"onauth");g(this,"baseEoseTimeout",4400);g(this,"publishTimeout",4400);g(this,"pingFrequency",29e3);g(this,"pingTimeout",2e4);g(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);g(this,"openSubs",new Map);g(this,"enablePing");g(this,"enableReconnect");g(this,"reconnectTimeoutHandle");g(this,"pingIntervalHandle");g(this,"reconnectAttempts",0);g(this,"closedIntentionally",!1);g(this,"connectionPromise");g(this,"openCountRequests",new Map);g(this,"openEventPublishes",new Map);g(this,"ws");g(this,"incomingMessageQueue",new Tf);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=xt(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket,this.enablePing=n.enablePing,this.enableReconnect=n.enableReconnect||!1}static async connect(e,n){const r=new Zi(e,n);return await r.connect(n),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},e)}handleHardClose(e){var r;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,(r=this.onclose)==null||r.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(e)}async connect(e){let n;return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((r,o)=>{e!=null&&e.timeout&&(n=setTimeout(()=>{var s;o("connection timed out"),this.connectionPromise=void 0,(s=this.onclose)==null||s.call(this),this.closeAllSubscriptions("relay connection timed out")},e.timeout)),e!=null&&e.abort&&(e.abort.onabort=o);try{this.ws=new this._WebSocket(this.url)}catch(s){clearTimeout(n),o(s);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(n),this._connected=!0;const s=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const i of this.openSubs.values()){if(i.eosed=!1,s)for(let a=0;a<i.filters.length;a++)i.lastEmitted&&(i.filters[a].since=i.lastEmitted+1);i.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),r()},this.ws.onerror=s=>{clearTimeout(n),o(s.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=s=>{clearTimeout(n),o(s.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,n)=>{if(!this.connectionPromise)return n(new Error(`no connection to ${this.url}, can't ping`));try{const r=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),r.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(r){n(r)}})}async pingpong(){var e,n,r;((e=this.ws)==null?void 0:e.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(s=>setTimeout(()=>s(!1),this.pingTimeout))])||((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Gf();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=Zf(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=Wf(e,"id"),c=(r=i.alreadyHaveEvent)==null?void 0:r.call(i,a);if((o=i.receivedEvent)==null||o.call(i,this,a),c)return}try{let i=JSON.parse(e);switch(i[0]){case"EVENT":{const a=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&Ff(a.filters,c)&&a.onevent(c),(!a.lastEmitted||a.lastEmitted<c.created_at)&&(a.lastEmitted=c.created_at);return}case"COUNT":{const a=i[1],c=i[2],l=this.openCountRequests.get(a);l&&(l.resolve(c.count),this.openCountRequests.delete(a));return}case"EOSE":{const a=this.openSubs.get(i[1]);if(!a)return;a.receivedEose();return}case"OK":{const a=i[1],c=i[2],l=i[3],d=this.openEventPublishes.get(a);d&&(clearTimeout(d.timeout),c?d.resolve(l):d.reject(new Error(l)),this.openEventPublishes.delete(a));return}case"CLOSED":{const a=i[1],c=this.openSubs.get(a);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":{this.onnotice(i[1]);return}case"AUTH":{this.challenge=i[1],this.onauth&&this.auth(this.onauth);return}default:{const a=this.openSubs.get(i[1]);(s=a==null?void 0:a.oncustom)==null||s.call(a,i);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Wi(e,this.url);this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){const n=this.challenge;if(!n)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,o)=>{try{let s=await e(Jf(this.url,n)),i=setTimeout(()=>{let a=this.openEventPublishes.get(s.id);a&&(a.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:r,reject:o,timeout:i}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(s){console.warn("subscribe auth function failed:",s)}}),this.authPromise)}async publish(e){const n=new Promise((r,o)=>{const s=setTimeout(()=>{const i=this.openEventPublishes.get(e.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:r,reject:o,timeout:s})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((s,i)=>{this.openCountRequests.set(r,{resolve:s,reject:i})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),n.abort&&(n.abort.onabort=()=>r.close(String(n.abort.reason||"<aborted>"))),r}prepareSubscription(e,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new Xf(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e,n,r;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.onclose)==null||e.call(this),((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close())}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Xf=class{constructor(e,n,r,o){g(this,"relay");g(this,"id");g(this,"lastEmitted");g(this,"closed",!1);g(this,"eosed",!1);g(this,"filters");g(this,"alreadyHaveEvent");g(this,"receivedEvent");g(this,"onevent");g(this,"oneose");g(this,"onclose");g(this,"oncustom");g(this,"eoseTimeout");g(this,"eoseTimeoutHandle");if(r.length===0)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(s=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,s)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(r){if(!(r instanceof Wi))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},Qf=class{constructor(e){g(this,"relays",new Map);g(this,"seenOn",new Map);g(this,"trackRelays",!1);g(this,"verifyEvent");g(this,"enablePing");g(this,"enableReconnect");g(this,"automaticallyAuth");g(this,"trustedRelayURLs",new Set);g(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,n){e=xt(e);let r=this.relays.get(e);if(r||(r=new Zi(e,{verifyEvent:this.trustedRelayURLs.has(e)?Yf:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),r.onclose=()=>{r&&!r.enableReconnect&&this.relays.delete(e)},this.relays.set(e,r)),this.automaticallyAuth){const o=this.automaticallyAuth(e);o&&(r.onauth=o)}return await r.connect({timeout:n==null?void 0:n.connectionTimeout,abort:n==null?void 0:n.abort}),r}close(e){e.map(xt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close(),this.relays.delete(n)})}subscribe(e,n,r){const o=[];for(let s=0;s<e.length;s++){const i=xt(e[s]);o.find(a=>a.url===i)||o.push({url:i,filter:n})}return this.subscribeMap(o,r)}subscribeMany(e,n,r){const o=[],s=[];for(let i=0;i<e.length;i++){const a=xt(e[i]);s.indexOf(a)===-1&&(s.push(a),o.push({url:a,filter:n}))}return this.subscribeMap(o,r)}subscribeMap(e,n){const r=new Map;for(const f of e){const{url:m,filter:h}=f;r.has(m)||r.set(m,[]),r.get(m).push(h)}const o=Array.from(r.entries()).map(([f,m])=>({url:f,filters:m}));this.trackRelays&&(n.receivedEvent=(f,m)=>{let h=this.seenOn.get(m);h||(h=new Set,this.seenOn.set(m,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var m;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((m=n.oneose)==null||m.call(n),c=()=>{}))};const l=[];let d=(f,m)=>{var h;l[f]||(c(f),l[f]=m,l.filter(y=>y).length===o.length&&((h=n.onclose)==null||h.call(n,l),d=()=>{}))};const u=f=>{var h;if((h=n.alreadyHaveEvent)!=null&&h.call(n,f))return!0;const m=s.has(f);return s.add(f),m},p=Promise.all(o.map(async({url:f,filters:m},h)=>{let y;try{y=await this.ensureRelay(f,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0,abort:n.abort})}catch(x){d(h,(x==null?void 0:x.message)||String(x));return}let v=y.subscribe(m,{...n,oneose:()=>c(h),onclose:x=>{x.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(m,{...n,oneose:()=>c(h),onclose:S=>{d(h,S)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort})}).catch(S=>{d(h,`auth was required and attempted, but failed with: ${S}`)}):d(h,x)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await p,i.forEach(m=>{m.close(f)})}}}subscribeEose(e,n,r){const o=this.subscribe(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}async querySync(e,n,r){return new Promise(async o=>{const s=[];this.subscribeEose(e,n,{...r,onevent(i){s.push(i)},onclose(i){o(s)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((s,i)=>i.created_at-s.created_at),o[0]||null}publish(e,n,r){return e.map(xt).map(async(o,s,i)=>{if(i.indexOf(o)!==s)return Promise.reject("duplicate url");let a=await this.ensureRelay(o);return a.publish(n).catch(async c=>{if(c instanceof Error&&c.message.startsWith("auth-required: ")&&(r!=null&&r.onauth))return await a.auth(r.onauth),a.publish(n);throw c}).then(c=>{if(this.trackRelays){let l=this.seenOn.get(n.id);l||(l=new Set,this.seenOn.set(n.id,l)),l.add(a)}return c})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},Ji;try{Ji=WebSocket}catch{}var ep=class extends Qf{constructor(e){super({verifyEvent:Ki,websocketImplementation:Ji,...e})}},Gi;try{Gi=fetch}catch{}var tp=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function np(t){let e=t.match(tp);if(e)try{const n=e[1],r=new URLSearchParams(e[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return rp(t)}async function rp(t){const e=t.match(zf);if(!e)return null;const[n,r="_",o]=e;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,i=await(await Gi(s,{redirect:"error"})).json();let a=i.names[r],c=i.nip46[a]||[];return{pubkey:a,relays:c,secret:null}}catch{return null}}var Yr=class{constructor(e,n){g(this,"params");g(this,"pool");g(this,"subCloser");g(this,"isOpen");g(this,"serial");g(this,"idPrefix");g(this,"listeners");g(this,"waitingForAuth");g(this,"secretKey");g(this,"conversationKey");g(this,"bp");g(this,"cachedPubKey");this.params=n,this.pool=n.pool||new ep,this.secretKey=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={}}static fromBunker(e,n,r={}){if(n.relays.length===0)throw new Error("no relays specified for this bunker");const o=new Yr(e,r);return o.conversationKey=Jr(e,n.pubkey),o.bp=n,o.setupSubscription(),o}static async fromURI(e,n,r={},o=3e5){const s=new Yr(e,r),i=new URL(n),a=Di(e);return new Promise((c,l)=>{let d=!1;const u=s.pool.subscribe(i.searchParams.getAll("relay"),{kinds:[Gr],"#p":[a],limit:0},{onevent:async p=>{try{const f=Jr(e,p.pubkey),m=Fi(p.content,f);JSON.parse(m).result===i.searchParams.get("secret")&&(u.close(),s.bp={pubkey:p.pubkey,relays:i.searchParams.getAll("relay"),secret:i.searchParams.get("secret")},s.conversationKey=Jr(e,p.pubkey),s.setupSubscription(),d=!0,await Promise.race([new Promise(y=>setTimeout(y,1e3)),s.switchRelays()]),c(s))}catch(f){console.warn("failed to process potential connection event",f)}},onclose:()=>{d||l(new Error("subscription closed before connection was established."))},maxWait:typeof o=="number"?o:void 0,abort:typeof o!="number"?o:void 0})})}setupSubscription(){const e=this.listeners,n=this.waitingForAuth,r=this.conversationKey;this.subCloser=this.pool.subscribe(this.bp.relays,{kinds:[Gr],authors:[this.bp.pubkey],"#p":[Di(this.secretKey)],limit:0},{onevent:async o=>{const s=JSON.parse(Fi(o.content,r)),{id:i,result:a,error:c}=s;if(a==="auth_url"&&n[i]){delete n[i],this.params.onauth?this.params.onauth(c):console.warn(`nostr-tools/nip46: remote signer ${this.bp.pubkey} tried to send an "auth_url"='${c}' but there was no onauth() callback configured.`);return}let l=e[i];l&&(c?l.reject(c):a&&l.resolve(a),delete e[i])},onclose:()=>{this.subCloser=void 0}}),this.isOpen=!0}async switchRelays(){try{const e=await this.sendRequest("switch_relays",[]);let n=JSON.parse(e);if(!n||JSON.stringify(n.sort())===JSON.stringify(this.bp.relays))return!1;this.bp.relays=n;let r=this.subCloser;return setTimeout(()=>{r.close()},5e3),this.subCloser=void 0,this.setupSubscription(),!0}catch{return!1}}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(e,n){return new Promise(async(r,o)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.subCloser||this.setupSubscription(),this.serial++;const s=`${this.idPrefix}-${this.serial}`,i=Hf(JSON.stringify({id:s,method:e,params:n}),this.conversationKey),a=Of({kind:Gr,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[s]={resolve:r,reject:o},this.waitingForAuth[s]=!0,await Promise.any(this.pool.publish(this.bp.relays,a))}catch(s){o(s)}})}async ping(){let e=await this.sendRequest("ping",[]);if(e!=="pong")throw new Error(`result is not pong: ${e}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async signEvent(e){let n=await this.sendRequest("sign_event",[JSON.stringify(e)]),r=JSON.parse(n);if(Ki(r))return r;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(r)}`)}async nip04Encrypt(e,n){return await this.sendRequest("nip04_encrypt",[e,n])}async nip04Decrypt(e,n){return await this.sendRequest("nip04_decrypt",[e,n])}async nip44Encrypt(e,n){return await this.sendRequest("nip44_encrypt",[e,n])}async nip44Decrypt(e,n){return await this.sendRequest("nip44_decrypt",[e,n])}};class yn{constructor(e){g(this,"signer");g(this,"cachedPubKey");this.signer=e}async connect(){await this.signer.connect()}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.signer.getPublicKey()),this.cachedPubKey}async signEvent(e){return await this.signer.signEvent(e)}async close(){await this.signer.close()}static async create(e){const n=await np(e);if(!n)throw new Error("Invalid bunker input");const r=Yr.fromBunker(kr(),n,{onauth:o=>{window.open(o,"_blank")}});return new yn(r)}}let Re={signer:null,signerInfo:null,loading:!1,error:null};const Xr=new Set;function re(t){Re={...Re,...t},Xr.forEach(e=>e())}function op(t){return Xr.add(t),()=>Xr.delete(t)}function Yi(){return Re}function sp(){return Re.signer!==null}function kt(){const{signer:t,signerInfo:e,loading:n,error:r}=z.useSyncExternalStore(op,Yi,Yi),o=z.useCallback(async()=>{if(!Wt.isAvailable()){re({error:"NIP-07 extension not found"});return}re({loading:!0,error:null});try{const u=new Wt,p=await u.getPublicKey();re({signer:u,signerInfo:{type:"nip07",pubkey:p},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),s=z.useCallback(async()=>{re({loading:!0,error:null});try{const u=new Et,p=await u.getPublicKey();re({signer:u,signerInfo:{type:"temp",pubkey:p},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),i=z.useCallback(async u=>{re({loading:!0,error:null});try{const p=Et.fromNsec(u.trim()),f=await p.getPublicKey();re({signer:p,signerInfo:{type:"temp",pubkey:f},loading:!1})}catch(p){throw re({error:p instanceof Error?p.message:"Invalid nsec",loading:!1}),p}},[]),a=z.useCallback(async u=>{re({loading:!0,error:null});try{const p=await yn.create(u);await p.connect();const f=await p.getPublicKey();re({signer:p,signerInfo:{type:"bunker",pubkey:f},loading:!1})}catch(p){re({error:p instanceof Error?p.message:"Login failed",loading:!1})}},[]),c=z.useCallback(()=>{var u;((u=Re.signerInfo)==null?void 0:u.type)==="bunker"&&Re.signer&&Re.signer.close(),re({signer:null,signerInfo:null,error:null})},[]),l=z.useCallback(()=>{re({error:null})},[]),d=z.useCallback(()=>{var u;return((u=Re.signerInfo)==null?void 0:u.type)==="temp"?Re.signer:null},[]);return{signer:t,signerInfo:e,loading:n,error:r,isLoggedIn:t!==null,loginWithNip07:o,loginWithTemp:s,loginWithNsec:i,loginWithBunker:a,logout:c,clearError:l,getTempSigner:d,isNip07Available:Wt.isAvailable()}}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ip(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Qr(t,e=""){if(!Number.isSafeInteger(t)||t<0){const n=e&&`"${e}" `;throw new Error(`${n}expected integer >= 0, got ${t}`)}}function ae(t,e,n=""){const r=ip(t),o=t==null?void 0:t.length,s=e!==void 0;if(!r||s&&o!==e){const i=n&&`"${n}" `,a=s?` of length ${e}`:"",c=r?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return t}function Xi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ap(t,e){ae(t,void 0,"digestInto() output");const n=e.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function eo(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function to(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ne(t,e){return t<<32-e|t>>>e}const Qi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",cp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ce(t){if(ae(t),Qi)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=cp[t[n]];return e}const Me={_0:48,_9:57,A:65,F:70,a:97,f:102};function ea(t){if(t>=Me._0&&t<=Me._9)return t-Me._0;if(t>=Me.A&&t<=Me.F)return t-(Me.A-10);if(t>=Me.a&&t<=Me.f)return t-(Me.a-10)}function lt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Qi)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=ea(t.charCodeAt(s)),a=ea(t.charCodeAt(s+1));if(i===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[o]=i*16+a}return r}function bn(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];ae(o),e+=o.length}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const s=t[r];n.set(s,o),o+=s.length}return n}function lp(t,e={}){const n=(o,s)=>t(s).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function ta(t=32){const e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(e==null?void 0:e.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}const up=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function dp(t,e,n){return t&e^~t&n}function hp(t,e,n){return t&e^t&n^e&n}class fp{constructor(e,n,r,o){g(this,"blockLen");g(this,"outputLen");g(this,"padOffset");g(this,"isLE");g(this,"buffer");g(this,"view");g(this,"finished",!1);g(this,"length",0);g(this,"pos",0);g(this,"destroyed",!1);this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=to(this.buffer)}update(e){Xi(this),ae(e);const{view:n,buffer:r,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=to(e);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Xi(this),ap(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,eo(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let u=i;u<o;u++)n[u]=0;r.setBigUint64(o-8,BigInt(this.length*8),s),this.process(r,0);const a=to(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pp=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64);class mp extends fp{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:a,H:c}=this;return[e,n,r,o,s,i,a,c]}set(e,n,r,o,s,i,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)Ge[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const p=Ge[u-15],f=Ge[u-2],m=Ne(p,7)^Ne(p,18)^p>>>3,h=Ne(f,17)^Ne(f,19)^f>>>10;Ge[u]=h+Ge[u-7]+m+Ge[u-16]|0}let{A:r,B:o,C:s,D:i,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const p=Ne(a,6)^Ne(a,11)^Ne(a,25),f=d+p+dp(a,c,l)+pp[u]+Ge[u]|0,h=(Ne(r,2)^Ne(r,13)^Ne(r,22))+hp(r,o,s)|0;d=l,l=c,c=a,a=i+f|0,i=s,s=o,o=r,r=f+h|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,s,i,a,c,l,d)}roundClean(){eo(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),eo(this.buffer)}}class gp extends mp{constructor(){super(32);g(this,"A",Je[0]|0);g(this,"B",Je[1]|0);g(this,"C",Je[2]|0);g(this,"D",Je[3]|0);g(this,"E",Je[4]|0);g(this,"F",Je[5]|0);g(this,"G",Je[6]|0);g(this,"H",Je[7]|0)}}const no=lp(()=>new gp,up(1)),ro=BigInt(0),oo=BigInt(1);function na(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}" `;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function yp(t){if(typeof t=="bigint"){if(!wp(t))throw new Error("positive bigint expected, got "+t)}else Qr(t);return t}function ra(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ro:BigInt("0x"+t)}function so(t){return ra(ce(t))}function oa(t){return ra(ce(bp(ae(t)).reverse()))}function io(t,e){Qr(e),t=yp(t);const n=lt(t.toString(16).padStart(e*2,"0"));if(n.length!==e)throw new Error("number too large");return n}function sa(t,e){return io(t,e).reverse()}function bp(t){return Uint8Array.from(t)}function ia(t){return Uint8Array.from(t,(e,n)=>{const r=e.charCodeAt(0);if(e.length!==1||r>127)throw new Error(`string contains non-ASCII character "${t[n]}" with code ${r} at position ${n}`);return r})}const wp=t=>typeof t=="bigint"&&ro<=t;function vp(t){let e;for(e=0;t>ro;t>>=oo,e+=1);return e}const aa=t=>(oo<<BigInt(t))-oo;function ca(t,e={},n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(s,i,a){const c=t[s];if(a&&c===void 0)return;const l=typeof c;if(l!==i||c===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${l}`)}const o=(s,i)=>Object.entries(s).forEach(([a,c])=>r(a,c,i));o(e,!1),o(n,!0)}function la(t){const e=new WeakMap;return(n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const le=BigInt(0),oe=BigInt(1),ut=BigInt(2),ua=BigInt(3),da=BigInt(4),ha=BigInt(5),Ep=BigInt(7),fa=BigInt(8),xp=BigInt(9),pa=BigInt(16);function we(t,e){const n=t%e;return n>=le?n:e+n}function pe(t,e,n){let r=t;for(;e-- >le;)r*=r,r%=n;return r}function ma(t,e){if(t===le)throw new Error("invert: expected non-zero number");if(e<=le)throw new Error("invert: expected positive modulus, got "+e);let n=we(t,e),r=e,o=le,s=oe;for(;n!==le;){const a=r/n,c=r%n,l=o-s*a;r=n,n=c,o=s,s=l}if(r!==oe)throw new Error("invert: does not exist");return we(o,e)}function ao(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function ga(t,e){const n=(t.ORDER+oe)/da,r=t.pow(e,n);return ao(t,r,e),r}function kp(t,e){const n=(t.ORDER-ha)/fa,r=t.mul(e,ut),o=t.pow(r,n),s=t.mul(e,o),i=t.mul(t.mul(s,ut),o),a=t.mul(s,t.sub(i,t.ONE));return ao(t,a,e),a}function _p(t){const e=wn(t),n=ya(t),r=n(e,e.neg(e.ONE)),o=n(e,r),s=n(e,e.neg(r)),i=(t+Ep)/pa;return(a,c)=>{let l=a.pow(c,i),d=a.mul(l,r);const u=a.mul(l,o),p=a.mul(l,s),f=a.eql(a.sqr(d),c),m=a.eql(a.sqr(u),c);l=a.cmov(l,d,f),d=a.cmov(p,u,m);const h=a.eql(a.sqr(d),c),y=a.cmov(l,d,h);return ao(a,y,c),y}}function ya(t){if(t<ua)throw new Error("sqrt is not defined for small field");let e=t-oe,n=0;for(;e%ut===le;)e/=ut,n++;let r=ut;const o=wn(t);for(;wa(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return ga;let s=o.pow(r,e);const i=(e+oe)/ut;return function(c,l){if(c.is0(l))return l;if(wa(c,l)!==1)throw new Error("Cannot find square root");let d=n,u=c.mul(c.ONE,s),p=c.pow(l,e),f=c.pow(l,i);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let m=1,h=c.sqr(p);for(;!c.eql(h,c.ONE);)if(m++,h=c.sqr(h),m===d)throw new Error("Cannot find square root");const y=oe<<BigInt(d-m-1),v=c.pow(u,y);d=m,u=c.sqr(v),p=c.mul(p,u),f=c.mul(f,v)}return f}}function Ap(t){return t%da===ua?ga:t%fa===ha?kp:t%pa===xp?_p(t):ya(t)}const Sp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Np(t){const e={ORDER:"bigint",BYTES:"number",BITS:"number"},n=Sp.reduce((r,o)=>(r[o]="function",r),e);return ca(t,n),t}function Cp(t,e,n){if(n<le)throw new Error("invalid exponent, negatives unsupported");if(n===le)return t.ONE;if(n===oe)return e;let r=t.ONE,o=e;for(;n>le;)n&oe&&(r=t.mul(r,o)),o=t.sqr(o),n>>=oe;return r}function ba(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),o=e.reduce((i,a,c)=>t.is0(a)?i:(r[c]=i,t.mul(i,a)),t.ONE),s=t.inv(o);return e.reduceRight((i,a,c)=>t.is0(a)?i:(r[c]=t.mul(i,r[c]),t.mul(i,a)),s),r}function wa(t,e){const n=(t.ORDER-oe)/ut,r=t.pow(e,n),o=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Bp(t,e){e!==void 0&&Qr(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}class Lp{constructor(e,n={}){g(this,"ORDER");g(this,"BITS");g(this,"BYTES");g(this,"isLE");g(this,"ZERO",le);g(this,"ONE",oe);g(this,"_lengths");g(this,"_sqrt");g(this,"_mod");var i;if(e<=le)throw new Error("invalid field: expected ORDER > 0, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=(i=n.allowedLengths)==null?void 0:i.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:o,nByteLength:s}=Bp(e,r);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return we(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return le<=e&&e<this.ORDER}is0(e){return e===le}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&oe)===oe}neg(e){return we(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return we(e*e,this.ORDER)}add(e,n){return we(e+n,this.ORDER)}sub(e,n){return we(e-n,this.ORDER)}mul(e,n){return we(e*n,this.ORDER)}pow(e,n){return Cp(this,e,n)}div(e,n){return we(e*ma(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return ma(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=Ap(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?sa(e,this.BYTES):io(e,this.BYTES)}fromBytes(e,n=!1){ae(e);const{_lengths:r,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(r){if(!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);const l=new Uint8Array(o);l.set(e,s?0:l.length-e.length),e=l}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=s?oa(e):so(e);if(a&&(c=we(c,i)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return ba(this,e)}cmov(e,n,r){return r?n:e}}function wn(t,e={}){return new Lp(t,e)}function va(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ip(t){const e=va(t);return e+Math.ceil(e/2)}function $p(t,e,n=!1){ae(t);const r=t.length,o=va(e),s=Ip(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?oa(t):so(t),a=we(i,e-oe)+oe;return n?sa(a,o):io(a,o)}const _t=BigInt(0),dt=BigInt(1);function vn(t,e){const n=e.negate();return t?n:e}function Ea(t,e){const n=ba(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function xa(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function co(t,e){xa(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),o=2**t,s=aa(t),i=BigInt(t);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function ka(t,e,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let a=Number(t&o),c=t>>i;a>r&&(a-=s,c+=dt);const l=e*r,d=l+Math.abs(a)-1,u=a===0,p=a<0,f=e%2!==0;return{nextN:c,offset:d,isZero:u,isNeg:p,isNegF:f,offsetF:l}}const lo=new WeakMap,_a=new WeakMap;function uo(t){return _a.get(t)||1}function Aa(t){if(t!==_t)throw new Error("invalid wNAF")}class Tp{constructor(e,n){g(this,"BASE");g(this,"ZERO");g(this,"Fn");g(this,"bits");this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let o=e;for(;n>_t;)n&dt&&(r=r.add(o)),o=o.double(),n>>=dt;return r}precomputeWindow(e,n){const{windows:r,windowSize:o}=co(n,this.bits),s=[];let i=e,a=i;for(let c=0;c<r;c++){a=i,s.push(a);for(let l=1;l<o;l++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=co(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:c,offset:l,isZero:d,isNeg:u,isNegF:p,offsetF:f}=ka(r,a,i);r=c,d?s=s.add(vn(p,n[f])):o=o.add(vn(u,n[l]))}return Aa(r),{p:o,f:s}}wNAFUnsafe(e,n,r,o=this.ZERO){const s=co(e,this.bits);for(let i=0;i<s.windows&&r!==_t;i++){const{nextN:a,offset:c,isZero:l,isNeg:d}=ka(r,i,s);if(r=a,!l){const u=n[c];o=o.add(d?u.negate():u)}}return Aa(r),o}getPrecomputes(e,n,r){let o=lo.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(o=r(o)),lo.set(n,o))),o}cached(e,n,r){const o=uo(e);return this.wNAF(o,this.getPrecomputes(o,e,r),n)}unsafe(e,n,r,o){const s=uo(e);return s===1?this._unsafeLadder(e,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),n,o)}createCache(e,n){xa(n,this.bits),_a.set(e,n),lo.delete(e)}hasCache(e){return uo(e)!==1}}function Pp(t,e,n,r){let o=e,s=t.ZERO,i=t.ZERO;for(;n>_t||r>_t;)n&dt&&(s=s.add(o)),r&dt&&(i=i.add(o)),o=o.double(),n>>=dt,r>>=dt;return{p1:s,p2:i}}function Sa(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Np(e),e}else return wn(t,{isLE:n})}function Up(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const l=e[c];if(!(typeof l=="bigint"&&l>_t))throw new Error(`CURVE.${c} must be positive bigint`)}const o=Sa(e.p,n.Fp,r),s=Sa(e.n,n.Fn,r),a=["Gx","Gy","a","b"];for(const c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function Op(t,e){return function(r){const o=t(r);return{secretKey:o,publicKey:e(o)}}}ia("HashToScalar-");const Na=(t,e)=>(t+(t>=0?e:-e)/Mp)/e;function Rp(t,e,n){const[[r,o],[s,i]]=e,a=Na(i*t,n),c=Na(-o*t,n);let l=t-a*r-c*s,d=-a*o-c*i;const u=l<Rt,p=d<Rt;u&&(l=-l),p&&(d=-d);const f=aa(Math.ceil(vp(n)/2))+En;if(l<Rt||l>=f||d<Rt||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:u,k1:l,k2neg:p,k2:d}}const Rt=BigInt(0),En=BigInt(1),Mp=BigInt(2),xn=BigInt(3),Dp=BigInt(4);function Kp(t,e={}){const n=Up("weierstrass",t,e),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:a}=s;ca(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c}=e;if(c&&(!r.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=zp(r,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(D,k,w){const{x:E,y:A}=k.toAffine(),I=r.toBytes(E);if(na(w,"isCompressed"),w){d();const C=!r.isOdd(A);return bn(Hp(C),I)}else return bn(Uint8Array.of(4),I,r.toBytes(A))}function p(D){ae(D,void 0,"Point");const{publicKey:k,publicKeyUncompressed:w}=l,E=D.length,A=D[0],I=D.subarray(1);if(E===k&&(A===2||A===3)){const C=r.fromBytes(I);if(!r.isValid(C))throw new Error("bad point: is not on curve, wrong x");const $=h(C);let B;try{B=r.sqrt($)}catch(V){const W=V instanceof Error?": "+V.message:"";throw new Error("bad point: is not on curve, sqrt error"+W)}d();const P=r.isOdd(B);return(A&1)===1!==P&&(B=r.neg(B)),{x:C,y:B}}else if(E===w&&A===4){const C=r.BYTES,$=r.fromBytes(I.subarray(0,C)),B=r.fromBytes(I.subarray(C,C*2));if(!y($,B))throw new Error("bad point: is not on curve");return{x:$,y:B}}else throw new Error(`bad point: got length ${E}, expected compressed=${k} or uncompressed=${w}`)}const f=e.toBytes||u,m=e.fromBytes||p;function h(D){const k=r.sqr(D),w=r.mul(k,D);return r.add(r.add(w,r.mul(D,s.a)),s.b)}function y(D,k){const w=r.sqr(k),E=h(D);return r.eql(w,E)}if(!y(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const v=r.mul(r.pow(s.a,xn),Dp),x=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(v,x)))throw new Error("bad curve params: a or b");function S(D,k,w=!1){if(!r.isValid(k)||w&&r.is0(k))throw new Error(`bad point coordinate ${D}`);return k}function M(D){if(!(D instanceof H))throw new Error("Weierstrass Point expected")}function R(D){if(!c||!c.basises)throw new Error("no endo");return Rp(D,c.basises,o.ORDER)}const _=la((D,k)=>{const{X:w,Y:E,Z:A}=D;if(r.eql(A,r.ONE))return{x:w,y:E};const I=D.is0();k==null&&(k=I?r.ONE:r.inv(A));const C=r.mul(w,k),$=r.mul(E,k),B=r.mul(A,k);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:C,y:$}}),N=la(D=>{if(D.is0()){if(e.allowInfinityPoint&&!r.is0(D.Y))return;throw new Error("bad point: ZERO")}const{x:k,y:w}=D.toAffine();if(!r.isValid(k)||!r.isValid(w))throw new Error("bad point: x or y not field elements");if(!y(k,w))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(D,k,w,E,A){return w=new H(r.mul(w.X,D),w.Y,w.Z),k=vn(E,k),w=vn(A,w),k.add(w)}const O=class O{constructor(k,w,E){g(this,"X");g(this,"Y");g(this,"Z");this.X=S("x",k),this.Y=S("y",w,!0),this.Z=S("z",E),Object.freeze(this)}static CURVE(){return s}static fromAffine(k){const{x:w,y:E}=k||{};if(!k||!r.isValid(w)||!r.isValid(E))throw new Error("invalid affine point");if(k instanceof O)throw new Error("projective point not allowed");return r.is0(w)&&r.is0(E)?O.ZERO:new O(w,E,r.ONE)}static fromBytes(k){const w=O.fromAffine(m(ae(k,void 0,"point")));return w.assertValidity(),w}static fromHex(k){return O.fromBytes(lt(k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,w=!0){return T.createCache(this,k),w||this.multiply(xn),this}assertValidity(){N(this)}hasEvenY(){const{y:k}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(k)}equals(k){M(k);const{X:w,Y:E,Z:A}=this,{X:I,Y:C,Z:$}=k,B=r.eql(r.mul(w,$),r.mul(I,A)),P=r.eql(r.mul(E,$),r.mul(C,A));return B&&P}negate(){return new O(this.X,r.neg(this.Y),this.Z)}double(){const{a:k,b:w}=s,E=r.mul(w,xn),{X:A,Y:I,Z:C}=this;let $=r.ZERO,B=r.ZERO,P=r.ZERO,q=r.mul(A,A),V=r.mul(I,I),W=r.mul(C,C),F=r.mul(A,I);return F=r.add(F,F),P=r.mul(A,C),P=r.add(P,P),$=r.mul(k,P),B=r.mul(E,W),B=r.add($,B),$=r.sub(V,B),B=r.add(V,B),B=r.mul($,B),$=r.mul(F,$),P=r.mul(E,P),W=r.mul(k,W),F=r.sub(q,W),F=r.mul(k,F),F=r.add(F,P),P=r.add(q,q),q=r.add(P,q),q=r.add(q,W),q=r.mul(q,F),B=r.add(B,q),W=r.mul(I,C),W=r.add(W,W),q=r.mul(W,F),$=r.sub($,q),P=r.mul(W,V),P=r.add(P,P),P=r.add(P,P),new O($,B,P)}add(k){M(k);const{X:w,Y:E,Z:A}=this,{X:I,Y:C,Z:$}=k;let B=r.ZERO,P=r.ZERO,q=r.ZERO;const V=s.a,W=r.mul(s.b,xn);let F=r.mul(w,I),X=r.mul(E,C),se=r.mul(A,$),ue=r.add(w,E),J=r.add(I,C);ue=r.mul(ue,J),J=r.add(F,X),ue=r.sub(ue,J),J=r.add(w,A);let de=r.add(I,$);return J=r.mul(J,de),de=r.add(F,se),J=r.sub(J,de),de=r.add(E,A),B=r.add(C,$),de=r.mul(de,B),B=r.add(X,se),de=r.sub(de,B),q=r.mul(V,J),B=r.mul(W,se),q=r.add(B,q),B=r.sub(X,q),q=r.add(X,q),P=r.mul(B,q),X=r.add(F,F),X=r.add(X,F),se=r.mul(V,se),J=r.mul(W,J),X=r.add(X,se),se=r.sub(F,se),se=r.mul(V,se),J=r.add(J,se),F=r.mul(X,J),P=r.add(P,F),F=r.mul(de,J),B=r.mul(ue,B),B=r.sub(B,F),F=r.mul(ue,X),q=r.mul(de,q),q=r.add(q,F),new O(B,P,q)}subtract(k){return this.add(k.negate())}is0(){return this.equals(O.ZERO)}multiply(k){const{endo:w}=e;if(!o.isValidNot0(k))throw new Error("invalid scalar: out of range");let E,A;const I=C=>T.cached(this,C,$=>Ea(O,$));if(w){const{k1neg:C,k1:$,k2neg:B,k2:P}=R(k),{p:q,f:V}=I($),{p:W,f:F}=I(P);A=V.add(F),E=L(w.beta,q,W,C,B)}else{const{p:C,f:$}=I(k);E=C,A=$}return Ea(O,[E,A])[0]}multiplyUnsafe(k){const{endo:w}=e,E=this;if(!o.isValid(k))throw new Error("invalid scalar: out of range");if(k===Rt||E.is0())return O.ZERO;if(k===En)return E;if(T.hasCache(this))return this.multiply(k);if(w){const{k1neg:A,k1:I,k2neg:C,k2:$}=R(k),{p1:B,p2:P}=Pp(O,E,I,$);return L(w.beta,B,P,A,C)}else return T.unsafe(E,k)}toAffine(k){return _(this,k)}isTorsionFree(){const{isTorsionFree:k}=e;return i===En?!0:k?k(O,this):T.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:k}=e;return i===En?this:k?k(O,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(k=!0){return na(k,"isCompressed"),this.assertValidity(),f(O,this,k)}toHex(k=!0){return ce(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};g(O,"BASE",new O(s.Gx,s.Gy,r.ONE)),g(O,"ZERO",new O(r.ZERO,r.ONE,r.ZERO)),g(O,"Fp",r),g(O,"Fn",o);let H=O;const U=o.BITS,T=new Tp(H,e.endo?Math.ceil(U/2):U);return H.BASE.precompute(8),H}function Hp(t){return Uint8Array.of(t?2:3)}function zp(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}const kn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},qp={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Vp=BigInt(0),ho=BigInt(2);function jp(t){const e=kn.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,d=l*l*t%e,u=pe(d,n,e)*d%e,p=pe(u,n,e)*d%e,f=pe(p,ho,e)*l%e,m=pe(f,o,e)*f%e,h=pe(m,s,e)*m%e,y=pe(h,a,e)*h%e,v=pe(y,c,e)*y%e,x=pe(v,a,e)*h%e,S=pe(x,n,e)*d%e,M=pe(S,i,e)*m%e,R=pe(M,r,e)*l%e,_=pe(R,ho,e);if(!_n.eql(_n.sqr(_),t))throw new Error("Cannot find square root");return _}const _n=wn(kn.p,{sqrt:jp}),At=Kp(kn,{Fp:_n,endo:qp}),Ca={};function An(t,...e){let n=Ca[t];if(n===void 0){const r=no(ia(t));n=bn(r,r),Ca[t]=n}return no(bn(n,...e))}const fo=t=>t.toBytes(!0).slice(1),po=t=>t%ho===Vp;function mo(t){const{Fn:e,BASE:n}=At,r=e.fromBytes(t),o=n.multiply(r);return{scalar:po(o.y)?r:e.neg(r),bytes:fo(o)}}function Ba(t){const e=_n;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const n=e.create(t*t),r=e.create(n*t+BigInt(7));let o=e.sqrt(r);po(o)||(o=e.neg(o));const s=At.fromAffine({x:t,y:o});return s.assertValidity(),s}const Mt=so;function La(...t){return At.Fn.create(Mt(An("BIP0340/challenge",...t)))}function Ia(t){return mo(t).bytes}function Fp(t,e,n=ta(32)){const{Fn:r}=At,o=ae(t,void 0,"message"),{bytes:s,scalar:i}=mo(e),a=ae(n,32,"auxRand"),c=r.toBytes(i^Mt(An("BIP0340/aux",a))),l=An("BIP0340/nonce",c,s,o),{bytes:d,scalar:u}=mo(l),p=La(d,s,o),f=new Uint8Array(64);if(f.set(d,0),f.set(r.toBytes(r.create(u+p*i)),32),!$a(f,o,s))throw new Error("sign: Invalid signature produced");return f}function $a(t,e,n){const{Fp:r,Fn:o,BASE:s}=At,i=ae(t,64,"signature"),a=ae(e,void 0,"message"),c=ae(n,32,"publicKey");try{const l=Ba(Mt(c)),d=Mt(i.subarray(0,32));if(!r.isValidNot0(d))return!1;const u=Mt(i.subarray(32,64));if(!o.isValidNot0(u))return!1;const p=La(o.toBytes(d),fo(l),a),f=s.multiplyUnsafe(u).add(l.multiplyUnsafe(o.neg(p))),{x:m,y:h}=f.toAffine();return!(f.is0()||!po(h)||m!==d)}catch{return!1}}const Dt=(()=>{const n=(r=ta(48))=>$p(r,kn.n);return{keygen:Op(n,Ia),getPublicKey:Ia,sign:Fp,verify:$a,Point:At,utils:{randomSecretKey:n,taggedHash:An,lift_x:Ba,pointToBytes:fo},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),ht=Symbol("verified"),Wp=t=>t instanceof Object;function Zp(t){if(!Wp(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}const Sn=new TextDecoder("utf-8"),Jp=new TextEncoder;function Ye(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}class Gp{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}}class Yp{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Gp(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}}class Xp{generateSecretKey(){return Dt.utils.randomSecretKey()}getPublicKey(e){return ce(Dt.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ce(Dt.getPublicKey(n)),r.id=go(r),r.sig=ce(Dt.sign(lt(go(r)),n)),r[ht]=!0,r}verifyEvent(e){if(typeof e[ht]=="boolean")return e[ht];const n=go(e);if(n!==e.id)return e[ht]=!1,!1;try{const r=Dt.verify(lt(e.sig),lt(n),lt(e.pubkey));return e[ht]=r,r}catch{return e[ht]=!1,!1}}}function Qp(t){if(!Zp(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function go(t){let e=no(Jp.encode(Qp(t)));return ce(e)}const Nn=new Xp;Nn.generateSecretKey,Nn.getPublicKey,Nn.finalizeEvent;const em=Nn.verifyEvent,tm=22242;function nm(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([s,i])=>s===n.slice(1)&&o.indexOf(i)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function rm(t,e){for(let n=0;n<t.length;n++)if(nm(t[n],e))return!0;return!1}function om(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function sm(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let s=r+1+o;return t.slice(r+1,s)}function im(t,e){return{kind:tm,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function am(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}const cm=t=>(t[ht]=!0,!0);class Ta extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}}class yo{constructor(e,n){g(this,"url");g(this,"_connected",!1);g(this,"onclose",null);g(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));g(this,"onauth");g(this,"baseEoseTimeout",4400);g(this,"publishTimeout",4400);g(this,"pingFrequency",29e3);g(this,"pingTimeout",2e4);g(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);g(this,"openSubs",new Map);g(this,"enablePing");g(this,"enableReconnect");g(this,"reconnectTimeoutHandle");g(this,"pingIntervalHandle");g(this,"reconnectAttempts",0);g(this,"closedIntentionally",!1);g(this,"connectionPromise");g(this,"openCountRequests",new Map);g(this,"openEventPublishes",new Map);g(this,"ws");g(this,"incomingMessageQueue",new Yp);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=Ye(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket,this.enablePing=n.enablePing,this.enableReconnect=n.enableReconnect||!1}static async connect(e,n){const r=new yo(e,n);return await r.connect(n),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},e)}handleHardClose(e){var r;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,(r=this.onclose)==null||r.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(e)}async connect(e){let n;return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((r,o)=>{e!=null&&e.timeout&&(n=setTimeout(()=>{var s;o("connection timed out"),this.connectionPromise=void 0,(s=this.onclose)==null||s.call(this),this.closeAllSubscriptions("relay connection timed out")},e.timeout)),e!=null&&e.abort&&(e.abort.onabort=o);try{this.ws=new this._WebSocket(this.url)}catch(s){clearTimeout(n),o(s);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(n),this._connected=!0;const s=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const i of this.openSubs.values()){if(i.eosed=!1,s)for(let a=0;a<i.filters.length;a++)i.lastEmitted&&(i.filters[a].since=i.lastEmitted+1);i.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),r()},this.ws.onerror=s=>{clearTimeout(n),o(s.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=s=>{clearTimeout(n),o(s.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,n)=>{if(!this.connectionPromise)return n(new Error(`no connection to ${this.url}, can't ping`));try{const r=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),r.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(r){n(r)}})}async pingpong(){var e,n,r;((e=this.ws)==null?void 0:e.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(s=>setTimeout(()=>s(!1),this.pingTimeout))])||((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await am();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=sm(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=om(e,"id"),c=(r=i.alreadyHaveEvent)==null?void 0:r.call(i,a);if((o=i.receivedEvent)==null||o.call(i,this,a),c)return}try{let i=JSON.parse(e);switch(i[0]){case"EVENT":{const a=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&rm(a.filters,c)&&a.onevent(c),(!a.lastEmitted||a.lastEmitted<c.created_at)&&(a.lastEmitted=c.created_at);return}case"COUNT":{const a=i[1],c=i[2],l=this.openCountRequests.get(a);l&&(l.resolve(c.count),this.openCountRequests.delete(a));return}case"EOSE":{const a=this.openSubs.get(i[1]);if(!a)return;a.receivedEose();return}case"OK":{const a=i[1],c=i[2],l=i[3],d=this.openEventPublishes.get(a);d&&(clearTimeout(d.timeout),c?d.resolve(l):d.reject(new Error(l)),this.openEventPublishes.delete(a));return}case"CLOSED":{const a=i[1],c=this.openSubs.get(a);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":{this.onnotice(i[1]);return}case"AUTH":{this.challenge=i[1],this.onauth&&this.auth(this.onauth);return}default:{const a=this.openSubs.get(i[1]);(s=a==null?void 0:a.oncustom)==null||s.call(a,i);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Ta(e,this.url);this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){const n=this.challenge;if(!n)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,o)=>{try{let s=await e(im(this.url,n)),i=setTimeout(()=>{let a=this.openEventPublishes.get(s.id);a&&(a.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:r,reject:o,timeout:i}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(s){console.warn("subscribe auth function failed:",s)}}),this.authPromise)}async publish(e){const n=new Promise((r,o)=>{const s=setTimeout(()=>{const i=this.openEventPublishes.get(e.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:r,reject:o,timeout:s})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((s,i)=>{this.openCountRequests.set(r,{resolve:s,reject:i})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),n.abort&&(n.abort.onabort=()=>r.close(String(n.abort.reason||"<aborted>"))),r}prepareSubscription(e,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new lm(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e,n,r;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.onclose)==null||e.call(this),((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close())}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}}class lm{constructor(e,n,r,o){g(this,"relay");g(this,"id");g(this,"lastEmitted");g(this,"closed",!1);g(this,"eosed",!1);g(this,"filters");g(this,"alreadyHaveEvent");g(this,"receivedEvent");g(this,"onevent");g(this,"oneose");g(this,"onclose");g(this,"oncustom");g(this,"eoseTimeout");g(this,"eoseTimeoutHandle");if(r.length===0)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(s=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,s)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(r){if(!(r instanceof Ta))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}}class um{constructor(e){g(this,"relays",new Map);g(this,"seenOn",new Map);g(this,"trackRelays",!1);g(this,"verifyEvent");g(this,"enablePing");g(this,"enableReconnect");g(this,"automaticallyAuth");g(this,"trustedRelayURLs",new Set);g(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,n){e=Ye(e);let r=this.relays.get(e);if(r||(r=new yo(e,{verifyEvent:this.trustedRelayURLs.has(e)?cm:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),r.onclose=()=>{r&&!r.enableReconnect&&this.relays.delete(e)},this.relays.set(e,r)),this.automaticallyAuth){const o=this.automaticallyAuth(e);o&&(r.onauth=o)}return await r.connect({timeout:n==null?void 0:n.connectionTimeout,abort:n==null?void 0:n.abort}),r}close(e){e.map(Ye).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close(),this.relays.delete(n)})}subscribe(e,n,r){const o=[];for(let s=0;s<e.length;s++){const i=Ye(e[s]);o.find(a=>a.url===i)||o.push({url:i,filter:n})}return this.subscribeMap(o,r)}subscribeMany(e,n,r){const o=[],s=[];for(let i=0;i<e.length;i++){const a=Ye(e[i]);s.indexOf(a)===-1&&(s.push(a),o.push({url:a,filter:n}))}return this.subscribeMap(o,r)}subscribeMap(e,n){const r=new Map;for(const f of e){const{url:m,filter:h}=f;r.has(m)||r.set(m,[]),r.get(m).push(h)}const o=Array.from(r.entries()).map(([f,m])=>({url:f,filters:m}));this.trackRelays&&(n.receivedEvent=(f,m)=>{let h=this.seenOn.get(m);h||(h=new Set,this.seenOn.set(m,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var m;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((m=n.oneose)==null||m.call(n),c=()=>{}))};const l=[];let d=(f,m)=>{var h;l[f]||(c(f),l[f]=m,l.filter(y=>y).length===o.length&&((h=n.onclose)==null||h.call(n,l),d=()=>{}))};const u=f=>{var h;if((h=n.alreadyHaveEvent)!=null&&h.call(n,f))return!0;const m=s.has(f);return s.add(f),m},p=Promise.all(o.map(async({url:f,filters:m},h)=>{let y;try{y=await this.ensureRelay(f,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0,abort:n.abort})}catch(x){d(h,(x==null?void 0:x.message)||String(x));return}let v=y.subscribe(m,{...n,oneose:()=>c(h),onclose:x=>{x.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(m,{...n,oneose:()=>c(h),onclose:S=>{d(h,S)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort})}).catch(S=>{d(h,`auth was required and attempted, but failed with: ${S}`)}):d(h,x)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await p,i.forEach(m=>{m.close(f)})}}}subscribeEose(e,n,r){const o=this.subscribe(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}async querySync(e,n,r){return new Promise(async o=>{const s=[];this.subscribeEose(e,n,{...r,onevent(i){s.push(i)},onclose(i){o(s)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((s,i)=>i.created_at-s.created_at),o[0]||null}publish(e,n,r){return e.map(Ye).map(async(o,s,i)=>{if(i.indexOf(o)!==s)return Promise.reject("duplicate url");let a=await this.ensureRelay(o);return a.publish(n).catch(async c=>{if(c instanceof Error&&c.message.startsWith("auth-required: ")&&(r!=null&&r.onauth))return await a.auth(r.onauth),a.publish(n);throw c}).then(c=>{if(this.trackRelays){let l=this.seenOn.get(n.id);l||(l=new Set,this.seenOn.set(n.id,l)),l.add(a)}return c})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}}var Pa;try{Pa=WebSocket}catch{}class dm extends um{constructor(e){super({verifyEvent:em,websocketImplementation:Pa,...e})}}var hm=Math.pow(2,8)-1,fm=Math.pow(2,16)-1,pm=Math.pow(2,32)-1;const mm=function(t){var e=t-1;if(e<=hm)return Uint8Array;if(e<=fm)return Uint16Array;if(e<=pm)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};function Xe(t){if(this.capacity=t,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var e=mm(t);this.forward=new e(t),this.backward=new e(t),this.K=new Array(t),this.V=new Array(t),this.size=0,this.head=0,this.tail=0,this.items={}}Xe.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},Xe.prototype.splayOnTop=function(t){var e=this.head;if(this.head===t)return this;var n=this.backward[t],r=this.forward[t];return this.tail===t?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[e]=t,this.head=t,this.forward[t]=e,this},Xe.prototype.set=function(t,e){var n=this.items[t];if(typeof n<"u"){this.splayOnTop(n),this.V[n]=e;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[t]=n,this.K[n]=t,this.V[n]=e,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},Xe.prototype.setpop=function(t,e){var n=null,r=null,o=this.items[t];return typeof o<"u"?(this.splayOnTop(o),n=this.V[o],this.V[o]=e,{evicted:!1,key:t,value:n}):(this.size<this.capacity?o=this.size++:(o=this.tail,this.tail=this.backward[o],n=this.V[o],r=this.K[o],delete this.items[r]),this.items[t]=o,this.K[o]=t,this.V[o]=e,this.forward[o]=this.head,this.backward[this.head]=o,this.head=o,r?{evicted:!0,key:r,value:n}:null)},Xe.prototype.has=function(t){return t in this.items},Xe.prototype.get=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.splayOnTop(e),this.V[e]},Xe.prototype.peek=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.V[e]};class Ua{constructor(e,n){g(this,"_batchLoadFn");g(this,"_maxBatchSize");g(this,"_cacheKeyFn");g(this,"_cacheMap");g(this,"_batch");if(typeof e!="function")throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`);this._batchLoadFn=e,this._maxBatchSize=(n==null?void 0:n.maxBatchSize)||1/0,this._cacheKeyFn=n==null?void 0:n.cacheKeyFn;const r=new Xe(2e3);this._cacheMap={get:n.transformCacheHit?o=>{var s;return(s=r.get(o))==null?void 0:s.then(n.transformCacheHit)}:o=>r.get(o),set(o,s){return r.set(o,s)},delete(o){r.set(o,void 0)},clear(){r.clear()}},this._batch=null}load(e){if(e==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const n=gm(this),r=this._cacheKeyFn(e),o=this._cacheMap.get(r);if(o){const i=n.cacheHits||(n.cacheHits=[]);return new Promise(a=>{i.push(()=>{a(o)})})}n.keys.push(e);const s=new Promise((i,a)=>{n.callbacks.push({resolve:i,reject:a})});return this._cacheMap.set(r,s),s}clear(e){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);n.delete(r)}return this}}function gm(t){const e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const n={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=n,setTimeout(()=>{ym(t,n)}),n}function ym(t,e){if(e.hasDispatched=!0,e.keys.length===0){wo(e);return}let n;try{n=t._batchLoadFn(e.keys)}catch(r){return bo(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(r)}.`))}if(!n||typeof n.then!="function")return bo(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(n)}.`));n.then(r=>{if(r.length!==e.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
3
3
 
4
4
  Keys:
5
5
  ${String(e.keys)}
6
6
 
7
7
  Values:
8
- ${String(r)}`);Eo(e);for(let o=0;o<e.callbacks.length;o++){const s=r[o];s instanceof Error?e.callbacks[o].reject(s):e.callbacks[o].resolve(s)}}).catch(r=>{vo(t,e,r)})}function vo(t,e,n){Eo(e);for(let r=0;r<e.keys.length;r++)t.clear(e.keys[r]),e.callbacks[r].reject(n)}function Eo(t){if(t.cacheHits)for(let e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}function Kt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function xo(t,e){let n;const r=()=>{if(n)return n;const o=indexedDB.open(t);return o.onupgradeneeded=()=>o.result.createObjectStore(e),n=Kt(o),n.then(s=>{s.onclose=()=>n=void 0},()=>{}),n};return(o,s)=>r().then(i=>s(i.transaction(e,o).objectStore(e)))}let ko;function Cn(){return ko||(ko=xo("keyval-store","keyval")),ko}function Pa(t,e,n=Cn()){return n("readwrite",r=>(r.put(e,t),Kt(r.transaction)))}function Ua(t,e=Cn()){return e("readwrite",n=>(t.forEach(r=>n.put(r[1],r[0])),Kt(n.transaction)))}function Oa(t,e=Cn()){return e("readonly",n=>Promise.all(t.map(r=>Kt(n.get(r)))))}function Ra(t,e=Cn()){return e("readwrite",n=>(n.delete(t),Kt(n.transaction)))}const _o=["wss://purplepag.es","wss://relay.nos.social","wss://relay.primal.net"],wm=["wss://purplepag.es","wss://relay.nos.social","wss://indexer.coracle.social"];function St(t){for(let e=0;e<64;e++){let n=t.charCodeAt(e);if(isNaN(n)||n<48||n>102||n>57&&n<97)return!1}return!0}function vm(t){return!!t}let Em=0;const Qe=Symbol("event was just downloaded or force-updated, not loaded from cache");Ce(3,_o,Me(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]})),Ce(10101,[],Me(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]})),Ce(10102,[],Me(t=>{if(t.length>=2&&t[0]==="relay")return t[1]})),Ce(10012,[],Me(t=>{if(t.length>=2)switch(t[0]){case"relay":return Ye(t[1]);case"a":const e=t[1].split(":");return!St(e[1])||e[0]!=="30002"?void 0:{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}}}));const Ao=Ce(10002,wm,Me(t=>{if(t.length===2)return{url:t[1],read:!0,write:!0};if(t[2]==="read")return{url:t[1],read:!0,write:!1};if(t[2]==="write")return{url:t[1],read:!1,write:!0}}));Ce(1e4,[],Me(t=>{if(t.length>=2){switch(t[0]){case"p":if(St(t[1]))return{label:"pubkey",value:t[1]};break;case"e":if(St(t[1]))return{label:"thread",value:t[1]};break;case"t":return{label:"hashtag",value:t[1]};case"word":return{label:"word",value:t[1]}}return}})),Ce(10003,[],Me(t=>{if(t.length>=2&&(t[0]==="e"||t[0]==="a")&&t[1])return t[1]})),Ce(10063,[],t=>t?t.tags.filter(([e,n])=>e==="server"&&n).map(([,e])=>"http"+Ye(e).substring(2)).filter(Boolean):[]),Ce(10030,[],Me(t=>{if(!(t.length<2)){if(t[0]==="a"){const e=t[1].split(":");return!St(e[1])||e[0]!=="30030"?void 0:{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}}if(!(t.length<3||t[0]!=="emoji"))return{shortcode:t[1],url:t[2]}}})),Ce(10001,[],Me(t=>{if(t.length>=2&&t[0]==="e"&&t[1])return t[1]}));function Me(t){return e=>e?e.tags.map(t).filter(vm):[]}function Ce(t,e,n){const r=xo(`@nostr/gadgets/list:${t}`,"cache"),o=new Ta(s=>new Promise(async i=>{var u;let a=[],c=Math.round(Date.now()/1e3),l=await Oa(s.map(p=>p.target),r).then(p=>p.map((f,m)=>{const h=s[m];if(h.index=m,typeof h.refreshStyle=="object"){const y={event:h.refreshStyle,items:n(h.refreshStyle),[Qe]:!0};return Pa(h.target,y,r),y}else return f?h.refreshStyle===!0||!f.lastAttempt||f.lastAttempt<c-3600*24*2?(h.refreshStyle!==!1&&a.push(h),{...f,[Qe]:!1}):f.event===null&&f.lastAttempt<Date.now()/1e3-3600?(h.refreshStyle!==!1&&a.push(h),{...f,[Qe]:!1}):{...f,[Qe]:!1}:(h.refreshStyle!==!1&&a.push(h),{items:h.defaultItems||[],event:null,[Qe]:!1})}));if(a.length===0){i(l);return}const d={};for(let p=0;p<a.length;p++){const f=a[p],m=f.relays.slice(0,Math.min(4,f.relays.length));do m.push(xm(e));while(m.length<3);for(let h=0;h<m.length;h++){const y=m[h];let v=d[y];v||(v={kinds:[t],authors:[]},d[y]=v),(u=v.authors)==null||u.push(f.target)}}try{let p;p=Ht.subscribeMap(Object.entries(d).map(([f,m])=>({url:f,filter:m})),{label:`kind:${t}:batch(${a.length})`,onevent(f){var m;for(let h=0;h<a.length;h++){const y=a[h];if(y.target===f.pubkey){const v=(m=l[y.index])==null?void 0:m.event;if(((v==null?void 0:v.created_at)||0)>f.created_at)return;l[y.index]={event:f,items:n(f),[Qe]:!0};return}}},oneose(){p==null||p.close()},async onclose(){i(l),Ua(a.map(f=>[f.target,{...l[f.index],lastAttempt:c}]),r)}})}catch(p){i(l.map(f=>p))}}),{cacheKeyFn:s=>s.target,transformCacheHit(s){return s[Qe]=!1,s}});return async function(s,i=[],a,c){if(a===null)return await Ra(s,r),o._cacheMap.delete(s),{items:c||[],event:null,[Qe]:!0};let l=i;if(t===10002)return await o.load({target:s,relays:l,refreshStyle:a,defaultItems:c});{const d=await Ao(s,i,a);l.push(...d.items.filter(({write:p})=>p).map(({url:p})=>p).slice(0,3));const u={target:s,relays:l,refreshStyle:a,defaultItems:c};return a&&o.clear(u),await o.load(u)}}}function xm(t){return t[Em++%t.length]}let Ht=new hm;new TextDecoder("utf-8"),new TextEncoder;function km(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}const _m=["wss://relay.damus.io/","wss://nos.lol/","wss://nostr.mom/"];function Da(){return[..._m]}async function So(t,e){return Ht.querySync(t,e)}function No(t,e,n,r){const o=Ht.subscribeMany(t,e,{onevent:n,oneose:r});return()=>o.close()}async function Bn(t,e){await Promise.any(Ht.publish(t,e))}async function Ln(t,e){const n=new Set;return t&&t.length>0?t.forEach(r=>n.add(km(r))):e&&e.length>0&&(await Promise.all(e.map(o=>Ao(o)))).forEach(o=>{o.items.forEach(s=>{s.read&&n.add(s.url)})}),n.size===0&&Da().forEach(r=>n.add(r)),Array.from(n)}const Am=Symbol("relays where this event was seen before stored");function Sm(t){return t[Am]||[]}const Ma=1111;function Ka(t){const{url:e,content:n,authorPubkeys:r}=t,o=[["I",e],["K","web"],["i",e],["k","web"]];return r&&r.length>0&&(o.push(["P",r[0]]),o.push(["p",r[0]])),{kind:Ma,content:n,tags:o,created_at:Math.floor(Date.now()/1e3)}}function Ha(t){const{url:e,content:n,parentEvent:r,authorPubkeys:o}=t,s=[["I",e],["K","web"]];o&&o.length>0&&s.push(["P",o[0]]);const i=Sm(r);return s.push(["e",r.id,i.length?i[0]:"",r.pubkey]),s.push(["k","1111"]),s.push(["p",r.pubkey]),{kind:Ma,content:n,tags:s,created_at:Math.floor(Date.now()/1e3)}}function Nm(t){return t.tags.some(e=>e[0]==="e")}function zt(t){const e=t.tags.find(n=>n[0]==="e");return e?e[1]:null}function Cm(t){const e=t.tags.find(n=>n[0]==="I");return e?e[1]:null}const za=1111;function qa(t){const{url:e,relays:n,limit:r=50,onEvent:o,onEose:s}=t,i=[e];return e.endsWith("/")?i.push(e.slice(0,-1)):i.push(e+"/"),No(n,{kinds:[za],"#I":i,limit:r},o,s)}async function Va(t){const{url:e,relays:n,limit:r=50,until:o}=t,s=[e];return e.endsWith("/")?s.push(e.slice(0,-1)):s.push(e+"/"),So(n,{kinds:[za],"#I":s,limit:r,...o?{until:o}:{}})}async function ja(t,e){const n=Ka(e),r=await t.signEvent(n);return await Bn(await Ln(e.relays,e.authorPubkeys),r),r}async function Fa(t,e){const n=Ha(e),r=await t.signEvent(n);return await Bn(await Ln(e.relays,e.authorPubkeys),r),r}function Wa(t){const e=new Map;t.forEach(i=>e.set(i.id,i));const n=i=>{const a=zt(i);if(!a)return null;const c=e.get(a);return!c||!zt(c)?a:n(c)},r=[...t].sort((i,a)=>i.created_at-a.created_at),o=[],s=new Map;return r.forEach(i=>{const a=zt(i);if(!a)o.push(i);else{const l=n(i)||a;s.has(l)||s.set(l,[]);const d=e.get(a),u=d&&!zt(d);s.get(l).push({event:i,children:[],replyTo:u?void 0:d})}}),o.sort((i,a)=>a.created_at-i.created_at),o.map(i=>({event:i,children:s.get(i.id)||[]}))}const Nt={comments:"Comments",writeComment:"Write a comment...",reply:"Reply",replyTo:"Reply to",publish:"Publish",publishing:"Publishing...",cancel:"Cancel",login:"Login",logout:"Logout",loginRequired:"Please login first",loginDescription:"Choose a method to login and post comments",extensionLogin:"Browser Extension",extensionLoginDesc:"Login with NIP-07 extension (Alby, nos2x, etc.)",bunkerLogin:"Bunker Remote Signing",bunkerLoginDesc:"Use NIP-46 Bunker for remote signing",bunkerUrlPlaceholder:"Enter bunker:// URL",connect:"Connect",connecting:"Connecting...",tempAccount:"Temporary Account",tempAccountDesc:"Create a temporary key pair",tempAccountCreated:"Account created successfully!",createAccount:"Create Account",copyKey:"Copy Private Key (nsec)",keyCopied:"Copied!",downloadKey:"Download Key File",keyCompatibility:"This is a standard Nostr private key. You can use it in any Nostr client like Jumble, Damus, Amethyst, and more.",startCommenting:"Start Commenting",importKey:"Import Existing Key",importKeyDesc:"Login with a previously saved nsec private key",importKeyPlaceholder:"Paste nsec1... private key",importKeyError:"Invalid private key format",like:"Like",liked:"Liked",loadMore:"Load More",loading:"Loading...",noComments:"No comments yet. Be the first to comment!",error:"Error",retry:"Retry",anonymous:"Anonymous",timeJustNow:"just now",timeMinutesAgo:"{{n}}m ago",timeHoursAgo:"{{n}}h ago",timeDaysAgo:"{{n}}d ago"},In={comments:"评论",writeComment:"写下你的评论...",reply:"回复",replyTo:"回复",publish:"发布",publishing:"发布中...",cancel:"取消",login:"登录",logout:"退出登录",loginRequired:"请先登录",loginDescription:"选择一种方式登录以发布评论",extensionLogin:"浏览器扩展",extensionLoginDesc:"使用 NIP-07 浏览器扩展(如 Alby、nos2x)登录",bunkerLogin:"Bunker 远程签名",bunkerLoginDesc:"使用 NIP-46 Bunker 进行远程签名",bunkerUrlPlaceholder:"输入 bunker:// URL",connect:"连接",connecting:"连接中...",tempAccount:"临时账号",tempAccountDesc:"创建一个临时密钥对",tempAccountCreated:"账号创建成功!",createAccount:"创建账号",copyKey:"复制私钥 (nsec)",keyCopied:"已复制!",downloadKey:"下载密钥文件",keyCompatibility:"此私钥是标准的 Nostr 密钥,可在 Jumble、Damus、Amethyst 等任何 Nostr 客户端中使用。",startCommenting:"开始评论",importKey:"导入已有密钥",importKeyDesc:"使用之前保存的 nsec 私钥登录",importKeyPlaceholder:"粘贴 nsec1... 私钥",importKeyError:"无效的私钥格式",like:"喜欢",liked:"已喜欢",loadMore:"加载更多",loading:"加载中...",noComments:"暂无评论,来说点什么吧",error:"出错了",retry:"重试",anonymous:"匿名用户",timeJustNow:"刚刚",timeMinutesAgo:"{{n}} 分钟前",timeHoursAgo:"{{n}} 小时前",timeDaysAgo:"{{n}} 天前"},Co={comments:"留言",writeComment:"撰寫留言...",reply:"回覆",replyTo:"回覆給",publish:"發布",publishing:"發布中...",cancel:"取消",login:"登入",logout:"登出",loginRequired:"請先登入",loginDescription:"選擇登入方式以發表留言",extensionLogin:"瀏覽器擴充功能",extensionLoginDesc:"使用 NIP-07 擴充功能登入(Alby、nos2x 等)",bunkerLogin:"Bunker 遠端簽署",bunkerLoginDesc:"使用 NIP-46 Bunker 進行遠端簽署",bunkerUrlPlaceholder:"輸入 bunker:// 網址",connect:"連線",connecting:"連線中...",tempAccount:"臨時帳號",tempAccountDesc:"建立臨時金鑰對",tempAccountCreated:"帳號建立成功!",createAccount:"建立帳號",copyKey:"複製私鑰(nsec)",keyCopied:"已複製!",downloadKey:"下載金鑰檔案",keyCompatibility:"這是標準的 Nostr 私鑰。您可以在任何 Nostr 客戶端使用,如 Jumble、Damus、Amethyst 等。",startCommenting:"開始留言",importKey:"匯入現有金鑰",importKeyDesc:"使用已儲存的 nsec 私鑰登入",importKeyPlaceholder:"貼上 nsec1... 私鑰",importKeyError:"私鑰格式無效",like:"讚",liked:"已按讚",loadMore:"載入更多",loading:"載入中...",noComments:"尚無留言。成為第一個留言的人吧!",error:"錯誤",retry:"重試",anonymous:"匿名",timeJustNow:"剛剛",timeMinutesAgo:"{{n}}分鐘前",timeHoursAgo:"{{n}}小時前",timeDaysAgo:"{{n}}天前"},Za={comments:"コメント",writeComment:"コメントを書く...",reply:"返信",replyTo:"返信先",publish:"投稿",publishing:"投稿中...",cancel:"キャンセル",login:"ログイン",logout:"ログアウト",loginRequired:"ログインしてください",loginDescription:"ログイン方法を選択してコメントを投稿",extensionLogin:"ブラウザ拡張機能",extensionLoginDesc:"NIP-07拡張機能でログイン(Alby、nos2xなど)",bunkerLogin:"Bunkerリモート署名",bunkerLoginDesc:"NIP-46 Bunkerでリモート署名",bunkerUrlPlaceholder:"bunker:// URLを入力",connect:"接続",connecting:"接続中...",tempAccount:"一時アカウント",tempAccountDesc:"一時的な鍵ペアを作成",tempAccountCreated:"アカウントが作成されました!",createAccount:"アカウント作成",copyKey:"秘密鍵をコピー(nsec)",keyCopied:"コピーしました!",downloadKey:"鍵ファイルをダウンロード",keyCompatibility:"これは標準的なNostr秘密鍵です。Jumble、Damus、Amethystなど、任意のNostrクライアントで使用できます。",startCommenting:"コメントを始める",importKey:"既存の鍵をインポート",importKeyDesc:"保存したnsec秘密鍵でログイン",importKeyPlaceholder:"nsec1...秘密鍵を貼り付け",importKeyError:"無効な秘密鍵形式",like:"いいね",liked:"いいね済み",loadMore:"もっと読み込む",loading:"読み込み中...",noComments:"まだコメントがありません。最初のコメントを投稿しましょう!",error:"エラー",retry:"再試行",anonymous:"匿名",timeJustNow:"たった今",timeMinutesAgo:"{{n}}分前",timeHoursAgo:"{{n}}時間前",timeDaysAgo:"{{n}}日前"},Ja={comments:"댓글",writeComment:"댓글 작성...",reply:"답글",replyTo:"답글 대상",publish:"게시",publishing:"게시 중...",cancel:"취소",login:"로그인",logout:"로그아웃",loginRequired:"먼저 로그인해 주세요",loginDescription:"로그인 방법을 선택하여 댓글 작성",extensionLogin:"브라우저 확장 프로그램",extensionLoginDesc:"NIP-07 확장 프로그램으로 로그인 (Alby, nos2x 등)",bunkerLogin:"Bunker 원격 서명",bunkerLoginDesc:"NIP-46 Bunker로 원격 서명 사용",bunkerUrlPlaceholder:"bunker:// URL 입력",connect:"연결",connecting:"연결 중...",tempAccount:"임시 계정",tempAccountDesc:"임시 키 쌍 생성",tempAccountCreated:"계정이 생성되었습니다!",createAccount:"계정 생성",copyKey:"개인 키 복사 (nsec)",keyCopied:"복사됨!",downloadKey:"키 파일 다운로드",keyCompatibility:"이것은 표준 Nostr 개인 키입니다. Jumble, Damus, Amethyst 등 모든 Nostr 클라이언트에서 사용할 수 있습니다.",startCommenting:"댓글 작성 시작",importKey:"기존 키 가져오기",importKeyDesc:"저장된 nsec 개인 키로 로그인",importKeyPlaceholder:"nsec1... 개인 키 붙여넣기",importKeyError:"잘못된 개인 키 형식",like:"좋아요",liked:"좋아요 완료",loadMore:"더 보기",loading:"로딩 중...",noComments:"아직 댓글이 없습니다. 첫 번째 댓글을 작성해 보세요!",error:"오류",retry:"다시 시도",anonymous:"익명",timeJustNow:"방금",timeMinutesAgo:"{{n}}분 전",timeHoursAgo:"{{n}}시간 전",timeDaysAgo:"{{n}}일 전"},Ct={comments:"Comentarios",writeComment:"Escribe un comentario...",reply:"Responder",replyTo:"Responder a",publish:"Publicar",publishing:"Publicando...",cancel:"Cancelar",login:"Iniciar sesión",logout:"Cerrar sesión",loginRequired:"Por favor, inicia sesión primero",loginDescription:"Elige un método para iniciar sesión y publicar comentarios",extensionLogin:"Extensión del navegador",extensionLoginDesc:"Inicia sesión con extensión NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Firma remota Bunker",bunkerLoginDesc:"Usa NIP-46 Bunker para firma remota",bunkerUrlPlaceholder:"Introduce URL bunker://",connect:"Conectar",connecting:"Conectando...",tempAccount:"Cuenta temporal",tempAccountDesc:"Crear un par de claves temporal",tempAccountCreated:"¡Cuenta creada exitosamente!",createAccount:"Crear cuenta",copyKey:"Copiar clave privada (nsec)",keyCopied:"¡Copiado!",downloadKey:"Descargar archivo de clave",keyCompatibility:"Esta es una clave privada estándar de Nostr. Puedes usarla en cualquier cliente de Nostr como Jumble, Damus, Amethyst y más.",startCommenting:"Empezar a comentar",importKey:"Importar clave existente",importKeyDesc:"Inicia sesión con una clave privada nsec guardada",importKeyPlaceholder:"Pega la clave privada nsec1...",importKeyError:"Formato de clave privada inválido",like:"Me gusta",liked:"Te gusta",loadMore:"Cargar más",loading:"Cargando...",noComments:"Aún no hay comentarios. ¡Sé el primero en comentar!",error:"Error",retry:"Reintentar",anonymous:"Anónimo",timeJustNow:"ahora mismo",timeMinutesAgo:"hace {{n}}m",timeHoursAgo:"hace {{n}}h",timeDaysAgo:"hace {{n}}d"},qt={comments:"Commentaires",writeComment:"Écrire un commentaire...",reply:"Répondre",replyTo:"Répondre à",publish:"Publier",publishing:"Publication...",cancel:"Annuler",login:"Connexion",logout:"Déconnexion",loginRequired:"Veuillez d'abord vous connecter",loginDescription:"Choisissez une méthode pour vous connecter et publier des commentaires",extensionLogin:"Extension navigateur",extensionLoginDesc:"Connexion avec extension NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Signature distante Bunker",bunkerLoginDesc:"Utiliser NIP-46 Bunker pour la signature distante",bunkerUrlPlaceholder:"Entrez l'URL bunker://",connect:"Connecter",connecting:"Connexion...",tempAccount:"Compte temporaire",tempAccountDesc:"Créer une paire de clés temporaire",tempAccountCreated:"Compte créé avec succès !",createAccount:"Créer un compte",copyKey:"Copier la clé privée (nsec)",keyCopied:"Copié !",downloadKey:"Télécharger le fichier de clé",keyCompatibility:"Ceci est une clé privée Nostr standard. Vous pouvez l'utiliser dans n'importe quel client Nostr comme Jumble, Damus, Amethyst, etc.",startCommenting:"Commencer à commenter",importKey:"Importer une clé existante",importKeyDesc:"Connexion avec une clé privée nsec sauvegardée",importKeyPlaceholder:"Collez la clé privée nsec1...",importKeyError:"Format de clé privée invalide",like:"J'aime",liked:"Aimé",loadMore:"Charger plus",loading:"Chargement...",noComments:"Pas encore de commentaires. Soyez le premier à commenter !",error:"Erreur",retry:"Réessayer",anonymous:"Anonyme",timeJustNow:"à l'instant",timeMinutesAgo:"il y a {{n}}min",timeHoursAgo:"il y a {{n}}h",timeDaysAgo:"il y a {{n}}j"},$n={comments:"Kommentare",writeComment:"Kommentar schreiben...",reply:"Antworten",replyTo:"Antworten auf",publish:"Veröffentlichen",publishing:"Veröffentliche...",cancel:"Abbrechen",login:"Anmelden",logout:"Abmelden",loginRequired:"Bitte melden Sie sich zuerst an",loginDescription:"Wählen Sie eine Methode zum Anmelden und Kommentieren",extensionLogin:"Browser-Erweiterung",extensionLoginDesc:"Mit NIP-07-Erweiterung anmelden (Alby, nos2x, etc.)",bunkerLogin:"Bunker-Fernsignatur",bunkerLoginDesc:"NIP-46 Bunker für Fernsignatur verwenden",bunkerUrlPlaceholder:"bunker:// URL eingeben",connect:"Verbinden",connecting:"Verbinde...",tempAccount:"Temporäres Konto",tempAccountDesc:"Temporäres Schlüsselpaar erstellen",tempAccountCreated:"Konto erfolgreich erstellt!",createAccount:"Konto erstellen",copyKey:"Privaten Schlüssel kopieren (nsec)",keyCopied:"Kopiert!",downloadKey:"Schlüsseldatei herunterladen",keyCompatibility:"Dies ist ein standardmäßiger Nostr-Privatschlüssel. Sie können ihn in jedem Nostr-Client wie Jumble, Damus, Amethyst und mehr verwenden.",startCommenting:"Mit dem Kommentieren beginnen",importKey:"Vorhandenen Schlüssel importieren",importKeyDesc:"Mit gespeichertem nsec-Privatschlüssel anmelden",importKeyPlaceholder:"nsec1... Privatschlüssel einfügen",importKeyError:"Ungültiges Privatschlüssel-Format",like:"Gefällt mir",liked:"Gefällt mir",loadMore:"Mehr laden",loading:"Lädt...",noComments:"Noch keine Kommentare. Seien Sie der Erste!",error:"Fehler",retry:"Erneut versuchen",anonymous:"Anonym",timeJustNow:"gerade eben",timeMinutesAgo:"vor {{n}}min",timeHoursAgo:"vor {{n}}h",timeDaysAgo:"vor {{n}}T"},Bo={comments:"Comentários",writeComment:"Escreva um comentário...",reply:"Responder",replyTo:"Responder a",publish:"Publicar",publishing:"Publicando...",cancel:"Cancelar",login:"Entrar",logout:"Sair",loginRequired:"Por favor, faça login primeiro",loginDescription:"Escolha um método para entrar e publicar comentários",extensionLogin:"Extensão do navegador",extensionLoginDesc:"Entre com extensão NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Assinatura remota Bunker",bunkerLoginDesc:"Use NIP-46 Bunker para assinatura remota",bunkerUrlPlaceholder:"Digite a URL bunker://",connect:"Conectar",connecting:"Conectando...",tempAccount:"Conta temporária",tempAccountDesc:"Criar um par de chaves temporário",tempAccountCreated:"Conta criada com sucesso!",createAccount:"Criar conta",copyKey:"Copiar chave privada (nsec)",keyCopied:"Copiado!",downloadKey:"Baixar arquivo de chave",keyCompatibility:"Esta é uma chave privada Nostr padrão. Você pode usá-la em qualquer cliente Nostr como Jumble, Damus, Amethyst e mais.",startCommenting:"Começar a comentar",importKey:"Importar chave existente",importKeyDesc:"Entre com uma chave privada nsec salva",importKeyPlaceholder:"Cole a chave privada nsec1...",importKeyError:"Formato de chave privada inválido",like:"Curtir",liked:"Curtido",loadMore:"Carregar mais",loading:"Carregando...",noComments:"Ainda não há comentários. Seja o primeiro a comentar!",error:"Erro",retry:"Tentar novamente",anonymous:"Anônimo",timeJustNow:"agora mesmo",timeMinutesAgo:"há {{n}}min",timeHoursAgo:"há {{n}}h",timeDaysAgo:"há {{n}}d"},Ga={comments:"Комментарии",writeComment:"Написать комментарий...",reply:"Ответить",replyTo:"Ответить",publish:"Опубликовать",publishing:"Публикация...",cancel:"Отмена",login:"Войти",logout:"Выйти",loginRequired:"Пожалуйста, сначала войдите",loginDescription:"Выберите способ входа для публикации комментариев",extensionLogin:"Расширение браузера",extensionLoginDesc:"Войти через NIP-07 расширение (Alby, nos2x и др.)",bunkerLogin:"Удалённая подпись Bunker",bunkerLoginDesc:"Использовать NIP-46 Bunker для удалённой подписи",bunkerUrlPlaceholder:"Введите URL bunker://",connect:"Подключить",connecting:"Подключение...",tempAccount:"Временный аккаунт",tempAccountDesc:"Создать временную пару ключей",tempAccountCreated:"Аккаунт успешно создан!",createAccount:"Создать аккаунт",copyKey:"Копировать приватный ключ (nsec)",keyCopied:"Скопировано!",downloadKey:"Скачать файл ключа",keyCompatibility:"Это стандартный приватный ключ Nostr. Вы можете использовать его в любом клиенте Nostr, таком как Jumble, Damus, Amethyst и других.",startCommenting:"Начать комментировать",importKey:"Импортировать существующий ключ",importKeyDesc:"Войти с сохранённым приватным ключом nsec",importKeyPlaceholder:"Вставьте приватный ключ nsec1...",importKeyError:"Неверный формат приватного ключа",like:"Нравится",liked:"Понравилось",loadMore:"Загрузить ещё",loading:"Загрузка...",noComments:"Пока нет комментариев. Будьте первым!",error:"Ошибка",retry:"Повторить",anonymous:"Аноним",timeJustNow:"только что",timeMinutesAgo:"{{n}} мин. назад",timeHoursAgo:"{{n}} ч. назад",timeDaysAgo:"{{n}} дн. назад"},Tn={comments:"التعليقات",writeComment:"اكتب تعليقاً...",reply:"رد",replyTo:"الرد على",publish:"نشر",publishing:"جارِ النشر...",cancel:"إلغاء",login:"تسجيل الدخول",logout:"تسجيل الخروج",loginRequired:"يرجى تسجيل الدخول أولاً",loginDescription:"اختر طريقة لتسجيل الدخول ونشر التعليقات",extensionLogin:"إضافة المتصفح",extensionLoginDesc:"تسجيل الدخول باستخدام إضافة NIP-07 (Alby، nos2x، إلخ)",bunkerLogin:"توقيع Bunker عن بُعد",bunkerLoginDesc:"استخدام NIP-46 Bunker للتوقيع عن بُعد",bunkerUrlPlaceholder:"أدخل رابط bunker://",connect:"اتصال",connecting:"جارِ الاتصال...",tempAccount:"حساب مؤقت",tempAccountDesc:"إنشاء زوج مفاتيح مؤقت",tempAccountCreated:"تم إنشاء الحساب بنجاح!",createAccount:"إنشاء حساب",copyKey:"نسخ المفتاح الخاص (nsec)",keyCopied:"تم النسخ!",downloadKey:"تحميل ملف المفتاح",keyCompatibility:"هذا مفتاح Nostr خاص قياسي. يمكنك استخدامه في أي عميل Nostr مثل Jumble وDamus وAmethyst وغيرها.",startCommenting:"ابدأ التعليق",importKey:"استيراد مفتاح موجود",importKeyDesc:"تسجيل الدخول بمفتاح nsec خاص محفوظ",importKeyPlaceholder:"الصق المفتاح الخاص nsec1...",importKeyError:"صيغة المفتاح الخاص غير صالحة",like:"إعجاب",liked:"أُعجبت",loadMore:"تحميل المزيد",loading:"جارِ التحميل...",noComments:"لا توجد تعليقات بعد. كن أول من يعلق!",error:"خطأ",retry:"إعادة المحاولة",anonymous:"مجهول",timeJustNow:"الآن",timeMinutesAgo:"منذ {{n}} دقيقة",timeHoursAgo:"منذ {{n}} ساعة",timeDaysAgo:"منذ {{n}} يوم"},Ya={comments:"Commenti",writeComment:"Scrivi un commento...",reply:"Rispondi",replyTo:"Rispondi a",publish:"Pubblica",publishing:"Pubblicazione...",cancel:"Annulla",login:"Accedi",logout:"Esci",loginRequired:"Effettua prima l'accesso",loginDescription:"Scegli un metodo per accedere e pubblicare commenti",extensionLogin:"Estensione browser",extensionLoginDesc:"Accedi con estensione NIP-07 (Alby, nos2x, ecc.)",bunkerLogin:"Firma remota Bunker",bunkerLoginDesc:"Usa NIP-46 Bunker per la firma remota",bunkerUrlPlaceholder:"Inserisci URL bunker://",connect:"Connetti",connecting:"Connessione...",tempAccount:"Account temporaneo",tempAccountDesc:"Crea una coppia di chiavi temporanea",tempAccountCreated:"Account creato con successo!",createAccount:"Crea account",copyKey:"Copia chiave privata (nsec)",keyCopied:"Copiato!",downloadKey:"Scarica file chiave",keyCompatibility:"Questa è una chiave privata Nostr standard. Puoi usarla in qualsiasi client Nostr come Jumble, Damus, Amethyst e altri.",startCommenting:"Inizia a commentare",importKey:"Importa chiave esistente",importKeyDesc:"Accedi con una chiave privata nsec salvata",importKeyPlaceholder:"Incolla la chiave privata nsec1...",importKeyError:"Formato chiave privata non valido",like:"Mi piace",liked:"Piaciuto",loadMore:"Carica altri",loading:"Caricamento...",noComments:"Ancora nessun commento. Sii il primo a commentare!",error:"Errore",retry:"Riprova",anonymous:"Anonimo",timeJustNow:"proprio ora",timeMinutesAgo:"{{n}}min fa",timeHoursAgo:"{{n}}h fa",timeDaysAgo:"{{n}}g fa"},Lo={comments:"Reacties",writeComment:"Schrijf een reactie...",reply:"Reageren",replyTo:"Reageren op",publish:"Publiceren",publishing:"Publiceren...",cancel:"Annuleren",login:"Inloggen",logout:"Uitloggen",loginRequired:"Log eerst in",loginDescription:"Kies een methode om in te loggen en reacties te plaatsen",extensionLogin:"Browserextensie",extensionLoginDesc:"Inloggen met NIP-07 extensie (Alby, nos2x, etc.)",bunkerLogin:"Bunker externe ondertekening",bunkerLoginDesc:"Gebruik NIP-46 Bunker voor externe ondertekening",bunkerUrlPlaceholder:"Voer bunker:// URL in",connect:"Verbinden",connecting:"Verbinden...",tempAccount:"Tijdelijk account",tempAccountDesc:"Maak een tijdelijk sleutelpaar aan",tempAccountCreated:"Account succesvol aangemaakt!",createAccount:"Account aanmaken",copyKey:"Kopieer privésleutel (nsec)",keyCopied:"Gekopieerd!",downloadKey:"Download sleutelbestand",keyCompatibility:"Dit is een standaard Nostr privésleutel. Je kunt deze gebruiken in elke Nostr-client zoals Jumble, Damus, Amethyst en meer.",startCommenting:"Begin met reageren",importKey:"Bestaande sleutel importeren",importKeyDesc:"Log in met een opgeslagen nsec privésleutel",importKeyPlaceholder:"Plak nsec1... privésleutel",importKeyError:"Ongeldig privésleutel formaat",like:"Vind ik leuk",liked:"Leuk gevonden",loadMore:"Meer laden",loading:"Laden...",noComments:"Nog geen reacties. Wees de eerste om te reageren!",error:"Fout",retry:"Opnieuw proberen",anonymous:"Anoniem",timeJustNow:"zojuist",timeMinutesAgo:"{{n}}min geleden",timeHoursAgo:"{{n}}u geleden",timeDaysAgo:"{{n}}d geleden"},Xa={comments:"Komentarze",writeComment:"Napisz komentarz...",reply:"Odpowiedz",replyTo:"Odpowiedz do",publish:"Opublikuj",publishing:"Publikowanie...",cancel:"Anuluj",login:"Zaloguj się",logout:"Wyloguj się",loginRequired:"Najpierw się zaloguj",loginDescription:"Wybierz metodę logowania i publikowania komentarzy",extensionLogin:"Rozszerzenie przeglądarki",extensionLoginDesc:"Zaloguj się za pomocą rozszerzenia NIP-07 (Alby, nos2x, itp.)",bunkerLogin:"Zdalne podpisywanie Bunker",bunkerLoginDesc:"Użyj NIP-46 Bunker do zdalnego podpisywania",bunkerUrlPlaceholder:"Wprowadź URL bunker://",connect:"Połącz",connecting:"Łączenie...",tempAccount:"Tymczasowe konto",tempAccountDesc:"Utwórz tymczasową parę kluczy",tempAccountCreated:"Konto utworzone pomyślnie!",createAccount:"Utwórz konto",copyKey:"Kopiuj klucz prywatny (nsec)",keyCopied:"Skopiowano!",downloadKey:"Pobierz plik klucza",keyCompatibility:"To jest standardowy klucz prywatny Nostr. Możesz go używać w dowolnym kliencie Nostr, takim jak Jumble, Damus, Amethyst i innych.",startCommenting:"Zacznij komentować",importKey:"Importuj istniejący klucz",importKeyDesc:"Zaloguj się za pomocą zapisanego klucza prywatnego nsec",importKeyPlaceholder:"Wklej klucz prywatny nsec1...",importKeyError:"Nieprawidłowy format klucza prywatnego",like:"Lubię",liked:"Polubione",loadMore:"Załaduj więcej",loading:"Ładowanie...",noComments:"Brak komentarzy. Bądź pierwszy!",error:"Błąd",retry:"Ponów",anonymous:"Anonim",timeJustNow:"właśnie teraz",timeMinutesAgo:"{{n}} min temu",timeHoursAgo:"{{n}} godz. temu",timeDaysAgo:"{{n}} dni temu"},Qa={comments:"Yorumlar",writeComment:"Yorum yaz...",reply:"Yanıtla",replyTo:"Yanıtla",publish:"Yayınla",publishing:"Yayınlanıyor...",cancel:"İptal",login:"Giriş yap",logout:"Çıkış yap",loginRequired:"Lütfen önce giriş yapın",loginDescription:"Giriş yapmak ve yorum yazmak için bir yöntem seçin",extensionLogin:"Tarayıcı eklentisi",extensionLoginDesc:"NIP-07 eklentisiyle giriş yapın (Alby, nos2x, vb.)",bunkerLogin:"Bunker uzaktan imzalama",bunkerLoginDesc:"Uzaktan imzalama için NIP-46 Bunker kullanın",bunkerUrlPlaceholder:"bunker:// URL'sini girin",connect:"Bağlan",connecting:"Bağlanıyor...",tempAccount:"Geçici hesap",tempAccountDesc:"Geçici anahtar çifti oluştur",tempAccountCreated:"Hesap başarıyla oluşturuldu!",createAccount:"Hesap oluştur",copyKey:"Özel anahtarı kopyala (nsec)",keyCopied:"Kopyalandı!",downloadKey:"Anahtar dosyasını indir",keyCompatibility:"Bu standart bir Nostr özel anahtarıdır. Jumble, Damus, Amethyst ve daha fazlası gibi herhangi bir Nostr istemcisinde kullanabilirsiniz.",startCommenting:"Yorum yapmaya başla",importKey:"Mevcut anahtarı içe aktar",importKeyDesc:"Kayıtlı nsec özel anahtarıyla giriş yapın",importKeyPlaceholder:"nsec1... özel anahtarını yapıştırın",importKeyError:"Geçersiz özel anahtar formatı",like:"Beğen",liked:"Beğenildi",loadMore:"Daha fazla yükle",loading:"Yükleniyor...",noComments:"Henüz yorum yok. İlk yorumu siz yapın!",error:"Hata",retry:"Tekrar dene",anonymous:"Anonim",timeJustNow:"az önce",timeMinutesAgo:"{{n}}dk önce",timeHoursAgo:"{{n}}sa önce",timeDaysAgo:"{{n}}g önce"},ec={comments:"Bình luận",writeComment:"Viết bình luận...",reply:"Trả lời",replyTo:"Trả lời",publish:"Đăng",publishing:"Đang đăng...",cancel:"Hủy",login:"Đăng nhập",logout:"Đăng xuất",loginRequired:"Vui lòng đăng nhập trước",loginDescription:"Chọn phương thức đăng nhập để đăng bình luận",extensionLogin:"Tiện ích trình duyệt",extensionLoginDesc:"Đăng nhập bằng tiện ích NIP-07 (Alby, nos2x, v.v.)",bunkerLogin:"Ký từ xa Bunker",bunkerLoginDesc:"Sử dụng NIP-46 Bunker để ký từ xa",bunkerUrlPlaceholder:"Nhập URL bunker://",connect:"Kết nối",connecting:"Đang kết nối...",tempAccount:"Tài khoản tạm thời",tempAccountDesc:"Tạo cặp khóa tạm thời",tempAccountCreated:"Tạo tài khoản thành công!",createAccount:"Tạo tài khoản",copyKey:"Sao chép khóa riêng (nsec)",keyCopied:"Đã sao chép!",downloadKey:"Tải file khóa",keyCompatibility:"Đây là khóa riêng Nostr tiêu chuẩn. Bạn có thể sử dụng nó trong bất kỳ ứng dụng Nostr nào như Jumble, Damus, Amethyst và nhiều hơn nữa.",startCommenting:"Bắt đầu bình luận",importKey:"Nhập khóa hiện có",importKeyDesc:"Đăng nhập bằng khóa riêng nsec đã lưu",importKeyPlaceholder:"Dán khóa riêng nsec1...",importKeyError:"Định dạng khóa riêng không hợp lệ",like:"Thích",liked:"Đã thích",loadMore:"Tải thêm",loading:"Đang tải...",noComments:"Chưa có bình luận. Hãy là người đầu tiên bình luận!",error:"Lỗi",retry:"Thử lại",anonymous:"Ẩn danh",timeJustNow:"vừa xong",timeMinutesAgo:"{{n}} phút trước",timeHoursAgo:"{{n}} giờ trước",timeDaysAgo:"{{n}} ngày trước"},tc={comments:"ความคิดเห็น",writeComment:"เขียนความคิดเห็น...",reply:"ตอบกลับ",replyTo:"ตอบกลับถึง",publish:"เผยแพร่",publishing:"กำลังเผยแพร่...",cancel:"ยกเลิก",login:"เข้าสู่ระบบ",logout:"ออกจากระบบ",loginRequired:"กรุณาเข้าสู่ระบบก่อน",loginDescription:"เลือกวิธีเข้าสู่ระบบเพื่อโพสต์ความคิดเห็น",extensionLogin:"ส่วนขยายเบราว์เซอร์",extensionLoginDesc:"เข้าสู่ระบบด้วยส่วนขยาย NIP-07 (Alby, nos2x ฯลฯ)",bunkerLogin:"ลงนามระยะไกล Bunker",bunkerLoginDesc:"ใช้ NIP-46 Bunker สำหรับการลงนามระยะไกล",bunkerUrlPlaceholder:"ใส่ URL bunker://",connect:"เชื่อมต่อ",connecting:"กำลังเชื่อมต่อ...",tempAccount:"บัญชีชั่วคราว",tempAccountDesc:"สร้างคู่คีย์ชั่วคราว",tempAccountCreated:"สร้างบัญชีสำเร็จ!",createAccount:"สร้างบัญชี",copyKey:"คัดลอกคีย์ส่วนตัว (nsec)",keyCopied:"คัดลอกแล้ว!",downloadKey:"ดาวน์โหลดไฟล์คีย์",keyCompatibility:"นี่คือคีย์ส่วนตัว Nostr มาตรฐาน คุณสามารถใช้งานได้ในไคลเอนต์ Nostr ใดก็ได้ เช่น Jumble, Damus, Amethyst และอื่นๆ",startCommenting:"เริ่มแสดงความคิดเห็น",importKey:"นำเข้าคีย์ที่มีอยู่",importKeyDesc:"เข้าสู่ระบบด้วยคีย์ส่วนตัว nsec ที่บันทึกไว้",importKeyPlaceholder:"วางคีย์ส่วนตัว nsec1...",importKeyError:"รูปแบบคีย์ส่วนตัวไม่ถูกต้อง",like:"ถูกใจ",liked:"ถูกใจแล้ว",loadMore:"โหลดเพิ่มเติม",loading:"กำลังโหลด...",noComments:"ยังไม่มีความคิดเห็น เป็นคนแรกที่แสดงความคิดเห็น!",error:"ข้อผิดพลาด",retry:"ลองอีกครั้ง",anonymous:"ไม่ระบุชื่อ",timeJustNow:"เมื่อกี้",timeMinutesAgo:"{{n}} นาทีที่แล้ว",timeHoursAgo:"{{n}} ชั่วโมงที่แล้ว",timeDaysAgo:"{{n}} วันที่แล้ว"},nc={comments:"Komentar",writeComment:"Tulis komentar...",reply:"Balas",replyTo:"Balas ke",publish:"Publikasikan",publishing:"Mempublikasikan...",cancel:"Batal",login:"Masuk",logout:"Keluar",loginRequired:"Silakan masuk terlebih dahulu",loginDescription:"Pilih metode untuk masuk dan memposting komentar",extensionLogin:"Ekstensi browser",extensionLoginDesc:"Masuk dengan ekstensi NIP-07 (Alby, nos2x, dll.)",bunkerLogin:"Penandatanganan jarak jauh Bunker",bunkerLoginDesc:"Gunakan NIP-46 Bunker untuk penandatanganan jarak jauh",bunkerUrlPlaceholder:"Masukkan URL bunker://",connect:"Hubungkan",connecting:"Menghubungkan...",tempAccount:"Akun sementara",tempAccountDesc:"Buat pasangan kunci sementara",tempAccountCreated:"Akun berhasil dibuat!",createAccount:"Buat akun",copyKey:"Salin kunci privat (nsec)",keyCopied:"Tersalin!",downloadKey:"Unduh file kunci",keyCompatibility:"Ini adalah kunci privat Nostr standar. Anda dapat menggunakannya di klien Nostr mana pun seperti Jumble, Damus, Amethyst, dan lainnya.",startCommenting:"Mulai berkomentar",importKey:"Impor kunci yang ada",importKeyDesc:"Masuk dengan kunci privat nsec yang tersimpan",importKeyPlaceholder:"Tempel kunci privat nsec1...",importKeyError:"Format kunci privat tidak valid",like:"Suka",liked:"Disukai",loadMore:"Muat lebih banyak",loading:"Memuat...",noComments:"Belum ada komentar. Jadilah yang pertama berkomentar!",error:"Kesalahan",retry:"Coba lagi",anonymous:"Anonim",timeJustNow:"baru saja",timeMinutesAgo:"{{n}} menit yang lalu",timeHoursAgo:"{{n}} jam yang lalu",timeDaysAgo:"{{n}} hari yang lalu"},rc={comments:"टिप्पणियाँ",writeComment:"टिप्पणी लिखें...",reply:"जवाब दें",replyTo:"जवाब दें",publish:"प्रकाशित करें",publishing:"प्रकाशित हो रहा है...",cancel:"रद्द करें",login:"लॉग इन करें",logout:"लॉग आउट करें",loginRequired:"कृपया पहले लॉग इन करें",loginDescription:"लॉग इन करने और टिप्पणी पोस्ट करने के लिए एक विधि चुनें",extensionLogin:"ब्राउज़र एक्सटेंशन",extensionLoginDesc:"NIP-07 एक्सटेंशन से लॉग इन करें (Alby, nos2x, आदि)",bunkerLogin:"Bunker रिमोट साइनिंग",bunkerLoginDesc:"रिमोट साइनिंग के लिए NIP-46 Bunker का उपयोग करें",bunkerUrlPlaceholder:"bunker:// URL दर्ज करें",connect:"कनेक्ट करें",connecting:"कनेक्ट हो रहा है...",tempAccount:"अस्थायी खाता",tempAccountDesc:"अस्थायी की पेयर बनाएं",tempAccountCreated:"खाता सफलतापूर्वक बनाया गया!",createAccount:"खाता बनाएं",copyKey:"प्राइवेट की कॉपी करें (nsec)",keyCopied:"कॉपी हो गया!",downloadKey:"की फ़ाइल डाउनलोड करें",keyCompatibility:"यह एक मानक Nostr प्राइवेट की है। आप इसे किसी भी Nostr क्लाइंट जैसे Jumble, Damus, Amethyst और अन्य में उपयोग कर सकते हैं।",startCommenting:"टिप्पणी करना शुरू करें",importKey:"मौजूदा की इम्पोर्ट करें",importKeyDesc:"सेव की गई nsec प्राइवेट की से लॉग इन करें",importKeyPlaceholder:"nsec1... प्राइवेट की पेस्ट करें",importKeyError:"अमान्य प्राइवेट की फ़ॉर्मेट",like:"पसंद करें",liked:"पसंद किया",loadMore:"और लोड करें",loading:"लोड हो रहा है...",noComments:"अभी कोई टिप्पणी नहीं। पहले टिप्पणी करने वाले बनें!",error:"त्रुटि",retry:"पुनः प्रयास करें",anonymous:"अनाम",timeJustNow:"अभी",timeMinutesAgo:"{{n}} मिनट पहले",timeHoursAgo:"{{n}} घंटे पहले",timeDaysAgo:"{{n}} दिन पहले"},oc={comments:"Коментарі",writeComment:"Написати коментар...",reply:"Відповісти",replyTo:"Відповісти",publish:"Опублікувати",publishing:"Публікація...",cancel:"Скасувати",login:"Увійти",logout:"Вийти",loginRequired:"Спочатку увійдіть",loginDescription:"Оберіть спосіб входу для публікації коментарів",extensionLogin:"Розширення браузера",extensionLoginDesc:"Увійти через розширення NIP-07 (Alby, nos2x тощо)",bunkerLogin:"Віддалений підпис Bunker",bunkerLoginDesc:"Використовувати NIP-46 Bunker для віддаленого підпису",bunkerUrlPlaceholder:"Введіть URL bunker://",connect:"Підключити",connecting:"Підключення...",tempAccount:"Тимчасовий акаунт",tempAccountDesc:"Створити тимчасову пару ключів",tempAccountCreated:"Акаунт успішно створено!",createAccount:"Створити акаунт",copyKey:"Копіювати приватний ключ (nsec)",keyCopied:"Скопійовано!",downloadKey:"Завантажити файл ключа",keyCompatibility:"Це стандартний приватний ключ Nostr. Ви можете використовувати його в будь-якому клієнті Nostr, такому як Jumble, Damus, Amethyst та інших.",startCommenting:"Почати коментувати",importKey:"Імпортувати існуючий ключ",importKeyDesc:"Увійти зі збереженим приватним ключем nsec",importKeyPlaceholder:"Вставте приватний ключ nsec1...",importKeyError:"Невірний формат приватного ключа",like:"Подобається",liked:"Сподобалось",loadMore:"Завантажити ще",loading:"Завантаження...",noComments:"Ще немає коментарів. Будьте першим!",error:"Помилка",retry:"Повторити",anonymous:"Анонім",timeJustNow:"щойно",timeMinutesAgo:"{{n}} хв. тому",timeHoursAgo:"{{n}} год. тому",timeDaysAgo:"{{n}} дн. тому"},Pn={en:Nt,"en-US":Nt,"en-GB":Nt,"en-AU":Nt,"en-CA":Nt,"zh-CN":In,"zh-Hans":In,"zh-TW":Co,"zh-Hant":Co,"zh-HK":Co,zh:In,ja:Za,"ja-JP":Za,ko:Ja,"ko-KR":Ja,es:Ct,"es-ES":Ct,"es-MX":Ct,"es-AR":Ct,"es-CO":Ct,"es-CL":Ct,fr:qt,"fr-FR":qt,"fr-CA":qt,"fr-BE":qt,"fr-CH":qt,de:$n,"de-DE":$n,"de-AT":$n,"de-CH":$n,pt:Bo,"pt-BR":Bo,"pt-PT":Bo,ru:Ga,"ru-RU":Ga,ar:Tn,"ar-SA":Tn,"ar-EG":Tn,"ar-AE":Tn,it:Ya,"it-IT":Ya,nl:Lo,"nl-NL":Lo,"nl-BE":Lo,pl:Xa,"pl-PL":Xa,tr:Qa,"tr-TR":Qa,vi:ec,"vi-VN":ec,th:tc,"th-TH":tc,id:nc,"id-ID":nc,hi:rc,"hi-IN":rc,uk:oc,"uk-UA":oc};function sc(){if(typeof navigator>"u")return"en";const t=navigator.languages||[navigator.language];for(const e of t){if(Pn[e])return e;const n=e.split("-")[0];if(Pn[n])return n}return"en"}function ic(t,e){const n=t||sc(),r=Pn[n]||Pn.en;return e?{...r,...e}:r}const ac=z.createContext(null);function cc({locale:t,translations:e,children:n}){const r=t||sc(),o=ic(r,e),s=i=>o[i]||i;return b.jsx(ac.Provider,{value:{locale:r,translations:o,t:s},children:n})}function et(){const t=z.useContext(ac);if(!t){const e=ic();return{locale:"en",translations:e,t:n=>e[n]||n}}return t}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function uc(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function Bm(t){if(typeof t!="function")throw new Error("function expected");return!0}function Vt(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function dc(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Io(t){if(!Array.isArray(t))throw new Error("array expected")}function hc(t,e){if(!uc(!0,e))throw new Error(`${t}: array of strings expected`)}function fc(t,e){if(!uc(!1,e))throw new Error(`${t}: array of numbers expected`)}function Lm(...t){const e=s=>s,n=(s,i)=>a=>s(i(a)),r=t.map(s=>s.encode).reduceRight(n,e),o=t.map(s=>s.decode).reduce(n,e);return{encode:r,decode:o}}function Im(t){const e=typeof t=="string"?t.split(""):t,n=e.length;hc("alphabet",e);const r=new Map(e.map((o,s)=>[o,s]));return{encode:o=>(Io(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);return e[s]})),decode:o=>(Io(o),o.map(s=>{Vt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);return i}))}}function $m(t=""){return Vt("join",t),{encode:e=>(hc("join.decode",e),e.join(t)),decode:e=>(Vt("join.decode",e),e.split(t))}}const pc=(t,e)=>e===0?t:pc(e,t%e),Un=(t,e)=>t+(e-pc(t,e)),On=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function $o(t,e,n,r){if(Io(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Un(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Un(e,n)}`);let o=0,s=0;const i=On[e],a=On[n]-1,c=[];for(const l of t){if(dc(l),l>=i)throw new Error(`convertRadix2: invalid data word=${l} from=${e}`);if(o=o<<e|l,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);const d=On[s];if(d===void 0)throw new Error("invalid carry");o&=d-1}if(o=o<<n-s&a,!r&&s>=e)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&c.push(o>>>0),c}function Tm(t,e=!1){if(dc(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Un(8,t)>32||Un(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!lc(n))throw new Error("radix2.encode input should be Uint8Array");return $o(Array.from(n),8,t,!e)},decode:n=>(fc("radix2.decode",n),Uint8Array.from($o(n,t,8,e)))}}function mc(t){return Bm(t),function(...e){try{return t.apply(null,e)}catch{}}}const To=Lm(Im("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),$m("")),gc=[996825010,642813549,513874426,1027748829,705979059];function jt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<gc.length;r++)(e>>r&1)===1&&(n^=gc[r]);return n}function yc(t,e,n=1){const r=t.length;let o=1;for(let s=0;s<r;s++){const i=t.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${t})`);o=jt(o)^i>>5}o=jt(o);for(let s=0;s<r;s++)o=jt(o)^t.charCodeAt(s)&31;for(let s of e)o=jt(o)^s;for(let s=0;s<6;s++)o=jt(o);return o^=n,To.encode($o([o%On[30]],30,5,!1))}function Pm(t){const e=t==="bech32"?1:734539939,n=Tm(5),r=n.decode,o=n.encode,s=mc(r);function i(u,p,f=90){Vt("bech32.encode prefix",u),lc(p)&&(p=Array.from(p)),fc("bech32.encode",p);const m=u.length;if(m===0)throw new TypeError(`Invalid prefix length ${m}`);const h=m+7+p.length;if(f!==!1&&h>f)throw new TypeError(`Length ${h} exceeds limit ${f}`);const y=u.toLowerCase(),v=yc(y,p,e);return`${y}1${To.encode(p)}${v}`}function a(u,p=90){Vt("bech32.decode input",u);const f=u.length;if(f<8||p!==!1&&f>p)throw new TypeError(`invalid string length: ${f} (${u}). Expected (8..${p})`);const m=u.toLowerCase();if(u!==m&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");const h=m.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const y=m.slice(0,h),v=m.slice(h+1);if(v.length<6)throw new Error("Data must be at least 6 characters long");const x=To.decode(v).slice(0,-6),S=yc(y,x,e);if(!v.endsWith(S))throw new Error(`Invalid checksum in ${u}: expected "${S}"`);return{prefix:y,words:x}}const c=mc(a);function l(u){const{prefix:p,words:f}=a(u,!1);return{prefix:p,words:f,bytes:r(f)}}function d(u,p){return i(u,o(p))}return{encode:i,decode:a,encodeFromBytes:d,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const Rn=Pm("bech32"),bc=5e3;function wc(t){var o,s,i,a,c,l,d;let{prefix:e,words:n}=Rn.decode(t,bc),r=new Uint8Array(Rn.fromWords(n));switch(e){case"nprofile":{let u=Po(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:ce(u[0][0]),relays:u[1]?u[1].map(p=>Sn.decode(p)):[]}}}case"nevent":{let u=Po(r);if(!((s=u[0])!=null&&s[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(u[3]&&u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:ce(u[0][0]),relays:u[1]?u[1].map(p=>Sn.decode(p)):[],author:(i=u[2])!=null&&i[0]?ce(u[2][0]):void 0,kind:(a=u[3])!=null&&a[0]?parseInt(ce(u[3][0]),16):void 0}}}case"naddr":{let u=Po(r);if(!((c=u[0])!=null&&c[0]))throw new Error("missing TLV 0 for naddr");if(!((l=u[2])!=null&&l[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((d=u[3])!=null&&d[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Sn.decode(u[0][0]),pubkey:ce(u[2][0]),kind:parseInt(ce(u[3][0]),16),relays:u[1]?u[1].map(p=>Sn.decode(p)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:ce(r)};default:throw new Error(`unknown prefix ${e}`)}}function Po(t){let e={},n=t;for(;n.length>0;){let r=n[0],o=n[1],s=n.slice(2,2+o);if(n=n.slice(2+o),s.length<o)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(s)}return e}function vc(t){return Om("npub",lt(t))}function Um(t,e){let n=Rn.toWords(e);return Rn.encode(t,n,bc)}function Om(t,e){return Um(t,e)}let Ec=0;function Dn(t){let e,n;if(t.startsWith("npub1")){let{data:r}=wc(t);n=r,e=t}else if(t.startsWith("nprofile")){let{data:r}=wc(t);n=r.pubkey,e=vc(n)}else n=t,e=vc(t);return{pubkey:n,npub:e,shortName:e.substring(0,8)+"…"+e.substring(59),metadata:{},lastUpdated:0}}const Mn=xo("@nostr/gadgets/metadata","cache");async function Rm(t){return typeof t=="string"?Kn.load({pubkey:t}):t.refreshStyle===null?(await Ra(t.pubkey,Mn),Kn._cacheMap.delete(t.pubkey),Dn(t.pubkey)):(t.refreshStyle&&Kn.clear(t),Kn.load(t))}const Kn=new Ta(async t=>new Promise(async e=>{const n=[];let r=Math.round(Date.now()/1e3),o=await Oa(t.map(i=>i.pubkey),Mn).then(i=>i.map((a,c)=>{const l=t[c];if(typeof l.refreshStyle=="object"){let d=Dn(l.pubkey);return xc(d,l.refreshStyle),Pa(l.pubkey,d,Mn),d}else{if(a)return l.refreshStyle===!0||a.lastAttempt<r-3600*24*2?(l.refreshStyle!==!1&&n.push(l),a.lastAttempt=r,a):(a.lastAttempt<r-3600&&!a.metadata.name&&!a.metadata.picture&&!a.metadata.about&&(l.refreshStyle!==!1&&n.push(l),a.lastAttempt=Math.round(Date.now()/1e3)),a);{l.refreshStyle!==!1&&n.push(l);let d=Dn(l.pubkey);return d.lastAttempt=r,d}}}));if(n.length===0){e(o);return}const s={};await Promise.all(n.map(async({pubkey:i,relays:a=[]})=>{const c=new Set(a.slice(0,3));try{const{items:l}=await Ao(i);let d=0;for(let u=0;u<l.length&&!(l[u].write&&(c.add(l[u].url),d++,d>=2));u++);}catch(l){console.error("Failed to load relay list for",i,l)}do c.add(_o[Ec%_o.length]),Ec++;while(c.size<2);for(let l of c)s[l]?s[l].push(i):s[l]=[i]}));try{const i=Object.entries(s).map(([c,l])=>({url:c,filter:{kinds:[0],authors:l}}));let a=Ht.subscribeMap(i,{label:`metadata(${t.length})`,onevent(c){for(let l=0;l<t.length;l++)if(t[l].pubkey===c.pubkey){const d=o[l];if(d.lastUpdated>c.created_at)return;xc(d,c);return}},oneose(){e(o),a.close();let c=[];for(let l=0;l<o.length;l++){let d=o[l];d.pubkey&&c.push([d.pubkey,d])}Ua(c,Mn)}})}catch(i){for(let a=0;a<o.length;a++)o[a]=i;e(o)}}),{cacheKeyFn:t=>t.pubkey});function xc(t,e){var r,o;let n={};try{n=JSON.parse(e.content)}catch{}t.metadata=n,t.shortName=n.name||n.display_name||((o=(r=n.nip05)==null?void 0:r.split("@"))==null?void 0:o[0])||t.shortName,t.lastUpdated=e.created_at,n.picture&&(t.image=n.picture)}function Uo(t){const[e,n]=z.useState(()=>Dn(t));return z.useEffect(()=>{Rm(t).then(n)},[t]),{profile:e}}const kc=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffc107","#ff9800","#ff5722","#795548"];function _c(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e),e=e&e;return kc[Math.abs(e)%kc.length]}function Ac(t,e=40){const n=_c(t),r=t.slice(0,2).toUpperCase();return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 ${e} ${e}">
8
+ ${String(r)}`);wo(e);for(let o=0;o<e.callbacks.length;o++){const s=r[o];s instanceof Error?e.callbacks[o].reject(s):e.callbacks[o].resolve(s)}}).catch(r=>{bo(t,e,r)})}function bo(t,e,n){wo(e);for(let r=0;r<e.keys.length;r++)t.clear(e.keys[r]),e.callbacks[r].reject(n)}function wo(t){if(t.cacheHits)for(let e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}function Kt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function vo(t,e){let n;const r=()=>{if(n)return n;const o=indexedDB.open(t);return o.onupgradeneeded=()=>o.result.createObjectStore(e),n=Kt(o),n.then(s=>{s.onclose=()=>n=void 0},()=>{}),n};return(o,s)=>r().then(i=>s(i.transaction(e,o).objectStore(e)))}let Eo;function Cn(){return Eo||(Eo=vo("keyval-store","keyval")),Eo}function Oa(t,e,n=Cn()){return n("readwrite",r=>(r.put(e,t),Kt(r.transaction)))}function Ra(t,e=Cn()){return e("readwrite",n=>(t.forEach(r=>n.put(r[1],r[0])),Kt(n.transaction)))}function Ma(t,e=Cn()){return e("readonly",n=>Promise.all(t.map(r=>Kt(n.get(r)))))}function Da(t,e=Cn()){return e("readwrite",n=>(n.delete(t),Kt(n.transaction)))}const xo=["wss://purplepag.es","wss://relay.nos.social","wss://relay.primal.net"],bm=["wss://purplepag.es","wss://relay.nos.social","wss://indexer.coracle.social"];function St(t){for(let e=0;e<64;e++){let n=t.charCodeAt(e);if(isNaN(n)||n<48||n>102||n>57&&n<97)return!1}return!0}function wm(t){return!!t}let vm=0;const Qe=Symbol("event was just downloaded or force-updated, not loaded from cache");Ce(3,xo,De(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]})),Ce(10101,[],De(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]})),Ce(10102,[],De(t=>{if(t.length>=2&&t[0]==="relay")return t[1]})),Ce(10012,[],De(t=>{if(t.length>=2)switch(t[0]){case"relay":return Ye(t[1]);case"a":const e=t[1].split(":");return!St(e[1])||e[0]!=="30002"?void 0:{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}}}));const ko=Ce(10002,bm,De(t=>{if(t.length===2)return{url:t[1],read:!0,write:!0};if(t[2]==="read")return{url:t[1],read:!0,write:!1};if(t[2]==="write")return{url:t[1],read:!1,write:!0}}));Ce(1e4,[],De(t=>{if(t.length>=2){switch(t[0]){case"p":if(St(t[1]))return{label:"pubkey",value:t[1]};break;case"e":if(St(t[1]))return{label:"thread",value:t[1]};break;case"t":return{label:"hashtag",value:t[1]};case"word":return{label:"word",value:t[1]}}return}})),Ce(10003,[],De(t=>{if(t.length>=2&&(t[0]==="e"||t[0]==="a")&&t[1])return t[1]})),Ce(10063,[],t=>t?t.tags.filter(([e,n])=>e==="server"&&n).map(([,e])=>"http"+Ye(e).substring(2)).filter(Boolean):[]),Ce(10030,[],De(t=>{if(!(t.length<2)){if(t[0]==="a"){const e=t[1].split(":");return!St(e[1])||e[0]!=="30030"?void 0:{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}}if(!(t.length<3||t[0]!=="emoji"))return{shortcode:t[1],url:t[2]}}})),Ce(10001,[],De(t=>{if(t.length>=2&&t[0]==="e"&&t[1])return t[1]}));function De(t){return e=>e?e.tags.map(t).filter(wm):[]}function Ce(t,e,n){const r=vo(`@nostr/gadgets/list:${t}`,"cache"),o=new Ua(s=>new Promise(async i=>{var u;let a=[],c=Math.round(Date.now()/1e3),l=await Ma(s.map(p=>p.target),r).then(p=>p.map((f,m)=>{const h=s[m];if(h.index=m,typeof h.refreshStyle=="object"){const y={event:h.refreshStyle,items:n(h.refreshStyle),[Qe]:!0};return Oa(h.target,y,r),y}else return f?h.refreshStyle===!0||!f.lastAttempt||f.lastAttempt<c-3600*24*2?(h.refreshStyle!==!1&&a.push(h),{...f,[Qe]:!1}):f.event===null&&f.lastAttempt<Date.now()/1e3-3600?(h.refreshStyle!==!1&&a.push(h),{...f,[Qe]:!1}):{...f,[Qe]:!1}:(h.refreshStyle!==!1&&a.push(h),{items:h.defaultItems||[],event:null,[Qe]:!1})}));if(a.length===0){i(l);return}const d={};for(let p=0;p<a.length;p++){const f=a[p],m=f.relays.slice(0,Math.min(4,f.relays.length));do m.push(Em(e));while(m.length<3);for(let h=0;h<m.length;h++){const y=m[h];let v=d[y];v||(v={kinds:[t],authors:[]},d[y]=v),(u=v.authors)==null||u.push(f.target)}}try{let p;p=Ht.subscribeMap(Object.entries(d).map(([f,m])=>({url:f,filter:m})),{label:`kind:${t}:batch(${a.length})`,onevent(f){var m;for(let h=0;h<a.length;h++){const y=a[h];if(y.target===f.pubkey){const v=(m=l[y.index])==null?void 0:m.event;if(((v==null?void 0:v.created_at)||0)>f.created_at)return;l[y.index]={event:f,items:n(f),[Qe]:!0};return}}},oneose(){p==null||p.close()},async onclose(){i(l),Ra(a.map(f=>[f.target,{...l[f.index],lastAttempt:c}]),r)}})}catch(p){i(l.map(f=>p))}}),{cacheKeyFn:s=>s.target,transformCacheHit(s){return s[Qe]=!1,s}});return async function(s,i=[],a,c){if(a===null)return await Da(s,r),o._cacheMap.delete(s),{items:c||[],event:null,[Qe]:!0};let l=i;if(t===10002)return await o.load({target:s,relays:l,refreshStyle:a,defaultItems:c});{const d=await ko(s,i,a);l.push(...d.items.filter(({write:p})=>p).map(({url:p})=>p).slice(0,3));const u={target:s,relays:l,refreshStyle:a,defaultItems:c};return a&&o.clear(u),await o.load(u)}}}function Em(t){return t[vm++%t.length]}let Ht=new dm;new TextDecoder("utf-8"),new TextEncoder;function xm(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}const km=/^[0-9a-f]{64}$/i;function _o(t){return km.test(t)}const _m=["wss://relay.damus.io/","wss://nos.lol/","wss://nostr.mom/"];function Ka(){return[..._m]}async function Ao(t,e){return Ht.querySync(t,e)}function So(t,e,n,r){const o=Ht.subscribeMany(t,e,{onevent:n,oneose:r});return()=>o.close()}async function No(t,e){await Promise.any(Ht.publish(t,e))}async function Co(t,e){const n=new Set;return t&&t.length>0&&t.forEach(r=>n.add(xm(r))),e&&_o(e)&&(await ko(e)).items.forEach(o=>{o.read&&n.add(o.url)}),n.size===0&&Ka().forEach(r=>n.add(r)),Array.from(n)}const Am=Symbol("relays where this event was seen before stored");function Sm(t){return t[Am]||[]}const Nm=1111;function Ha(t){const{url:e,content:n,parentEvent:r}=t,o=t.mention&&_o(t.mention)?t.mention:void 0,s=[["I",e],["K","web"]];if(o&&s.push(["P",o]),r){const i=Sm(r);s.push(["e",r.id,i.length?i[0]:"",r.pubkey]),s.push(["k","1111"]),s.push(["p",r.pubkey])}else s.push(["i",e]),s.push(["k","web"]),o&&s.push(["p",o]);return{kind:Nm,content:n,tags:s,created_at:Math.floor(Date.now()/1e3)}}function Cm(t){return t.tags.some(e=>e[0]==="e")}function zt(t){const e=t.tags.find(n=>n[0]==="e");return e?e[1]:null}function Bm(t){const e=t.tags.find(n=>n[0]==="I");return e?e[1]:null}const Lm=`
9
+ const utf8Encoder = new TextEncoder();
10
+
11
+ async function sha256Hex(message) {
12
+ const msgBuffer = utf8Encoder.encode(message);
13
+ const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
14
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
15
+ return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
16
+ }
17
+
18
+ function getPow(hex) {
19
+ let count = 0;
20
+ for (let i = 0; i < 64; i += 8) {
21
+ const nibble = parseInt(hex.substring(i, i + 8), 16);
22
+ if (nibble === 0) {
23
+ count += 32;
24
+ } else {
25
+ count += Math.clz32(nibble);
26
+ break;
27
+ }
28
+ }
29
+ return count;
30
+ }
31
+
32
+ async function fastEventHash(evt) {
33
+ return sha256Hex(JSON.stringify([0, evt.pubkey, evt.created_at, evt.kind, evt.tags, evt.content]));
34
+ }
35
+
36
+ async function minePow(unsigned, difficulty) {
37
+ let count = 0;
38
+ const event = { ...unsigned, tags: [...unsigned.tags] };
39
+ const tag = ["nonce", count.toString(), difficulty.toString()];
40
+ event.tags.push(tag);
41
+
42
+ while (true) {
43
+ const now = Math.floor(Date.now() / 1000);
44
+ if (now !== event.created_at) {
45
+ count = 0;
46
+ event.created_at = now;
47
+ }
48
+ tag[1] = (++count).toString();
49
+ event.id = await fastEventHash(event);
50
+ if (getPow(event.id) >= difficulty) {
51
+ break;
52
+ }
53
+ }
54
+ return event;
55
+ }
56
+
57
+ self.onmessage = async (e) => {
58
+ const { unsigned, difficulty } = e.data;
59
+ try {
60
+ const result = await minePow(unsigned, difficulty);
61
+ self.postMessage({ success: true, result });
62
+ } catch (error) {
63
+ self.postMessage({ success: false, error: error.message });
64
+ }
65
+ };
66
+ `;let Bo=null;function Im(){if(!Bo){const t=new Blob([Lm],{type:"application/javascript"}),e=URL.createObjectURL(t);Bo=new Worker(e)}return Bo}function $m(t,e){return new Promise((n,r)=>{const o=Im(),s=i=>{o.removeEventListener("message",s),i.data.success?n(i.data.result):r(new Error(i.data.error))};o.addEventListener("message",s),o.postMessage({unsigned:t,difficulty:e})})}const za=1111;function qa(t){const{url:e,relays:n,limit:r=50,onEvent:o,onEose:s}=t,i=[e];return e.endsWith("/")?i.push(e.slice(0,-1)):i.push(e+"/"),So(n,{kinds:[za],"#I":i,limit:r},o,s)}async function Va(t){const{url:e,relays:n,limit:r=50,until:o}=t,s=[e];return e.endsWith("/")?s.push(e.slice(0,-1)):s.push(e+"/"),Ao(n,{kinds:[za],"#I":s,limit:r,...o?{until:o}:{}})}async function ja(t,e){let n=Ha(e);if(e.pow&&e.pow>0){const o=await t.getPublicKey(),s={...n,pubkey:o},i=await $m(s,e.pow);n={...n,tags:i.tags,created_at:i.created_at}}const r=await t.signEvent(n);return await No(await Co(e.relays,e.mention),r),r}function Fa(t){const e=new Map;t.forEach(i=>e.set(i.id,i));const n=i=>{const a=zt(i);if(!a)return null;const c=e.get(a);return!c||!zt(c)?a:n(c)},r=[...t].sort((i,a)=>i.created_at-a.created_at),o=[],s=new Map;return r.forEach(i=>{const a=zt(i);if(!a)o.push(i);else{const l=n(i)||a;s.has(l)||s.set(l,[]);const d=e.get(a),u=d&&!zt(d);s.get(l).push({event:i,children:[],replyTo:u?void 0:d})}}),o.sort((i,a)=>a.created_at-i.created_at),o.map(i=>({event:i,children:s.get(i.id)||[]}))}const Nt={comments:"Comments",writeComment:"Write a comment...",reply:"Reply",replyTo:"Reply to",publish:"Publish",publishing:"Publishing...",computing:"Computing...",cancel:"Cancel",login:"Login",logout:"Logout",loginRequired:"Please login first",loginDescription:"Choose a method to login and post comments",extensionLogin:"Browser Extension",extensionLoginDesc:"Login with NIP-07 extension (Alby, nos2x, etc.)",bunkerLogin:"Bunker Remote Signing",bunkerLoginDesc:"Use NIP-46 Bunker for remote signing",bunkerUrlPlaceholder:"Enter bunker:// URL",connect:"Connect",connecting:"Connecting...",tempAccount:"Temporary Account",tempAccountDesc:"Create a temporary key pair",tempAccountCreated:"Account created successfully!",createAccount:"Create Account",copyKey:"Copy Private Key (nsec)",keyCopied:"Copied!",downloadKey:"Download Key File",keyCompatibility:"This is a standard Nostr private key. You can use it in any Nostr client like Jumble, Damus, Amethyst, and more.",startCommenting:"Start Commenting",importKey:"Import Existing Key",importKeyDesc:"Login with a previously saved nsec private key",importKeyPlaceholder:"Paste nsec1... private key",importKeyError:"Invalid private key format",like:"Like",liked:"Liked",loadMore:"Load More",loading:"Loading...",noComments:"No comments yet. Be the first to comment!",error:"Error",retry:"Retry",anonymous:"Anonymous",timeJustNow:"just now",timeMinutesAgo:"{{n}}m ago",timeHoursAgo:"{{n}}h ago",timeDaysAgo:"{{n}}d ago"},Bn={comments:"评论",writeComment:"写下你的评论...",reply:"回复",replyTo:"回复",publish:"发布",publishing:"发布中...",computing:"计算中...",cancel:"取消",login:"登录",logout:"退出登录",loginRequired:"请先登录",loginDescription:"选择一种方式登录以发布评论",extensionLogin:"浏览器扩展",extensionLoginDesc:"使用 NIP-07 浏览器扩展(如 Alby、nos2x)登录",bunkerLogin:"Bunker 远程签名",bunkerLoginDesc:"使用 NIP-46 Bunker 进行远程签名",bunkerUrlPlaceholder:"输入 bunker:// URL",connect:"连接",connecting:"连接中...",tempAccount:"临时账号",tempAccountDesc:"创建一个临时密钥对",tempAccountCreated:"账号创建成功!",createAccount:"创建账号",copyKey:"复制私钥 (nsec)",keyCopied:"已复制!",downloadKey:"下载密钥文件",keyCompatibility:"此私钥是标准的 Nostr 密钥,可在 Jumble、Damus、Amethyst 等任何 Nostr 客户端中使用。",startCommenting:"开始评论",importKey:"导入已有密钥",importKeyDesc:"使用之前保存的 nsec 私钥登录",importKeyPlaceholder:"粘贴 nsec1... 私钥",importKeyError:"无效的私钥格式",like:"喜欢",liked:"已喜欢",loadMore:"加载更多",loading:"加载中...",noComments:"暂无评论,来说点什么吧",error:"出错了",retry:"重试",anonymous:"匿名用户",timeJustNow:"刚刚",timeMinutesAgo:"{{n}} 分钟前",timeHoursAgo:"{{n}} 小时前",timeDaysAgo:"{{n}} 天前"},Lo={comments:"留言",writeComment:"撰寫留言...",reply:"回覆",replyTo:"回覆給",publish:"發布",publishing:"發布中...",computing:"計算中...",cancel:"取消",login:"登入",logout:"登出",loginRequired:"請先登入",loginDescription:"選擇登入方式以發表留言",extensionLogin:"瀏覽器擴充功能",extensionLoginDesc:"使用 NIP-07 擴充功能登入(Alby、nos2x 等)",bunkerLogin:"Bunker 遠端簽署",bunkerLoginDesc:"使用 NIP-46 Bunker 進行遠端簽署",bunkerUrlPlaceholder:"輸入 bunker:// 網址",connect:"連線",connecting:"連線中...",tempAccount:"臨時帳號",tempAccountDesc:"建立臨時金鑰對",tempAccountCreated:"帳號建立成功!",createAccount:"建立帳號",copyKey:"複製私鑰(nsec)",keyCopied:"已複製!",downloadKey:"下載金鑰檔案",keyCompatibility:"這是標準的 Nostr 私鑰。您可以在任何 Nostr 客戶端使用,如 Jumble、Damus、Amethyst 等。",startCommenting:"開始留言",importKey:"匯入現有金鑰",importKeyDesc:"使用已儲存的 nsec 私鑰登入",importKeyPlaceholder:"貼上 nsec1... 私鑰",importKeyError:"私鑰格式無效",like:"讚",liked:"已按讚",loadMore:"載入更多",loading:"載入中...",noComments:"尚無留言。成為第一個留言的人吧!",error:"錯誤",retry:"重試",anonymous:"匿名",timeJustNow:"剛剛",timeMinutesAgo:"{{n}}分鐘前",timeHoursAgo:"{{n}}小時前",timeDaysAgo:"{{n}}天前"},Wa={comments:"コメント",writeComment:"コメントを書く...",reply:"返信",replyTo:"返信先",publish:"投稿",publishing:"投稿中...",computing:"計算中...",cancel:"キャンセル",login:"ログイン",logout:"ログアウト",loginRequired:"ログインしてください",loginDescription:"ログイン方法を選択してコメントを投稿",extensionLogin:"ブラウザ拡張機能",extensionLoginDesc:"NIP-07拡張機能でログイン(Alby、nos2xなど)",bunkerLogin:"Bunkerリモート署名",bunkerLoginDesc:"NIP-46 Bunkerでリモート署名",bunkerUrlPlaceholder:"bunker:// URLを入力",connect:"接続",connecting:"接続中...",tempAccount:"一時アカウント",tempAccountDesc:"一時的な鍵ペアを作成",tempAccountCreated:"アカウントが作成されました!",createAccount:"アカウント作成",copyKey:"秘密鍵をコピー(nsec)",keyCopied:"コピーしました!",downloadKey:"鍵ファイルをダウンロード",keyCompatibility:"これは標準的なNostr秘密鍵です。Jumble、Damus、Amethystなど、任意のNostrクライアントで使用できます。",startCommenting:"コメントを始める",importKey:"既存の鍵をインポート",importKeyDesc:"保存したnsec秘密鍵でログイン",importKeyPlaceholder:"nsec1...秘密鍵を貼り付け",importKeyError:"無効な秘密鍵形式",like:"いいね",liked:"いいね済み",loadMore:"もっと読み込む",loading:"読み込み中...",noComments:"まだコメントがありません。最初のコメントを投稿しましょう!",error:"エラー",retry:"再試行",anonymous:"匿名",timeJustNow:"たった今",timeMinutesAgo:"{{n}}分前",timeHoursAgo:"{{n}}時間前",timeDaysAgo:"{{n}}日前"},Za={comments:"댓글",writeComment:"댓글 작성...",reply:"답글",replyTo:"답글 대상",publish:"게시",publishing:"게시 중...",computing:"계산 중...",cancel:"취소",login:"로그인",logout:"로그아웃",loginRequired:"먼저 로그인해 주세요",loginDescription:"로그인 방법을 선택하여 댓글 작성",extensionLogin:"브라우저 확장 프로그램",extensionLoginDesc:"NIP-07 확장 프로그램으로 로그인 (Alby, nos2x 등)",bunkerLogin:"Bunker 원격 서명",bunkerLoginDesc:"NIP-46 Bunker로 원격 서명 사용",bunkerUrlPlaceholder:"bunker:// URL 입력",connect:"연결",connecting:"연결 중...",tempAccount:"임시 계정",tempAccountDesc:"임시 키 쌍 생성",tempAccountCreated:"계정이 생성되었습니다!",createAccount:"계정 생성",copyKey:"개인 키 복사 (nsec)",keyCopied:"복사됨!",downloadKey:"키 파일 다운로드",keyCompatibility:"이것은 표준 Nostr 개인 키입니다. Jumble, Damus, Amethyst 등 모든 Nostr 클라이언트에서 사용할 수 있습니다.",startCommenting:"댓글 작성 시작",importKey:"기존 키 가져오기",importKeyDesc:"저장된 nsec 개인 키로 로그인",importKeyPlaceholder:"nsec1... 개인 키 붙여넣기",importKeyError:"잘못된 개인 키 형식",like:"좋아요",liked:"좋아요 완료",loadMore:"더 보기",loading:"로딩 중...",noComments:"아직 댓글이 없습니다. 첫 번째 댓글을 작성해 보세요!",error:"오류",retry:"다시 시도",anonymous:"익명",timeJustNow:"방금",timeMinutesAgo:"{{n}}분 전",timeHoursAgo:"{{n}}시간 전",timeDaysAgo:"{{n}}일 전"},Ct={comments:"Comentarios",writeComment:"Escribe un comentario...",reply:"Responder",replyTo:"Responder a",publish:"Publicar",publishing:"Publicando...",computing:"Calculando...",cancel:"Cancelar",login:"Iniciar sesión",logout:"Cerrar sesión",loginRequired:"Por favor, inicia sesión primero",loginDescription:"Elige un método para iniciar sesión y publicar comentarios",extensionLogin:"Extensión del navegador",extensionLoginDesc:"Inicia sesión con extensión NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Firma remota Bunker",bunkerLoginDesc:"Usa NIP-46 Bunker para firma remota",bunkerUrlPlaceholder:"Introduce URL bunker://",connect:"Conectar",connecting:"Conectando...",tempAccount:"Cuenta temporal",tempAccountDesc:"Crear un par de claves temporal",tempAccountCreated:"¡Cuenta creada exitosamente!",createAccount:"Crear cuenta",copyKey:"Copiar clave privada (nsec)",keyCopied:"¡Copiado!",downloadKey:"Descargar archivo de clave",keyCompatibility:"Esta es una clave privada estándar de Nostr. Puedes usarla en cualquier cliente de Nostr como Jumble, Damus, Amethyst y más.",startCommenting:"Empezar a comentar",importKey:"Importar clave existente",importKeyDesc:"Inicia sesión con una clave privada nsec guardada",importKeyPlaceholder:"Pega la clave privada nsec1...",importKeyError:"Formato de clave privada inválido",like:"Me gusta",liked:"Te gusta",loadMore:"Cargar más",loading:"Cargando...",noComments:"Aún no hay comentarios. ¡Sé el primero en comentar!",error:"Error",retry:"Reintentar",anonymous:"Anónimo",timeJustNow:"ahora mismo",timeMinutesAgo:"hace {{n}}m",timeHoursAgo:"hace {{n}}h",timeDaysAgo:"hace {{n}}d"},qt={comments:"Commentaires",writeComment:"Écrire un commentaire...",reply:"Répondre",replyTo:"Répondre à",publish:"Publier",publishing:"Publication...",computing:"Calcul...",cancel:"Annuler",login:"Connexion",logout:"Déconnexion",loginRequired:"Veuillez d'abord vous connecter",loginDescription:"Choisissez une méthode pour vous connecter et publier des commentaires",extensionLogin:"Extension navigateur",extensionLoginDesc:"Connexion avec extension NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Signature distante Bunker",bunkerLoginDesc:"Utiliser NIP-46 Bunker pour la signature distante",bunkerUrlPlaceholder:"Entrez l'URL bunker://",connect:"Connecter",connecting:"Connexion...",tempAccount:"Compte temporaire",tempAccountDesc:"Créer une paire de clés temporaire",tempAccountCreated:"Compte créé avec succès !",createAccount:"Créer un compte",copyKey:"Copier la clé privée (nsec)",keyCopied:"Copié !",downloadKey:"Télécharger le fichier de clé",keyCompatibility:"Ceci est une clé privée Nostr standard. Vous pouvez l'utiliser dans n'importe quel client Nostr comme Jumble, Damus, Amethyst, etc.",startCommenting:"Commencer à commenter",importKey:"Importer une clé existante",importKeyDesc:"Connexion avec une clé privée nsec sauvegardée",importKeyPlaceholder:"Collez la clé privée nsec1...",importKeyError:"Format de clé privée invalide",like:"J'aime",liked:"Aimé",loadMore:"Charger plus",loading:"Chargement...",noComments:"Pas encore de commentaires. Soyez le premier à commenter !",error:"Erreur",retry:"Réessayer",anonymous:"Anonyme",timeJustNow:"à l'instant",timeMinutesAgo:"il y a {{n}}min",timeHoursAgo:"il y a {{n}}h",timeDaysAgo:"il y a {{n}}j"},Ln={comments:"Kommentare",writeComment:"Kommentar schreiben...",reply:"Antworten",replyTo:"Antworten auf",publish:"Veröffentlichen",publishing:"Veröffentliche...",computing:"Berechne...",cancel:"Abbrechen",login:"Anmelden",logout:"Abmelden",loginRequired:"Bitte melden Sie sich zuerst an",loginDescription:"Wählen Sie eine Methode zum Anmelden und Kommentieren",extensionLogin:"Browser-Erweiterung",extensionLoginDesc:"Mit NIP-07-Erweiterung anmelden (Alby, nos2x, etc.)",bunkerLogin:"Bunker-Fernsignatur",bunkerLoginDesc:"NIP-46 Bunker für Fernsignatur verwenden",bunkerUrlPlaceholder:"bunker:// URL eingeben",connect:"Verbinden",connecting:"Verbinde...",tempAccount:"Temporäres Konto",tempAccountDesc:"Temporäres Schlüsselpaar erstellen",tempAccountCreated:"Konto erfolgreich erstellt!",createAccount:"Konto erstellen",copyKey:"Privaten Schlüssel kopieren (nsec)",keyCopied:"Kopiert!",downloadKey:"Schlüsseldatei herunterladen",keyCompatibility:"Dies ist ein standardmäßiger Nostr-Privatschlüssel. Sie können ihn in jedem Nostr-Client wie Jumble, Damus, Amethyst und mehr verwenden.",startCommenting:"Mit dem Kommentieren beginnen",importKey:"Vorhandenen Schlüssel importieren",importKeyDesc:"Mit gespeichertem nsec-Privatschlüssel anmelden",importKeyPlaceholder:"nsec1... Privatschlüssel einfügen",importKeyError:"Ungültiges Privatschlüssel-Format",like:"Gefällt mir",liked:"Gefällt mir",loadMore:"Mehr laden",loading:"Lädt...",noComments:"Noch keine Kommentare. Seien Sie der Erste!",error:"Fehler",retry:"Erneut versuchen",anonymous:"Anonym",timeJustNow:"gerade eben",timeMinutesAgo:"vor {{n}}min",timeHoursAgo:"vor {{n}}h",timeDaysAgo:"vor {{n}}T"},Io={comments:"Comentários",writeComment:"Escreva um comentário...",reply:"Responder",replyTo:"Responder a",publish:"Publicar",publishing:"Publicando...",computing:"Calculando...",cancel:"Cancelar",login:"Entrar",logout:"Sair",loginRequired:"Por favor, faça login primeiro",loginDescription:"Escolha um método para entrar e publicar comentários",extensionLogin:"Extensão do navegador",extensionLoginDesc:"Entre com extensão NIP-07 (Alby, nos2x, etc.)",bunkerLogin:"Assinatura remota Bunker",bunkerLoginDesc:"Use NIP-46 Bunker para assinatura remota",bunkerUrlPlaceholder:"Digite a URL bunker://",connect:"Conectar",connecting:"Conectando...",tempAccount:"Conta temporária",tempAccountDesc:"Criar um par de chaves temporário",tempAccountCreated:"Conta criada com sucesso!",createAccount:"Criar conta",copyKey:"Copiar chave privada (nsec)",keyCopied:"Copiado!",downloadKey:"Baixar arquivo de chave",keyCompatibility:"Esta é uma chave privada Nostr padrão. Você pode usá-la em qualquer cliente Nostr como Jumble, Damus, Amethyst e mais.",startCommenting:"Começar a comentar",importKey:"Importar chave existente",importKeyDesc:"Entre com uma chave privada nsec salva",importKeyPlaceholder:"Cole a chave privada nsec1...",importKeyError:"Formato de chave privada inválido",like:"Curtir",liked:"Curtido",loadMore:"Carregar mais",loading:"Carregando...",noComments:"Ainda não há comentários. Seja o primeiro a comentar!",error:"Erro",retry:"Tentar novamente",anonymous:"Anônimo",timeJustNow:"agora mesmo",timeMinutesAgo:"há {{n}}min",timeHoursAgo:"há {{n}}h",timeDaysAgo:"há {{n}}d"},Ja={comments:"Комментарии",writeComment:"Написать комментарий...",reply:"Ответить",replyTo:"Ответить",publish:"Опубликовать",publishing:"Публикация...",computing:"Вычисление...",cancel:"Отмена",login:"Войти",logout:"Выйти",loginRequired:"Пожалуйста, сначала войдите",loginDescription:"Выберите способ входа для публикации комментариев",extensionLogin:"Расширение браузера",extensionLoginDesc:"Войти через NIP-07 расширение (Alby, nos2x и др.)",bunkerLogin:"Удалённая подпись Bunker",bunkerLoginDesc:"Использовать NIP-46 Bunker для удалённой подписи",bunkerUrlPlaceholder:"Введите URL bunker://",connect:"Подключить",connecting:"Подключение...",tempAccount:"Временный аккаунт",tempAccountDesc:"Создать временную пару ключей",tempAccountCreated:"Аккаунт успешно создан!",createAccount:"Создать аккаунт",copyKey:"Копировать приватный ключ (nsec)",keyCopied:"Скопировано!",downloadKey:"Скачать файл ключа",keyCompatibility:"Это стандартный приватный ключ Nostr. Вы можете использовать его в любом клиенте Nostr, таком как Jumble, Damus, Amethyst и других.",startCommenting:"Начать комментировать",importKey:"Импортировать существующий ключ",importKeyDesc:"Войти с сохранённым приватным ключом nsec",importKeyPlaceholder:"Вставьте приватный ключ nsec1...",importKeyError:"Неверный формат приватного ключа",like:"Нравится",liked:"Понравилось",loadMore:"Загрузить ещё",loading:"Загрузка...",noComments:"Пока нет комментариев. Будьте первым!",error:"Ошибка",retry:"Повторить",anonymous:"Аноним",timeJustNow:"только что",timeMinutesAgo:"{{n}} мин. назад",timeHoursAgo:"{{n}} ч. назад",timeDaysAgo:"{{n}} дн. назад"},In={comments:"التعليقات",writeComment:"اكتب تعليقاً...",reply:"رد",replyTo:"الرد على",publish:"نشر",publishing:"جارِ النشر...",computing:"جارِ الحساب...",cancel:"إلغاء",login:"تسجيل الدخول",logout:"تسجيل الخروج",loginRequired:"يرجى تسجيل الدخول أولاً",loginDescription:"اختر طريقة لتسجيل الدخول ونشر التعليقات",extensionLogin:"إضافة المتصفح",extensionLoginDesc:"تسجيل الدخول باستخدام إضافة NIP-07 (Alby، nos2x، إلخ)",bunkerLogin:"توقيع Bunker عن بُعد",bunkerLoginDesc:"استخدام NIP-46 Bunker للتوقيع عن بُعد",bunkerUrlPlaceholder:"أدخل رابط bunker://",connect:"اتصال",connecting:"جارِ الاتصال...",tempAccount:"حساب مؤقت",tempAccountDesc:"إنشاء زوج مفاتيح مؤقت",tempAccountCreated:"تم إنشاء الحساب بنجاح!",createAccount:"إنشاء حساب",copyKey:"نسخ المفتاح الخاص (nsec)",keyCopied:"تم النسخ!",downloadKey:"تحميل ملف المفتاح",keyCompatibility:"هذا مفتاح Nostr خاص قياسي. يمكنك استخدامه في أي عميل Nostr مثل Jumble وDamus وAmethyst وغيرها.",startCommenting:"ابدأ التعليق",importKey:"استيراد مفتاح موجود",importKeyDesc:"تسجيل الدخول بمفتاح nsec خاص محفوظ",importKeyPlaceholder:"الصق المفتاح الخاص nsec1...",importKeyError:"صيغة المفتاح الخاص غير صالحة",like:"إعجاب",liked:"أُعجبت",loadMore:"تحميل المزيد",loading:"جارِ التحميل...",noComments:"لا توجد تعليقات بعد. كن أول من يعلق!",error:"خطأ",retry:"إعادة المحاولة",anonymous:"مجهول",timeJustNow:"الآن",timeMinutesAgo:"منذ {{n}} دقيقة",timeHoursAgo:"منذ {{n}} ساعة",timeDaysAgo:"منذ {{n}} يوم"},Ga={comments:"Commenti",writeComment:"Scrivi un commento...",reply:"Rispondi",replyTo:"Rispondi a",publish:"Pubblica",publishing:"Pubblicazione...",computing:"Calcolo...",cancel:"Annulla",login:"Accedi",logout:"Esci",loginRequired:"Effettua prima l'accesso",loginDescription:"Scegli un metodo per accedere e pubblicare commenti",extensionLogin:"Estensione browser",extensionLoginDesc:"Accedi con estensione NIP-07 (Alby, nos2x, ecc.)",bunkerLogin:"Firma remota Bunker",bunkerLoginDesc:"Usa NIP-46 Bunker per la firma remota",bunkerUrlPlaceholder:"Inserisci URL bunker://",connect:"Connetti",connecting:"Connessione...",tempAccount:"Account temporaneo",tempAccountDesc:"Crea una coppia di chiavi temporanea",tempAccountCreated:"Account creato con successo!",createAccount:"Crea account",copyKey:"Copia chiave privata (nsec)",keyCopied:"Copiato!",downloadKey:"Scarica file chiave",keyCompatibility:"Questa è una chiave privata Nostr standard. Puoi usarla in qualsiasi client Nostr come Jumble, Damus, Amethyst e altri.",startCommenting:"Inizia a commentare",importKey:"Importa chiave esistente",importKeyDesc:"Accedi con una chiave privata nsec salvata",importKeyPlaceholder:"Incolla la chiave privata nsec1...",importKeyError:"Formato chiave privata non valido",like:"Mi piace",liked:"Piaciuto",loadMore:"Carica altri",loading:"Caricamento...",noComments:"Ancora nessun commento. Sii il primo a commentare!",error:"Errore",retry:"Riprova",anonymous:"Anonimo",timeJustNow:"proprio ora",timeMinutesAgo:"{{n}}min fa",timeHoursAgo:"{{n}}h fa",timeDaysAgo:"{{n}}g fa"},$o={comments:"Reacties",writeComment:"Schrijf een reactie...",reply:"Reageren",replyTo:"Reageren op",publish:"Publiceren",publishing:"Publiceren...",computing:"Berekenen...",cancel:"Annuleren",login:"Inloggen",logout:"Uitloggen",loginRequired:"Log eerst in",loginDescription:"Kies een methode om in te loggen en reacties te plaatsen",extensionLogin:"Browserextensie",extensionLoginDesc:"Inloggen met NIP-07 extensie (Alby, nos2x, etc.)",bunkerLogin:"Bunker externe ondertekening",bunkerLoginDesc:"Gebruik NIP-46 Bunker voor externe ondertekening",bunkerUrlPlaceholder:"Voer bunker:// URL in",connect:"Verbinden",connecting:"Verbinden...",tempAccount:"Tijdelijk account",tempAccountDesc:"Maak een tijdelijk sleutelpaar aan",tempAccountCreated:"Account succesvol aangemaakt!",createAccount:"Account aanmaken",copyKey:"Kopieer privésleutel (nsec)",keyCopied:"Gekopieerd!",downloadKey:"Download sleutelbestand",keyCompatibility:"Dit is een standaard Nostr privésleutel. Je kunt deze gebruiken in elke Nostr-client zoals Jumble, Damus, Amethyst en meer.",startCommenting:"Begin met reageren",importKey:"Bestaande sleutel importeren",importKeyDesc:"Log in met een opgeslagen nsec privésleutel",importKeyPlaceholder:"Plak nsec1... privésleutel",importKeyError:"Ongeldig privésleutel formaat",like:"Vind ik leuk",liked:"Leuk gevonden",loadMore:"Meer laden",loading:"Laden...",noComments:"Nog geen reacties. Wees de eerste om te reageren!",error:"Fout",retry:"Opnieuw proberen",anonymous:"Anoniem",timeJustNow:"zojuist",timeMinutesAgo:"{{n}}min geleden",timeHoursAgo:"{{n}}u geleden",timeDaysAgo:"{{n}}d geleden"},Ya={comments:"Komentarze",writeComment:"Napisz komentarz...",reply:"Odpowiedz",replyTo:"Odpowiedz do",publish:"Opublikuj",publishing:"Publikowanie...",computing:"Obliczanie...",cancel:"Anuluj",login:"Zaloguj się",logout:"Wyloguj się",loginRequired:"Najpierw się zaloguj",loginDescription:"Wybierz metodę logowania i publikowania komentarzy",extensionLogin:"Rozszerzenie przeglądarki",extensionLoginDesc:"Zaloguj się za pomocą rozszerzenia NIP-07 (Alby, nos2x, itp.)",bunkerLogin:"Zdalne podpisywanie Bunker",bunkerLoginDesc:"Użyj NIP-46 Bunker do zdalnego podpisywania",bunkerUrlPlaceholder:"Wprowadź URL bunker://",connect:"Połącz",connecting:"Łączenie...",tempAccount:"Tymczasowe konto",tempAccountDesc:"Utwórz tymczasową parę kluczy",tempAccountCreated:"Konto utworzone pomyślnie!",createAccount:"Utwórz konto",copyKey:"Kopiuj klucz prywatny (nsec)",keyCopied:"Skopiowano!",downloadKey:"Pobierz plik klucza",keyCompatibility:"To jest standardowy klucz prywatny Nostr. Możesz go używać w dowolnym kliencie Nostr, takim jak Jumble, Damus, Amethyst i innych.",startCommenting:"Zacznij komentować",importKey:"Importuj istniejący klucz",importKeyDesc:"Zaloguj się za pomocą zapisanego klucza prywatnego nsec",importKeyPlaceholder:"Wklej klucz prywatny nsec1...",importKeyError:"Nieprawidłowy format klucza prywatnego",like:"Lubię",liked:"Polubione",loadMore:"Załaduj więcej",loading:"Ładowanie...",noComments:"Brak komentarzy. Bądź pierwszy!",error:"Błąd",retry:"Ponów",anonymous:"Anonim",timeJustNow:"właśnie teraz",timeMinutesAgo:"{{n}} min temu",timeHoursAgo:"{{n}} godz. temu",timeDaysAgo:"{{n}} dni temu"},Xa={comments:"Yorumlar",writeComment:"Yorum yaz...",reply:"Yanıtla",replyTo:"Yanıtla",publish:"Yayınla",publishing:"Yayınlanıyor...",computing:"Hesaplanıyor...",cancel:"İptal",login:"Giriş yap",logout:"Çıkış yap",loginRequired:"Lütfen önce giriş yapın",loginDescription:"Giriş yapmak ve yorum yazmak için bir yöntem seçin",extensionLogin:"Tarayıcı eklentisi",extensionLoginDesc:"NIP-07 eklentisiyle giriş yapın (Alby, nos2x, vb.)",bunkerLogin:"Bunker uzaktan imzalama",bunkerLoginDesc:"Uzaktan imzalama için NIP-46 Bunker kullanın",bunkerUrlPlaceholder:"bunker:// URL'sini girin",connect:"Bağlan",connecting:"Bağlanıyor...",tempAccount:"Geçici hesap",tempAccountDesc:"Geçici anahtar çifti oluştur",tempAccountCreated:"Hesap başarıyla oluşturuldu!",createAccount:"Hesap oluştur",copyKey:"Özel anahtarı kopyala (nsec)",keyCopied:"Kopyalandı!",downloadKey:"Anahtar dosyasını indir",keyCompatibility:"Bu standart bir Nostr özel anahtarıdır. Jumble, Damus, Amethyst ve daha fazlası gibi herhangi bir Nostr istemcisinde kullanabilirsiniz.",startCommenting:"Yorum yapmaya başla",importKey:"Mevcut anahtarı içe aktar",importKeyDesc:"Kayıtlı nsec özel anahtarıyla giriş yapın",importKeyPlaceholder:"nsec1... özel anahtarını yapıştırın",importKeyError:"Geçersiz özel anahtar formatı",like:"Beğen",liked:"Beğenildi",loadMore:"Daha fazla yükle",loading:"Yükleniyor...",noComments:"Henüz yorum yok. İlk yorumu siz yapın!",error:"Hata",retry:"Tekrar dene",anonymous:"Anonim",timeJustNow:"az önce",timeMinutesAgo:"{{n}}dk önce",timeHoursAgo:"{{n}}sa önce",timeDaysAgo:"{{n}}g önce"},Qa={comments:"Bình luận",writeComment:"Viết bình luận...",reply:"Trả lời",replyTo:"Trả lời",publish:"Đăng",publishing:"Đang đăng...",computing:"Đang tính toán...",cancel:"Hủy",login:"Đăng nhập",logout:"Đăng xuất",loginRequired:"Vui lòng đăng nhập trước",loginDescription:"Chọn phương thức đăng nhập để đăng bình luận",extensionLogin:"Tiện ích trình duyệt",extensionLoginDesc:"Đăng nhập bằng tiện ích NIP-07 (Alby, nos2x, v.v.)",bunkerLogin:"Ký từ xa Bunker",bunkerLoginDesc:"Sử dụng NIP-46 Bunker để ký từ xa",bunkerUrlPlaceholder:"Nhập URL bunker://",connect:"Kết nối",connecting:"Đang kết nối...",tempAccount:"Tài khoản tạm thời",tempAccountDesc:"Tạo cặp khóa tạm thời",tempAccountCreated:"Tạo tài khoản thành công!",createAccount:"Tạo tài khoản",copyKey:"Sao chép khóa riêng (nsec)",keyCopied:"Đã sao chép!",downloadKey:"Tải file khóa",keyCompatibility:"Đây là khóa riêng Nostr tiêu chuẩn. Bạn có thể sử dụng nó trong bất kỳ ứng dụng Nostr nào như Jumble, Damus, Amethyst và nhiều hơn nữa.",startCommenting:"Bắt đầu bình luận",importKey:"Nhập khóa hiện có",importKeyDesc:"Đăng nhập bằng khóa riêng nsec đã lưu",importKeyPlaceholder:"Dán khóa riêng nsec1...",importKeyError:"Định dạng khóa riêng không hợp lệ",like:"Thích",liked:"Đã thích",loadMore:"Tải thêm",loading:"Đang tải...",noComments:"Chưa có bình luận. Hãy là người đầu tiên bình luận!",error:"Lỗi",retry:"Thử lại",anonymous:"Ẩn danh",timeJustNow:"vừa xong",timeMinutesAgo:"{{n}} phút trước",timeHoursAgo:"{{n}} giờ trước",timeDaysAgo:"{{n}} ngày trước"},ec={comments:"ความคิดเห็น",writeComment:"เขียนความคิดเห็น...",reply:"ตอบกลับ",replyTo:"ตอบกลับถึง",publish:"เผยแพร่",publishing:"กำลังเผยแพร่...",computing:"กำลังคำนวณ...",cancel:"ยกเลิก",login:"เข้าสู่ระบบ",logout:"ออกจากระบบ",loginRequired:"กรุณาเข้าสู่ระบบก่อน",loginDescription:"เลือกวิธีเข้าสู่ระบบเพื่อโพสต์ความคิดเห็น",extensionLogin:"ส่วนขยายเบราว์เซอร์",extensionLoginDesc:"เข้าสู่ระบบด้วยส่วนขยาย NIP-07 (Alby, nos2x ฯลฯ)",bunkerLogin:"ลงนามระยะไกล Bunker",bunkerLoginDesc:"ใช้ NIP-46 Bunker สำหรับการลงนามระยะไกล",bunkerUrlPlaceholder:"ใส่ URL bunker://",connect:"เชื่อมต่อ",connecting:"กำลังเชื่อมต่อ...",tempAccount:"บัญชีชั่วคราว",tempAccountDesc:"สร้างคู่คีย์ชั่วคราว",tempAccountCreated:"สร้างบัญชีสำเร็จ!",createAccount:"สร้างบัญชี",copyKey:"คัดลอกคีย์ส่วนตัว (nsec)",keyCopied:"คัดลอกแล้ว!",downloadKey:"ดาวน์โหลดไฟล์คีย์",keyCompatibility:"นี่คือคีย์ส่วนตัว Nostr มาตรฐาน คุณสามารถใช้งานได้ในไคลเอนต์ Nostr ใดก็ได้ เช่น Jumble, Damus, Amethyst และอื่นๆ",startCommenting:"เริ่มแสดงความคิดเห็น",importKey:"นำเข้าคีย์ที่มีอยู่",importKeyDesc:"เข้าสู่ระบบด้วยคีย์ส่วนตัว nsec ที่บันทึกไว้",importKeyPlaceholder:"วางคีย์ส่วนตัว nsec1...",importKeyError:"รูปแบบคีย์ส่วนตัวไม่ถูกต้อง",like:"ถูกใจ",liked:"ถูกใจแล้ว",loadMore:"โหลดเพิ่มเติม",loading:"กำลังโหลด...",noComments:"ยังไม่มีความคิดเห็น เป็นคนแรกที่แสดงความคิดเห็น!",error:"ข้อผิดพลาด",retry:"ลองอีกครั้ง",anonymous:"ไม่ระบุชื่อ",timeJustNow:"เมื่อกี้",timeMinutesAgo:"{{n}} นาทีที่แล้ว",timeHoursAgo:"{{n}} ชั่วโมงที่แล้ว",timeDaysAgo:"{{n}} วันที่แล้ว"},tc={comments:"Komentar",writeComment:"Tulis komentar...",reply:"Balas",replyTo:"Balas ke",publish:"Publikasikan",publishing:"Mempublikasikan...",computing:"Menghitung...",cancel:"Batal",login:"Masuk",logout:"Keluar",loginRequired:"Silakan masuk terlebih dahulu",loginDescription:"Pilih metode untuk masuk dan memposting komentar",extensionLogin:"Ekstensi browser",extensionLoginDesc:"Masuk dengan ekstensi NIP-07 (Alby, nos2x, dll.)",bunkerLogin:"Penandatanganan jarak jauh Bunker",bunkerLoginDesc:"Gunakan NIP-46 Bunker untuk penandatanganan jarak jauh",bunkerUrlPlaceholder:"Masukkan URL bunker://",connect:"Hubungkan",connecting:"Menghubungkan...",tempAccount:"Akun sementara",tempAccountDesc:"Buat pasangan kunci sementara",tempAccountCreated:"Akun berhasil dibuat!",createAccount:"Buat akun",copyKey:"Salin kunci privat (nsec)",keyCopied:"Tersalin!",downloadKey:"Unduh file kunci",keyCompatibility:"Ini adalah kunci privat Nostr standar. Anda dapat menggunakannya di klien Nostr mana pun seperti Jumble, Damus, Amethyst, dan lainnya.",startCommenting:"Mulai berkomentar",importKey:"Impor kunci yang ada",importKeyDesc:"Masuk dengan kunci privat nsec yang tersimpan",importKeyPlaceholder:"Tempel kunci privat nsec1...",importKeyError:"Format kunci privat tidak valid",like:"Suka",liked:"Disukai",loadMore:"Muat lebih banyak",loading:"Memuat...",noComments:"Belum ada komentar. Jadilah yang pertama berkomentar!",error:"Kesalahan",retry:"Coba lagi",anonymous:"Anonim",timeJustNow:"baru saja",timeMinutesAgo:"{{n}} menit yang lalu",timeHoursAgo:"{{n}} jam yang lalu",timeDaysAgo:"{{n}} hari yang lalu"},nc={comments:"टिप्पणियाँ",writeComment:"टिप्पणी लिखें...",reply:"जवाब दें",replyTo:"जवाब दें",publish:"प्रकाशित करें",publishing:"प्रकाशित हो रहा है...",computing:"गणना हो रही है...",cancel:"रद्द करें",login:"लॉग इन करें",logout:"लॉग आउट करें",loginRequired:"कृपया पहले लॉग इन करें",loginDescription:"लॉग इन करने और टिप्पणी पोस्ट करने के लिए एक विधि चुनें",extensionLogin:"ब्राउज़र एक्सटेंशन",extensionLoginDesc:"NIP-07 एक्सटेंशन से लॉग इन करें (Alby, nos2x, आदि)",bunkerLogin:"Bunker रिमोट साइनिंग",bunkerLoginDesc:"रिमोट साइनिंग के लिए NIP-46 Bunker का उपयोग करें",bunkerUrlPlaceholder:"bunker:// URL दर्ज करें",connect:"कनेक्ट करें",connecting:"कनेक्ट हो रहा है...",tempAccount:"अस्थायी खाता",tempAccountDesc:"अस्थायी की पेयर बनाएं",tempAccountCreated:"खाता सफलतापूर्वक बनाया गया!",createAccount:"खाता बनाएं",copyKey:"प्राइवेट की कॉपी करें (nsec)",keyCopied:"कॉपी हो गया!",downloadKey:"की फ़ाइल डाउनलोड करें",keyCompatibility:"यह एक मानक Nostr प्राइवेट की है। आप इसे किसी भी Nostr क्लाइंट जैसे Jumble, Damus, Amethyst और अन्य में उपयोग कर सकते हैं।",startCommenting:"टिप्पणी करना शुरू करें",importKey:"मौजूदा की इम्पोर्ट करें",importKeyDesc:"सेव की गई nsec प्राइवेट की से लॉग इन करें",importKeyPlaceholder:"nsec1... प्राइवेट की पेस्ट करें",importKeyError:"अमान्य प्राइवेट की फ़ॉर्मेट",like:"पसंद करें",liked:"पसंद किया",loadMore:"और लोड करें",loading:"लोड हो रहा है...",noComments:"अभी कोई टिप्पणी नहीं। पहले टिप्पणी करने वाले बनें!",error:"त्रुटि",retry:"पुनः प्रयास करें",anonymous:"अनाम",timeJustNow:"अभी",timeMinutesAgo:"{{n}} मिनट पहले",timeHoursAgo:"{{n}} घंटे पहले",timeDaysAgo:"{{n}} दिन पहले"},rc={comments:"Коментарі",writeComment:"Написати коментар...",reply:"Відповісти",replyTo:"Відповісти",publish:"Опублікувати",publishing:"Публікація...",computing:"Обчислення...",cancel:"Скасувати",login:"Увійти",logout:"Вийти",loginRequired:"Спочатку увійдіть",loginDescription:"Оберіть спосіб входу для публікації коментарів",extensionLogin:"Розширення браузера",extensionLoginDesc:"Увійти через розширення NIP-07 (Alby, nos2x тощо)",bunkerLogin:"Віддалений підпис Bunker",bunkerLoginDesc:"Використовувати NIP-46 Bunker для віддаленого підпису",bunkerUrlPlaceholder:"Введіть URL bunker://",connect:"Підключити",connecting:"Підключення...",tempAccount:"Тимчасовий акаунт",tempAccountDesc:"Створити тимчасову пару ключів",tempAccountCreated:"Акаунт успішно створено!",createAccount:"Створити акаунт",copyKey:"Копіювати приватний ключ (nsec)",keyCopied:"Скопійовано!",downloadKey:"Завантажити файл ключа",keyCompatibility:"Це стандартний приватний ключ Nostr. Ви можете використовувати його в будь-якому клієнті Nostr, такому як Jumble, Damus, Amethyst та інших.",startCommenting:"Почати коментувати",importKey:"Імпортувати існуючий ключ",importKeyDesc:"Увійти зі збереженим приватним ключем nsec",importKeyPlaceholder:"Вставте приватний ключ nsec1...",importKeyError:"Невірний формат приватного ключа",like:"Подобається",liked:"Сподобалось",loadMore:"Завантажити ще",loading:"Завантаження...",noComments:"Ще немає коментарів. Будьте першим!",error:"Помилка",retry:"Повторити",anonymous:"Анонім",timeJustNow:"щойно",timeMinutesAgo:"{{n}} хв. тому",timeHoursAgo:"{{n}} год. тому",timeDaysAgo:"{{n}} дн. тому"},$n={en:Nt,"en-US":Nt,"en-GB":Nt,"en-AU":Nt,"en-CA":Nt,"zh-CN":Bn,"zh-Hans":Bn,"zh-TW":Lo,"zh-Hant":Lo,"zh-HK":Lo,zh:Bn,ja:Wa,"ja-JP":Wa,ko:Za,"ko-KR":Za,es:Ct,"es-ES":Ct,"es-MX":Ct,"es-AR":Ct,"es-CO":Ct,"es-CL":Ct,fr:qt,"fr-FR":qt,"fr-CA":qt,"fr-BE":qt,"fr-CH":qt,de:Ln,"de-DE":Ln,"de-AT":Ln,"de-CH":Ln,pt:Io,"pt-BR":Io,"pt-PT":Io,ru:Ja,"ru-RU":Ja,ar:In,"ar-SA":In,"ar-EG":In,"ar-AE":In,it:Ga,"it-IT":Ga,nl:$o,"nl-NL":$o,"nl-BE":$o,pl:Ya,"pl-PL":Ya,tr:Xa,"tr-TR":Xa,vi:Qa,"vi-VN":Qa,th:ec,"th-TH":ec,id:tc,"id-ID":tc,hi:nc,"hi-IN":nc,uk:rc,"uk-UA":rc};function oc(){if(typeof navigator>"u")return"en";const t=navigator.languages||[navigator.language];for(const e of t){if($n[e])return e;const n=e.split("-")[0];if($n[n])return n}return"en"}function sc(t,e){const n=t||oc(),r=$n[n]||$n.en;return e?{...r,...e}:r}const ic=z.createContext(null);function ac({locale:t,translations:e,children:n}){const r=t||oc(),o=sc(r,e),s=i=>o[i]||i;return b.jsx(ic.Provider,{value:{locale:r,translations:o,t:s},children:n})}function et(){const t=z.useContext(ic);if(!t){const e=sc();return{locale:"en",translations:e,t:n=>e[n]||n}}return t}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function cc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function lc(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function Tm(t){if(typeof t!="function")throw new Error("function expected");return!0}function Vt(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function uc(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function To(t){if(!Array.isArray(t))throw new Error("array expected")}function dc(t,e){if(!lc(!0,e))throw new Error(`${t}: array of strings expected`)}function hc(t,e){if(!lc(!1,e))throw new Error(`${t}: array of numbers expected`)}function Pm(...t){const e=s=>s,n=(s,i)=>a=>s(i(a)),r=t.map(s=>s.encode).reduceRight(n,e),o=t.map(s=>s.decode).reduce(n,e);return{encode:r,decode:o}}function Um(t){const e=typeof t=="string"?t.split(""):t,n=e.length;dc("alphabet",e);const r=new Map(e.map((o,s)=>[o,s]));return{encode:o=>(To(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);return e[s]})),decode:o=>(To(o),o.map(s=>{Vt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);return i}))}}function Om(t=""){return Vt("join",t),{encode:e=>(dc("join.decode",e),e.join(t)),decode:e=>(Vt("join.decode",e),e.split(t))}}const fc=(t,e)=>e===0?t:fc(e,t%e),Tn=(t,e)=>t+(e-fc(t,e)),Pn=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Po(t,e,n,r){if(To(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Tn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Tn(e,n)}`);let o=0,s=0;const i=Pn[e],a=Pn[n]-1,c=[];for(const l of t){if(uc(l),l>=i)throw new Error(`convertRadix2: invalid data word=${l} from=${e}`);if(o=o<<e|l,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);const d=Pn[s];if(d===void 0)throw new Error("invalid carry");o&=d-1}if(o=o<<n-s&a,!r&&s>=e)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&c.push(o>>>0),c}function Rm(t,e=!1){if(uc(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Tn(8,t)>32||Tn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!cc(n))throw new Error("radix2.encode input should be Uint8Array");return Po(Array.from(n),8,t,!e)},decode:n=>(hc("radix2.decode",n),Uint8Array.from(Po(n,t,8,e)))}}function pc(t){return Tm(t),function(...e){try{return t.apply(null,e)}catch{}}}const Uo=Pm(Um("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Om("")),mc=[996825010,642813549,513874426,1027748829,705979059];function jt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<mc.length;r++)(e>>r&1)===1&&(n^=mc[r]);return n}function gc(t,e,n=1){const r=t.length;let o=1;for(let s=0;s<r;s++){const i=t.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${t})`);o=jt(o)^i>>5}o=jt(o);for(let s=0;s<r;s++)o=jt(o)^t.charCodeAt(s)&31;for(let s of e)o=jt(o)^s;for(let s=0;s<6;s++)o=jt(o);return o^=n,Uo.encode(Po([o%Pn[30]],30,5,!1))}function Mm(t){const e=t==="bech32"?1:734539939,n=Rm(5),r=n.decode,o=n.encode,s=pc(r);function i(u,p,f=90){Vt("bech32.encode prefix",u),cc(p)&&(p=Array.from(p)),hc("bech32.encode",p);const m=u.length;if(m===0)throw new TypeError(`Invalid prefix length ${m}`);const h=m+7+p.length;if(f!==!1&&h>f)throw new TypeError(`Length ${h} exceeds limit ${f}`);const y=u.toLowerCase(),v=gc(y,p,e);return`${y}1${Uo.encode(p)}${v}`}function a(u,p=90){Vt("bech32.decode input",u);const f=u.length;if(f<8||p!==!1&&f>p)throw new TypeError(`invalid string length: ${f} (${u}). Expected (8..${p})`);const m=u.toLowerCase();if(u!==m&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");const h=m.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const y=m.slice(0,h),v=m.slice(h+1);if(v.length<6)throw new Error("Data must be at least 6 characters long");const x=Uo.decode(v).slice(0,-6),S=gc(y,x,e);if(!v.endsWith(S))throw new Error(`Invalid checksum in ${u}: expected "${S}"`);return{prefix:y,words:x}}const c=pc(a);function l(u){const{prefix:p,words:f}=a(u,!1);return{prefix:p,words:f,bytes:r(f)}}function d(u,p){return i(u,o(p))}return{encode:i,decode:a,encodeFromBytes:d,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const Un=Mm("bech32"),yc=5e3;function bc(t){var o,s,i,a,c,l,d;let{prefix:e,words:n}=Un.decode(t,yc),r=new Uint8Array(Un.fromWords(n));switch(e){case"nprofile":{let u=Oo(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:ce(u[0][0]),relays:u[1]?u[1].map(p=>Sn.decode(p)):[]}}}case"nevent":{let u=Oo(r);if(!((s=u[0])!=null&&s[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(u[3]&&u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:ce(u[0][0]),relays:u[1]?u[1].map(p=>Sn.decode(p)):[],author:(i=u[2])!=null&&i[0]?ce(u[2][0]):void 0,kind:(a=u[3])!=null&&a[0]?parseInt(ce(u[3][0]),16):void 0}}}case"naddr":{let u=Oo(r);if(!((c=u[0])!=null&&c[0]))throw new Error("missing TLV 0 for naddr");if(!((l=u[2])!=null&&l[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((d=u[3])!=null&&d[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Sn.decode(u[0][0]),pubkey:ce(u[2][0]),kind:parseInt(ce(u[3][0]),16),relays:u[1]?u[1].map(p=>Sn.decode(p)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:ce(r)};default:throw new Error(`unknown prefix ${e}`)}}function Oo(t){let e={},n=t;for(;n.length>0;){let r=n[0],o=n[1],s=n.slice(2,2+o);if(n=n.slice(2+o),s.length<o)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(s)}return e}function wc(t){return Km("npub",lt(t))}function Dm(t,e){let n=Un.toWords(e);return Un.encode(t,n,yc)}function Km(t,e){return Dm(t,e)}let vc=0;function On(t){let e,n;if(t.startsWith("npub1")){let{data:r}=bc(t);n=r,e=t}else if(t.startsWith("nprofile")){let{data:r}=bc(t);n=r.pubkey,e=wc(n)}else n=t,e=wc(t);return{pubkey:n,npub:e,shortName:e.substring(0,8)+"…"+e.substring(59),metadata:{},lastUpdated:0}}const Rn=vo("@nostr/gadgets/metadata","cache");async function Hm(t){return typeof t=="string"?Mn.load({pubkey:t}):t.refreshStyle===null?(await Da(t.pubkey,Rn),Mn._cacheMap.delete(t.pubkey),On(t.pubkey)):(t.refreshStyle&&Mn.clear(t),Mn.load(t))}const Mn=new Ua(async t=>new Promise(async e=>{const n=[];let r=Math.round(Date.now()/1e3),o=await Ma(t.map(i=>i.pubkey),Rn).then(i=>i.map((a,c)=>{const l=t[c];if(typeof l.refreshStyle=="object"){let d=On(l.pubkey);return Ec(d,l.refreshStyle),Oa(l.pubkey,d,Rn),d}else{if(a)return l.refreshStyle===!0||a.lastAttempt<r-3600*24*2?(l.refreshStyle!==!1&&n.push(l),a.lastAttempt=r,a):(a.lastAttempt<r-3600&&!a.metadata.name&&!a.metadata.picture&&!a.metadata.about&&(l.refreshStyle!==!1&&n.push(l),a.lastAttempt=Math.round(Date.now()/1e3)),a);{l.refreshStyle!==!1&&n.push(l);let d=On(l.pubkey);return d.lastAttempt=r,d}}}));if(n.length===0){e(o);return}const s={};await Promise.all(n.map(async({pubkey:i,relays:a=[]})=>{const c=new Set(a.slice(0,3));try{const{items:l}=await ko(i);let d=0;for(let u=0;u<l.length&&!(l[u].write&&(c.add(l[u].url),d++,d>=2));u++);}catch(l){console.error("Failed to load relay list for",i,l)}do c.add(xo[vc%xo.length]),vc++;while(c.size<2);for(let l of c)s[l]?s[l].push(i):s[l]=[i]}));try{const i=Object.entries(s).map(([c,l])=>({url:c,filter:{kinds:[0],authors:l}}));let a=Ht.subscribeMap(i,{label:`metadata(${t.length})`,onevent(c){for(let l=0;l<t.length;l++)if(t[l].pubkey===c.pubkey){const d=o[l];if(d.lastUpdated>c.created_at)return;Ec(d,c);return}},oneose(){e(o),a.close();let c=[];for(let l=0;l<o.length;l++){let d=o[l];d.pubkey&&c.push([d.pubkey,d])}Ra(c,Rn)}})}catch(i){for(let a=0;a<o.length;a++)o[a]=i;e(o)}}),{cacheKeyFn:t=>t.pubkey});function Ec(t,e){var r,o;let n={};try{n=JSON.parse(e.content)}catch{}t.metadata=n,t.shortName=n.name||n.display_name||((o=(r=n.nip05)==null?void 0:r.split("@"))==null?void 0:o[0])||t.shortName,t.lastUpdated=e.created_at,n.picture&&(t.image=n.picture)}function Ro(t){const[e,n]=z.useState(()=>On(t));return z.useEffect(()=>{Hm(t).then(n)},[t]),{profile:e}}const xc=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffc107","#ff9800","#ff5722","#795548"];function kc(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e),e=e&e;return xc[Math.abs(e)%xc.length]}function _c(t,e=40){const n=kc(t),r=t.slice(0,2).toUpperCase();return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 ${e} ${e}">
9
67
  <rect width="${e}" height="${e}" fill="${n}" rx="${e/5}"/>
10
68
  <text x="50%" y="50%" fill="white" font-family="system-ui, sans-serif" font-size="${e*.4}" font-weight="600" text-anchor="middle" dominant-baseline="central">${r}</text>
11
- </svg>`}function Oo(t,e=40){const n=Ac(t,e);return`data:image/svg+xml,${encodeURIComponent(n)}`}function Hn({pubkey:t,size:e=32,className:n=""}){const{profile:r}=Uo(t),o=r.image||Oo(t,e),i=`https://jumble.social/users/${wt.npubEncode(t)}`;return b.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:`nc-avatar-link ${n}`,children:b.jsx("img",{src:o,alt:"",width:e,height:e,className:"nc-avatar",style:{height:"fit-content"},onError:a=>{const c=a.target;c.src=Oo(t,e)}})})}function Ft({pubkey:t,className:e=""}){const{profile:n}=Uo(t),o=`https://jumble.social/users/${wt.npubEncode(t)}`;return b.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:`nc-username ${e}`,title:t,children:n.shortName})}function Sc({url:t,relays:e,authorPubkeys:n,parentEvent:r,onClearParent:o,onPublished:s,onLoginRequired:i,onError:a,className:c=""}){const{signer:l,signerInfo:d,isLoggedIn:u}=kt(),{t:p}=et(),[f,m]=z.useState(""),[h,y]=z.useState(!1),v=async S=>{if(S.preventDefault(),!!f.trim()){if(!u||!l){i();return}y(!0);try{let U;r?U=await Fa(l,{url:t,content:f.trim(),parentEvent:r,relays:e,authorPubkeys:n}):U=await ja(l,{url:t,content:f.trim(),relays:e,authorPubkeys:n}),m(""),o==null||o(),s==null||s(U)}catch(U){a==null||a(U instanceof Error?U:new Error("Failed to publish"))}finally{y(!1)}}},x=()=>{u||i()};return b.jsxs("form",{onSubmit:v,className:`nc-editor ${c}`,children:[r&&b.jsxs("div",{className:"nc-editor__reply-to",children:[b.jsx("span",{className:"nc-editor__reply-to-label",children:p("replyTo")}),b.jsx(Ft,{pubkey:r.pubkey,className:"nc-editor__reply-to-author"}),b.jsx("span",{className:"nc-editor__reply-to-content",children:r.content}),b.jsx("button",{type:"button",onClick:o,className:"nc-editor__cancel-reply",children:p("cancel")})]}),b.jsxs("div",{className:"nc-editor__main",children:[u&&d&&b.jsx(Hn,{pubkey:d.pubkey,size:40}),b.jsxs("div",{className:"nc-editor__input-wrapper",children:[b.jsx("textarea",{value:f,onInput:S=>m(S.target.value),onFocus:x,placeholder:p("writeComment"),className:"nc-editor__textarea",rows:3}),b.jsx("div",{className:"nc-editor__actions",children:b.jsx("button",{type:"submit",disabled:!f.trim()||h||!u,className:"nc-editor__submit",children:p(h?"publishing":"publish")})})]})]})]})}function Dm(t,e,n){const r=new Date(t*1e3),s=new Date().getTime()-r.getTime(),i=Math.floor(s/6e4),a=Math.floor(s/36e5),c=Math.floor(s/864e5);return i<1?e("timeJustNow"):i<60?e("timeMinutesAgo").replace("{{n}}",String(i)):a<24?e("timeHoursAgo").replace("{{n}}",String(a)):c<30?e("timeDaysAgo").replace("{{n}}",String(c)):r.toLocaleDateString(n,{year:"numeric",month:"short",day:"numeric"})}function Ro({comment:t,relays:e,onReply:n,onLoginRequired:r,currentPubkey:o,className:s="",isChild:i=!1}){const{event:a,children:c,replyTo:l}=t,{t:d,locale:u}=et(),p=!i&&c.length>0;return b.jsxs("div",{className:`nc-comment ${s}`,children:[b.jsxs("div",{className:"nc-comment__main",children:[b.jsx(Hn,{pubkey:a.pubkey,size:i?28:40}),b.jsxs("div",{className:"nc-comment__content",children:[b.jsx("div",{className:"nc-comment__header",children:b.jsx(Ft,{pubkey:a.pubkey,className:"nc-comment__author"})}),l&&b.jsxs("div",{className:"nc-comment__reply-preview",children:[b.jsx(Ft,{pubkey:l.pubkey,className:"nc-comment__reply-preview-author"}),b.jsx("span",{className:"nc-comment__reply-preview-text",children:l.content.replace(/\n/g," ")})]}),b.jsx("p",{className:"nc-comment__text",children:a.content}),b.jsxs("div",{className:"nc-comment__actions",children:[b.jsx("span",{className:"nc-comment__time",children:Dm(a.created_at,d,u)}),b.jsx("button",{type:"button",className:"nc-comment__reply-btn",onClick:()=>n(a),children:d("reply")})]})]}),p&&b.jsx("div",{className:"nc-comment__vline"})]}),p&&b.jsx("div",{className:"nc-comment__children",children:c.map((f,m)=>b.jsxs("div",{className:`nc-comment__child-wrapper ${m<c.length-1?"nc-comment__child-wrapper--continue":""}`,children:[b.jsx("div",{className:"nc-comment__connector"}),m<c.length-1&&b.jsx("div",{className:"nc-comment__connector-line"}),b.jsx(Ro,{comment:f,relays:e,onReply:n,onLoginRequired:r,currentPubkey:o,isChild:!0})]},f.event.id))})]})}function Nc({comments:t,loading:e,loadingMore:n,hasMore:r,error:o,relays:s,onReply:i,onLoginRequired:a,onLoadMore:c,onRetry:l,currentPubkey:d,className:u=""}){const{t:p}=et();return e?b.jsx("div",{className:`nc-list nc-list--loading ${u}`,children:b.jsxs("div",{className:"nc-loading",children:[b.jsx("div",{className:"nc-loading__spinner"}),b.jsx("span",{children:p("loading")})]})}):o?b.jsx("div",{className:`nc-list nc-list--error ${u}`,children:b.jsxs("div",{className:"nc-error",children:[b.jsxs("span",{children:[p("error"),": ",o]}),b.jsx("button",{type:"button",onClick:l,className:"nc-error__retry",children:p("retry")})]})}):t.length===0?b.jsx("div",{className:`nc-list nc-list--empty ${u}`,children:b.jsx("p",{className:"nc-empty",children:p("noComments")})}):b.jsxs("div",{className:`nc-list ${u}`,children:[t.map(f=>b.jsx(Ro,{comment:f,relays:s,onReply:i,onLoginRequired:a,currentPubkey:d},f.event.id)),r&&b.jsx("button",{type:"button",onClick:c,disabled:n,className:"nc-load-more",children:p(n?"loading":"loadMore")})]})}/**
69
+ </svg>`}function Mo(t,e=40){const n=_c(t,e);return`data:image/svg+xml,${encodeURIComponent(n)}`}function Dn({pubkey:t,size:e=32,className:n=""}){const{profile:r}=Ro(t),o=r.image||Mo(t,e),i=`https://jumble.social/users/${wt.npubEncode(t)}`;return b.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:`nc-avatar-link ${n}`,children:b.jsx("img",{src:o,alt:"",width:e,height:e,className:"nc-avatar",style:{height:"fit-content"},onError:a=>{const c=a.target;c.src=Mo(t,e)}})})}function Ft({pubkey:t,className:e=""}){const{profile:n}=Ro(t),o=`https://jumble.social/users/${wt.npubEncode(t)}`;return b.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:`nc-username ${e}`,title:t,children:n.shortName})}function Ac({url:t,relays:e,mention:n,pow:r,parentEvent:o,onClearParent:s,onPublished:i,onLoginRequired:a,onError:c,className:l=""}){const{signer:d,signerInfo:u,isLoggedIn:p}=kt(),{t:f}=et(),[m,h]=z.useState(""),[y,v]=z.useState(!1),x=async M=>{if(M.preventDefault(),!!m.trim()){if(!p||!d){a();return}v(!0);try{const R=await ja(d,{url:t,content:m.trim(),parentEvent:o,relays:e,mention:n,pow:r});h(""),s==null||s(),i==null||i(R)}catch(R){c==null||c(R instanceof Error?R:new Error("Failed to publish"))}finally{v(!1)}}},S=()=>{p||a()};return b.jsxs("form",{onSubmit:x,className:`nc-editor ${l}`,children:[o&&b.jsxs("div",{className:"nc-editor__reply-to",children:[b.jsx("span",{className:"nc-editor__reply-to-label",children:f("replyTo")}),b.jsx(Ft,{pubkey:o.pubkey,className:"nc-editor__reply-to-author"}),b.jsx("span",{className:"nc-editor__reply-to-content",children:o.content}),b.jsx("button",{type:"button",onClick:s,className:"nc-editor__cancel-reply",children:f("cancel")})]}),b.jsxs("div",{className:"nc-editor__main",children:[p&&u&&b.jsx(Dn,{pubkey:u.pubkey,size:40}),b.jsxs("div",{className:"nc-editor__input-wrapper",children:[b.jsx("textarea",{value:m,onInput:M=>h(M.target.value),onFocus:S,placeholder:f("writeComment"),className:"nc-editor__textarea",rows:3,disabled:y}),b.jsx("div",{className:"nc-editor__actions",children:b.jsx("button",{type:"submit",disabled:!m.trim()||y||!p,className:"nc-editor__submit",children:f(y?r?"computing":"publishing":"publish")})})]})]})]})}function zm(t,e,n){const r=new Date(t*1e3),s=new Date().getTime()-r.getTime(),i=Math.floor(s/6e4),a=Math.floor(s/36e5),c=Math.floor(s/864e5);return i<1?e("timeJustNow"):i<60?e("timeMinutesAgo").replace("{{n}}",String(i)):a<24?e("timeHoursAgo").replace("{{n}}",String(a)):c<30?e("timeDaysAgo").replace("{{n}}",String(c)):r.toLocaleDateString(n,{year:"numeric",month:"short",day:"numeric"})}function Do({comment:t,relays:e,onReply:n,onLoginRequired:r,currentPubkey:o,className:s="",isChild:i=!1}){const{event:a,children:c,replyTo:l}=t,{t:d,locale:u}=et(),p=!i&&c.length>0;return b.jsxs("div",{className:`nc-comment ${s}`,children:[b.jsxs("div",{className:"nc-comment__main",children:[b.jsx(Dn,{pubkey:a.pubkey,size:i?28:40}),b.jsxs("div",{className:"nc-comment__content",children:[b.jsx("div",{className:"nc-comment__header",children:b.jsx(Ft,{pubkey:a.pubkey,className:"nc-comment__author"})}),l&&b.jsxs("div",{className:"nc-comment__reply-preview",children:[b.jsx(Ft,{pubkey:l.pubkey,className:"nc-comment__reply-preview-author"}),b.jsx("span",{className:"nc-comment__reply-preview-text",children:l.content.replace(/\n/g," ")})]}),b.jsx("p",{className:"nc-comment__text",children:a.content}),b.jsxs("div",{className:"nc-comment__actions",children:[b.jsx("span",{className:"nc-comment__time",children:zm(a.created_at,d,u)}),b.jsx("button",{type:"button",className:"nc-comment__reply-btn",onClick:()=>n(a),children:d("reply")})]})]}),p&&b.jsx("div",{className:"nc-comment__vline"})]}),p&&b.jsx("div",{className:"nc-comment__children",children:c.map((f,m)=>b.jsxs("div",{className:`nc-comment__child-wrapper ${m<c.length-1?"nc-comment__child-wrapper--continue":""}`,children:[b.jsx("div",{className:"nc-comment__connector"}),m<c.length-1&&b.jsx("div",{className:"nc-comment__connector-line"}),b.jsx(Do,{comment:f,relays:e,onReply:n,onLoginRequired:r,currentPubkey:o,isChild:!0})]},f.event.id))})]})}function Sc({comments:t,loading:e,loadingMore:n,hasMore:r,error:o,relays:s,onReply:i,onLoginRequired:a,onLoadMore:c,onRetry:l,currentPubkey:d,className:u=""}){const{t:p}=et();return e?b.jsx("div",{className:`nc-list nc-list--loading ${u}`,children:b.jsxs("div",{className:"nc-loading",children:[b.jsx("div",{className:"nc-loading__spinner"}),b.jsx("span",{children:p("loading")})]})}):o?b.jsx("div",{className:`nc-list nc-list--error ${u}`,children:b.jsxs("div",{className:"nc-error",children:[b.jsxs("span",{children:[p("error"),": ",o]}),b.jsx("button",{type:"button",onClick:l,className:"nc-error__retry",children:p("retry")})]})}):t.length===0?b.jsx("div",{className:`nc-list nc-list--empty ${u}`,children:b.jsx("p",{className:"nc-empty",children:p("noComments")})}):b.jsxs("div",{className:`nc-list ${u}`,children:[t.map(f=>b.jsx(Do,{comment:f,relays:s,onReply:i,onLoginRequired:a,currentPubkey:d},f.event.id)),r&&b.jsx("button",{type:"button",onClick:c,disabled:n,className:"nc-load-more",children:p(n?"loading":"loadMore")})]})}/**
12
70
  * @license lucide-react v0.563.0 - ISC
13
71
  *
14
72
  * This source code is licensed under the ISC license.
15
73
  * See the LICENSE file in the root directory of this source tree.
16
- */const Cc=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/**
74
+ */const Nc=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/**
17
75
  * @license lucide-react v0.563.0 - ISC
18
76
  *
19
77
  * This source code is licensed under the ISC license.
20
78
  * See the LICENSE file in the root directory of this source tree.
21
- */const Mm=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
79
+ */const qm=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
22
80
  * @license lucide-react v0.563.0 - ISC
23
81
  *
24
82
  * This source code is licensed under the ISC license.
25
83
  * See the LICENSE file in the root directory of this source tree.
26
- */const Km=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
84
+ */const Vm=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
27
85
  * @license lucide-react v0.563.0 - ISC
28
86
  *
29
87
  * This source code is licensed under the ISC license.
30
88
  * See the LICENSE file in the root directory of this source tree.
31
- */const Bc=t=>{const e=Km(t);return e.charAt(0).toUpperCase()+e.slice(1)};/**
89
+ */const Cc=t=>{const e=Vm(t);return e.charAt(0).toUpperCase()+e.slice(1)};/**
32
90
  * @license lucide-react v0.563.0 - ISC
33
91
  *
34
92
  * This source code is licensed under the ISC license.
35
93
  * See the LICENSE file in the root directory of this source tree.
36
- */var Hm={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
94
+ */var jm={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
37
95
  * @license lucide-react v0.563.0 - ISC
38
96
  *
39
97
  * This source code is licensed under the ISC license.
40
98
  * See the LICENSE file in the root directory of this source tree.
41
- */const zm=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};/**
99
+ */const Fm=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};/**
42
100
  * @license lucide-react v0.563.0 - ISC
43
101
  *
44
102
  * This source code is licensed under the ISC license.
45
103
  * See the LICENSE file in the root directory of this source tree.
46
- */const qm=z.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},c)=>z.createElement("svg",{ref:c,...Hm,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Cc("lucide",o),...!s&&!zm(a)&&{"aria-hidden":"true"},...a},[...i.map(([l,d])=>z.createElement(l,d)),...Array.isArray(s)?s:[s]]));/**
104
+ */const Wm=z.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},c)=>z.createElement("svg",{ref:c,...jm,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Nc("lucide",o),...!s&&!Fm(a)&&{"aria-hidden":"true"},...a},[...i.map(([l,d])=>z.createElement(l,d)),...Array.isArray(s)?s:[s]]));/**
47
105
  * @license lucide-react v0.563.0 - ISC
48
106
  *
49
107
  * This source code is licensed under the ISC license.
50
108
  * See the LICENSE file in the root directory of this source tree.
51
- */const Ke=(t,e)=>{const n=z.forwardRef(({className:r,...o},s)=>z.createElement(qm,{ref:s,iconNode:e,className:Cc(`lucide-${Mm(Bc(t))}`,`lucide-${t}`,r),...o}));return n.displayName=Bc(t),n};/**
109
+ */const Ke=(t,e)=>{const n=z.forwardRef(({className:r,...o},s)=>z.createElement(Wm,{ref:s,iconNode:e,className:Nc(`lucide-${qm(Cc(t))}`,`lucide-${t}`,r),...o}));return n.displayName=Cc(t),n};/**
52
110
  * @license lucide-react v0.563.0 - ISC
53
111
  *
54
112
  * This source code is licensed under the ISC license.
55
113
  * See the LICENSE file in the root directory of this source tree.
56
- */const zn=Ke("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
114
+ */const Kn=Ke("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
57
115
  * @license lucide-react v0.563.0 - ISC
58
116
  *
59
117
  * This source code is licensed under the ISC license.
60
118
  * See the LICENSE file in the root directory of this source tree.
61
- */const Vm=Ke("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
119
+ */const Zm=Ke("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
62
120
  * @license lucide-react v0.563.0 - ISC
63
121
  *
64
122
  * This source code is licensed under the ISC license.
65
123
  * See the LICENSE file in the root directory of this source tree.
66
- */const Lc=Ke("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
124
+ */const Bc=Ke("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
67
125
  * @license lucide-react v0.563.0 - ISC
68
126
  *
69
127
  * This source code is licensed under the ISC license.
70
128
  * See the LICENSE file in the root directory of this source tree.
71
- */const Ic=Ke("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
129
+ */const Lc=Ke("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
72
130
  * @license lucide-react v0.563.0 - ISC
73
131
  *
74
132
  * This source code is licensed under the ISC license.
75
133
  * See the LICENSE file in the root directory of this source tree.
76
- */const jm=Ke("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
134
+ */const Jm=Ke("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
77
135
  * @license lucide-react v0.563.0 - ISC
78
136
  *
79
137
  * This source code is licensed under the ISC license.
80
138
  * See the LICENSE file in the root directory of this source tree.
81
- */const $c=Ke("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
139
+ */const Ic=Ke("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
82
140
  * @license lucide-react v0.563.0 - ISC
83
141
  *
84
142
  * This source code is licensed under the ISC license.
85
143
  * See the LICENSE file in the root directory of this source tree.
86
- */const Fm=Ke("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
144
+ */const Gm=Ke("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
87
145
  * @license lucide-react v0.563.0 - ISC
88
146
  *
89
147
  * This source code is licensed under the ISC license.
90
148
  * See the LICENSE file in the root directory of this source tree.
91
- */const Tc=Ke("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);/**
149
+ */const $c=Ke("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);/**
92
150
  * @license lucide-react v0.563.0 - ISC
93
151
  *
94
152
  * This source code is licensed under the ISC license.
95
153
  * See the LICENSE file in the root directory of this source tree.
96
- */const Wm=Ke("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Zm({onSuccess:t}){const{loginWithNip07:e,loading:n,error:r,isNip07Available:o}=kt(),{t:s}=et(),i=async()=>{await e(),t()};return o?b.jsxs("button",{type:"button",onClick:i,disabled:n,className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx($c,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:s("extensionLogin")}),b.jsx("p",{children:s("extensionLoginDesc")}),r&&b.jsx("p",{className:"nc-login-option__error",children:r})]})]}):b.jsxs("div",{className:"nc-login-option nc-login-option--disabled",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx($c,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:s("extensionLogin")}),b.jsx("p",{children:s("extensionLoginDesc")}),b.jsx("p",{className:"nc-login-option__hint",children:"No extension detected"})]})]})}function Jm({onSuccess:t}){const{loginWithBunker:e,loading:n,error:r}=kt(),{t:o}=et(),[s,i]=z.useState(""),a=async c=>{c.preventDefault(),s.trim()&&(await e(s.trim()),r||t())};return b.jsxs("div",{className:"nc-login-option nc-login-option--bunker",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(jm,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:o("bunkerLogin")}),b.jsx("p",{children:o("bunkerLoginDesc")}),b.jsxs("form",{onSubmit:a,className:"nc-bunker-form",children:[b.jsx("input",{type:"text",value:s,onInput:c=>i(c.target.value),placeholder:o("bunkerUrlPlaceholder"),className:"nc-bunker-form__input"}),b.jsx("button",{type:"submit",disabled:n||!s.trim(),className:"nc-bunker-form__submit",children:o(n?"connecting":"connect")})]}),r&&b.jsx("p",{className:"nc-login-option__error",children:r})]})]})}function Pc({isOpen:t,onClose:e,enabledSigners:n=["nip07","bunker","temp"],className:r=""}){const{isLoggedIn:o,signerInfo:s,logout:i,loginWithNsec:a,loading:c,getTempSigner:l}=kt(),{t:d}=et(),[u,p]=z.useState(!1),[f,m]=z.useState("list"),[h,y]=z.useState(null),[v,x]=z.useState(!1),[S,U]=z.useState(!1),[K,_]=z.useState(""),[N,L]=z.useState(null);if(z.useEffect(()=>{t||(m("list"),y(null),x(!1),U(!1),_(""),L(null))},[t]),z.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),z.useEffect(()=>{const V=W=>{W.key==="Escape"&&(f!=="list"?T():e())};return t&&window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[t,f,e]),!t)return null;const H=()=>{e()},T=()=>{m("list"),y(null),x(!1),U(!1),_(""),L(null)},O=async()=>{const V=l();V&&(await V.copyNsec(),p(!0),setTimeout(()=>p(!1),3e3))},D=()=>{const V=l();V&&V.downloadKeyFile()},R=async()=>{h&&(await h.copyNsec(),x(!0),setTimeout(()=>x(!1),3e3))},k=()=>{h&&(h.downloadKeyFile(),U(!0))},w=async()=>{if(h){const V=h.getNsec();await a(V),H()}},E=async V=>{if(V.preventDefault(),!!K.trim()){L(null);try{await a(K),H()}catch{L(d("importKeyError"))}}},A=(s==null?void 0:s.type)==="temp",I=A?l():null,C=(I==null?void 0:I.getNsec())||"",$=()=>d(o?"logout":f==="create"?"createAccount":f==="import"?"importKey":"login"),B=()=>b.jsx("button",{type:"button",onClick:T,className:"nc-modal__back","aria-label":"Back",children:b.jsx(Vm,{size:20})}),P=()=>{if(!h)return null;const V=h.getNsec();return b.jsxs("div",{className:"nc-temp-view nc-temp-view--created",children:[b.jsxs("div",{className:"nc-temp-view__header",children:[b.jsx("div",{className:"nc-temp-view__icon nc-temp-view__icon--success",children:b.jsx(zn,{size:24})}),b.jsx("h4",{className:"nc-temp-view__title",children:d("tempAccountCreated")})]}),b.jsxs("div",{className:"nc-temp-view__key-section",children:[b.jsxs("div",{className:"nc-temp-view__key-box",children:[b.jsx("code",{className:"nc-temp-view__key-code",children:V}),b.jsxs("div",{className:"nc-temp-view__key-actions",children:[b.jsx("button",{type:"button",onClick:R,className:`nc-temp-view__key-btn ${v?"nc-temp-view__key-btn--success":""}`,title:d("copyKey"),children:v?b.jsx(zn,{size:16}):b.jsx(Lc,{size:16})}),b.jsx("button",{type:"button",onClick:k,className:`nc-temp-view__key-btn ${S?"nc-temp-view__key-btn--success":""}`,title:d("downloadKey"),children:S?b.jsx(zn,{size:16}):b.jsx(Ic,{size:16})})]})]}),b.jsx("p",{className:"nc-temp-view__key-hint",children:d("keyCompatibility")})]}),b.jsx("button",{type:"button",onClick:w,className:"nc-temp-view__submit",children:d("startCommenting")})]})},q=()=>b.jsxs("div",{className:"nc-temp-view",children:[b.jsx("div",{className:"nc-temp-view__icon",children:b.jsx(Tc,{size:32})}),b.jsx("h4",{className:"nc-temp-view__title",children:d("importKey")}),b.jsx("p",{className:"nc-temp-view__desc",children:d("importKeyDesc")}),b.jsxs("form",{onSubmit:E,className:"nc-temp-view__form",children:[b.jsx("input",{type:"password",value:K,onInput:V=>{_(V.target.value),L(null)},placeholder:d("importKeyPlaceholder"),className:"nc-temp-view__input",autoComplete:"off"}),N&&b.jsx("p",{className:"nc-temp-view__error",children:N}),b.jsx("button",{type:"submit",disabled:c||!K.trim(),className:"nc-temp-view__submit",children:d("login")})]})]});return b.jsx("div",{className:`nc-modal-overlay ${r}`,onClick:e,children:b.jsxs("div",{className:"nc-modal",onClick:V=>V.stopPropagation(),children:[b.jsxs("div",{className:"nc-modal__header",children:[f!=="list"&&!o&&B(),b.jsx("h3",{children:$()}),b.jsx("button",{type:"button",onClick:e,className:"nc-modal__close","aria-label":"Close",children:b.jsx(Wm,{size:20})})]}),b.jsx("div",{className:"nc-modal__body",children:o&&s?b.jsxs("div",{className:"nc-logged-in",children:[b.jsxs("div",{className:"nc-logged-in__user",children:[b.jsx(Hn,{pubkey:s.pubkey,size:48}),b.jsxs("div",{className:"nc-logged-in__info",children:[b.jsx(Ft,{pubkey:s.pubkey,className:"nc-logged-in__name"}),b.jsxs("span",{className:"nc-logged-in__type",children:[s.type==="nip07"&&d("extensionLogin"),s.type==="bunker"&&d("bunkerLogin"),s.type==="temp"&&d("tempAccount")]})]})]}),A&&b.jsxs("div",{className:"nc-logged-in__temp-backup",children:[b.jsx("div",{className:"nc-temp-nsec",children:b.jsx("code",{className:"nc-temp-nsec__code",children:C})}),b.jsx("p",{className:"nc-login-option__compatibility",children:d("keyCompatibility")}),b.jsxs("div",{className:"nc-temp-actions",children:[b.jsxs("button",{type:"button",onClick:O,className:`nc-temp-actions__btn ${u?"nc-temp-actions__btn--success":""}`,children:[u?b.jsx(zn,{size:16}):b.jsx(Lc,{size:16}),d(u?"keyCopied":"copyKey")]}),b.jsxs("button",{type:"button",onClick:D,className:"nc-temp-actions__btn",children:[b.jsx(Ic,{size:16}),d("downloadKey")]})]})]}),b.jsx("button",{type:"button",onClick:()=>{i(),e()},className:"nc-logged-in__logout",children:d("logout")})]}):f==="create"?P():f==="import"?q():b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"nc-modal__description",children:d("loginDescription")}),b.jsxs("div",{className:"nc-login-options",children:[n.includes("nip07")&&b.jsx(Zm,{onSuccess:H}),n.includes("bunker")&&b.jsx(Jm,{onSuccess:H}),n.includes("temp")&&b.jsxs(b.Fragment,{children:[b.jsxs("button",{type:"button",onClick:()=>{const V=new Et;y(V),m("create")},className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Fm,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:d("createAccount")}),b.jsx("p",{children:d("tempAccountDesc")})]})]}),b.jsxs("button",{type:"button",onClick:()=>m("import"),className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Tc,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:d("importKey")}),b.jsx("p",{children:d("importKeyDesc")})]})]})]})]})]})})]})})}function Uc(t){const{url:e,relays:n,authors:r,pageSize:o=50}=t,[s,i]=z.useState([]),[a,c]=z.useState(!0),[l,d]=z.useState(!1),[u,p]=z.useState(null),[f,m]=z.useState(),h=JSON.stringify(n),y=JSON.stringify(r||[]),v=z.useCallback(async()=>{c(!0),p(null),i([]);const _=[];let N=!1;return qa({url:e,relays:await Ln(n,r),limit:o,onEvent:H=>{N?i(T=>T.some(O=>O.id===H.id)?T:[H,...T]):_.push(H)},onEose:()=>{N=!0;const T=_.sort((O,D)=>D.created_at-O.created_at).slice(0,o);i(T),m(T.length>=o?T[T.length-1].created_at-1:void 0),c(!1)}})},[e,o,h,y]),x=z.useCallback(async()=>{if(!(a||l||f===void 0)){d(!0);try{const _=await Va({url:e,relays:await Ln(n,r),limit:o,until:f});if(_.length===0){m(void 0);return}i(N=>{const L=_.filter(H=>!N.some(T=>T.id===H.id));return[...N,...L]}),m(_[_.length-1].created_at-1)}catch(_){p(_ instanceof Error?_.message:"Failed to load more")}finally{d(!1)}}},[e,o,a,l,f,h,y]);z.useEffect(()=>{const _=v();return()=>{_.then(N=>N())}},[v]);const S=z.useCallback(_=>{i(N=>N.some(L=>L.id===_.id)?N:[_,...N])},[]),{comments:U,commentCount:K}=z.useMemo(()=>{const _=Wa(s);let N=0;const L=H=>{H.forEach(T=>{N++,L(T.children)})};return L(_),{comments:_,commentCount:N}},[s]);return{comments:U,commentCount:K,events:s,loading:a,loadingMore:l,error:u,hasMore:f!==void 0,reload:v,loadMore:x,addEvent:S}}const Gm=':where(.nostr-comments){--nc-bg: #ffffff;--nc-text: #1f2937;--nc-primary: #319cfc;--nc-error: #dc2626;--nc-success: #16a34a;--nc-bg-secondary: color-mix(in srgb, var(--nc-text) 4%, var(--nc-bg));--nc-bg-hover: color-mix(in srgb, var(--nc-text) 6%, var(--nc-bg));--nc-border: color-mix(in srgb, var(--nc-text) 18%, var(--nc-bg));--nc-text-secondary: color-mix(in srgb, var(--nc-text) 60%, var(--nc-bg));--nc-text-muted: color-mix(in srgb, var(--nc-text) 40%, var(--nc-bg));--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, black);--nc-primary-light: color-mix(in srgb, var(--nc-primary) 8%, var(--nc-bg));--nc-error-light: color-mix(in srgb, var(--nc-error) 6%, var(--nc-bg));--nc-success-light: color-mix(in srgb, var(--nc-success) 12%, var(--nc-bg));--nc-space-xs: 3px;--nc-space-sm: 6px;--nc-space-md: 10px;--nc-space-lg: 14px;--nc-space-xl: 20px;--nc-radius-sm: 6px;--nc-radius-md: 8px;--nc-radius-lg: 10px;--nc-radius-xl: 16px;--nc-radius-full: 9999px;--nc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;--nc-font-size-xs: 11px;--nc-font-size-sm: 12px;--nc-font-size-md: 13px;--nc-font-size-lg: 15px;--nc-avatar-radius: 50%;--nc-shadow-sm: 0 1px 3px rgba(0, 0, 0, .04);--nc-shadow-md: 0 4px 12px rgba(0, 0, 0, .06);--nc-shadow-lg: 0 12px 32px rgba(0, 0, 0, .12);--nc-transition: .2s ease-out}:where(.nostr-comments[data-theme=dark]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}@media(prefers-color-scheme:dark){:where(.nostr-comments[data-theme=auto]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}}.nostr-comments:not([data-headless=true]){font-family:var(--nc-font-family);font-size:var(--nc-font-size-md);color:var(--nc-text);line-height:1.5}.nostr-comments:not([data-headless=true]) *{box-sizing:border-box}.nostr-comments:not([data-headless=true]) .nc-header{margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-title{font-size:var(--nc-font-size-lg);font-weight:600;margin:0;display:flex;align-items:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-count{font-weight:400;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-editor{margin-bottom:var(--nc-space-xl)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary-light);border-radius:var(--nc-radius-md);margin-bottom:var(--nc-space-md);font-size:var(--nc-font-size-sm);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-label{font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-content{color:var(--nc-text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply{margin-left:auto;background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs) var(--nc-space-sm);border-radius:var(--nc-radius-sm);transition:background var(--nc-transition);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-editor__main{display:flex;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__input-wrapper{flex:1}.nostr-comments:not([data-headless=true]) .nc-editor__textarea{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:color-mix(in srgb,var(--nc-bg) 60%,transparent);color:var(--nc-text);font-family:inherit;font-size:var(--nc-font-size-md);resize:vertical;min-height:96px;transition:border-color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea::placeholder{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-editor__actions{display:flex;justify-content:flex-end;margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__submit{padding:var(--nc-space-sm) var(--nc-space-xl);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-list{display:flex;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-loading,.nostr-comments:not([data-headless=true]) .nc-empty,.nostr-comments:not([data-headless=true]) .nc-error{text-align:center;padding:var(--nc-space-xl);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-loading{display:flex;align-items:center;justify-content:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-loading__spinner{width:16px;height:16px;border:1.5px solid var(--nc-border);border-top-color:var(--nc-primary);border-radius:50%;animation:nc-spin .8s linear infinite}@keyframes nc-spin{to{transform:rotate(360deg)}}.nostr-comments:not([data-headless=true]) .nc-error__retry{margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);cursor:pointer;color:var(--nc-text);transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-error__retry:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-comment{padding-top:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-comment:first-child{padding-top:0}.nostr-comments:not([data-headless=true]) .nc-comment__main{display:flex;align-items:flex-start;gap:var(--nc-space-md);position:relative}.nostr-comments:not([data-headless=true]) .nc-comment__vline{position:absolute;left:20px;top:48px;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__content{flex:1;min-width:0;padding-top:2px}.nostr-comments:not([data-headless=true]) .nc-comment__header{margin-bottom:var(--nc-space-xs);display:flex}.nostr-comments:not([data-headless=true]) .nc-comment__author{font-weight:500;color:var(--nc-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-comment__text{margin:0;color:var(--nc-text);white-space:pre-wrap;word-wrap:break-word}.nostr-comments:not([data-headless=true]) .nc-comment__actions{display:flex;align-items:center;gap:var(--nc-space-md);margin-top:var(--nc-space-xs);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-comment__time{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:0;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn:hover{color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-comment__child-wrapper{position:relative;padding-left:50px}.nostr-comments:not([data-headless=true]) .nc-comment__connector{position:absolute;left:20px;top:0;width:26px;height:32px;border-left:1.5px solid var(--nc-border);border-bottom:1.5px solid var(--nc-border);border-bottom-left-radius:var(--nc-radius-xl)}.nostr-comments:not([data-headless=true]) .nc-comment__connector-line{position:absolute;left:20px;top:0;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview{display:flex;align-items:center;gap:var(--nc-space-xs);padding:var(--nc-space-xs) var(--nc-space-sm);margin-bottom:var(--nc-space-xs);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-sm);border-left:2px solid var(--nc-primary);font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);overflow:hidden;width:fit-content;max-width:100%}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-load-more{display:block;width:100%;padding:var(--nc-space-md);margin-top:var(--nc-space-lg);background:transparent;border:none;color:var(--nc-text-muted);font-size:var(--nc-font-size-sm);cursor:pointer;transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-load-more:hover:not(:disabled){color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-load-more:disabled{cursor:wait}.nostr-comments:not([data-headless=true]) .nc-avatar-link{flex-shrink:0;text-decoration:none;margin-top:4px}.nostr-comments:not([data-headless=true]) .nc-avatar-link:hover{opacity:.8}.nostr-comments:not([data-headless=true]) .nc-avatar{flex-shrink:0;border-radius:var(--nc-avatar-radius, 50%);object-fit:cover;aspect-ratio:1 / 1}.nostr-comments:not([data-headless=true]) .nc-username{color:inherit;text-decoration:none}.nostr-comments:not([data-headless=true]) .nc-username:hover{text-decoration:underline}.nostr-comments:not([data-headless=true]) .nc-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:9999;padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal{background:var(--nc-bg);border-radius:var(--nc-radius-xl);width:100%;max-width:400px;max-height:90vh;overflow-y:auto;box-shadow:var(--nc-shadow-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__header{display:flex;align-items:center;padding:var(--nc-space-lg);border-bottom:1px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-modal__header h3{margin:0;font-size:var(--nc-font-size-lg);font-weight:600;flex:1}.nostr-comments:not([data-headless=true]) .nc-modal__back{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;transition:background var(--nc-transition);margin-right:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-modal__back:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__close{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;margin-left:auto;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-modal__close:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__body{padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__description{margin:0 0 var(--nc-space-lg);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-options{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-login-option{display:flex;gap:var(--nc-space-md);padding:var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);text-align:left;cursor:pointer;transition:border-color var(--nc-transition),background var(--nc-transition);width:100%}.nostr-comments:not([data-headless=true]) .nc-login-option:hover:not(:disabled):not(.nc-login-option--disabled){border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-login-option--disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker{cursor:default;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker .nc-login-option__icon{display:none}.nostr-comments:not([data-headless=true]) .nc-login-option__icon{flex-shrink:0;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%}.nostr-comments:not([data-headless=true]) .nc-login-option__icon--success{background:var(--nc-success-light);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-login-option__content h4{margin:0 0 var(--nc-space-xs);font-size:var(--nc-font-size-md);font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-login-option__content p{margin:0;font-size:var(--nc-font-size-sm);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-option__hint{margin-top:var(--nc-space-sm)!important;color:var(--nc-text-muted)!important;font-style:italic}.nostr-comments:not([data-headless=true]) .nc-login-option__error{margin-top:var(--nc-space-sm)!important;color:var(--nc-error)!important}.nostr-comments:not([data-headless=true]) .nc-login-option__warning{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-error-light);border-radius:var(--nc-radius-sm);color:var(--nc-error)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-bunker-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit{padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-temp-nsec{margin-top:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);overflow:hidden}.nostr-comments:not([data-headless=true]) .nc-temp-nsec__code{display:block;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-login-option__compatibility{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-primary-light);border-radius:var(--nc-radius-sm);color:var(--nc-primary)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-temp-actions{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn{flex:1;display:flex;align-items:center;justify-content:center;gap:var(--nc-space-xs);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);color:var(--nc-text);cursor:pointer;font-size:var(--nc-font-size-sm);transition:background var(--nc-transition),border-color var(--nc-transition),color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success:hover{background:var(--nc-success-light)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue{width:100%;margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);border:none;border-radius:var(--nc-radius-md);color:#fff;cursor:pointer;font-weight:500;transition:background var(--nc-transition),opacity var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue:hover{background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue--muted{opacity:.6}.nostr-comments:not([data-headless=true]) .nc-import-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-import-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-import-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit{padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-sm);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-import-form__back{margin-top:var(--nc-space-md);padding:var(--nc-space-sm);background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__back:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view{display:flex;flex-direction:column;align-items:center;text-align:center;padding:var(--nc-space-xl) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon{width:52px;height:52px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon--success{width:36px;height:36px;background:var(--nc-success-light);color:var(--nc-success);margin-bottom:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__title{margin:0 0 var(--nc-space-sm);font-size:var(--nc-font-size-lg);font-weight:600;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view__desc{margin:0 0 var(--nc-space-xl);color:var(--nc-text-secondary);max-width:320px}.nostr-comments:not([data-headless=true]) .nc-temp-view--created{padding:var(--nc-space-lg) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__header{display:flex;align-items:center;gap:var(--nc-space-md);margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__header .nc-temp-view__title{margin:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-section{width:100%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-box{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-code{flex:1;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;text-align:left;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-actions{display:flex;gap:var(--nc-space-xs);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:50%;color:var(--nc-text-secondary);cursor:pointer;transition:all var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn:hover{border-color:var(--nc-primary);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-hint{margin:var(--nc-space-sm) 0 0;font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);text-align:left}.nostr-comments:not([data-headless=true]) .nc-temp-view__form{width:100%;max-width:320px;display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm);text-align:center}.nostr-comments:not([data-headless=true]) .nc-temp-view__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input::placeholder{font-family:var(--nc-font-family)}.nostr-comments:not([data-headless=true]) .nc-temp-view__error{margin:0;color:var(--nc-error);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit{width:100%;padding:var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;font-size:var(--nc-font-size-md);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-logged-in{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__user{display:flex;align-items:center;gap:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__info{display:flex;flex-direction:column;gap:var(--nc-space-xs)}.nostr-comments:not([data-headless=true]) .nc-logged-in__name{font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-logged-in__type{font-size:var(--nc-font-size-sm);color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-logged-in__temp-backup{display:flex;flex-direction:column;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout{margin-top:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-error-light);border:1px solid var(--nc-error);border-radius:var(--nc-radius-md);color:var(--nc-error);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout:hover{background:var(--nc-error);color:#fff}',Oc="nostr-comments-styles";function Ym(){if(document.getElementById(Oc)||document.querySelector('style[data-vite-dev-id*="base.css"]'))return;const e=document.createElement("style");e.id=Oc,e.textContent=Gm,document.head.appendChild(e)}function Xm({url:t,authorPubkeys:e,relays:n,pageSize:r=50,enabledSigners:o=["nip07","bunker","temp"],classNames:s={},onCommentPublished:i,onError:a}){const{t:c}=et(),{signerInfo:l}=kt(),[d,u]=z.useState(!1),[p,f]=z.useState(null),{comments:m,commentCount:h,loading:y,loadingMore:v,error:x,hasMore:S,reload:U,loadMore:K,addEvent:_}=Uc({url:t,relays:n,authors:e,pageSize:r}),N=T=>{_(T),i==null||i(T)},L=T=>{a==null||a(T)},H=T=>{f(T);const O=document.querySelector(".nc-editor");O&&O.scrollIntoView({behavior:"smooth",block:"center"})};return b.jsxs("div",{className:`nc-root ${s.root||""}`,children:[b.jsx("div",{className:"nc-header",children:b.jsxs("h3",{className:"nc-title",children:[c("comments"),h>0&&b.jsxs("span",{className:"nc-count",children:["(",h,")"]})]})}),b.jsx(Sc,{url:t,relays:n,authorPubkeys:e,parentEvent:p,onClearParent:()=>f(null),onPublished:N,onLoginRequired:()=>u(!0),onError:L,className:s.editor}),b.jsx(Nc,{comments:m,loading:y,loadingMore:v,hasMore:S,error:x,relays:n,onReply:H,onLoginRequired:()=>u(!0),onLoadMore:K,onRetry:U,currentPubkey:l==null?void 0:l.pubkey,className:s.list}),b.jsx(Pc,{isOpen:d,onClose:()=>u(!1),enabledSigners:o,className:s.loginModal})]})}function Qm({locale:t,translations:e,theme:n="auto",headless:r=!1,...o}){return z.useEffect(()=>{r||Ym()},[r]),b.jsx(cc,{locale:t,translations:e,children:b.jsx("div",{className:"nostr-comments","data-theme":n,"data-headless":r?"true":void 0,children:b.jsx(Xm,{...o})})})}const Do=7;function eg(t){const{eventIds:e,relays:n,onEvent:r,onEose:o}=t;return e.length===0?(o==null||o(),()=>{}):No(n,{kinds:[Do],"#e":e},r,o)}async function tg(t){const{eventIds:e,relays:n}=t;return e.length===0?[]:So(n,{kinds:[Do],"#e":e})}function Rc(t,e="+"){return{kind:Do,content:e,tags:[["e",t.id],["p",t.pubkey]],created_at:Math.floor(Date.now()/1e3)}}async function ng(t,e,n,r="+"){const o=Rc(n,r),s=await t.signEvent(o);return await Bn(e,s),s}function rg(t,e){return t.filter(n=>{const r=n.tags.find(o=>o[0]==="e");return r&&r[1]===e&&(n.content==="+"||n.content==="")}).length}function og(t,e,n){return t.some(r=>{const o=r.tags.find(s=>s[0]==="e");return o&&o[1]===e&&r.pubkey===n&&(r.content==="+"||r.content==="")})}M.Avatar=Hn,M.BunkerSigner=yn,M.CommentEditor=Sc,M.CommentItem=Ro,M.CommentList=Nc,M.I18nProvider=cc,M.LoginModal=Pc,M.Nip07Signer=Wt,M.NostrComments=Qm,M.TempSigner=Et,M.Username=Ft,M.buildCommentTree=Wa,M.buildReactionEvent=Rc,M.buildReplyComment=Ha,M.buildWebComment=Ka,M.countLikes=rg,M.en=Nt,M.fetchComments=Va,M.fetchReactions=tg,M.generateAvatarSvg=Ac,M.getAvatarDataUrl=Oo,M.getColorFromPubkey=_c,M.getDefaultRelays=Da,M.getParentId=zt,M.getRootUrl=Cm,M.hasLiked=og,M.isLoggedIn=ip,M.isReply=Nm,M.publishComment=ja,M.publishEvent=Bn,M.publishReaction=ng,M.publishReply=Fa,M.queryEvents=So,M.subscribeComments=qa,M.subscribeEvents=No,M.subscribeReactions=eg,M.useComments=Uc,M.useI18n=et,M.useProfile=Uo,M.useSigner=kt,M.zhCN=In,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
154
+ */const Ym=Ke("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Xm({onSuccess:t}){const{loginWithNip07:e,loading:n,error:r,isNip07Available:o}=kt(),{t:s}=et(),i=async()=>{await e(),t()};return o?b.jsxs("button",{type:"button",onClick:i,disabled:n,className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Ic,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:s("extensionLogin")}),b.jsx("p",{children:s("extensionLoginDesc")}),r&&b.jsx("p",{className:"nc-login-option__error",children:r})]})]}):b.jsxs("div",{className:"nc-login-option nc-login-option--disabled",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Ic,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:s("extensionLogin")}),b.jsx("p",{children:s("extensionLoginDesc")}),b.jsx("p",{className:"nc-login-option__hint",children:"No extension detected"})]})]})}function Qm({onSuccess:t}){const{loginWithBunker:e,loading:n,error:r}=kt(),{t:o}=et(),[s,i]=z.useState(""),a=async c=>{c.preventDefault(),s.trim()&&(await e(s.trim()),r||t())};return b.jsxs("div",{className:"nc-login-option nc-login-option--bunker",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Jm,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:o("bunkerLogin")}),b.jsx("p",{children:o("bunkerLoginDesc")}),b.jsxs("form",{onSubmit:a,className:"nc-bunker-form",children:[b.jsx("input",{type:"text",value:s,onInput:c=>i(c.target.value),placeholder:o("bunkerUrlPlaceholder"),className:"nc-bunker-form__input"}),b.jsx("button",{type:"submit",disabled:n||!s.trim(),className:"nc-bunker-form__submit",children:o(n?"connecting":"connect")})]}),r&&b.jsx("p",{className:"nc-login-option__error",children:r})]})]})}function Tc({isOpen:t,onClose:e,enabledSigners:n=["nip07","bunker","temp"],className:r=""}){const{isLoggedIn:o,signerInfo:s,logout:i,loginWithNsec:a,loading:c,getTempSigner:l}=kt(),{t:d}=et(),[u,p]=z.useState(!1),[f,m]=z.useState("list"),[h,y]=z.useState(null),[v,x]=z.useState(!1),[S,M]=z.useState(!1),[R,_]=z.useState(""),[N,L]=z.useState(null);if(z.useEffect(()=>{t||(m("list"),y(null),x(!1),M(!1),_(""),L(null))},[t]),z.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),z.useEffect(()=>{const V=W=>{W.key==="Escape"&&(f!=="list"?U():e())};return t&&window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[t,f,e]),!t)return null;const H=()=>{e()},U=()=>{m("list"),y(null),x(!1),M(!1),_(""),L(null)},T=async()=>{const V=l();V&&(await V.copyNsec(),p(!0),setTimeout(()=>p(!1),3e3))},O=()=>{const V=l();V&&V.downloadKeyFile()},D=async()=>{h&&(await h.copyNsec(),x(!0),setTimeout(()=>x(!1),3e3))},k=()=>{h&&(h.downloadKeyFile(),M(!0))},w=async()=>{if(h){const V=h.getNsec();await a(V),H()}},E=async V=>{if(V.preventDefault(),!!R.trim()){L(null);try{await a(R),H()}catch{L(d("importKeyError"))}}},A=(s==null?void 0:s.type)==="temp",I=A?l():null,C=(I==null?void 0:I.getNsec())||"",$=()=>d(o?"logout":f==="create"?"createAccount":f==="import"?"importKey":"login"),B=()=>b.jsx("button",{type:"button",onClick:U,className:"nc-modal__back","aria-label":"Back",children:b.jsx(Zm,{size:20})}),P=()=>{if(!h)return null;const V=h.getNsec();return b.jsxs("div",{className:"nc-temp-view nc-temp-view--created",children:[b.jsxs("div",{className:"nc-temp-view__header",children:[b.jsx("div",{className:"nc-temp-view__icon nc-temp-view__icon--success",children:b.jsx(Kn,{size:24})}),b.jsx("h4",{className:"nc-temp-view__title",children:d("tempAccountCreated")})]}),b.jsxs("div",{className:"nc-temp-view__key-section",children:[b.jsxs("div",{className:"nc-temp-view__key-box",children:[b.jsx("code",{className:"nc-temp-view__key-code",children:V}),b.jsxs("div",{className:"nc-temp-view__key-actions",children:[b.jsx("button",{type:"button",onClick:D,className:`nc-temp-view__key-btn ${v?"nc-temp-view__key-btn--success":""}`,title:d("copyKey"),children:v?b.jsx(Kn,{size:16}):b.jsx(Bc,{size:16})}),b.jsx("button",{type:"button",onClick:k,className:`nc-temp-view__key-btn ${S?"nc-temp-view__key-btn--success":""}`,title:d("downloadKey"),children:S?b.jsx(Kn,{size:16}):b.jsx(Lc,{size:16})})]})]}),b.jsx("p",{className:"nc-temp-view__key-hint",children:d("keyCompatibility")})]}),b.jsx("button",{type:"button",onClick:w,className:"nc-temp-view__submit",children:d("startCommenting")})]})},q=()=>b.jsxs("div",{className:"nc-temp-view",children:[b.jsx("div",{className:"nc-temp-view__icon",children:b.jsx($c,{size:32})}),b.jsx("h4",{className:"nc-temp-view__title",children:d("importKey")}),b.jsx("p",{className:"nc-temp-view__desc",children:d("importKeyDesc")}),b.jsxs("form",{onSubmit:E,className:"nc-temp-view__form",children:[b.jsx("input",{type:"password",value:R,onInput:V=>{_(V.target.value),L(null)},placeholder:d("importKeyPlaceholder"),className:"nc-temp-view__input",autoComplete:"off"}),N&&b.jsx("p",{className:"nc-temp-view__error",children:N}),b.jsx("button",{type:"submit",disabled:c||!R.trim(),className:"nc-temp-view__submit",children:d("login")})]})]});return b.jsx("div",{className:`nc-modal-overlay ${r}`,onClick:e,children:b.jsxs("div",{className:"nc-modal",onClick:V=>V.stopPropagation(),children:[b.jsxs("div",{className:"nc-modal__header",children:[f!=="list"&&!o&&B(),b.jsx("h3",{children:$()}),b.jsx("button",{type:"button",onClick:e,className:"nc-modal__close","aria-label":"Close",children:b.jsx(Ym,{size:20})})]}),b.jsx("div",{className:"nc-modal__body",children:o&&s?b.jsxs("div",{className:"nc-logged-in",children:[b.jsxs("div",{className:"nc-logged-in__user",children:[b.jsx(Dn,{pubkey:s.pubkey,size:48}),b.jsxs("div",{className:"nc-logged-in__info",children:[b.jsx(Ft,{pubkey:s.pubkey,className:"nc-logged-in__name"}),b.jsxs("span",{className:"nc-logged-in__type",children:[s.type==="nip07"&&d("extensionLogin"),s.type==="bunker"&&d("bunkerLogin"),s.type==="temp"&&d("tempAccount")]})]})]}),A&&b.jsxs("div",{className:"nc-logged-in__temp-backup",children:[b.jsx("div",{className:"nc-temp-nsec",children:b.jsx("code",{className:"nc-temp-nsec__code",children:C})}),b.jsx("p",{className:"nc-login-option__compatibility",children:d("keyCompatibility")}),b.jsxs("div",{className:"nc-temp-actions",children:[b.jsxs("button",{type:"button",onClick:T,className:`nc-temp-actions__btn ${u?"nc-temp-actions__btn--success":""}`,children:[u?b.jsx(Kn,{size:16}):b.jsx(Bc,{size:16}),d(u?"keyCopied":"copyKey")]}),b.jsxs("button",{type:"button",onClick:O,className:"nc-temp-actions__btn",children:[b.jsx(Lc,{size:16}),d("downloadKey")]})]})]}),b.jsx("button",{type:"button",onClick:()=>{i(),e()},className:"nc-logged-in__logout",children:d("logout")})]}):f==="create"?P():f==="import"?q():b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"nc-modal__description",children:d("loginDescription")}),b.jsxs("div",{className:"nc-login-options",children:[n.includes("nip07")&&b.jsx(Xm,{onSuccess:H}),n.includes("bunker")&&b.jsx(Qm,{onSuccess:H}),n.includes("temp")&&b.jsxs(b.Fragment,{children:[b.jsxs("button",{type:"button",onClick:()=>{const V=new Et;y(V),m("create")},className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Gm,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:d("createAccount")}),b.jsx("p",{children:d("tempAccountDesc")})]})]}),b.jsxs("button",{type:"button",onClick:()=>m("import"),className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx($c,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:d("importKey")}),b.jsx("p",{children:d("importKeyDesc")})]})]})]})]})]})})]})})}new TextDecoder("utf-8"),new TextEncoder;function eg(t){let e=0;for(let n=0;n<64;n+=8){const r=parseInt(t.substring(n,n+8),16);if(r===0)e+=32;else{e+=Math.clz32(r);break}}return e}function Pc(t){const{url:e,relays:n,mention:r,pageSize:o=50,pow:s=18}=t,[i,a]=z.useState([]),[c,l]=z.useState(!0),[d,u]=z.useState(!1),[p,f]=z.useState(null),[m,h]=z.useState(),y=JSON.stringify(n),v=z.useCallback(async()=>{l(!0),f(null),a([]);const _=[];let N=!1;return qa({url:e,relays:await Co(n,r),limit:o,onEvent:H=>{N?a(U=>U.some(T=>T.id===H.id)?U:[H,...U]):_.push(H)},onEose:()=>{N=!0;const U=_.sort((T,O)=>O.created_at-T.created_at).slice(0,o);a(U),h(U.length>=o?U[U.length-1].created_at-1:void 0),l(!1)}})},[e,o,y,r]),x=z.useCallback(async()=>{if(!(c||d||m===void 0)){u(!0);try{const _=await Va({url:e,relays:await Co(n,r),limit:o,until:m});if(_.length===0){h(void 0);return}a(N=>{const L=_.filter(H=>!N.some(U=>U.id===H.id));return[...N,...L]}),h(_[_.length-1].created_at-1)}catch(_){f(_ instanceof Error?_.message:"Failed to load more")}finally{u(!1)}}},[e,o,c,d,m,y,r]);z.useEffect(()=>{const _=v();return()=>{_.then(N=>N())}},[v]);const S=z.useCallback(_=>{a(N=>N.some(L=>L.id===_.id)?N:[_,...N])},[]),{comments:M,commentCount:R}=z.useMemo(()=>{const _=s&&s>0?i.filter(U=>eg(U.id)>=s):i,N=Fa(_);let L=0;const H=U=>{U.forEach(T=>{L++,H(T.children)})};return H(N),{comments:N,commentCount:L}},[i,s]);return{comments:M,commentCount:R,events:i,loading:c,loadingMore:d,error:p,hasMore:m!==void 0,reload:v,loadMore:x,addEvent:S}}const tg=':where(.nostr-comments){--nc-bg: #ffffff;--nc-text: #1f2937;--nc-primary: #319cfc;--nc-error: #dc2626;--nc-success: #16a34a;--nc-bg-secondary: color-mix(in srgb, var(--nc-text) 4%, var(--nc-bg));--nc-bg-hover: color-mix(in srgb, var(--nc-text) 6%, var(--nc-bg));--nc-border: color-mix(in srgb, var(--nc-text) 18%, var(--nc-bg));--nc-text-secondary: color-mix(in srgb, var(--nc-text) 60%, var(--nc-bg));--nc-text-muted: color-mix(in srgb, var(--nc-text) 40%, var(--nc-bg));--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, black);--nc-primary-light: color-mix(in srgb, var(--nc-primary) 8%, var(--nc-bg));--nc-error-light: color-mix(in srgb, var(--nc-error) 6%, var(--nc-bg));--nc-success-light: color-mix(in srgb, var(--nc-success) 12%, var(--nc-bg));--nc-space-xs: 3px;--nc-space-sm: 6px;--nc-space-md: 10px;--nc-space-lg: 14px;--nc-space-xl: 20px;--nc-radius-sm: 6px;--nc-radius-md: 8px;--nc-radius-lg: 10px;--nc-radius-xl: 16px;--nc-radius-full: 9999px;--nc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;--nc-font-size-xs: 11px;--nc-font-size-sm: 12px;--nc-font-size-md: 13px;--nc-font-size-lg: 15px;--nc-avatar-radius: 50%;--nc-shadow-sm: 0 1px 3px rgba(0, 0, 0, .04);--nc-shadow-md: 0 4px 12px rgba(0, 0, 0, .06);--nc-shadow-lg: 0 12px 32px rgba(0, 0, 0, .12);--nc-transition: .2s ease-out}:where(.nostr-comments[data-theme=dark]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}@media(prefers-color-scheme:dark){:where(.nostr-comments[data-theme=auto]){--nc-bg: #0d1117;--nc-text: #e6edf3;--nc-primary: #58a6ff;--nc-primary-hover: color-mix(in srgb, var(--nc-primary) 85%, white);--nc-error: #f85149;--nc-success: #3fb950;--nc-border: #30363d;--nc-bg-secondary: #161b22;--nc-bg-hover: #21262d;--nc-primary-light: rgba(88, 166, 255, .15);--nc-error-light: rgba(248, 81, 73, .15);--nc-success-light: rgba(63, 185, 80, .15)}}.nostr-comments:not([data-headless=true]){font-family:var(--nc-font-family);font-size:var(--nc-font-size-md);color:var(--nc-text);line-height:1.5}.nostr-comments:not([data-headless=true]) *{box-sizing:border-box}.nostr-comments:not([data-headless=true]) .nc-header{margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-title{font-size:var(--nc-font-size-lg);font-weight:600;margin:0;display:flex;align-items:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-count{font-weight:400;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-editor{margin-bottom:var(--nc-space-xl)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary-light);border-radius:var(--nc-radius-md);margin-bottom:var(--nc-space-md);font-size:var(--nc-font-size-sm);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-label{font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-editor__reply-to-content{color:var(--nc-text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply{margin-left:auto;background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs) var(--nc-space-sm);border-radius:var(--nc-radius-sm);transition:background var(--nc-transition);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-editor__cancel-reply:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-editor__main{display:flex;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__input-wrapper{flex:1}.nostr-comments:not([data-headless=true]) .nc-editor__textarea{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:color-mix(in srgb,var(--nc-bg) 60%,transparent);color:var(--nc-text);font-family:inherit;font-size:var(--nc-font-size-md);resize:vertical;min-height:96px;transition:border-color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-editor__textarea::placeholder{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-editor__actions{display:flex;justify-content:flex-end;margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-editor__submit{padding:var(--nc-space-sm) var(--nc-space-xl);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-editor__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-list{display:flex;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-loading,.nostr-comments:not([data-headless=true]) .nc-empty,.nostr-comments:not([data-headless=true]) .nc-error{text-align:center;padding:var(--nc-space-xl);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-loading{display:flex;align-items:center;justify-content:center;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-loading__spinner{width:16px;height:16px;border:1.5px solid var(--nc-border);border-top-color:var(--nc-primary);border-radius:50%;animation:nc-spin .8s linear infinite}@keyframes nc-spin{to{transform:rotate(360deg)}}.nostr-comments:not([data-headless=true]) .nc-error__retry{margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);cursor:pointer;color:var(--nc-text);transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-error__retry:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-comment{padding-top:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-comment:first-child{padding-top:0}.nostr-comments:not([data-headless=true]) .nc-comment__main{display:flex;align-items:flex-start;gap:var(--nc-space-md);position:relative}.nostr-comments:not([data-headless=true]) .nc-comment__vline{position:absolute;left:20px;top:48px;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__content{flex:1;min-width:0;padding-top:2px}.nostr-comments:not([data-headless=true]) .nc-comment__header{margin-bottom:var(--nc-space-xs);display:flex}.nostr-comments:not([data-headless=true]) .nc-comment__author{font-weight:500;color:var(--nc-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nostr-comments:not([data-headless=true]) .nc-comment__text{margin:0;color:var(--nc-text);white-space:pre-wrap;word-wrap:break-word}.nostr-comments:not([data-headless=true]) .nc-comment__actions{display:flex;align-items:center;gap:var(--nc-space-md);margin-top:var(--nc-space-xs);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-comment__time{color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:0;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-btn:hover{color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-comment__child-wrapper{position:relative;padding-left:50px}.nostr-comments:not([data-headless=true]) .nc-comment__connector{position:absolute;left:20px;top:0;width:26px;height:32px;border-left:1.5px solid var(--nc-border);border-bottom:1.5px solid var(--nc-border);border-bottom-left-radius:var(--nc-radius-xl)}.nostr-comments:not([data-headless=true]) .nc-comment__connector-line{position:absolute;left:20px;top:0;bottom:0;border-left:1.5px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview{display:flex;align-items:center;gap:var(--nc-space-xs);padding:var(--nc-space-xs) var(--nc-space-sm);margin-bottom:var(--nc-space-xs);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-sm);border-left:2px solid var(--nc-primary);font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);overflow:hidden;width:fit-content;max-width:100%}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author{color:var(--nc-primary);font-weight:500;flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-author:after{content:":"}.nostr-comments:not([data-headless=true]) .nc-comment__reply-preview-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-load-more{display:block;width:100%;padding:var(--nc-space-md);margin-top:var(--nc-space-lg);background:transparent;border:none;color:var(--nc-text-muted);font-size:var(--nc-font-size-sm);cursor:pointer;transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-load-more:hover:not(:disabled){color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-load-more:disabled{cursor:wait}.nostr-comments:not([data-headless=true]) .nc-avatar-link{flex-shrink:0;text-decoration:none;margin-top:4px}.nostr-comments:not([data-headless=true]) .nc-avatar-link:hover{opacity:.8}.nostr-comments:not([data-headless=true]) .nc-avatar{flex-shrink:0;border-radius:var(--nc-avatar-radius, 50%);object-fit:cover;aspect-ratio:1 / 1}.nostr-comments:not([data-headless=true]) .nc-username{color:inherit;text-decoration:none}.nostr-comments:not([data-headless=true]) .nc-username:hover{text-decoration:underline}.nostr-comments:not([data-headless=true]) .nc-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:9999;padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal{background:var(--nc-bg);border-radius:var(--nc-radius-xl);width:100%;max-width:400px;max-height:90vh;overflow-y:auto;box-shadow:var(--nc-shadow-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__header{display:flex;align-items:center;padding:var(--nc-space-lg);border-bottom:1px solid var(--nc-border)}.nostr-comments:not([data-headless=true]) .nc-modal__header h3{margin:0;font-size:var(--nc-font-size-lg);font-weight:600;flex:1}.nostr-comments:not([data-headless=true]) .nc-modal__back{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;transition:background var(--nc-transition);margin-right:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-modal__back:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__close{background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;padding:var(--nc-space-xs);border-radius:50%;display:flex;margin-left:auto;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-modal__close:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-modal__body{padding:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-modal__description{margin:0 0 var(--nc-space-lg);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-options{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-login-option{display:flex;gap:var(--nc-space-md);padding:var(--nc-space-lg);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);text-align:left;cursor:pointer;transition:border-color var(--nc-transition),background var(--nc-transition);width:100%}.nostr-comments:not([data-headless=true]) .nc-login-option:hover:not(:disabled):not(.nc-login-option--disabled){border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-login-option--disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker{cursor:default;flex-direction:column}.nostr-comments:not([data-headless=true]) .nc-login-option--bunker .nc-login-option__icon{display:none}.nostr-comments:not([data-headless=true]) .nc-login-option__icon{flex-shrink:0;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%}.nostr-comments:not([data-headless=true]) .nc-login-option__icon--success{background:var(--nc-success-light);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-login-option__content h4{margin:0 0 var(--nc-space-xs);font-size:var(--nc-font-size-md);font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-login-option__content p{margin:0;font-size:var(--nc-font-size-sm);color:var(--nc-text-secondary)}.nostr-comments:not([data-headless=true]) .nc-login-option__hint{margin-top:var(--nc-space-sm)!important;color:var(--nc-text-muted)!important;font-style:italic}.nostr-comments:not([data-headless=true]) .nc-login-option__error{margin-top:var(--nc-space-sm)!important;color:var(--nc-error)!important}.nostr-comments:not([data-headless=true]) .nc-login-option__warning{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-error-light);border-radius:var(--nc-radius-sm);color:var(--nc-error)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-bunker-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit{padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-bunker-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-temp-nsec{margin-top:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);overflow:hidden}.nostr-comments:not([data-headless=true]) .nc-temp-nsec__code{display:block;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-login-option__compatibility{margin-top:var(--nc-space-sm)!important;padding:var(--nc-space-sm);background:var(--nc-primary-light);border-radius:var(--nc-radius-sm);color:var(--nc-primary)!important;font-size:var(--nc-font-size-sm)!important}.nostr-comments:not([data-headless=true]) .nc-temp-actions{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn{flex:1;display:flex;align-items:center;justify-content:center;gap:var(--nc-space-xs);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);color:var(--nc-text);cursor:pointer;font-size:var(--nc-font-size-sm);transition:background var(--nc-transition),border-color var(--nc-transition),color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn:hover{background:var(--nc-bg-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__btn--success:hover{background:var(--nc-success-light)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue{width:100%;margin-top:var(--nc-space-md);padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);border:none;border-radius:var(--nc-radius-md);color:#fff;cursor:pointer;font-weight:500;transition:background var(--nc-transition),opacity var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue:hover{background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-actions__continue--muted{opacity:.6}.nostr-comments:not([data-headless=true]) .nc-import-form{display:flex;gap:var(--nc-space-sm);margin-top:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-import-form__input{flex:1;padding:var(--nc-space-sm) var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-sm);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-import-form__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit{padding:var(--nc-space-sm) var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-sm);cursor:pointer;white-space:nowrap;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-import-form__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-import-form__back{margin-top:var(--nc-space-md);padding:var(--nc-space-sm);background:none;border:none;color:var(--nc-text-secondary);cursor:pointer;font-size:var(--nc-font-size-sm);transition:color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-import-form__back:hover{color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view{display:flex;flex-direction:column;align-items:center;text-align:center;padding:var(--nc-space-xl) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon{width:52px;height:52px;display:flex;align-items:center;justify-content:center;background:var(--nc-primary-light);color:var(--nc-primary);border-radius:50%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__icon--success{width:36px;height:36px;background:var(--nc-success-light);color:var(--nc-success);margin-bottom:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__title{margin:0 0 var(--nc-space-sm);font-size:var(--nc-font-size-lg);font-weight:600;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-temp-view__desc{margin:0 0 var(--nc-space-xl);color:var(--nc-text-secondary);max-width:320px}.nostr-comments:not([data-headless=true]) .nc-temp-view--created{padding:var(--nc-space-lg) 0}.nostr-comments:not([data-headless=true]) .nc-temp-view__header{display:flex;align-items:center;gap:var(--nc-space-md);margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__header .nc-temp-view__title{margin:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-section{width:100%;margin-bottom:var(--nc-space-lg)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-box{display:flex;align-items:center;gap:var(--nc-space-sm);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-code{flex:1;font-family:monospace;font-size:var(--nc-font-size-xs);color:var(--nc-text);word-break:break-all;text-align:left;-webkit-user-select:all;user-select:all}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-actions{display:flex;gap:var(--nc-space-xs);flex-shrink:0}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--nc-bg);border:1px solid var(--nc-border);border-radius:50%;color:var(--nc-text-secondary);cursor:pointer;transition:all var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn:hover{border-color:var(--nc-primary);color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-btn--success{background:var(--nc-success-light);border-color:var(--nc-success);color:var(--nc-success)}.nostr-comments:not([data-headless=true]) .nc-temp-view__key-hint{margin:var(--nc-space-sm) 0 0;font-size:var(--nc-font-size-sm);color:var(--nc-text-muted);text-align:left}.nostr-comments:not([data-headless=true]) .nc-temp-view__form{width:100%;max-width:320px;display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input{width:100%;padding:var(--nc-space-md);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);background:var(--nc-bg);color:var(--nc-text);font-family:monospace;font-size:var(--nc-font-size-sm);text-align:center}.nostr-comments:not([data-headless=true]) .nc-temp-view__input:focus{outline:none;border-color:var(--nc-primary)}.nostr-comments:not([data-headless=true]) .nc-temp-view__input::placeholder{font-family:var(--nc-font-family)}.nostr-comments:not([data-headless=true]) .nc-temp-view__error{margin:0;color:var(--nc-error);font-size:var(--nc-font-size-sm)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit{width:100%;padding:var(--nc-space-md);background:var(--nc-primary);color:#fff;border:none;border-radius:var(--nc-radius-md);font-weight:500;font-size:var(--nc-font-size-md);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:hover:not(:disabled){background:var(--nc-primary-hover)}.nostr-comments:not([data-headless=true]) .nc-temp-view__submit:disabled{opacity:.6;cursor:not-allowed}.nostr-comments:not([data-headless=true]) .nc-logged-in{display:flex;flex-direction:column;gap:var(--nc-space-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__user{display:flex;align-items:center;gap:var(--nc-space-md);padding:var(--nc-space-md);background:var(--nc-bg-secondary);border-radius:var(--nc-radius-md)}.nostr-comments:not([data-headless=true]) .nc-logged-in__info{display:flex;flex-direction:column;gap:var(--nc-space-xs)}.nostr-comments:not([data-headless=true]) .nc-logged-in__name{font-weight:500;color:var(--nc-text)}.nostr-comments:not([data-headless=true]) .nc-logged-in__type{font-size:var(--nc-font-size-sm);color:var(--nc-text-muted)}.nostr-comments:not([data-headless=true]) .nc-logged-in__temp-backup{display:flex;flex-direction:column;gap:var(--nc-space-sm)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout{margin-top:var(--nc-space-sm);padding:var(--nc-space-sm) var(--nc-space-lg);background:var(--nc-error-light);border:1px solid var(--nc-error);border-radius:var(--nc-radius-md);color:var(--nc-error);cursor:pointer;transition:background var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-logged-in__logout:hover{background:var(--nc-error);color:#fff}',Uc="nostr-comments-styles";function ng(){if(document.getElementById(Uc)||document.querySelector('style[data-vite-dev-id*="base.css"]'))return;const e=document.createElement("style");e.id=Uc,e.textContent=tg,document.head.appendChild(e)}function rg({url:t,mention:e,relays:n,pageSize:r=50,enabledSigners:o=["nip07","bunker","temp"],pow:s=18,classNames:i={},onCommentPublished:a,onError:c}){const{t:l}=et(),{signerInfo:d}=kt(),[u,p]=z.useState(!1),[f,m]=z.useState(null),{comments:h,commentCount:y,loading:v,loadingMore:x,error:S,hasMore:M,reload:R,loadMore:_,addEvent:N}=Pc({url:t,relays:n,mention:e,pageSize:r,pow:s}),L=T=>{N(T),a==null||a(T)},H=T=>{c==null||c(T)},U=T=>{m(T);const O=document.querySelector(".nc-editor");O&&O.scrollIntoView({behavior:"smooth",block:"center"})};return b.jsxs("div",{className:`nc-root ${i.root||""}`,children:[b.jsx("div",{className:"nc-header",children:b.jsxs("h3",{className:"nc-title",children:[l("comments"),y>0&&b.jsxs("span",{className:"nc-count",children:["(",y,")"]})]})}),b.jsx(Ac,{url:t,relays:n,mention:e,pow:s,parentEvent:f,onClearParent:()=>m(null),onPublished:L,onLoginRequired:()=>p(!0),onError:H,className:i.editor}),b.jsx(Sc,{comments:h,loading:v,loadingMore:x,hasMore:M,error:S,relays:n,onReply:U,onLoginRequired:()=>p(!0),onLoadMore:_,onRetry:R,currentPubkey:d==null?void 0:d.pubkey,className:i.list}),b.jsx(Tc,{isOpen:u,onClose:()=>p(!1),enabledSigners:o,className:i.loginModal})]})}function og({locale:t,translations:e,theme:n="auto",headless:r=!1,...o}){return z.useEffect(()=>{r||ng()},[r]),b.jsx(ac,{locale:t,translations:e,children:b.jsx("div",{className:"nostr-comments","data-theme":n,"data-headless":r?"true":void 0,children:b.jsx(rg,{...o})})})}const Ko=7;function sg(t){const{eventIds:e,relays:n,onEvent:r,onEose:o}=t;return e.length===0?(o==null||o(),()=>{}):So(n,{kinds:[Ko],"#e":e},r,o)}async function ig(t){const{eventIds:e,relays:n}=t;return e.length===0?[]:Ao(n,{kinds:[Ko],"#e":e})}function Oc(t,e="+"){return{kind:Ko,content:e,tags:[["e",t.id],["p",t.pubkey]],created_at:Math.floor(Date.now()/1e3)}}async function ag(t,e,n,r="+"){const o=Oc(n,r),s=await t.signEvent(o);return await No(e,s),s}function cg(t,e){return t.filter(n=>{const r=n.tags.find(o=>o[0]==="e");return r&&r[1]===e&&(n.content==="+"||n.content==="")}).length}function lg(t,e,n){return t.some(r=>{const o=r.tags.find(s=>s[0]==="e");return o&&o[1]===e&&r.pubkey===n&&(r.content==="+"||r.content==="")})}K.Avatar=Dn,K.BunkerSigner=yn,K.CommentEditor=Ac,K.CommentItem=Do,K.CommentList=Sc,K.I18nProvider=ac,K.LoginModal=Tc,K.Nip07Signer=Wt,K.NostrComments=og,K.TempSigner=Et,K.Username=Ft,K.buildCommentTree=Fa,K.buildReactionEvent=Oc,K.buildWebComment=Ha,K.countLikes=cg,K.en=Nt,K.fetchComments=Va,K.fetchReactions=ig,K.generateAvatarSvg=_c,K.getAvatarDataUrl=Mo,K.getColorFromPubkey=kc,K.getDefaultRelays=Ka,K.getParentId=zt,K.getRootUrl=Bm,K.hasLiked=lg,K.isLoggedIn=sp,K.isReply=Cm,K.isValidPubkey=_o,K.publishComment=ja,K.publishEvent=No,K.publishReaction=ag,K.queryEvents=Ao,K.subscribeComments=qa,K.subscribeEvents=So,K.subscribeReactions=sg,K.useComments=Pc,K.useI18n=et,K.useProfile=Ro,K.useSigner=kt,K.zhCN=Bn,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})}));