nostr-comments 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +294 -0
  2. package/dist/NostrComments.d.ts +2 -0
  3. package/dist/components/Avatar.d.ts +7 -0
  4. package/dist/components/CommentEditor.d.ts +14 -0
  5. package/dist/components/CommentItem.d.ts +14 -0
  6. package/dist/components/CommentList.d.ts +18 -0
  7. package/dist/components/LoginModal/BunkerLogin.d.ts +5 -0
  8. package/dist/components/LoginModal/Nip07Login.d.ts +5 -0
  9. package/dist/components/LoginModal/index.d.ts +9 -0
  10. package/dist/components/Username.d.ts +6 -0
  11. package/dist/components/index.d.ts +6 -0
  12. package/dist/hooks/index.d.ts +4 -0
  13. package/dist/hooks/useComments.d.ts +20 -0
  14. package/dist/hooks/useProfile.d.ts +4 -0
  15. package/dist/hooks/useSigner.d.ts +18 -0
  16. package/dist/i18n/index.d.ts +35 -0
  17. package/dist/i18n/locales/ar.d.ts +2 -0
  18. package/dist/i18n/locales/de.d.ts +2 -0
  19. package/dist/i18n/locales/en.d.ts +2 -0
  20. package/dist/i18n/locales/es.d.ts +2 -0
  21. package/dist/i18n/locales/fr.d.ts +2 -0
  22. package/dist/i18n/locales/hi.d.ts +2 -0
  23. package/dist/i18n/locales/id.d.ts +2 -0
  24. package/dist/i18n/locales/it.d.ts +2 -0
  25. package/dist/i18n/locales/ja.d.ts +2 -0
  26. package/dist/i18n/locales/ko.d.ts +2 -0
  27. package/dist/i18n/locales/nl.d.ts +2 -0
  28. package/dist/i18n/locales/pl.d.ts +2 -0
  29. package/dist/i18n/locales/pt.d.ts +2 -0
  30. package/dist/i18n/locales/ru.d.ts +2 -0
  31. package/dist/i18n/locales/th.d.ts +2 -0
  32. package/dist/i18n/locales/tr.d.ts +2 -0
  33. package/dist/i18n/locales/uk.d.ts +2 -0
  34. package/dist/i18n/locales/vi.d.ts +2 -0
  35. package/dist/i18n/locales/zh-CN.d.ts +2 -0
  36. package/dist/i18n/locales/zh-TW.d.ts +2 -0
  37. package/dist/index.d.ts +14 -0
  38. package/dist/nostr-comments.cjs +96 -0
  39. package/dist/nostr-comments.js +10257 -0
  40. package/dist/nostr-comments.umd.js +96 -0
  41. package/dist/services/comment.d.ts +32 -0
  42. package/dist/services/nostr.d.ts +6 -0
  43. package/dist/services/reaction.d.ts +18 -0
  44. package/dist/signers/BunkerSigner.d.ts +13 -0
  45. package/dist/signers/Nip07Signer.d.ts +16 -0
  46. package/dist/signers/TempSigner.d.ts +19 -0
  47. package/dist/signers/index.d.ts +4 -0
  48. package/dist/signers/types.d.ts +10 -0
  49. package/dist/types/index.d.ts +80 -0
  50. package/dist/utils/avatar.d.ts +3 -0
  51. package/dist/utils/ensureStyles.d.ts +1 -0
  52. package/dist/utils/nip22.d.ts +17 -0
  53. package/package.json +64 -0
@@ -0,0 +1,96 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");n.id="nostr-comments-styles",n.appendChild(document.createTextNode(':root{--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}[data-theme=dark],.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){[data-theme=auto],.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:var(--nc-bg);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:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);color:var(--nc-text-secondary);cursor:pointer;transition:background var(--nc-transition),color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-load-more:hover:not(:disabled){background:var(--nc-bg-hover);color:var(--nc-text)}.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}.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
+ "use strict";var Mc=Object.defineProperty;var Kc=(t,e,n)=>e in t?Mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var g=(t,e,n)=>Kc(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),j=require("react");class en{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 Ko(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Ws(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 jc(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ko(t.outputLen),Ko(t.blockLen)}function cn(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){Ws(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 Zs=t=>t instanceof Uint8Array,zn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ve=(t,e)=>t<<32-e|t>>>e,zc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zc)throw new Error("Non little-endian hardware is not supported");function qc(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Kr(t){if(typeof t=="string"&&(t=qc(t)),!Zs(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Vc(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Zs(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let Js=class{clone(){return this._cloneInto()}};function Fc(t){const e=r=>t().update(Kr(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Gs(t=32){if(Hn&&typeof Hn.getRandomValues=="function")return Hn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Wc(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 Zc=class extends Js{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){cn(this);const{view:n,buffer:r,blockLen:o}=this;e=Kr(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){cn(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;Wc(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 Jc=(t,e,n)=>t&e^~t&n,Gc=(t,e,n)=>t&e^t&n^e&n,Yc=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]),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),je=new Uint32Array(64);let Xc=class extends Zc{constructor(){super(64,32,8,!1),this.A=Ke[0]|0,this.B=Ke[1]|0,this.C=Ke[2]|0,this.D=Ke[3]|0,this.E=Ke[4]|0,this.F=Ke[5]|0,this.G=Ke[6]|0,this.H=Ke[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 m=je[u-15],f=je[u-2],p=ve(m,7)^ve(m,18)^m>>>3,h=ve(f,17)^ve(f,19)^f>>>10;je[u]=h+je[u-7]+p+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 m=ve(a,6)^ve(a,11)^ve(a,25),f=d+m+Jc(a,c,l)+Yc[u]+je[u]|0,h=(ve(r,2)^ve(r,13)^ve(r,22))+Gc(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)}};const pr=Fc(()=>new Xc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const Qc=BigInt(1),el=BigInt(2),kn=t=>t instanceof Uint8Array,tl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Et(t){if(!kn(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=tl[t[n]];return e}function jr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function Ot(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 ce(t){return jr(Et(t))}function Hr(t){if(!kn(t))throw new Error("Uint8Array expected");return jr(Et(Uint8Array.from(t).reverse()))}function Ge(t,e){return Ot(t.toString(16).padStart(e*2,"0"))}function zr(t,e){return Ge(t,e).reverse()}function ee(t,e,n){let r;if(typeof e=="string")try{r=Ot(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(kn(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 ct(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!kn(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}const qr=t=>(el<<BigInt(t-1))-Qc,qn=t=>new Uint8Array(t),jo=t=>Uint8Array.from(t);function Ys(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=qn(t),o=qn(t),s=0;const i=()=>{r.fill(1),o.fill(0),s=0},a=(...u)=>n(o,r,...u),c=(u=qn())=>{o=a(jo([0]),u),r=a(),u.length!==0&&(o=a(jo([1]),u),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const m=[];for(;u<e;){r=a();const f=r.slice();m.push(f),u+=r.length}return ct(...m)};return(u,m)=>{i(),c(u);let f;for(;!(f=m(l()));)c();return i(),f}}const nl={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 Ht(t,e,n={}){const r=(o,s,i)=>{const a=nl[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 rl=Object.freeze(Object.defineProperty({__proto__:null,bitMask:qr,bytesToHex:Et,bytesToNumberBE:ce,bytesToNumberLE:Hr,concatBytes:ct,createHmacDrbg:Ys,ensureBytes:ee,hexToBytes:Ot,hexToNumber:jr,numberToBytesBE:Ge,numberToBytesLE:zr,validateObject:Ht},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const X=BigInt(0),J=BigInt(1),rt=BigInt(2),ol=BigInt(3),gr=BigInt(4),Ho=BigInt(5),zo=BigInt(8);BigInt(9);BigInt(16);function Q(t,e){const n=t%e;return n>=X?n:e+n}function sl(t,e,n){if(n<=X||e<X)throw new Error("Expected power/modulo > 0");if(n===J)return X;let r=J;for(;e>X;)e&J&&(r=r*t%n),t=t*t%n,e>>=J;return r}function de(t,e,n){let r=t;for(;e-- >X;)r*=r,r%=n;return r}function yr(t,e){if(t===X||e<=X)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Q(t,e),r=e,o=X,s=J;for(;n!==X;){const a=r/n,c=r%n,l=o-s*a;r=n,n=c,o=s,s=l}if(r!==J)throw new Error("invert: does not exist");return Q(o,e)}function il(t){const e=(t-J)/rt;let n,r,o;for(n=t-J,r=0;n%rt===X;n/=rt,r++);for(o=rt;o<t&&sl(o,e,t)!==t-J;o++);if(r===1){const i=(t+J)/gr;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+J)/rt;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),m=a.pow(c,n);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let f=1;for(let h=a.sqr(m);f<l&&!a.eql(h,a.ONE);f++)h=a.sqr(h);const p=a.pow(d,J<<BigInt(l-f-1));d=a.sqr(p),u=a.mul(u,p),m=a.mul(m,d),l=f}return u}}function al(t){if(t%gr===ol){const e=(t+J)/gr;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%zo===Ho){const e=(t-Ho)/zo;return function(r,o){const s=r.mul(o,rt),i=r.pow(s,e),a=r.mul(o,i),c=r.mul(r.mul(a,rt),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 il(t)}const cl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ll(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=cl.reduce((r,o)=>(r[o]="function",r),e);return Ht(t,n)}function ul(t,e,n){if(n<X)throw new Error("Expected power > 0");if(n===X)return t.ONE;if(n===J)return e;let r=t.ONE,o=e;for(;n>X;)n&J&&(r=t.mul(r,o)),o=t.sqr(o),n>>=J;return r}function dl(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 Xs(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function hl(t,e,n=!1,r={}){if(t<=X)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:s}=Xs(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=al(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:s,MASK:qr(o),ZERO:X,ONE:J,create:c=>Q(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return X<=c&&c<t},is0:c=>c===X,isOdd:c=>(c&J)===J,neg:c=>Q(-c,t),eql:(c,l)=>c===l,sqr:c=>Q(c*c,t),add:(c,l)=>Q(c+l,t),sub:(c,l)=>Q(c-l,t),mul:(c,l)=>Q(c*l,t),pow:(c,l)=>ul(a,c,l),div:(c,l)=>Q(c*yr(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>yr(c,t),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>dl(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>n?zr(c,s):Ge(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return n?Hr(c):ce(c)}});return Object.freeze(a)}function Qs(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 ei(t){const e=Qs(t);return e+Math.ceil(e/2)}function fl(t,e,n=!1){const r=t.length,o=Qs(e),s=ei(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const i=n?ce(t):Hr(t),a=Q(i,e-J)+J;return n?zr(a,o):Ge(a,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ml=BigInt(0),Vn=BigInt(1);function pl(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>ml;)s&Vn&&(i=i.add(a)),a=a.double(),s>>=Vn;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 m=1;m<a;m++)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),m=2**o,f=BigInt(o);for(let p=0;p<a;p++){const h=p*c;let y=Number(i&u);i>>=f,y>c&&(y-=m,i+=Vn);const v=h,E=h+Math.abs(y)-1,S=p%2!==0,P=y<0;y===0?d=d.add(n(S,s[v])):l=l.add(n(P,s[E]))}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 ti(t){return ll(t.Fp),Ht(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xs(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gl(t){const e=ti(t);Ht(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:yl,hexToBytes:bl}=rl,ot={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=ot;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:yl(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=ot,n=typeof t=="string"?bl(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}=ot._parseInt(n.subarray(2)),{d:i,l:a}=ot._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}`}},Ie=BigInt(0),fe=BigInt(1);BigInt(2);const qo=BigInt(3);BigInt(4);function wl(t){const e=gl(t),{Fp:n}=e,r=e.toBytes||((p,h,y)=>{const v=h.toAffine();return ct(Uint8Array.from([4]),n.toBytes(v.x),n.toBytes(v.y))}),o=e.fromBytes||(p=>{const h=p.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(p){const{a:h,b:y}=e,v=n.sqr(p),E=n.mul(v,p);return n.add(n.add(E,n.mul(p,h)),y)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(p){return typeof p=="bigint"&&Ie<p&&p<e.n}function a(p){if(!i(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){const{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:v,n:E}=e;if(h&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=Et(p)),typeof p!="string"||!h.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let S;try{S=typeof p=="bigint"?p:ce(ee("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return v&&(S=Q(S,E)),a(S),S}const l=new Map;function d(p){if(!(p 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 E=S=>n.eql(S,n.ZERO);return E(y)&&E(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,E)=>v.toAffine(y[E])).map(u.fromAffine)}static fromHex(h){const y=u.fromAffine(o(ee("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),E=s(h);if(!n.eql(v,E))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:E}=this,{px:S,py:P,pz:M}=h,_=n.eql(n.mul(y,M),n.mul(S,E)),N=n.eql(n.mul(v,M),n.mul(P,E));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,qo),{px:E,py:S,pz:P}=this;let M=n.ZERO,_=n.ZERO,N=n.ZERO,L=n.mul(E,E),K=n.mul(S,S),$=n.mul(P,P),U=n.mul(E,S);return U=n.add(U,U),N=n.mul(E,P),N=n.add(N,N),M=n.mul(h,N),_=n.mul(v,$),_=n.add(M,_),M=n.sub(K,_),_=n.add(K,_),_=n.mul(M,_),M=n.mul(U,M),N=n.mul(v,N),$=n.mul(h,$),U=n.sub(L,$),U=n.mul(h,U),U=n.add(U,N),N=n.add(L,L),L=n.add(N,L),L=n.add(L,$),L=n.mul(L,U),_=n.add(_,L),$=n.mul(S,P),$=n.add($,$),L=n.mul($,U),M=n.sub(M,L),N=n.mul($,K),N=n.add(N,N),N=n.add(N,N),new u(M,_,N)}add(h){d(h);const{px:y,py:v,pz:E}=this,{px:S,py:P,pz:M}=h;let _=n.ZERO,N=n.ZERO,L=n.ZERO;const K=e.a,$=n.mul(e.b,qo);let U=n.mul(y,S),D=n.mul(v,P),O=n.mul(E,M),k=n.add(y,v),w=n.add(S,P);k=n.mul(k,w),w=n.add(U,D),k=n.sub(k,w),w=n.add(y,E);let x=n.add(S,M);return w=n.mul(w,x),x=n.add(U,O),w=n.sub(w,x),x=n.add(v,E),_=n.add(P,M),x=n.mul(x,_),_=n.add(D,O),x=n.sub(x,_),L=n.mul(K,w),_=n.mul($,O),L=n.add(_,L),_=n.sub(D,L),L=n.add(D,L),N=n.mul(_,L),D=n.add(U,U),D=n.add(D,U),O=n.mul(K,O),w=n.mul($,w),D=n.add(D,O),O=n.sub(U,O),O=n.mul(K,O),w=n.add(w,O),U=n.mul(D,w),N=n.add(N,U),U=n.mul(x,w),_=n.mul(k,_),_=n.sub(_,U),U=n.mul(k,D),L=n.mul(x,L),L=n.add(L,U),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(E=>E.pz));return y.map((E,S)=>E.toAffine(v[S])).map(u.fromAffine)})}multiplyUnsafe(h){const y=u.ZERO;if(h===Ie)return y;if(a(h),h===fe)return this;const{endo:v}=e;if(!v)return f.unsafeLadder(this,h);let{k1neg:E,k1:S,k2neg:P,k2:M}=v.splitScalar(h),_=y,N=y,L=this;for(;S>Ie||M>Ie;)S&fe&&(_=_.add(L)),M&fe&&(N=N.add(L)),L=L.double(),S>>=fe,M>>=fe;return E&&(_=_.negate()),P&&(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,E;const{endo:S}=e;if(S){const{k1neg:P,k1:M,k2neg:_,k2:N}=S.splitScalar(y);let{p:L,f:K}=this.wNAF(M),{p:$,f:U}=this.wNAF(N);L=f.constTimeNegate(P,L),$=f.constTimeNegate(_,$),$=new u(n.mul($.px,S.beta),$.py,$.pz),v=L.add($),E=K.add(U)}else{const{p:P,f:M}=this.wNAF(y);v=P,E=M}return u.normalizeZ([v,E])[0]}multiplyAndAddUnsafe(h,y,v){const E=u.BASE,S=(M,_)=>_===Ie||_===fe||!M.equals(E)?M.multiplyUnsafe(_):M.multiply(_),P=S(this,y).add(S(h,v));return P.is0()?void 0:P}toAffine(h){const{px:y,py:v,pz:E}=this,S=this.is0();h==null&&(h=S?n.ONE:n.inv(E));const P=n.mul(y,h),M=n.mul(v,h),_=n.mul(E,h);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:P,y:M}}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 Et(this.toRawBytes(h))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const m=e.nBitLength,f=pl(u,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function vl(t){const e=ti(t);return Ht(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function xl(t){const e=vl(t),{Fp:n,n:r}=e,o=n.BYTES+1,s=2*n.BYTES+1;function i(w){return Ie<w&&w<n.ORDER}function a(w){return Q(w,r)}function c(w){return yr(w,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:u,isWithinCurveOrder:m}=wl({...e,toBytes(w,x,A){const I=x.toAffine(),C=n.toBytes(I.x),R=ct;return A?R(Uint8Array.from([x.hasEvenY()?2:3]),C):R(Uint8Array.from([4]),C,n.toBytes(I.y))},fromBytes(w){const x=w.length,A=w[0],I=w.subarray(1);if(x===o&&(A===2||A===3)){const C=ce(I);if(!i(C))throw new Error("Point is not on curve");const R=u(C);let B=n.sqrt(R);const T=(B&fe)===fe;return(A&1)===1!==T&&(B=n.neg(B)),{x:C,y:B}}else if(x===s&&A===4){const C=n.fromBytes(I.subarray(0,n.BYTES)),R=n.fromBytes(I.subarray(n.BYTES,2*n.BYTES));return{x:C,y:R}}else throw new Error(`Point of length ${x} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),f=w=>Et(Ge(w,e.nByteLength));function p(w){const x=r>>fe;return w>x}function h(w){return p(w)?a(-w):w}const y=(w,x,A)=>ce(w.slice(x,A));class v{constructor(x,A,I){this.r=x,this.s=A,this.recovery=I,this.assertValidity()}static fromCompact(x){const A=e.nByteLength;return x=ee("compactSignature",x,A*2),new v(y(x,0,A),y(x,A,2*A))}static fromDER(x){const{r:A,s:I}=ot.toSig(ee("DER",x));return new v(A,I)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(x){return new v(this.r,this.s,x)}recoverPublicKey(x){const{r:A,s:I,recovery:C}=this,R=N(ee("msgHash",x));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 T=(C&1)===0?"02":"03",H=l.fromHex(T+f(B)),z=c(B),F=a(-R*z),q=a(I*z),G=l.BASE.multiplyAndAddUnsafe(H,F,q);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Ot(this.toDERHex())}toDERHex(){return ot.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ot(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const E={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=ei(e.n);return fl(e.randomBytes(w),e.n)},precompute(w=8,x=l.BASE){return x._setWindowSize(w),x.multiply(BigInt(3)),x}};function S(w,x=!0){return l.fromPrivateKey(w).toRawBytes(x)}function P(w){const x=w instanceof Uint8Array,A=typeof w=="string",I=(x||A)&&w.length;return x?I===o||I===s:A?I===2*o||I===2*s:w instanceof l}function M(w,x,A=!0){if(P(w))throw new Error("first arg must be private key");if(!P(x))throw new Error("second arg must be public key");return l.fromHex(x).multiply(d(w)).toRawBytes(A)}const _=e.bits2int||function(w){const x=ce(w),A=w.length*8-e.nBitLength;return A>0?x>>BigInt(A):x},N=e.bits2int_modN||function(w){return a(_(w))},L=qr(e.nBitLength);function K(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(Ie<=w&&w<L))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ge(w,e.nByteLength)}function $(w,x,A=U){if(["recovered","canonical"].some(se=>se in A))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:C}=e;let{lowS:R,prehash:B,extraEntropy:T}=A;R==null&&(R=!0),w=ee("msgHash",w),B&&(w=ee("prehashed msgHash",I(w)));const H=N(w),z=d(x),F=[K(z),K(H)];if(T!=null){const se=T===!0?C(n.BYTES):T;F.push(ee("extraEntropy",se))}const q=ct(...F),G=H;function ne(se){const Z=_(se);if(!m(Z))return;const ue=c(Z),ht=l.BASE.multiply(Z).toAffine(),me=a(ht.x);if(me===Ie)return;const ft=a(ue*a(G+me*z));if(ft===Ie)return;let Do=(ht.x===me?0:2)|Number(ht.y&fe),Mo=ft;return R&&p(ft)&&(Mo=h(ft),Do^=1),new v(me,Mo,Do)}return{seed:q,k2sig:ne}}const U={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function O(w,x,A=U){const{seed:I,k2sig:C}=$(w,x,A),R=e;return Ys(R.hash.outputLen,R.nByteLength,R.hmac)(I,C)}l.BASE._setWindowSize(8);function k(w,x,A,I=D){var ht;const C=w;if(x=ee("msgHash",x),A=ee("publicKey",A),"strict"in I)throw new Error("options.strict was renamed to lowS");const{lowS:R,prehash:B}=I;let T,H;try{if(typeof C=="string"||C instanceof Uint8Array)try{T=v.fromDER(C)}catch(me){if(!(me instanceof ot.Err))throw me;T=v.fromCompact(C)}else if(typeof C=="object"&&typeof C.r=="bigint"&&typeof C.s=="bigint"){const{r:me,s:ft}=C;T=new v(me,ft)}else throw new Error("PARSE");H=l.fromHex(A)}catch(me){if(me.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(R&&T.hasHighS())return!1;B&&(x=e.hash(x));const{r:z,s:F}=T,q=N(x),G=c(F),ne=a(q*G),se=a(z*G),Z=(ht=l.BASE.multiplyAndAddUnsafe(H,ne,se))==null?void 0:ht.toAffine();return Z?a(Z.x)===z:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:M,sign:O,verify:k,ProjectivePoint:l,Signature:v,utils:E}}let ni=class extends Js{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,jc(e);const r=Kr(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 cn(this),this.iHash.update(e),this}digestInto(e){cn(this),Ws(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 ri=(t,e,n)=>new ni(t,e).update(n).digest();ri.create=(t,e)=>new ni(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function El(t){return{hash:t,hmac:(e,...n)=>ri(t,e,Vc(...n)),randomBytes:Gs}}function kl(t,e){const n=r=>xl({...t,...El(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _n=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ln=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),oi=BigInt(1),un=BigInt(2),Vo=(t,e)=>(t+e/un)/e;function si(t){const e=_n,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=de(d,n,e)*d%e,m=de(u,n,e)*d%e,f=de(m,un,e)*l%e,p=de(f,o,e)*f%e,h=de(p,s,e)*p%e,y=de(h,a,e)*h%e,v=de(y,c,e)*y%e,E=de(v,a,e)*h%e,S=de(E,n,e)*d%e,P=de(S,i,e)*p%e,M=de(P,r,e)*l%e,_=de(M,un,e);if(!br.eql(br.sqr(_),t))throw new Error("Cannot find square root");return _}const br=hl(_n,void 0,void 0,{sqrt:si}),ut=kl({a:BigInt(0),b:BigInt(7),Fp:br,n:ln,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ln,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-oi*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,i=BigInt("0x100000000000000000000000000000000"),a=Vo(s*t,e),c=Vo(-r*t,e);let l=Q(t-a*n-c*o,e),d=Q(-a*r-c*s,e);const u=l>i,m=d>i;if(u&&(l=e-l),m&&(d=e-d),l>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:m,k2:d}}}},pr),An=BigInt(0),ii=t=>typeof t=="bigint"&&An<t&&t<_n,_l=t=>typeof t=="bigint"&&An<t&&t<ln,Fo={};function dn(t,...e){let n=Fo[t];if(n===void 0){const r=pr(Uint8Array.from(t,o=>o.charCodeAt(0)));n=ct(r,r),Fo[t]=n}return pr(ct(n,...e))}const Vr=t=>t.toRawBytes(!0).slice(1),wr=t=>Ge(t,32),Fn=t=>Q(t,_n),Dt=t=>Q(t,ln),Fr=ut.ProjectivePoint,Al=(t,e,n)=>Fr.BASE.multiplyAndAddUnsafe(t,e,n);function vr(t){let e=ut.utils.normPrivateKeyToScalar(t),n=Fr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Dt(-e),bytes:Vr(n)}}function ai(t){if(!ii(t))throw new Error("bad x: need 0 < x < p");const e=Fn(t*t),n=Fn(e*t+BigInt(7));let r=si(n);r%un!==An&&(r=Fn(-r));const o=new Fr(t,r,oi);return o.assertValidity(),o}function ci(...t){return Dt(ce(dn("BIP0340/challenge",...t)))}function Sl(t){return vr(t).bytes}function Nl(t,e,n=Gs(32)){const r=ee("message",t),{bytes:o,scalar:s}=vr(e),i=ee("auxRand",n,32),a=wr(s^ce(dn("BIP0340/aux",i))),c=dn("BIP0340/nonce",a,o,r),l=Dt(ce(c));if(l===An)throw new Error("sign failed: k is zero");const{bytes:d,scalar:u}=vr(l),m=ci(d,o,r),f=new Uint8Array(64);if(f.set(d,0),f.set(wr(Dt(u+m*s)),32),!li(f,r,o))throw new Error("sign: Invalid signature produced");return f}function li(t,e,n){const r=ee("signature",t,64),o=ee("message",e),s=ee("publicKey",n,32);try{const i=ai(ce(s)),a=ce(r.subarray(0,32));if(!ii(a))return!1;const c=ce(r.subarray(32,64));if(!_l(c))return!1;const l=ci(wr(a),Vr(i),o),d=Al(i,c,Dt(-l));return!(!d||!d.hasEvenY()||d.toAffine().x!==a)}catch{return!1}}const ke={getPublicKey:Sl,sign:Nl,verify:li,utils:{randomPrivateKey:ut.utils.randomPrivateKey,lift_x:ai,pointToBytes:Vr,numberToBytesBE:Ge,bytesToNumberBE:ce,taggedHash:dn,mod:Q}},Wn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wr=t=>t instanceof Uint8Array,Zn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),xe=(t,e)=>t<<32-e|t>>>e,Cl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Cl)throw new Error("Non little-endian hardware is not supported");const Bl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Y(t){if(!Wr(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Bl[t[n]];return e}function lt(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 Ll(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Mt(t){if(typeof t=="string"&&(t=Ll(t)),!Wr(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function dt(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Wr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class ui{clone(){return this._cloneInto()}}function di(t){const e=r=>t().update(Mt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Zr(t=32){if(Wn&&typeof Wn.getRandomValues=="function")return Wn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function xr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Il(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function hi(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 Rl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xr(t.outputLen),xr(t.blockLen)}function $l(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 Tl(t,e){hi(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const _e={number:xr,bool:Il,bytes:hi,hash:Rl,exists:$l,output:Tl};function Pl(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 Ul extends ui{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){_e.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=Mt(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){_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;Pl(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 Ol=(t,e,n)=>t&e^~t&n,Dl=(t,e,n)=>t&e^t&n^e&n,Ml=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);class fi extends Ul{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 m=ze[u-15],f=ze[u-2],p=xe(m,7)^xe(m,18)^m>>>3,h=xe(f,17)^xe(f,19)^f>>>10;ze[u]=h+ze[u-7]+p+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 m=xe(a,6)^xe(a,11)^xe(a,25),f=d+m+Ol(a,c,l)+Ml[u]+ze[u]|0,h=(xe(r,2)^xe(r,13)^xe(r,22))+Dl(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)}}class Kl extends fi{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 be=di(()=>new fi);di(()=>new Kl);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Nt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Pe(...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 Ue(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(Nt(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 Oe(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 Sn(t,e="="){if(Nt(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 mi(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function Wo(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(Nt(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 pi=(t,e)=>e?pi(e,t%e):t,hn=(t,e)=>t+(e-pi(t,e));function Er(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(hn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${hn(e,n)}`);let o=0,s=0;const i=2**n-1,a=[];for(const c of t){if(Nt(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 jl(t){return Nt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Wo(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(Wo(e,t,2**8))}}}function Ye(t,e=!1){if(Nt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(hn(8,t)>32||hn(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 Er(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(Er(n,t,8,e))}}}function Zo(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Hl=Pe(Ye(4),Ue("0123456789ABCDEF"),Oe("")),zl=Pe(Ye(5),Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Sn(5),Oe(""));Pe(Ye(5),Ue("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Sn(5),Oe(""));Pe(Ye(5),Ue("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Oe(""),mi(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const ge=Pe(Ye(6),Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Sn(6),Oe("")),ql=Pe(Ye(6),Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Sn(6),Oe("")),Jr=t=>Pe(jl(58),Ue(t),Oe("")),kr=Jr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Jr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");Jr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Jo=[0,2,3,5,6,7,9,10,11],Vl={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=kr.encode(r).padStart(Jo[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=Jo.indexOf(r.length),s=kr.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)}},_r=Pe(Ue("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Oe("")),Go=[996825010,642813549,513874426,1027748829,705979059];function Lt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Go.length;r++)(e>>r&1)===1&&(n^=Go[r]);return n}function Yo(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=Lt(o)^i>>5}o=Lt(o);for(let s=0;s<r;s++)o=Lt(o)^t.charCodeAt(s)&31;for(let s of e)o=Lt(o)^s;for(let s=0;s<6;s++)o=Lt(o);return o^=n,_r.encode(Er([o%2**30],30,5,!1))}function gi(t){const e=t==="bech32"?1:734539939,n=Ye(5),r=n.decode,o=n.encode,s=Zo(r);function i(d,u,m=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(m!==!1&&f>m)throw new TypeError(`Length ${f} exceeds limit ${m}`);return d=d.toLowerCase(),`${d}1${_r.encode(u)}${Yo(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 m=d.toLowerCase();if(d!==m&&d!==d.toUpperCase())throw new Error("String must be lowercase or uppercase");d=m;const f=d.lastIndexOf("1");if(f===0||f===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=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=_r.decode(h).slice(0,-6),v=Yo(p,y,e);if(!h.endsWith(v))throw new Error(`Invalid checksum in ${d}: expected "${v}"`);return{prefix:p,words:y}}const c=Zo(a);function l(d){const{prefix:u,words:m}=a(d,!1);return{prefix:u,words:m,bytes:r(m)}}return{encode:i,decode:a,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const kt=gi("bech32");gi("bech32m");const Fl={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Wl=Pe(Ye(4),Ue("0123456789abcdef"),Oe(""),mi(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()})),Zl={utf8:Fl,hex:Wl,base16:Hl,base32:zl,base64:ge,base64url:ql,base58:kr,base58xmr:Vl};`${Object.keys(Zl).join(", ")}`;function Jn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Xo(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 te=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Gl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Gl)throw new Error("Non little-endian hardware is not supported");const Yl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function mt(t){Ae(t);let e="";for(let n=0;n<t.length;n++)e+=Yl[t[n]];return e}const Ce={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Qo(t){if(t>=Ce._0&&t<=Ce._9)return t-Ce._0;if(t>=Ce._A&&t<=Ce._F)return t-(Ce._A-10);if(t>=Ce._a&&t<=Ce._f)return t-(Ce._a-10)}function yi(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=Qo(t.charCodeAt(s)),a=Qo(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 Xl(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function bi(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 Ql=(t,e)=>(Object.assign(e,t),e),Je=16,eu=283;function Gr(t){return t<<1^eu&-(t>>7)}function wt(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=Gr(t);return n}const Ar=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Gr(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})(),tu=Ar.map((t,e)=>Ar.indexOf(e)),nu=t=>t<<24|t>>>8,Gn=t=>t<<8|t>>>24;function wi(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(Gn),o=r.map(Gn),s=o.map(Gn),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 Yr=wi(Ar,t=>wt(t,3)<<24|t<<16|t<<8|wt(t,2)),vi=wi(tu,t=>wt(t,11)<<24|wt(t,13)<<16|wt(t,9)<<8|wt(t,14)),ru=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=Gr(n))t[e]=n;return t})();function xi(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}=Yr,r=te(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(nu(c))^ru[a/o-1]:o>6&&a%o===4&&(c=s(c)),i[a]=i[a-o]^c}return i}function ou(t){const e=xi(t),n=e.slice(),r=e.length,{sbox2:o}=Yr,{T0:s,T1:i,T2:a,T3:c}=vi;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 es(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=Yr;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let p=0;p<l;p++){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),E=t[c++]^Ze(i,a,o,e,n,r);e=h,n=y,r=v,o=E}const d=t[c++]^Se(s,e,n,r,o),u=t[c++]^Se(s,n,r,o,e),m=t[c++]^Se(s,r,o,e,n),f=t[c++]^Se(s,o,e,n,r);return{s0:d,s1:u,s2:m,s3:f}}function su(t,e,n,r,o){const{sbox2:s,T01:i,T23:a}=vi;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let p=0;p<l;p++){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),E=t[c++]^Ze(i,a,o,r,n,e);e=h,n=y,r=v,o=E}const d=t[c++]^Se(s,e,o,r,n),u=t[c++]^Se(s,n,e,o,r),m=t[c++]^Se(s,r,n,e,o),f=t[c++]^Se(s,o,r,n,e);return{s0:d,s1:u,s2:m,s3:f}}function Ei(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 iu(t){if(Ae(t),t.length%Je!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Je}`)}function au(t,e,n){let r=t.length;const o=r%Je;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=te(t);if(e){let c=Je-o;c||(c=Je),r=r+c}const i=Ei(r,n),a=te(i);return{b:s,o:a,out:i}}function cu(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 lu(t){const e=new Uint8Array(16),n=te(e);e.set(t);const r=Je-t.length;for(let o=Je-r;o<Je;o++)e[o]=r;return n}const ki=Ql({blockSize:16,nonceLength:16},function(e,n,r={}){Ae(e),Ae(n,16);const o=!r.disablePadding;return{encrypt:(s,i)=>{const a=xi(e),{b:c,o:l,out:d}=au(s,o,i),u=te(n);let m=u[0],f=u[1],p=u[2],h=u[3],y=0;for(;y+4<=c.length;)m^=c[y+0],f^=c[y+1],p^=c[y+2],h^=c[y+3],{s0:m,s1:f,s2:p,s3:h}=es(a,m,f,p,h),l[y++]=m,l[y++]=f,l[y++]=p,l[y++]=h;if(o){const v=lu(s.subarray(y*4));m^=v[0],f^=v[1],p^=v[2],h^=v[3],{s0:m,s1:f,s2:p,s3:h}=es(a,m,f,p,h),l[y++]=m,l[y++]=f,l[y++]=p,l[y++]=h}return a.fill(0),d},decrypt:(s,i)=>{iu(s);const a=ou(e),c=te(n),l=Ei(s.length,i),d=te(s),u=te(l);let m=c[0],f=c[1],p=c[2],h=c[3];for(let y=0;y+4<=d.length;){const v=m,E=f,S=p,P=h;m=d[y+0],f=d[y+1],p=d[y+2],h=d[y+3];const{s0:M,s1:_,s2:N,s3:L}=su(a,m,f,p,h);u[y++]=M^v,u[y++]=_^E,u[y++]=N^S,u[y++]=L^P}return a.fill(0),cu(l,o)}}}),_i=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),uu=_i("expand 16-byte k"),du=_i("expand 32-byte k"),hu=te(uu),Ai=te(du);Ai.slice();function V(t,e){return t<<e|t>>>32-e}function Sr(t){return t.byteOffset%4===0}const Ft=64,fu=16,Si=2**32-1,ts=new Uint32Array;function mu(t,e,n,r,o,s,i,a){const c=o.length,l=new Uint8Array(Ft),d=te(l),u=Sr(o)&&Sr(s),m=u?te(o):ts,f=u?te(s):ts;for(let p=0;p<c;i++){if(t(e,n,r,d,i,a),i>=Si)throw new Error("arx: counter overflow");const h=Math.min(Ft,c-p);if(u&&h===Ft){const y=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let v=0,E;v<fu;v++)E=y+v,f[E]=m[E]^d[v];p+=Ft;continue}for(let y=0,v;y<h;y++)v=p+y,s[v]=o[v]^l[y];p+=h}}function pu(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=Xl({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Jn(o),Jn(i),Xo(s),Xo(n),(a,c,l,d,u=0)=>{Ae(a),Ae(c),Ae(l);const m=l.length;if(d||(d=new Uint8Array(m)),Ae(d),Jn(u),u<0||u>=Si)throw new Error("arx: counter overflow");if(d.length<m)throw new Error(`arx: output (${d.length}) is shorter than data (${m})`);const f=[];let p=a.length,h,y;if(p===32)h=a.slice(),f.push(h),y=Ai;else if(p===16&&n)h=new Uint8Array(32),h.set(a),h.set(a,16),y=hu,f.push(h);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Sr(c)||(c=c.slice(),f.push(c));const v=te(h);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(y,v,te(c.subarray(0,16)),v),c=c.subarray(16)}const E=16-o;if(E!==c.length)throw new Error(`arx: nonce must be ${E} or 16 bytes`);if(E!==12){const P=new Uint8Array(12);P.set(c,s?0:12-c.length),c=P,f.push(c)}const S=te(c);for(mu(t,y,v,S,l,d,u,i);f.length>0;)f.pop().fill(0);return d}}function gu(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],m=e[2],f=e[3],p=e[4],h=e[5],y=e[6],v=e[7],E=o,S=n[0],P=n[1],M=n[2],_=i,N=a,L=c,K=l,$=d,U=u,D=m,O=f,k=p,w=h,x=y,A=v,I=E,C=S,R=P,B=M;for(let H=0;H<s;H+=2)_=_+$|0,I=V(I^_,16),k=k+I|0,$=V($^k,12),_=_+$|0,I=V(I^_,8),k=k+I|0,$=V($^k,7),N=N+U|0,C=V(C^N,16),w=w+C|0,U=V(U^w,12),N=N+U|0,C=V(C^N,8),w=w+C|0,U=V(U^w,7),L=L+D|0,R=V(R^L,16),x=x+R|0,D=V(D^x,12),L=L+D|0,R=V(R^L,8),x=x+R|0,D=V(D^x,7),K=K+O|0,B=V(B^K,16),A=A+B|0,O=V(O^A,12),K=K+O|0,B=V(B^K,8),A=A+B|0,O=V(O^A,7),_=_+U|0,B=V(B^_,16),x=x+B|0,U=V(U^x,12),_=_+U|0,B=V(B^_,8),x=x+B|0,U=V(U^x,7),N=N+D|0,I=V(I^N,16),A=A+I|0,D=V(D^A,12),N=N+D|0,I=V(I^N,8),A=A+I|0,D=V(D^A,7),L=L+O|0,C=V(C^L,16),k=k+C|0,O=V(O^k,12),L=L+O|0,C=V(C^L,8),k=k+C|0,O=V(O^k,7),K=K+$|0,R=V(R^K,16),w=w+R|0,$=V($^w,12),K=K+$|0,R=V(R^K,8),w=w+R|0,$=V($^w,7);let T=0;r[T++]=i+_|0,r[T++]=a+N|0,r[T++]=c+L|0,r[T++]=l+K|0,r[T++]=d+$|0,r[T++]=u+U|0,r[T++]=m+D|0,r[T++]=f+O|0,r[T++]=p+k|0,r[T++]=h+w|0,r[T++]=y+x|0,r[T++]=v+A|0,r[T++]=E+I|0,r[T++]=S+C|0,r[T++]=P+R|0,r[T++]=M+B|0}const Nn=pu(gu,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Ni extends ui{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,_e.hash(e);const r=Mt(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 zt=(t,e,n)=>new Ni(t,e).update(n).digest();zt.create=(t,e)=>new Ni(t,e);function Ci(t,e,n){return _e.hash(t),zt(t,Mt(n),Mt(e))}const Yn=new Uint8Array([0]),ns=new Uint8Array;function Bi(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=ns);const s=new Uint8Array(o*t.outputLen),i=zt.create(t,e),a=i._cloneInto(),c=new Uint8Array(i.outputLen);for(let l=0;l<o;l++)Yn[0]=l+1,a.update(l===0?ns:c).update(n).update(Yn).digestInto(c),s.set(c,t.outputLen*l),i._cloneInto(a);return i.destroy(),a.destroy(),c.fill(0),Yn.fill(0),s.slice(0,r)}var yu=Object.defineProperty,W=(t,e)=>{for(var n in e)yu(t,n,{get:e[n],enumerable:!0})},pt=Symbol("verified"),bu=t=>t instanceof Object;function Xr(t){if(!bu(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 wu={};W(wu,{Queue:()=>ku,QueueNode:()=>Li,binarySearch:()=>Qr,bytesToHex:()=>Y,hexToBytes:()=>lt,insertEventIntoAscendingList:()=>Eu,insertEventIntoDescendingList:()=>xu,normalizeURL:()=>vu,utf8Decoder:()=>Te,utf8Encoder:()=>ye});var Te=new TextDecoder("utf-8"),ye=new TextEncoder;function vu(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 xu(t,e){const[n,r]=Qr(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 Eu(t,e){const[n,r]=Qr(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 Qr(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 Li=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},ku=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Li(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}},_u=class{generateSecretKey(){return ke.utils.randomPrivateKey()}getPublicKey(e){return Y(ke.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(ke.getPublicKey(n)),r.id=tn(r),r.sig=Y(ke.sign(tn(r),n)),r[pt]=!0,r}verifyEvent(e){if(typeof e[pt]=="boolean")return e[pt];const n=tn(e);if(n!==e.id)return e[pt]=!1,!1;try{const r=ke.verify(e.sig,n,e.pubkey);return e[pt]=r,r}catch{return e[pt]=!1,!1}}};function Au(t){if(!Xr(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 tn(t){let e=be(ye.encode(Au(t)));return Y(e)}var Cn=new _u,eo=Cn.generateSecretKey,Bn=Cn.getPublicKey,we=Cn.finalizeEvent,to=Cn.verifyEvent,Su={};W(Su,{Application:()=>Dd,BadgeAward:()=>Tu,BadgeDefinition:()=>Id,BlockedRelaysList:()=>fd,BlossomServerList:()=>vd,BookmarkList:()=>ud,Bookmarksets:()=>Cd,Calendar:()=>Vd,CalendarEventRSVP:()=>Fd,ChannelCreation:()=>Ui,ChannelHideMessage:()=>Mi,ChannelMessage:()=>Di,ChannelMetadata:()=>Oi,ChannelMuteUser:()=>Ki,ChatMessage:()=>Pu,ClassifiedListing:()=>jd,ClientAuth:()=>Hi,Comment:()=>qu,CommunitiesList:()=>dd,CommunityDefinition:()=>Gd,CommunityPostApproval:()=>Xu,Contacts:()=>Iu,CreateOrUpdateProduct:()=>Td,CreateOrUpdateStall:()=>$d,Curationsets:()=>Bd,Date:()=>zd,DirectMessageRelaysList:()=>bd,DraftClassifiedListing:()=>Hd,DraftLong:()=>Ud,Emojisets:()=>Od,EncryptedDirectMessage:()=>Ru,EventDeletion:()=>$u,FavoriteRelays:()=>pd,FileMessage:()=>Ou,FileMetadata:()=>zu,FileServerPreference:()=>wd,Followsets:()=>Ad,ForumThread:()=>Uu,GenericRepost:()=>io,Genericlists:()=>Sd,GiftWrap:()=>ji,GroupMetadata:()=>Yd,HTTPAuth:()=>ao,Handlerinformation:()=>Jd,Handlerrecommendation:()=>Zd,Highlights:()=>sd,InterestsList:()=>gd,Interestsets:()=>Rd,JobFeedback:()=>td,JobRequest:()=>Qu,JobResult:()=>ed,Label:()=>Yu,LightningPubRPC:()=>Ed,LiveChatMessage:()=>Vu,LiveEvent:()=>Md,LongFormArticle:()=>Pd,Metadata:()=>Bu,Mutelist:()=>ad,NWCWalletInfo:()=>xd,NWCWalletRequest:()=>zi,NWCWalletResponse:()=>kd,NormalVideo:()=>Mu,NostrConnect:()=>_d,OpenTimestamps:()=>ju,Photo:()=>Du,Pinlist:()=>cd,Poll:()=>Hu,PollResponse:()=>id,PrivateDirectMessage:()=>Pi,ProblemTracker:()=>Zu,ProfileBadges:()=>Ld,PublicChatsList:()=>hd,Reaction:()=>so,RecommendRelay:()=>Lu,RelayList:()=>ld,RelayReview:()=>Wd,Relaysets:()=>Nd,Report:()=>Ju,Reporting:()=>Gu,Repost:()=>oo,Seal:()=>Ti,SearchRelaysList:()=>md,ShortTextNote:()=>$i,ShortVideo:()=>Ku,Time:()=>qd,UserEmojiList:()=>yd,UserStatuses:()=>Kd,Voice:()=>Fu,VoiceComment:()=>Wu,Zap:()=>od,ZapGoal:()=>nd,ZapRequest:()=>rd,classifyKind:()=>Nu,isAddressableKind:()=>ro,isEphemeralKind:()=>Ri,isKind:()=>Cu,isRegularKind:()=>Ii,isReplaceableKind:()=>no});function Ii(t){return t<1e4&&t!==0&&t!==3}function no(t){return t===0||t===3||1e4<=t&&t<2e4}function Ri(t){return 2e4<=t&&t<3e4}function ro(t){return 3e4<=t&&t<4e4}function Nu(t){return Ii(t)?"regular":no(t)?"replaceable":Ri(t)?"ephemeral":ro(t)?"parameterized":"unknown"}function Cu(t,e){const n=e instanceof Array?e:[e];return Xr(t)&&n.includes(t.kind)||!1}var Bu=0,$i=1,Lu=2,Iu=3,Ru=4,$u=5,oo=6,so=7,Tu=8,Pu=9,Uu=11,Ti=13,Pi=14,Ou=15,io=16,Du=20,Mu=21,Ku=22,Ui=40,Oi=41,Di=42,Mi=43,Ki=44,ju=1040,ji=1059,Hu=1068,zu=1063,qu=1111,Vu=1311,Fu=1222,Wu=1244,Zu=1971,Ju=1984,Gu=1984,Yu=1985,Xu=4550,Qu=5999,ed=6999,td=7e3,nd=9041,rd=9734,od=9735,sd=9802,id=1018,ad=1e4,cd=10001,ld=10002,ud=10003,dd=10004,hd=10005,fd=10006,md=10007,pd=10012,gd=10015,yd=10030,bd=10050,wd=10096,vd=10063,xd=13194,Ed=21e3,Hi=22242,zi=23194,kd=23195,_d=24133,ao=27235,Ad=3e4,Sd=30001,Nd=30002,Cd=30003,Bd=30004,Ld=30008,Id=30009,Rd=30015,$d=30017,Td=30018,Pd=30023,Ud=30024,Od=30030,Dd=30078,Md=30311,Kd=30315,jd=30402,Hd=30403,zd=31922,qd=31923,Vd=31924,Fd=31925,Wd=31987,Zd=31989,Jd=31990,Gd=34550,Yd=39e3,Xd={};W(Xd,{getHex64:()=>co,getInt:()=>qi,getSubscriptionId:()=>Qd,matchEventId:()=>eh,matchEventKind:()=>nh,matchEventPubkey:()=>th});function co(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 qi(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 Qd(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 eh(t,e){return e===co(t,"id")}function th(t,e){return e===co(t,"pubkey")}function nh(t,e){return e===qi(t,"kind")}var rh={};W(rh,{makeAuthEvent:()=>oh});function oh(t,e){return{kind:Hi,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}var sh;try{sh=WebSocket}catch{}var ih;try{ih=WebSocket}catch{}var vt={};W(vt,{BECH32_REGEX:()=>Vi,Bech32MaxSize:()=>lo,NostrTypeGuard:()=>ah,decode:()=>Ln,decodeNostrURI:()=>lh,encodeBytes:()=>Rn,naddrEncode:()=>ph,neventEncode:()=>mh,noteEncode:()=>hh,nprofileEncode:()=>fh,npubEncode:()=>dh,nsecEncode:()=>uh});var ah={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||"")},lo=5e3,Vi=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function ch(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 lh(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}=kt.decode(t,lo),r=new Uint8Array(kt.fromWords(n));switch(e){case"nprofile":{let u=Xn(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(m=>Te.decode(m)):[]}}}case"nevent":{let u=Xn(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(m=>Te.decode(m)):[],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=Xn(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:Te.decode(u[0][0]),pubkey:Y(u[2][0]),kind:parseInt(Y(u[3][0]),16),relays:u[1]?u[1].map(m=>Te.decode(m)):[]}}}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 Xn(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 uh(t){return Rn("nsec",t)}function dh(t){return Rn("npub",lt(t))}function hh(t){return Rn("note",lt(t))}function In(t,e){let n=kt.toWords(e);return kt.encode(t,n,lo)}function Rn(t,e){return In(t,e)}function fh(t){let e=uo({0:[lt(t.pubkey)],1:(t.relays||[]).map(n=>ye.encode(n))});return In("nprofile",e)}function mh(t){let e;t.kind!==void 0&&(e=ch(t.kind));let n=uo({0:[lt(t.id)],1:(t.relays||[]).map(r=>ye.encode(r)),2:t.author?[lt(t.author)]:[],3:e?[new Uint8Array(e)]:[]});return In("nevent",n)}function ph(t){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,t.kind,!1);let n=uo({0:[ye.encode(t.identifier)],1:(t.relays||[]).map(r=>ye.encode(r)),2:[lt(t.pubkey)],3:[new Uint8Array(e)]});return In("naddr",n)}function uo(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)})}),dt(...e)}var gh={};W(gh,{decrypt:()=>yh,encrypt:()=>Fi});function Fi(t,e,n){const r=t instanceof Uint8Array?Y(t):t,o=ut.getSharedSecret(r,"02"+e),s=Wi(o);let i=Uint8Array.from(Zr(16)),a=ye.encode(n),c=ki(s,i).encrypt(a),l=ge.encode(new Uint8Array(c)),d=ge.encode(new Uint8Array(i.buffer));return`${l}?iv=${d}`}function yh(t,e,n){const r=t instanceof Uint8Array?Y(t):t;let[o,s]=n.split("?iv="),i=ut.getSharedSecret(r,"02"+e),a=Wi(i),c=ge.decode(s),l=ge.decode(o),d=ki(a,c).decrypt(l);return Te.decode(d)}function Wi(t){return t.slice(1,33)}var bh={};W(bh,{NIP05_REGEX:()=>ho,isNip05:()=>wh,isValid:()=>Eh,queryProfile:()=>Zi,searchDomain:()=>xh,useFetchImplementation:()=>vh});var ho=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,wh=t=>ho.test(t||""),$n;try{$n=fetch}catch{}function vh(t){$n=t}async function xh(t,e=""){try{const n=`https://${t}/.well-known/nostr.json?name=${e}`,r=await $n(n,{redirect:"manual"});if(r.status!==200)throw Error("Wrong response code");return(await r.json()).names}catch{return{}}}async function Zi(t){var o;const e=t.match(ho);if(!e)return null;const[,n="_",r]=e;try{const s=`https://${r}/.well-known/nostr.json?name=${n}`,i=await $n(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 Eh(t,e){const n=await Zi(e);return n?n.pubkey===t:!1}var kh={};W(kh,{parse:()=>_h});function _h(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 Ah={};W(Ah,{fetchRelayInformation:()=>Nh,useFetchImplementation:()=>Sh});var Ji;try{Ji=fetch}catch{}function Sh(t){Ji=t}async function Nh(t){return await(await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var Ch={};W(Ch,{fastEventHash:()=>Yi,getPow:()=>Gi,minePow:()=>Bh});function Gi(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 Bh(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=Yi(r),Gi(r.id)>=e)break}return r}function Yi(t){return Y(be(ye.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}var Lh={};W(Lh,{unwrapEvent:()=>Hh,unwrapManyEvents:()=>zh,wrapEvent:()=>ua,wrapManyEvents:()=>jh});var Ih={};W(Ih,{createRumor:()=>ia,createSeal:()=>aa,createWrap:()=>ca,unwrapEvent:()=>yo,unwrapManyEvents:()=>la,wrapEvent:()=>fn,wrapManyEvents:()=>Mh});var Rh={};W(Rh,{decrypt:()=>go,encrypt:()=>po,getConversationKey:()=>fo,v2:()=>Oh});var Xi=1,Qi=65535;function fo(t,e){const n=ut.getSharedSecret(t,"02"+e).subarray(1,33);return Ci(be,n,"nip44-v2")}function ea(t,e){const n=Bi(be,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function mo(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 $h(t){if(!Number.isSafeInteger(t)||t<Xi||t>Qi)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 Th(t){const e=ye.encode(t),n=e.length,r=$h(n),o=new Uint8Array(mo(n)-n);return dt(r,e,o)}function Ph(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Xi||e>Qi||n.length!==e||t.length!==2+mo(e))throw new Error("invalid padding");return Te.decode(n)}function ta(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=dt(n,e);return zt(be,t,r)}function Uh(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 po(t,e,n=Zr(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=ea(e,n),i=Th(t),a=Nn(r,o,i),c=ta(s,a,n);return ge.encode(dt(new Uint8Array([2]),n,a,c))}function go(t,e){const{nonce:n,ciphertext:r,mac:o}=Uh(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=ea(e,n),c=ta(a,r,n);if(!bi(c,o))throw new Error("invalid MAC");const l=Nn(s,i,r);return Ph(l)}var Oh={utils:{getConversationKey:fo,calcPaddedLen:mo},encrypt:po,decrypt:go},Dh=2880*60,na=()=>Math.round(Date.now()/1e3),ra=()=>Math.round(na()-Math.random()*Dh),oa=(t,e)=>fo(t,e),sa=(t,e,n)=>po(JSON.stringify(t),oa(e,n)),rs=(t,e)=>JSON.parse(go(t.content,oa(e,t.pubkey)));function ia(t,e){const n={created_at:na(),content:"",tags:[],...t,pubkey:Bn(e)};return n.id=tn(n),n}function aa(t,e,n){return we({kind:Ti,content:sa(t,e,n),created_at:ra(),tags:[]},e)}function ca(t,e){const n=eo();return we({kind:ji,content:sa(t,n,e),created_at:ra(),tags:[["p",e]]},n)}function fn(t,e,n){const r=ia(t,e),o=aa(r,e,n);return ca(o,n)}function Mh(t,e,n){if(!n||n.length===0)throw new Error("At least one recipient is required.");const r=Bn(e),o=[fn(t,e,r)];return n.forEach(s=>{o.push(fn(t,e,s))}),o}function yo(t,e){const n=rs(t,e);return rs(n,e)}function la(t,e){let n=[];return t.forEach(r=>{n.push(yo(r,e))}),n.sort((r,o)=>r.created_at-o.created_at),n}function Kh(t,e,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:Pi,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 ua(t,e,n,r,o){const s=Kh(e,n,r,o);return fn(s,t,e.publicKey)}function jh(t,e,n,r,o){if(!e||e.length===0)throw new Error("At least one recipient is required.");return[{publicKey:Bn(t)},...e].map(i=>ua(t,i,n,r,o))}var Hh=yo,zh=la,qh={};W(qh,{finishRepostEvent:()=>Vh,getRepostedEvent:()=>Fh,getRepostedEventPointer:()=>da});function Vh(t,e,n,r){var i;let o;const s=[...t.tags??[],["e",e.id,n],["p",e.pubkey]];return e.kind===$i?o=oo:(o=io,s.push(["k",String(e.kind)])),we({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 da(t){if(![oo,io].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 Fh(t,{skipVerification:e}={}){const n=da(t);if(n===void 0||t.content==="")return;let r;try{r=JSON.parse(t.content)}catch{return}if(r.id===n.id&&!(!e&&!to(r)))return r}var Wh={};W(Wh,{NOSTR_URI_REGEX:()=>bo,parse:()=>Jh,test:()=>Zh});var bo=new RegExp(`nostr:(${Vi.source})`);function Zh(t){return typeof t=="string"&&new RegExp(`^${bo.source}$`).test(t)}function Jh(t){const e=t.match(new RegExp(`^${bo.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:Ln(e[1])}}var Gh={};W(Gh,{finishReactionEvent:()=>Yh,getReactedEventPointer:()=>Xh});function Yh(t,e,n){const r=e.tags.filter(o=>o.length>=2&&(o[0]==="e"||o[0]==="p"));return we({...t,kind:so,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function Xh(t){if(t.kind!==so)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 Qh={};W(Qh,{parse:()=>tf});var os=/\W/m,ss=/[^\w\/] |[^\w\/]$|$|,| /m,ef=42;function*tf(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+ef).match(os),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(os),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(ss),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(ss),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 nf={};W(nf,{channelCreateEvent:()=>rf,channelHideMessageEvent:()=>af,channelMessageEvent:()=>sf,channelMetadataEvent:()=>of,channelMuteUserEvent:()=>cf});var rf=(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 we({kind:Ui,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},of=(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 we({kind:Oi,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},sf=(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"]),we({kind:Di,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},af=(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 we({kind:Mi,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},cf=(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 we({kind:Ki,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)},lf={};W(lf,{EMOJI_SHORTCODE_REGEX:()=>ha,matchAll:()=>uf,regex:()=>wo,replaceAll:()=>df});var ha=/:(\w+):/,wo=()=>new RegExp(`\\B${ha.source}\\B`,"g");function*uf(t){const e=t.matchAll(wo());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 df(t,e){return t.replaceAll(wo(),(n,r)=>e({shortcode:n,name:r}))}var hf={};W(hf,{useFetchImplementation:()=>ff,validateGithub:()=>mf});var vo;try{vo=fetch}catch{}function ff(t){vo=t}async function mf(t,e,n){try{return await(await vo(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch{return!1}}var pf={};W(pf,{makeNwcRequestEvent:()=>yf,parseConnectionString:()=>gf});function gf(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 yf(t,e,n){const o=Fi(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:n}})),s={kind:zi,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",t]]};return we(s,e)}var bf={};W(bf,{normalizeIdentifier:()=>wf});function wf(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 vf={};W(vf,{getSatoshisAmountFromBolt11:()=>Sf,getZapEndpoint:()=>Ef,makeZapReceipt:()=>Af,makeZapRequest:()=>kf,useFetchImplementation:()=>xf,validateZapRequest:()=>_f});var xo;try{xo=fetch}catch{}function xf(t){xo=t}async function Ef(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}=kt.decode(n,1e3),a=kt.fromWords(i);e=Te.decode(a)}else return null;let s=await(await xo(e)).json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch{}return null}function kf(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]),no(t.event.kind)){const n=["a",`${t.event.kind}:${t.event.pubkey}:`];e.tags.push(n)}else if(ro(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 _f(t){let e;try{e=JSON.parse(t)}catch{return"Invalid zap request JSON."}if(!Xr(e))return"Zap request is not a valid Nostr event.";if(!to(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 Af({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 Sf(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 Nf={};W(Nf,{Negentropy:()=>ma,NegentropyStorageVector:()=>Lf,NegentropySync:()=>If});var Qn=97,xt=32,fa=16,et={Skip:0,Fingerprint:1,IdList:2},Re=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 Re&&(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 Wt(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 Le(t){if(t===0)return new Re(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 Re(new Uint8Array(e))}function Cf(t){return nn(t,1)[0]}function nn(t,e){if(t.length<e)throw Error("parse ends prematurely");return t.shiftN(e)}var Bf=class{constructor(){g(this,"buf");this.setToZero()}setToZero(){this.buf=new Uint8Array(xt)}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(xt);e[0]=1,this.add(e)}getFingerprint(t){let e=new Re;return e.extend(this.buf),e.extend(Le(t)),be(e.unwrap()).subarray(0,fa)}},Lf=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=yi(e);if(n.byteLength!==xt)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(er);for(let t=1;t<this.items.length;t++)if(er(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=>er(r,n)<0)}fingerprint(t,e){let n=new Bf;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}},ma=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 Re;return t.extend(new Uint8Array([Qn])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),mt(t.unwrap())}reconcile(t,e,n){const r=new Re(yi(t));this.lastTimestampIn=this.lastTimestampOut=0;let o=new Re;o.extend(new Uint8Array([Qn]));let s=Cf(r);if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(s!==Qn)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 Re,u=()=>{l&&(l=!1,d.extend(this.encodeBound(a)),d.extend(Le(et.Skip)))},m=this.decodeBound(r),f=Wt(r),p=c,h=this.storage.findLowerBound(c,i,m);if(f===et.Skip)l=!0;else if(f===et.Fingerprint){let y=nn(r,fa),v=this.storage.fingerprint(p,h);pa(y,v)!==0?(u(),this.splitRange(p,h,m,d)):l=!0}else if(f===et.IdList){let y=Wt(r),v={};for(let E=0;E<y;E++){let S=nn(r,xt);v[mt(S)]=S}if(l=!0,this.storage.iterate(p,h,E=>{let S=E.id;const P=mt(S);return v[P]?delete v[mt(S)]:e==null||e(P),!0}),n)for(let E of Object.values(v))n(mt(E))}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(Le(et.Fingerprint)),o.extend(y);break}else o.extend(d);c=h,a=m}return o.length===1?null:mt(o.unwrap())}splitRange(t,e,n,r){let o=e-t,s=16;if(o<s*2)r.extend(this.encodeBound(n)),r.extend(Le(et.IdList)),r.extend(Le(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 m;if(c===e)m=n;else{let f,p;this.storage.iterate(c-1,c+1,(h,y)=>(y===c-1?f=h:p=h,!0)),m=this.getMinimalBound(f,p)}r.extend(this.encodeBound(m)),r.extend(Le(et.Fingerprint)),r.extend(u)}}}exceededFrameSizeLimit(t){return t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=Wt(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=Wt(t);if(n>xt)throw Error("bound key too long");let r=nn(t,n);return{timestamp:e,id:r}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,Le(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,Le(t+1)}encodeBound(t){let e=new Re;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(Le(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<xt&&r[s]===o[s];s++)n++;return this._bound(e.timestamp,e.id.subarray(0,n+1))}}};function pa(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 er(t,e){return t.timestamp===e.timestamp?pa(t.id,e.id):t.timestamp-e.timestamp}var If=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 ma(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()}},Rf={};W(Rf,{getToken:()=>$f,hashPayload:()=>Eo,unpackEventFromToken:()=>ya,validateEvent:()=>ka,validateEventKind:()=>wa,validateEventMethodTag:()=>xa,validateEventPayloadTag:()=>Ea,validateEventTimestamp:()=>ba,validateEventUrlTag:()=>va,validateToken:()=>Tf});var ga="Nostr ";async function $f(t,e,n,r=!1,o){const s={kind:ao,tags:[["u",t],["method",e]],created_at:Math.round(new Date().getTime()/1e3),content:""};o&&s.tags.push(["payload",Eo(o)]);const i=await n(s);return(r?ga:"")+ge.encode(ye.encode(JSON.stringify(i)))}async function Tf(t,e,n){const r=await ya(t).catch(s=>{throw s});return await ka(r,e,n).catch(s=>{throw s})}async function ya(t){if(!t)throw new Error("Missing token");t=t.replace(ga,"");const e=Te.decode(ge.decode(t));if(!e||e.length===0||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}function ba(t){return t.created_at?Math.round(new Date().getTime()/1e3)-t.created_at<60:!1}function wa(t){return t.kind===ao}function va(t,e){const n=t.tags.find(r=>r[0]==="u");return n?n.length>0&&n[1]===e:!1}function xa(t,e){const n=t.tags.find(r=>r[0]==="method");return n?n.length>0&&n[1].toLowerCase()===e.toLowerCase():!1}function Eo(t){const e=be(ye.encode(JSON.stringify(t)));return Y(e)}function Ea(t,e){const n=t.tags.find(o=>o[0]==="payload");if(!n)return!1;const r=Eo(e);return n.length>0&&n[1]===r}async function ka(t,e,n,r){if(!to(t))throw new Error("Invalid nostr event, signature invalid");if(!wa(t))throw new Error("Invalid nostr event, kind invalid");if(!ba(t))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!va(t,e))throw new Error("Invalid nostr event, url tag invalid");if(!xa(t,n))throw new Error("Invalid nostr event, method tag invalid");if(r&&typeof r=="object"&&Object.keys(r).length>0&&!Ea(t,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}class _t{constructor(e){g(this,"secretKey");g(this,"pubkey");this.secretKey=e||eo(),this.pubkey=Bn(this.secretKey)}async getPublicKey(){return this.pubkey}async signEvent(e){return we(e,this.secretKey)}getNsec(){return vt.nsecEncode(this.secretKey)}getNpub(){return vt.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}=vt.decode(e);if(n!=="nsec")throw new Error("Invalid nsec");return new _t(r)}}var tt=Symbol("verified"),Pf=t=>t instanceof Object;function Uf(t){if(!Pf(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 Of=new TextDecoder("utf-8"),_a=new TextEncoder;function yt(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 Df=class{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}},Mf=class{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Df(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}},Kf=class{generateSecretKey(){return ke.utils.randomPrivateKey()}getPublicKey(e){return Y(ke.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=Y(ke.getPublicKey(n)),r.id=tr(r),r.sig=Y(ke.sign(tr(r),n)),r[tt]=!0,r}verifyEvent(e){if(typeof e[tt]=="boolean")return e[tt];const n=tr(e);if(n!==e.id)return e[tt]=!1,!1;try{const r=ke.verify(e.sig,n,e.pubkey);return e[tt]=r,r}catch{return e[tt]=!1,!1}}};function jf(t){if(!Uf(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 tr(t){let e=be(_a.encode(jf(t)));return Y(e)}var Tn=new Kf;Tn.generateSecretKey;var is=Tn.getPublicKey,Hf=Tn.finalizeEvent,Aa=Tn.verifyEvent,Sa=1,Na=65535;function nr(t,e){const n=ut.getSharedSecret(t,"02"+e).subarray(1,33);return Ci(be,n,"nip44-v2")}function Ca(t,e){const n=Bi(be,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Ba(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 zf(t){if(!Number.isSafeInteger(t)||t<Sa||t>Na)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 qf(t){const e=_a.encode(t),n=e.length,r=zf(n),o=new Uint8Array(Ba(n)-n);return dt(r,e,o)}function Vf(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Sa||e>Na||n.length!==e||t.length!==2+Ba(e))throw new Error("invalid padding");return Of.decode(n)}function La(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=dt(n,e);return zt(be,t,r)}function Ff(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 Wf(t,e,n=Zr(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=Ca(e,n),i=qf(t),a=Nn(r,o,i),c=La(s,a,n);return ge.encode(dt(new Uint8Array([2]),n,a,c))}function as(t,e){const{nonce:n,ciphertext:r,mac:o}=Ff(t),{chacha_key:s,chacha_nonce:i,hmac_key:a}=Ca(e,n),c=La(a,r,n);if(!bi(c,o))throw new Error("invalid MAC");const l=Nn(s,i,r);return Vf(l)}var Zf=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Jf;try{Jf=fetch}catch{}var Gf=22242,rr=24133;function Yf(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 Xf(t,e){for(let n=0;n<t.length;n++)if(Yf(t[n],e))return!0;return!1}function Qf(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 em(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 tm(t,e){return{kind:Gf,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function nm(){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 rm=t=>(t[tt]=!0,!0),Ia=class extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}},Ra=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 Mf);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=yt(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 Ra(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 nm();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=em(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=Qf(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)&&Xf(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(tm(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 om(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()}},om=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 Ia))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},sm=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=yt(e);let r=this.relays.get(e);if(r||(r=new Ra(e,{verifyEvent:this.trustedRelayURLs.has(e)?rm: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(yt).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=yt(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=yt(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:p,filter:h}=f;r.has(p)||r.set(p,[]),r.get(p).push(h)}const o=Array.from(r.entries()).map(([f,p])=>({url:f,filters:p}));this.trackRelays&&(n.receivedEvent=(f,p)=>{let h=this.seenOn.get(p);h||(h=new Set,this.seenOn.set(p,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var p;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((p=n.oneose)==null||p.call(n),c=()=>{}))};const l=[];let d=(f,p)=>{var h;l[f]||(c(f),l[f]=p,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 p=s.has(f);return s.add(f),p},m=Promise.all(o.map(async({url:f,filters:p},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(E){d(h,(E==null?void 0:E.message)||String(E));return}let v=y.subscribe(p,{...n,oneose:()=>c(h),onclose:E=>{E.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(p,{...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,E)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await m,i.forEach(p=>{p.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(yt).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}},$a;try{$a=WebSocket}catch{}var im=class extends sm{constructor(e){super({verifyEvent:Aa,websocketImplementation:$a,...e})}},Ta;try{Ta=fetch}catch{}var am=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function cm(t){let e=t.match(am);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 lm(t)}async function lm(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 Ta(s,{redirect:"error"})).json();let a=i.names[r],c=i.nip46[a]||[];return{pubkey:a,relays:c,secret:null}}catch{return null}}var Nr=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 im,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 Nr(e,r);return o.conversationKey=nr(e,n.pubkey),o.bp=n,o.setupSubscription(),o}static async fromURI(e,n,r={},o=3e5){const s=new Nr(e,r),i=new URL(n),a=is(e);return new Promise((c,l)=>{let d=!1;const u=s.pool.subscribe(i.searchParams.getAll("relay"),{kinds:[rr],"#p":[a],limit:0},{onevent:async m=>{try{const f=nr(e,m.pubkey),p=as(m.content,f);JSON.parse(p).result===i.searchParams.get("secret")&&(u.close(),s.bp={pubkey:m.pubkey,relays:i.searchParams.getAll("relay"),secret:i.searchParams.get("secret")},s.conversationKey=nr(e,m.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:[rr],authors:[this.bp.pubkey],"#p":[is(this.secretKey)],limit:0},{onevent:async o=>{const s=JSON.parse(as(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=Wf(JSON.stringify({id:s,method:e,params:n}),this.conversationKey),a=Hf({kind:rr,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(Aa(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 Pn{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 cm(e);if(!n)throw new Error("Invalid bunker input");const r=Nr.fromBunker(eo(),n,{onauth:o=>{window.open(o,"_blank")}});return new Pn(r)}}let $e={signer:null,signerInfo:null,loading:!1,error:null};const Cr=new Set;function re(t){$e={...$e,...t},Cr.forEach(e=>e())}function um(t){return Cr.add(t),()=>Cr.delete(t)}function cs(){return $e}function dm(){return $e.signer!==null}function Ct(){const{signer:t,signerInfo:e,loading:n,error:r}=j.useSyncExternalStore(um,cs,cs),o=j.useCallback(async()=>{if(!en.isAvailable()){re({error:"NIP-07 extension not found"});return}re({loading:!0,error:null});try{const u=new en,m=await u.getPublicKey();re({signer:u,signerInfo:{type:"nip07",pubkey:m},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),s=j.useCallback(async()=>{re({loading:!0,error:null});try{const u=new _t,m=await u.getPublicKey();re({signer:u,signerInfo:{type:"temp",pubkey:m},loading:!1})}catch(u){re({error:u instanceof Error?u.message:"Login failed",loading:!1})}},[]),i=j.useCallback(async u=>{re({loading:!0,error:null});try{const m=_t.fromNsec(u.trim()),f=await m.getPublicKey();re({signer:m,signerInfo:{type:"temp",pubkey:f},loading:!1})}catch(m){throw re({error:m instanceof Error?m.message:"Invalid nsec",loading:!1}),m}},[]),a=j.useCallback(async u=>{re({loading:!0,error:null});try{const m=await Pn.create(u);await m.connect();const f=await m.getPublicKey();re({signer:m,signerInfo:{type:"bunker",pubkey:f},loading:!1})}catch(m){re({error:m instanceof Error?m.message:"Login failed",loading:!1})}},[]),c=j.useCallback(()=>{var u;((u=$e.signerInfo)==null?void 0:u.type)==="bunker"&&$e.signer&&$e.signer.close(),re({signer:null,signerInfo:null,error:null})},[]),l=j.useCallback(()=>{re({error:null})},[]),d=j.useCallback(()=>{var u;return((u=$e.signerInfo)==null?void 0:u.type)==="temp"?$e.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:en.isAvailable()}}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function hm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ko(t,e=""){if(!Number.isSafeInteger(t)||t<0){const n=e&&`"${e}" `;throw new Error(`${n}expected integer >= 0, got ${t}`)}}function le(t,e,n=""){const r=hm(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 ls(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 fm(t,e){le(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 Br(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function or(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ee(t,e){return t<<32-e|t>>>e}const Pa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",mm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ie(t){if(le(t),Pa)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=mm[t[n]];return e}const Be={_0:48,_9:57,A:65,F:70,a:97,f:102};function us(t){if(t>=Be._0&&t<=Be._9)return t-Be._0;if(t>=Be.A&&t<=Be.F)return t-(Be.A-10);if(t>=Be.a&&t<=Be.f)return t-(Be.a-10)}function st(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Pa)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=us(t.charCodeAt(s)),a=us(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 mn(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];le(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 pm(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 Ua(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 gm=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ym(t,e,n){return t&e^~t&n}function bm(t,e,n){return t&e^t&n^e&n}class wm{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=or(this.buffer)}update(e){ls(this),le(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=or(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){ls(this),fm(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,Br(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=or(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 qe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vm=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]),Ve=new Uint32Array(64);class xm extends wm{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)Ve[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const m=Ve[u-15],f=Ve[u-2],p=Ee(m,7)^Ee(m,18)^m>>>3,h=Ee(f,17)^Ee(f,19)^f>>>10;Ve[u]=h+Ve[u-7]+p+Ve[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 m=Ee(a,6)^Ee(a,11)^Ee(a,25),f=d+m+ym(a,c,l)+vm[u]+Ve[u]|0,h=(Ee(r,2)^Ee(r,13)^Ee(r,22))+bm(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(){Br(Ve)}destroy(){this.set(0,0,0,0,0,0,0,0),Br(this.buffer)}}class Em extends xm{constructor(){super(32);g(this,"A",qe[0]|0);g(this,"B",qe[1]|0);g(this,"C",qe[2]|0);g(this,"D",qe[3]|0);g(this,"E",qe[4]|0);g(this,"F",qe[5]|0);g(this,"G",qe[6]|0);g(this,"H",qe[7]|0)}}const Lr=pm(()=>new Em,gm(1)),_o=BigInt(0),Ir=BigInt(1);function ds(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}" `;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function km(t){if(typeof t=="bigint"){if(!Am(t))throw new Error("positive bigint expected, got "+t)}else ko(t);return t}function Oa(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?_o:BigInt("0x"+t)}function Ao(t){return Oa(ie(t))}function Da(t){return Oa(ie(_m(le(t)).reverse()))}function So(t,e){ko(e),t=km(t);const n=st(t.toString(16).padStart(e*2,"0"));if(n.length!==e)throw new Error("number too large");return n}function Ma(t,e){return So(t,e).reverse()}function _m(t){return Uint8Array.from(t)}function Ka(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 Am=t=>typeof t=="bigint"&&_o<=t;function Sm(t){let e;for(e=0;t>_o;t>>=Ir,e+=1);return e}const ja=t=>(Ir<<BigInt(t))-Ir;function Ha(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 hs(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 ae=BigInt(0),oe=BigInt(1),it=BigInt(2),za=BigInt(3),qa=BigInt(4),Va=BigInt(5),Nm=BigInt(7),Fa=BigInt(8),Cm=BigInt(9),Wa=BigInt(16);function pe(t,e){const n=t%e;return n>=ae?n:e+n}function he(t,e,n){let r=t;for(;e-- >ae;)r*=r,r%=n;return r}function fs(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let n=pe(t,e),r=e,o=ae,s=oe;for(;n!==ae;){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 pe(o,e)}function No(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function Za(t,e){const n=(t.ORDER+oe)/qa,r=t.pow(e,n);return No(t,r,e),r}function Bm(t,e){const n=(t.ORDER-Va)/Fa,r=t.mul(e,it),o=t.pow(r,n),s=t.mul(e,o),i=t.mul(t.mul(s,it),o),a=t.mul(s,t.sub(i,t.ONE));return No(t,a,e),a}function Lm(t){const e=Un(t),n=Ja(t),r=n(e,e.neg(e.ONE)),o=n(e,r),s=n(e,e.neg(r)),i=(t+Nm)/Wa;return(a,c)=>{let l=a.pow(c,i),d=a.mul(l,r);const u=a.mul(l,o),m=a.mul(l,s),f=a.eql(a.sqr(d),c),p=a.eql(a.sqr(u),c);l=a.cmov(l,d,f),d=a.cmov(m,u,p);const h=a.eql(a.sqr(d),c),y=a.cmov(l,d,h);return No(a,y,c),y}}function Ja(t){if(t<za)throw new Error("sqrt is not defined for small field");let e=t-oe,n=0;for(;e%it===ae;)e/=it,n++;let r=it;const o=Un(t);for(;ms(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Za;let s=o.pow(r,e);const i=(e+oe)/it;return function(c,l){if(c.is0(l))return l;if(ms(c,l)!==1)throw new Error("Cannot find square root");let d=n,u=c.mul(c.ONE,s),m=c.pow(l,e),f=c.pow(l,i);for(;!c.eql(m,c.ONE);){if(c.is0(m))return c.ZERO;let p=1,h=c.sqr(m);for(;!c.eql(h,c.ONE);)if(p++,h=c.sqr(h),p===d)throw new Error("Cannot find square root");const y=oe<<BigInt(d-p-1),v=c.pow(u,y);d=p,u=c.sqr(v),m=c.mul(m,u),f=c.mul(f,v)}return f}}function Im(t){return t%qa===za?Za:t%Fa===Va?Bm:t%Wa===Cm?Lm(t):Ja(t)}const Rm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $m(t){const e={ORDER:"bigint",BYTES:"number",BITS:"number"},n=Rm.reduce((r,o)=>(r[o]="function",r),e);return Ha(t,n),t}function Tm(t,e,n){if(n<ae)throw new Error("invalid exponent, negatives unsupported");if(n===ae)return t.ONE;if(n===oe)return e;let r=t.ONE,o=e;for(;n>ae;)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 ms(t,e){const n=(t.ORDER-oe)/it,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 Pm(t,e){e!==void 0&&ko(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}class Um{constructor(e,n={}){g(this,"ORDER");g(this,"BITS");g(this,"BYTES");g(this,"isLE");g(this,"ZERO",ae);g(this,"ONE",oe);g(this,"_lengths");g(this,"_sqrt");g(this,"_mod");var i;if(e<=ae)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}=Pm(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 pe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return ae<=e&&e<this.ORDER}is0(e){return e===ae}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&oe)===oe}neg(e){return pe(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return pe(e*e,this.ORDER)}add(e,n){return pe(e+n,this.ORDER)}sub(e,n){return pe(e-n,this.ORDER)}mul(e,n){return pe(e*n,this.ORDER)}pow(e,n){return Tm(this,e,n)}div(e,n){return pe(e*fs(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 fs(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=Im(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?Ma(e,this.BYTES):So(e,this.BYTES)}fromBytes(e,n=!1){le(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?Da(e):Ao(e);if(a&&(c=pe(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 Un(t,e={}){return new Um(t,e)}function Ya(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 Om(t){const e=Ya(t);return e+Math.ceil(e/2)}function Dm(t,e,n=!1){le(t);const r=t.length,o=Ya(e),s=Om(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?Da(t):Ao(t),a=pe(i,e-oe)+oe;return n?Ma(a,o):So(a,o)}const At=BigInt(0),at=BigInt(1);function pn(t,e){const n=e.negate();return t?n:e}function ps(t,e){const n=Ga(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 sr(t,e){Xa(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),o=2**t,s=ja(t),i=BigInt(t);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function gs(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+=at);const l=e*r,d=l+Math.abs(a)-1,u=a===0,m=a<0,f=e%2!==0;return{nextN:c,offset:d,isZero:u,isNeg:m,isNegF:f,offsetF:l}}const ir=new WeakMap,Qa=new WeakMap;function ar(t){return Qa.get(t)||1}function ys(t){if(t!==At)throw new Error("invalid wNAF")}class Mm{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>At;)n&at&&(r=r.add(o)),o=o.double(),n>>=at;return r}precomputeWindow(e,n){const{windows:r,windowSize:o}=sr(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=sr(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:c,offset:l,isZero:d,isNeg:u,isNegF:m,offsetF:f}=gs(r,a,i);r=c,d?s=s.add(pn(m,n[f])):o=o.add(pn(u,n[l]))}return ys(r),{p:o,f:s}}wNAFUnsafe(e,n,r,o=this.ZERO){const s=sr(e,this.bits);for(let i=0;i<s.windows&&r!==At;i++){const{nextN:a,offset:c,isZero:l,isNeg:d}=gs(r,i,s);if(r=a,!l){const u=n[c];o=o.add(d?u.negate():u)}}return ys(r),o}getPrecomputes(e,n,r){let o=ir.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(o=r(o)),ir.set(n,o))),o}cached(e,n,r){const o=ar(e);return this.wNAF(o,this.getPrecomputes(o,e,r),n)}unsafe(e,n,r,o){const s=ar(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),Qa.set(e,n),ir.delete(e)}hasCache(e){return ar(e)!==1}}function Km(t,e,n,r){let o=e,s=t.ZERO,i=t.ZERO;for(;n>At||r>At;)n&at&&(s=s.add(o)),r&at&&(i=i.add(o)),o=o.double(),n>>=at,r>>=at;return{p1:s,p2:i}}function bs(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return $m(e),e}else return Un(t,{isLE:n})}function jm(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>At))throw new Error(`CURVE.${c} must be positive bigint`)}const o=bs(e.p,n.Fp,r),s=bs(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 Hm(t,e){return function(r){const o=t(r);return{secretKey:o,publicKey:e(o)}}}Ka("HashToScalar-");const ws=(t,e)=>(t+(t>=0?e:-e)/qm)/e;function zm(t,e,n){const[[r,o],[s,i]]=e,a=ws(i*t,n),c=ws(-o*t,n);let l=t-a*r-c*s,d=-a*o-c*i;const u=l<Tt,m=d<Tt;u&&(l=-l),m&&(d=-d);const f=ja(Math.ceil(Sm(n)/2))+rn;if(l<Tt||l>=f||d<Tt||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:u,k1:l,k2neg:m,k2:d}}const Tt=BigInt(0),rn=BigInt(1),qm=BigInt(2),Zt=BigInt(3),Vm=BigInt(4);function Fm(t,e={}){const n=jm("weierstrass",t,e),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:a}=s;Ha(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=Zm(r,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(O,k,w){const{x,y:A}=k.toAffine(),I=r.toBytes(x);if(ds(w,"isCompressed"),w){d();const C=!r.isOdd(A);return mn(Wm(C),I)}else return mn(Uint8Array.of(4),I,r.toBytes(A))}function m(O){le(O,void 0,"Point");const{publicKey:k,publicKeyUncompressed:w}=l,x=O.length,A=O[0],I=O.subarray(1);if(x===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 R=h(C);let B;try{B=r.sqrt(R)}catch(z){const F=z instanceof Error?": "+z.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}d();const T=r.isOdd(B);return(A&1)===1!==T&&(B=r.neg(B)),{x:C,y:B}}else if(x===w&&A===4){const C=r.BYTES,R=r.fromBytes(I.subarray(0,C)),B=r.fromBytes(I.subarray(C,C*2));if(!y(R,B))throw new Error("bad point: is not on curve");return{x:R,y:B}}else throw new Error(`bad point: got length ${x}, expected compressed=${k} or uncompressed=${w}`)}const f=e.toBytes||u,p=e.fromBytes||m;function h(O){const k=r.sqr(O),w=r.mul(k,O);return r.add(r.add(w,r.mul(O,s.a)),s.b)}function y(O,k){const w=r.sqr(k),x=h(O);return r.eql(w,x)}if(!y(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const v=r.mul(r.pow(s.a,Zt),Vm),E=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(v,E)))throw new Error("bad curve params: a or b");function S(O,k,w=!1){if(!r.isValid(k)||w&&r.is0(k))throw new Error(`bad point coordinate ${O}`);return k}function P(O){if(!(O instanceof K))throw new Error("Weierstrass Point expected")}function M(O){if(!c||!c.basises)throw new Error("no endo");return zm(O,c.basises,o.ORDER)}const _=hs((O,k)=>{const{X:w,Y:x,Z:A}=O;if(r.eql(A,r.ONE))return{x:w,y:x};const I=O.is0();k==null&&(k=I?r.ONE:r.inv(A));const C=r.mul(w,k),R=r.mul(x,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:R}}),N=hs(O=>{if(O.is0()){if(e.allowInfinityPoint&&!r.is0(O.Y))return;throw new Error("bad point: ZERO")}const{x:k,y:w}=O.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(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(O,k,w,x,A){return w=new K(r.mul(w.X,O),w.Y,w.Z),k=pn(x,k),w=pn(A,w),k.add(w)}const D=class D{constructor(k,w,x){g(this,"X");g(this,"Y");g(this,"Z");this.X=S("x",k),this.Y=S("y",w,!0),this.Z=S("z",x),Object.freeze(this)}static CURVE(){return s}static fromAffine(k){const{x:w,y:x}=k||{};if(!k||!r.isValid(w)||!r.isValid(x))throw new Error("invalid affine point");if(k instanceof D)throw new Error("projective point not allowed");return r.is0(w)&&r.is0(x)?D.ZERO:new D(w,x,r.ONE)}static fromBytes(k){const w=D.fromAffine(p(le(k,void 0,"point")));return w.assertValidity(),w}static fromHex(k){return D.fromBytes(st(k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,w=!0){return U.createCache(this,k),w||this.multiply(Zt),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){P(k);const{X:w,Y:x,Z:A}=this,{X:I,Y:C,Z:R}=k,B=r.eql(r.mul(w,R),r.mul(I,A)),T=r.eql(r.mul(x,R),r.mul(C,A));return B&&T}negate(){return new D(this.X,r.neg(this.Y),this.Z)}double(){const{a:k,b:w}=s,x=r.mul(w,Zt),{X:A,Y:I,Z:C}=this;let R=r.ZERO,B=r.ZERO,T=r.ZERO,H=r.mul(A,A),z=r.mul(I,I),F=r.mul(C,C),q=r.mul(A,I);return q=r.add(q,q),T=r.mul(A,C),T=r.add(T,T),R=r.mul(k,T),B=r.mul(x,F),B=r.add(R,B),R=r.sub(z,B),B=r.add(z,B),B=r.mul(R,B),R=r.mul(q,R),T=r.mul(x,T),F=r.mul(k,F),q=r.sub(H,F),q=r.mul(k,q),q=r.add(q,T),T=r.add(H,H),H=r.add(T,H),H=r.add(H,F),H=r.mul(H,q),B=r.add(B,H),F=r.mul(I,C),F=r.add(F,F),H=r.mul(F,q),R=r.sub(R,H),T=r.mul(F,z),T=r.add(T,T),T=r.add(T,T),new D(R,B,T)}add(k){P(k);const{X:w,Y:x,Z:A}=this,{X:I,Y:C,Z:R}=k;let B=r.ZERO,T=r.ZERO,H=r.ZERO;const z=s.a,F=r.mul(s.b,Zt);let q=r.mul(w,I),G=r.mul(x,C),ne=r.mul(A,R),se=r.add(w,x),Z=r.add(I,C);se=r.mul(se,Z),Z=r.add(q,G),se=r.sub(se,Z),Z=r.add(w,A);let ue=r.add(I,R);return Z=r.mul(Z,ue),ue=r.add(q,ne),Z=r.sub(Z,ue),ue=r.add(x,A),B=r.add(C,R),ue=r.mul(ue,B),B=r.add(G,ne),ue=r.sub(ue,B),H=r.mul(z,Z),B=r.mul(F,ne),H=r.add(B,H),B=r.sub(G,H),H=r.add(G,H),T=r.mul(B,H),G=r.add(q,q),G=r.add(G,q),ne=r.mul(z,ne),Z=r.mul(F,Z),G=r.add(G,ne),ne=r.sub(q,ne),ne=r.mul(z,ne),Z=r.add(Z,ne),q=r.mul(G,Z),T=r.add(T,q),q=r.mul(ue,Z),B=r.mul(se,B),B=r.sub(B,q),q=r.mul(se,G),H=r.mul(ue,H),H=r.add(H,q),new D(B,T,H)}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 x,A;const I=C=>U.cached(this,C,R=>ps(D,R));if(w){const{k1neg:C,k1:R,k2neg:B,k2:T}=M(k),{p:H,f:z}=I(R),{p:F,f:q}=I(T);A=z.add(q),x=L(w.beta,H,F,C,B)}else{const{p:C,f:R}=I(k);x=C,A=R}return ps(D,[x,A])[0]}multiplyUnsafe(k){const{endo:w}=e,x=this;if(!o.isValid(k))throw new Error("invalid scalar: out of range");if(k===Tt||x.is0())return D.ZERO;if(k===rn)return x;if(U.hasCache(this))return this.multiply(k);if(w){const{k1neg:A,k1:I,k2neg:C,k2:R}=M(k),{p1:B,p2:T}=Km(D,x,I,R);return L(w.beta,B,T,A,C)}else return U.unsafe(x,k)}toAffine(k){return _(this,k)}isTorsionFree(){const{isTorsionFree:k}=e;return i===rn?!0:k?k(D,this):U.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:k}=e;return i===rn?this:k?k(D,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(k=!0){return ds(k,"isCompressed"),this.assertValidity(),f(D,this,k)}toHex(k=!0){return ie(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 K=D;const $=o.BITS,U=new Mm(K,e.endo?Math.ceil($/2):$);return K.BASE.precompute(8),K}function Wm(t){return Uint8Array.of(t?2:3)}function Zm(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}const On={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Jm={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Gm=BigInt(0),Rr=BigInt(2);function Ym(t){const e=On.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=he(d,n,e)*d%e,m=he(u,n,e)*d%e,f=he(m,Rr,e)*l%e,p=he(f,o,e)*f%e,h=he(p,s,e)*p%e,y=he(h,a,e)*h%e,v=he(y,c,e)*y%e,E=he(v,a,e)*h%e,S=he(E,n,e)*d%e,P=he(S,i,e)*p%e,M=he(P,r,e)*l%e,_=he(M,Rr,e);if(!gn.eql(gn.sqr(_),t))throw new Error("Cannot find square root");return _}const gn=Un(On.p,{sqrt:Ym}),Bt=Fm(On,{Fp:gn,endo:Jm}),vs={};function yn(t,...e){let n=vs[t];if(n===void 0){const r=Lr(Ka(t));n=mn(r,r),vs[t]=n}return Lr(mn(n,...e))}const Co=t=>t.toBytes(!0).slice(1),Bo=t=>t%Rr===Gm;function $r(t){const{Fn:e,BASE:n}=Bt,r=e.fromBytes(t),o=n.multiply(r);return{scalar:Bo(o.y)?r:e.neg(r),bytes:Co(o)}}function ec(t){const e=gn;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);Bo(o)||(o=e.neg(o));const s=Bt.fromAffine({x:t,y:o});return s.assertValidity(),s}const Ut=Ao;function tc(...t){return Bt.Fn.create(Ut(yn("BIP0340/challenge",...t)))}function xs(t){return $r(t).bytes}function Xm(t,e,n=Ua(32)){const{Fn:r}=Bt,o=le(t,void 0,"message"),{bytes:s,scalar:i}=$r(e),a=le(n,32,"auxRand"),c=r.toBytes(i^Ut(yn("BIP0340/aux",a))),l=yn("BIP0340/nonce",c,s,o),{bytes:d,scalar:u}=$r(l),m=tc(d,s,o),f=new Uint8Array(64);if(f.set(d,0),f.set(r.toBytes(r.create(u+m*i)),32),!nc(f,o,s))throw new Error("sign: Invalid signature produced");return f}function nc(t,e,n){const{Fp:r,Fn:o,BASE:s}=Bt,i=le(t,64,"signature"),a=le(e,void 0,"message"),c=le(n,32,"publicKey");try{const l=ec(Ut(c)),d=Ut(i.subarray(0,32));if(!r.isValidNot0(d))return!1;const u=Ut(i.subarray(32,64));if(!o.isValidNot0(u))return!1;const m=tc(o.toBytes(d),Co(l),a),f=s.multiplyUnsafe(u).add(l.multiplyUnsafe(o.neg(m))),{x:p,y:h}=f.toAffine();return!(f.is0()||!Bo(h)||p!==d)}catch{return!1}}const It=(()=>{const n=(r=Ua(48))=>Dm(r,On.n);return{keygen:Hm(n,xs),getPublicKey:xs,sign:Xm,verify:nc,Point:Bt,utils:{randomSecretKey:n,taggedHash:yn,lift_x:ec,pointToBytes:Co},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),nt=Symbol("verified"),Qm=t=>t instanceof Object;function ep(t){if(!Qm(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 Jt=new TextDecoder("utf-8"),tp=new TextEncoder;function We(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 np{constructor(e){g(this,"value");g(this,"next",null);g(this,"prev",null);this.value=e}}class rp{constructor(){g(this,"first");g(this,"last");this.first=null,this.last=null}enqueue(e){const n=new np(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 op{generateSecretKey(){return It.utils.randomSecretKey()}getPublicKey(e){return ie(It.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ie(It.getPublicKey(n)),r.id=cr(r),r.sig=ie(It.sign(st(cr(r)),n)),r[nt]=!0,r}verifyEvent(e){if(typeof e[nt]=="boolean")return e[nt];const n=cr(e);if(n!==e.id)return e[nt]=!1,!1;try{const r=It.verify(st(e.sig),st(n),st(e.pubkey));return e[nt]=r,r}catch{return e[nt]=!1,!1}}}function sp(t){if(!ep(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 cr(t){let e=Lr(tp.encode(sp(t)));return ie(e)}const Dn=new op;Dn.generateSecretKey;Dn.getPublicKey;Dn.finalizeEvent;const ip=Dn.verifyEvent,ap=22242;function cp(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 lp(t,e){for(let n=0;n<t.length;n++)if(cp(t[n],e))return!0;return!1}function up(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 dp(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 hp(t,e){return{kind:ap,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function fp(){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 mp=t=>(t[nt]=!0,!0);class rc extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}}class Lo{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 rp);g(this,"queueRunning",!1);g(this,"challenge");g(this,"authPromise");g(this,"serial",0);g(this,"verifyEvent");g(this,"_WebSocket");this.url=We(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 Lo(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 fp();this.queueRunning=!1}handleNext(){var r,o,s;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=dp(e);if(n){const i=this.openSubs.get(n);if(!i)return;const a=up(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)&&lp(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 rc(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(hp(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 pp(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 pp{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 rc))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}}class gp{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=We(e);let r=this.relays.get(e);if(r||(r=new Lo(e,{verifyEvent:this.trustedRelayURLs.has(e)?mp: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(We).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=We(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=We(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:p,filter:h}=f;r.has(p)||r.set(p,[]),r.get(p).push(h)}const o=Array.from(r.entries()).map(([f,p])=>({url:f,filters:p}));this.trackRelays&&(n.receivedEvent=(f,p)=>{let h=this.seenOn.get(p);h||(h=new Set,this.seenOn.set(p,h)),h.add(f)});const s=new Set,i=[],a=[];let c=f=>{var p;a[f]||(a[f]=!0,a.filter(h=>h).length===o.length&&((p=n.oneose)==null||p.call(n),c=()=>{}))};const l=[];let d=(f,p)=>{var h;l[f]||(c(f),l[f]=p,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 p=s.has(f);return s.add(f),p},m=Promise.all(o.map(async({url:f,filters:p},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(E){d(h,(E==null?void 0:E.message)||String(E));return}let v=y.subscribe(p,{...n,oneose:()=>c(h),onclose:E=>{E.startsWith("auth-required: ")&&n.onauth?y.auth(n.onauth).then(()=>{y.subscribe(p,{...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,E)},alreadyHaveEvent:u,eoseTimeout:n.maxWait,abort:n.abort});i.push(v)}));return{async close(f){await m,i.forEach(p=>{p.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(We).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 oc;try{oc=WebSocket}catch{}class yp extends gp{constructor(e){super({verifyEvent:ip,websocketImplementation:oc,...e})}}var bp=Math.pow(2,8)-1,wp=Math.pow(2,16)-1,vp=Math.pow(2,32)-1;const xp=function(t){var e=t-1;if(e<=bp)return Uint8Array;if(e<=wp)return Uint16Array;if(e<=vp)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=xp(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 sc{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=Ep(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 Ep(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(()=>{kp(t,n)}),n}function kp(t,e){if(e.hasDispatched=!0,e.keys.length===0){Tr(e);return}let n;try{n=t._batchLoadFn(e.keys)}catch(r){return lr(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 lr(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
+
4
+ Keys:
5
+ ${String(e.keys)}
6
+
7
+ Values:
8
+ ${String(r)}`);Tr(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=>{lr(t,e,r)})}function lr(t,e,n){Tr(e);for(let r=0;r<e.keys.length;r++)t.clear(e.keys[r]),e.callbacks[r].reject(n)}function Tr(t){if(t.cacheHits)for(let e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}function qt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function Io(t,e){let n;const r=()=>{if(n)return n;const o=indexedDB.open(t);return o.onupgradeneeded=()=>o.result.createObjectStore(e),n=qt(o),n.then(s=>{s.onclose=()=>n=void 0},()=>{}),n};return(o,s)=>r().then(i=>s(i.transaction(e,o).objectStore(e)))}let ur;function Mn(){return ur||(ur=Io("keyval-store","keyval")),ur}function ic(t,e,n=Mn()){return n("readwrite",r=>(r.put(e,t),qt(r.transaction)))}function ac(t,e=Mn()){return e("readwrite",n=>(t.forEach(r=>n.put(r[1],r[0])),qt(n.transaction)))}function cc(t,e=Mn()){return e("readonly",n=>Promise.all(t.map(r=>qt(n.get(r)))))}function lc(t,e=Mn()){return e("readwrite",n=>(n.delete(t),qt(n.transaction)))}const Pr=["wss://purplepag.es","wss://relay.nos.social","wss://relay.primal.net"],_p=["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 Ap(t){return!!t}let Sp=0;const Fe=Symbol("event was just downloaded or force-updated, not loaded from cache");Ne(3,Pr,De(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]}));Ne(10101,[],De(t=>{if(t.length>=2&&t[0]==="p"&&St(t[1]))return t[1]}));Ne(10102,[],De(t=>{if(t.length>=2&&t[0]==="relay")return t[1]}));Ne(10012,[],De(t=>{if(t.length>=2)switch(t[0]){case"relay":return We(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 Ro=Ne(10002,_p,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}}));Ne(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}}));Ne(10003,[],De(t=>{if(t.length>=2&&(t[0]==="e"||t[0]==="a")&&t[1])return t[1]}));Ne(10063,[],t=>t?t.tags.filter(([e,n])=>e==="server"&&n).map(([,e])=>"http"+We(e).substring(2)).filter(Boolean):[]);Ne(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]}}}));Ne(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(Ap):[]}function Ne(t,e,n){const r=Io(`@nostr/gadgets/list:${t}`,"cache"),o=new sc(s=>new Promise(async i=>{var u;let a=[],c=Math.round(Date.now()/1e3),l=await cc(s.map(m=>m.target),r).then(m=>m.map((f,p)=>{const h=s[p];if(h.index=p,typeof h.refreshStyle=="object"){const y={event:h.refreshStyle,items:n(h.refreshStyle),[Fe]:!0};return ic(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,[Fe]:!1}):f.event===null&&f.lastAttempt<Date.now()/1e3-3600?(h.refreshStyle!==!1&&a.push(h),{...f,[Fe]:!1}):{...f,[Fe]:!1}:(h.refreshStyle!==!1&&a.push(h),{items:h.defaultItems||[],event:null,[Fe]:!1})}));if(a.length===0){i(l);return}const d={};for(let m=0;m<a.length;m++){const f=a[m],p=f.relays.slice(0,Math.min(4,f.relays.length));do p.push(Np(e));while(p.length<3);for(let h=0;h<p.length;h++){const y=p[h];let v=d[y];v||(v={kinds:[t],authors:[]},d[y]=v),(u=v.authors)==null||u.push(f.target)}}try{let m;m=Vt.subscribeMap(Object.entries(d).map(([f,p])=>({url:f,filter:p})),{label:`kind:${t}:batch(${a.length})`,onevent(f){var p;for(let h=0;h<a.length;h++){const y=a[h];if(y.target===f.pubkey){const v=(p=l[y.index])==null?void 0:p.event;if(((v==null?void 0:v.created_at)||0)>f.created_at)return;l[y.index]={event:f,items:n(f),[Fe]:!0};return}}},oneose(){m==null||m.close()},async onclose(){i(l),ac(a.map(f=>[f.target,{...l[f.index],lastAttempt:c}]),r)}})}catch(m){i(l.map(f=>m))}}),{cacheKeyFn:s=>s.target,transformCacheHit(s){return s[Fe]=!1,s}});return async function(s,i=[],a,c){if(a===null)return await lc(s,r),o._cacheMap.delete(s),{items:c||[],event:null,[Fe]:!0};let l=i;if(t===10002)return await o.load({target:s,relays:l,refreshStyle:a,defaultItems:c});{const d=await Ro(s,i,a);l.push(...d.items.filter(({write:m})=>m).map(({url:m})=>m).slice(0,3));const u={target:s,relays:l,refreshStyle:a,defaultItems:c};return a&&o.clear(u),await o.load(u)}}}function Np(t){return t[Sp++%t.length]}let Vt=new yp;new TextDecoder("utf-8");new TextEncoder;function Cp(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 Bp=["wss://relay.damus.io/","wss://nos.lol/","wss://nostr.mom/"];function uc(){return[...Bp]}async function $o(t,e){return Vt.querySync(t,e)}function To(t,e,n,r){const o=Vt.subscribeMany(t,e,{onevent:n,oneose:r});return()=>o.close()}async function Kn(t,e){await Promise.any(Vt.publish(t,e))}async function bn(t,e){const n=new Set;return t&&t.length>0?t.forEach(r=>n.add(Cp(r))):e&&e.length>0&&(await Promise.all(e.map(o=>Ro(o)))).forEach(o=>{o.items.forEach(s=>{s.read&&n.add(s.url)})}),n.size===0&&uc().forEach(r=>n.add(r)),Array.from(n)}const Lp=Symbol("relays where this event was seen before stored");function Ip(t){return t[Lp]||[]}const dc=1111;function hc(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:dc,content:n,tags:o,created_at:Math.floor(Date.now()/1e3)}}function fc(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=Ip(r);return s.push(["e",r.id,i.length?i[0]:"",r.pubkey]),s.push(["k","1111"]),s.push(["p",r.pubkey]),{kind:dc,content:n,tags:s,created_at:Math.floor(Date.now()/1e3)}}function Rp(t){return t.tags.some(e=>e[0]==="e")}function Pt(t){const e=t.tags.find(n=>n[0]==="e");return e?e[1]:null}function $p(t){const e=t.tags.find(n=>n[0]==="I");return e?e[1]:null}const mc=1111;function pc(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+"/"),To(n,{kinds:[mc],"#I":i,limit:r},o,s)}async function gc(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+"/"),$o(n,{kinds:[mc],"#I":s,limit:r,...o?{until:o}:{}})}async function yc(t,e){const n=hc(e),r=await t.signEvent(n);return await Kn(await bn(e.relays,e.authorPubkeys),r),r}async function bc(t,e){const n=fc(e),r=await t.signEvent(n);return await Kn(await bn(e.relays,e.authorPubkeys),r),r}function wc(t){const e=new Map;t.forEach(i=>e.set(i.id,i));const n=i=>{const a=Pt(i);if(!a)return null;const c=e.get(a);return!c||!Pt(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=Pt(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&&!Pt(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 bt={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"},on={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}} 天前"},dr={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}}天前"},Es={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}}日前"},ks={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}}일 전"},gt={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"},Rt={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"},Gt={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"},hr={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"},_s={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}} дн. назад"},Yt={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}} يوم"},As={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"},fr={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"},Ss={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"},Ns={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"},Cs={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"},Bs={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}} วันที่แล้ว"},Ls={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"},Is={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}} दिन पहले"},Rs={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}} дн. тому"},wn={en:bt,"en-US":bt,"en-GB":bt,"en-AU":bt,"en-CA":bt,"zh-CN":on,"zh-Hans":on,"zh-TW":dr,"zh-Hant":dr,"zh-HK":dr,zh:on,ja:Es,"ja-JP":Es,ko:ks,"ko-KR":ks,es:gt,"es-ES":gt,"es-MX":gt,"es-AR":gt,"es-CO":gt,"es-CL":gt,fr:Rt,"fr-FR":Rt,"fr-CA":Rt,"fr-BE":Rt,"fr-CH":Rt,de:Gt,"de-DE":Gt,"de-AT":Gt,"de-CH":Gt,pt:hr,"pt-BR":hr,"pt-PT":hr,ru:_s,"ru-RU":_s,ar:Yt,"ar-SA":Yt,"ar-EG":Yt,"ar-AE":Yt,it:As,"it-IT":As,nl:fr,"nl-NL":fr,"nl-BE":fr,pl:Ss,"pl-PL":Ss,tr:Ns,"tr-TR":Ns,vi:Cs,"vi-VN":Cs,th:Bs,"th-TH":Bs,id:Ls,"id-ID":Ls,hi:Is,"hi-IN":Is,uk:Rs,"uk-UA":Rs};function vc(){if(typeof navigator>"u")return"en";const t=navigator.languages||[navigator.language];for(const e of t){if(wn[e])return e;const n=e.split("-")[0];if(wn[n])return n}return"en"}function xc(t,e){const n=t||vc(),r=wn[n]||wn.en;return e?{...r,...e}:r}const Ec=j.createContext(null);function kc({locale:t,translations:e,children:n}){const r=t||vc(),o=xc(r,e),s=i=>o[i]||i;return b.jsx(Ec.Provider,{value:{locale:r,translations:o,t:s},children:n})}function Qe(){const t=j.useContext(Ec);if(!t){const e=xc();return{locale:"en",translations:e,t:n=>e[n]||n}}return t}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _c(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ac(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 Tp(t){if(typeof t!="function")throw new Error("function expected");return!0}function Kt(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function Sc(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ur(t){if(!Array.isArray(t))throw new Error("array expected")}function Nc(t,e){if(!Ac(!0,e))throw new Error(`${t}: array of strings expected`)}function Cc(t,e){if(!Ac(!1,e))throw new Error(`${t}: array of numbers expected`)}function Pp(...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 Up(t){const e=typeof t=="string"?t.split(""):t,n=e.length;Nc("alphabet",e);const r=new Map(e.map((o,s)=>[o,s]));return{encode:o=>(Ur(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=>(Ur(o),o.map(s=>{Kt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);return i}))}}function Op(t=""){return Kt("join",t),{encode:e=>(Nc("join.decode",e),e.join(t)),decode:e=>(Kt("join.decode",e),e.split(t))}}const Bc=(t,e)=>e===0?t:Bc(e,t%e),vn=(t,e)=>t+(e-Bc(t,e)),sn=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Or(t,e,n,r){if(Ur(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(vn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${vn(e,n)}`);let o=0,s=0;const i=sn[e],a=sn[n]-1,c=[];for(const l of t){if(Sc(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=sn[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 Dp(t,e=!1){if(Sc(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(vn(8,t)>32||vn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!_c(n))throw new Error("radix2.encode input should be Uint8Array");return Or(Array.from(n),8,t,!e)},decode:n=>(Cc("radix2.decode",n),Uint8Array.from(Or(n,t,8,e)))}}function $s(t){return Tp(t),function(...e){try{return t.apply(null,e)}catch{}}}const Dr=Pp(Up("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Op("")),Ts=[996825010,642813549,513874426,1027748829,705979059];function $t(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Ts.length;r++)(e>>r&1)===1&&(n^=Ts[r]);return n}function Ps(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=$t(o)^i>>5}o=$t(o);for(let s=0;s<r;s++)o=$t(o)^t.charCodeAt(s)&31;for(let s of e)o=$t(o)^s;for(let s=0;s<6;s++)o=$t(o);return o^=n,Dr.encode(Or([o%sn[30]],30,5,!1))}function Mp(t){const e=t==="bech32"?1:734539939,n=Dp(5),r=n.decode,o=n.encode,s=$s(r);function i(u,m,f=90){Kt("bech32.encode prefix",u),_c(m)&&(m=Array.from(m)),Cc("bech32.encode",m);const p=u.length;if(p===0)throw new TypeError(`Invalid prefix length ${p}`);const h=p+7+m.length;if(f!==!1&&h>f)throw new TypeError(`Length ${h} exceeds limit ${f}`);const y=u.toLowerCase(),v=Ps(y,m,e);return`${y}1${Dr.encode(m)}${v}`}function a(u,m=90){Kt("bech32.decode input",u);const f=u.length;if(f<8||m!==!1&&f>m)throw new TypeError(`invalid string length: ${f} (${u}). Expected (8..${m})`);const p=u.toLowerCase();if(u!==p&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");const h=p.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const y=p.slice(0,h),v=p.slice(h+1);if(v.length<6)throw new Error("Data must be at least 6 characters long");const E=Dr.decode(v).slice(0,-6),S=Ps(y,E,e);if(!v.endsWith(S))throw new Error(`Invalid checksum in ${u}: expected "${S}"`);return{prefix:y,words:E}}const c=$s(a);function l(u){const{prefix:m,words:f}=a(u,!1);return{prefix:m,words:f,bytes:r(f)}}function d(u,m){return i(u,o(m))}return{encode:i,decode:a,encodeFromBytes:d,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const xn=Mp("bech32"),Lc=5e3;function Us(t){var o,s,i,a,c,l,d;let{prefix:e,words:n}=xn.decode(t,Lc),r=new Uint8Array(xn.fromWords(n));switch(e){case"nprofile":{let u=mr(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:ie(u[0][0]),relays:u[1]?u[1].map(m=>Jt.decode(m)):[]}}}case"nevent":{let u=mr(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:ie(u[0][0]),relays:u[1]?u[1].map(m=>Jt.decode(m)):[],author:(i=u[2])!=null&&i[0]?ie(u[2][0]):void 0,kind:(a=u[3])!=null&&a[0]?parseInt(ie(u[3][0]),16):void 0}}}case"naddr":{let u=mr(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:Jt.decode(u[0][0]),pubkey:ie(u[2][0]),kind:parseInt(ie(u[3][0]),16),relays:u[1]?u[1].map(m=>Jt.decode(m)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:ie(r)};default:throw new Error(`unknown prefix ${e}`)}}function mr(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 Os(t){return jp("npub",st(t))}function Kp(t,e){let n=xn.toWords(e);return xn.encode(t,n,Lc)}function jp(t,e){return Kp(t,e)}let Ds=0;function En(t){let e,n;if(t.startsWith("npub1")){let{data:r}=Us(t);n=r,e=t}else if(t.startsWith("nprofile")){let{data:r}=Us(t);n=r.pubkey,e=Os(n)}else n=t,e=Os(t);return{pubkey:n,npub:e,shortName:e.substring(0,8)+"…"+e.substring(59),metadata:{},lastUpdated:0}}const an=Io("@nostr/gadgets/metadata","cache");async function Hp(t){return typeof t=="string"?Xt.load({pubkey:t}):t.refreshStyle===null?(await lc(t.pubkey,an),Xt._cacheMap.delete(t.pubkey),En(t.pubkey)):(t.refreshStyle&&Xt.clear(t),Xt.load(t))}const Xt=new sc(async t=>new Promise(async e=>{const n=[];let r=Math.round(Date.now()/1e3),o=await cc(t.map(i=>i.pubkey),an).then(i=>i.map((a,c)=>{const l=t[c];if(typeof l.refreshStyle=="object"){let d=En(l.pubkey);return Ms(d,l.refreshStyle),ic(l.pubkey,d,an),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=En(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 Ro(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(Pr[Ds%Pr.length]),Ds++;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=Vt.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;Ms(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])}ac(c,an)}})}catch(i){for(let a=0;a<o.length;a++)o[a]=i;e(o)}}),{cacheKeyFn:t=>t.pubkey});function Ms(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 Po(t){const[e,n]=j.useState(()=>En(t));return j.useEffect(()=>{Hp(t).then(n)},[t]),{profile:e}}const Ks=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffc107","#ff9800","#ff5722","#795548"];function Ic(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e),e=e&e;return Ks[Math.abs(e)%Ks.length]}function Rc(t,e=40){const n=Ic(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
+ <rect width="${e}" height="${e}" fill="${n}" rx="${e/5}"/>
10
+ <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 Mr(t,e=40){const n=Rc(t,e);return`data:image/svg+xml,${encodeURIComponent(n)}`}function jn({pubkey:t,size:e=32,className:n=""}){const{profile:r}=Po(t),o=r.image||Mr(t,e),i=`https://jumble.social/users/${vt.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=Mr(t,e)}})})}function jt({pubkey:t,className:e=""}){const{profile:n}=Po(t),o=`https://jumble.social/users/${vt.npubEncode(t)}`;return b.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:`nc-username ${e}`,title:t,children:n.shortName})}function $c({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}=Ct(),{t:m}=Qe(),[f,p]=j.useState(""),[h,y]=j.useState(!1),v=async S=>{if(S.preventDefault(),!!f.trim()){if(!u||!l){i();return}y(!0);try{let P;r?P=await bc(l,{url:t,content:f.trim(),parentEvent:r,relays:e,authorPubkeys:n}):P=await yc(l,{url:t,content:f.trim(),relays:e,authorPubkeys:n}),p(""),o==null||o(),s==null||s(P)}catch(P){a==null||a(P instanceof Error?P:new Error("Failed to publish"))}finally{y(!1)}}},E=()=>{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:m("replyTo")}),b.jsx(jt,{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:m("cancel")})]}),b.jsxs("div",{className:"nc-editor__main",children:[u&&d&&b.jsx(jn,{pubkey:d.pubkey,size:40}),b.jsxs("div",{className:"nc-editor__input-wrapper",children:[b.jsx("textarea",{value:f,onInput:S=>p(S.target.value),onFocus:E,placeholder:m("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:m(h?"publishing":"publish")})})]})]})]})}function zp(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 Uo({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}=Qe(),m=!i&&c.length>0;return b.jsxs("div",{className:`nc-comment ${s}`,children:[b.jsxs("div",{className:"nc-comment__main",children:[b.jsx(jn,{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(jt,{pubkey:a.pubkey,className:"nc-comment__author"})}),l&&b.jsxs("div",{className:"nc-comment__reply-preview",children:[b.jsx(jt,{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:zp(a.created_at,d,u)}),b.jsx("button",{type:"button",className:"nc-comment__reply-btn",onClick:()=>n(a),children:d("reply")})]})]}),m&&b.jsx("div",{className:"nc-comment__vline"})]}),m&&b.jsx("div",{className:"nc-comment__children",children:c.map((f,p)=>b.jsxs("div",{className:`nc-comment__child-wrapper ${p<c.length-1?"nc-comment__child-wrapper--continue":""}`,children:[b.jsx("div",{className:"nc-comment__connector"}),p<c.length-1&&b.jsx("div",{className:"nc-comment__connector-line"}),b.jsx(Uo,{comment:f,relays:e,onReply:n,onLoginRequired:r,currentPubkey:o,isChild:!0})]},f.event.id))})]})}function Tc({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:m}=Qe();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:m("loading")})]})}):o?b.jsx("div",{className:`nc-list nc-list--error ${u}`,children:b.jsxs("div",{className:"nc-error",children:[b.jsxs("span",{children:[m("error"),": ",o]}),b.jsx("button",{type:"button",onClick:l,className:"nc-error__retry",children:m("retry")})]})}):t.length===0?b.jsx("div",{className:`nc-list nc-list--empty ${u}`,children:b.jsx("p",{className:"nc-empty",children:m("noComments")})}):b.jsxs("div",{className:`nc-list ${u}`,children:[t.map(f=>b.jsx(Uo,{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:m(n?"loading":"loadMore")})]})}/**
12
+ * @license lucide-react v0.563.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Pc=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/**
17
+ * @license lucide-react v0.563.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const qp=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
22
+ * @license lucide-react v0.563.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Vp=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
27
+ * @license lucide-react v0.563.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const js=t=>{const e=Vp(t);return e.charAt(0).toUpperCase()+e.slice(1)};/**
32
+ * @license lucide-react v0.563.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */var Fp={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
+ * @license lucide-react v0.563.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Wp=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};/**
42
+ * @license lucide-react v0.563.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Zp=j.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},c)=>j.createElement("svg",{ref:c,...Fp,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Pc("lucide",o),...!s&&!Wp(a)&&{"aria-hidden":"true"},...a},[...i.map(([l,d])=>j.createElement(l,d)),...Array.isArray(s)?s:[s]]));/**
47
+ * @license lucide-react v0.563.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Me=(t,e)=>{const n=j.forwardRef(({className:r,...o},s)=>j.createElement(Zp,{ref:s,iconNode:e,className:Pc(`lucide-${qp(js(t))}`,`lucide-${t}`,r),...o}));return n.displayName=js(t),n};/**
52
+ * @license lucide-react v0.563.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Jp=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Qt=Me("check",Jp);/**
57
+ * @license lucide-react v0.563.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const Gp=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Yp=Me("chevron-left",Gp);/**
62
+ * @license lucide-react v0.563.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Xp=[["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"}]],Hs=Me("copy",Xp);/**
67
+ * @license lucide-react v0.563.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Qp=[["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"}]],zs=Me("download",Qp);/**
72
+ * @license lucide-react v0.563.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const eg=[["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"}]],tg=Me("key",eg);/**
77
+ * @license lucide-react v0.563.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const ng=[["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"}]],qs=Me("lock",ng);/**
82
+ * @license lucide-react v0.563.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const rg=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],og=Me("plus",rg);/**
87
+ * @license lucide-react v0.563.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const sg=[["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"}]],Vs=Me("upload",sg);/**
92
+ * @license lucide-react v0.563.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const ig=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ag=Me("x",ig);function cg({onSuccess:t}){const{loginWithNip07:e,loading:n,error:r,isNip07Available:o}=Ct(),{t:s}=Qe(),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(qs,{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(qs,{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 lg({onSuccess:t}){const{loginWithBunker:e,loading:n,error:r}=Ct(),{t:o}=Qe(),[s,i]=j.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(tg,{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 Uc({isOpen:t,onClose:e,enabledSigners:n=["nip07","bunker","temp"],className:r=""}){const{isLoggedIn:o,signerInfo:s,logout:i,loginWithNsec:a,loading:c,getTempSigner:l}=Ct(),{t:d}=Qe(),[u,m]=j.useState(!1),[f,p]=j.useState("list"),[h,y]=j.useState(null),[v,E]=j.useState(!1),[S,P]=j.useState(!1),[M,_]=j.useState(""),[N,L]=j.useState(null);if(j.useEffect(()=>{t||(p("list"),y(null),E(!1),P(!1),_(""),L(null))},[t]),j.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),j.useEffect(()=>{const z=F=>{F.key==="Escape"&&(f!=="list"?$():e())};return t&&window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,f,e]),!t)return null;const K=()=>{e()},$=()=>{p("list"),y(null),E(!1),P(!1),_(""),L(null)},U=async()=>{const z=l();z&&(await z.copyNsec(),m(!0),setTimeout(()=>m(!1),3e3))},D=()=>{const z=l();z&&z.downloadKeyFile()},O=async()=>{h&&(await h.copyNsec(),E(!0),setTimeout(()=>E(!1),3e3))},k=()=>{h&&(h.downloadKeyFile(),P(!0))},w=async()=>{if(h){const z=h.getNsec();await a(z),K()}},x=async z=>{if(z.preventDefault(),!!M.trim()){L(null);try{await a(M),K()}catch{L(d("importKeyError"))}}},A=(s==null?void 0:s.type)==="temp",I=A?l():null,C=(I==null?void 0:I.getNsec())||"",R=()=>d(o?"logout":f==="create"?"createAccount":f==="import"?"importKey":"login"),B=()=>b.jsx("button",{type:"button",onClick:$,className:"nc-modal__back","aria-label":"Back",children:b.jsx(Yp,{size:20})}),T=()=>{if(!h)return null;const z=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(Qt,{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:z}),b.jsxs("div",{className:"nc-temp-view__key-actions",children:[b.jsx("button",{type:"button",onClick:O,className:`nc-temp-view__key-btn ${v?"nc-temp-view__key-btn--success":""}`,title:d("copyKey"),children:v?b.jsx(Qt,{size:16}):b.jsx(Hs,{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(Qt,{size:16}):b.jsx(zs,{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")})]})},H=()=>b.jsxs("div",{className:"nc-temp-view",children:[b.jsx("div",{className:"nc-temp-view__icon",children:b.jsx(Vs,{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:x,className:"nc-temp-view__form",children:[b.jsx("input",{type:"password",value:M,onInput:z=>{_(z.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||!M.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:z=>z.stopPropagation(),children:[b.jsxs("div",{className:"nc-modal__header",children:[f!=="list"&&!o&&B(),b.jsx("h3",{children:R()}),b.jsx("button",{type:"button",onClick:e,className:"nc-modal__close","aria-label":"Close",children:b.jsx(ag,{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(jn,{pubkey:s.pubkey,size:48}),b.jsxs("div",{className:"nc-logged-in__info",children:[b.jsx(jt,{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:U,className:`nc-temp-actions__btn ${u?"nc-temp-actions__btn--success":""}`,children:[u?b.jsx(Qt,{size:16}):b.jsx(Hs,{size:16}),d(u?"keyCopied":"copyKey")]}),b.jsxs("button",{type:"button",onClick:D,className:"nc-temp-actions__btn",children:[b.jsx(zs,{size:16}),d("downloadKey")]})]})]}),b.jsx("button",{type:"button",onClick:()=>{i(),e()},className:"nc-logged-in__logout",children:d("logout")})]}):f==="create"?T():f==="import"?H():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(cg,{onSuccess:K}),n.includes("bunker")&&b.jsx(lg,{onSuccess:K}),n.includes("temp")&&b.jsxs(b.Fragment,{children:[b.jsxs("button",{type:"button",onClick:()=>{const z=new _t;y(z),p("create")},className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(og,{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:()=>p("import"),className:"nc-login-option",children:[b.jsx("div",{className:"nc-login-option__icon",children:b.jsx(Vs,{size:24})}),b.jsxs("div",{className:"nc-login-option__content",children:[b.jsx("h4",{children:d("importKey")}),b.jsx("p",{children:d("importKeyDesc")})]})]})]})]})]})})]})})}function Oc(t){const{url:e,relays:n,authors:r,pageSize:o=50}=t,[s,i]=j.useState([]),[a,c]=j.useState(!0),[l,d]=j.useState(!1),[u,m]=j.useState(null),[f,p]=j.useState(),h=JSON.stringify(n),y=JSON.stringify(r||[]),v=j.useCallback(async()=>{c(!0),m(null),i([]);const _=[];let N=!1;return pc({url:e,relays:await bn(n,r),limit:o,onEvent:K=>{N?i($=>$.some(U=>U.id===K.id)?$:[K,...$]):_.push(K)},onEose:()=>{N=!0;const $=_.sort((U,D)=>D.created_at-U.created_at).slice(0,o);i($),p($.length>=o?$[$.length-1].created_at-1:void 0),c(!1)}})},[e,o,h,y]),E=j.useCallback(async()=>{if(!(a||l||f===void 0)){d(!0);try{const _=await gc({url:e,relays:await bn(n,r),limit:o,until:f});if(_.length===0){p(void 0);return}i(N=>{const L=_.filter(K=>!N.some($=>$.id===K.id));return[...N,...L]}),p(_[_.length-1].created_at-1)}catch(_){m(_ instanceof Error?_.message:"Failed to load more")}finally{d(!1)}}},[e,o,a,l,f,h,y]);j.useEffect(()=>{const _=v();return()=>{_.then(N=>N())}},[v]);const S=j.useCallback(_=>{i(N=>N.some(L=>L.id===_.id)?N:[_,...N])},[]),{comments:P,commentCount:M}=j.useMemo(()=>{const _=wc(s);let N=0;const L=K=>{K.forEach($=>{N++,L($.children)})};return L(_),{comments:_,commentCount:N}},[s]);return{comments:P,commentCount:M,events:s,loading:a,loadingMore:l,error:u,hasMore:f!==void 0,reload:v,loadMore:E,addEvent:S}}const ug=':root{--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}[data-theme=dark],.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){[data-theme=auto],.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:var(--nc-bg);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:var(--nc-bg-secondary);border:1px solid var(--nc-border);border-radius:var(--nc-radius-md);color:var(--nc-text-secondary);cursor:pointer;transition:background var(--nc-transition),color var(--nc-transition)}.nostr-comments:not([data-headless=true]) .nc-load-more:hover:not(:disabled){background:var(--nc-bg-hover);color:var(--nc-text)}.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}.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}',Fs="nostr-comments-styles";function dg(){if(document.getElementById(Fs)||document.querySelector('style[data-vite-dev-id*="base.css"]'))return;const e=document.createElement("style");e.id=Fs,e.textContent=ug,document.head.appendChild(e)}function hg({url:t,authorPubkeys:e,relays:n,pageSize:r=50,enabledSigners:o=["nip07","bunker","temp"],classNames:s={},onCommentPublished:i,onError:a}){const{t:c}=Qe(),{signerInfo:l}=Ct(),[d,u]=j.useState(!1),[m,f]=j.useState(null),{comments:p,commentCount:h,loading:y,loadingMore:v,error:E,hasMore:S,reload:P,loadMore:M,addEvent:_}=Oc({url:t,relays:n,authors:e,pageSize:r}),N=$=>{_($),i==null||i($)},L=$=>{a==null||a($)},K=$=>{f($);const U=document.querySelector(".nc-editor");U&&U.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($c,{url:t,relays:n,authorPubkeys:e,parentEvent:m,onClearParent:()=>f(null),onPublished:N,onLoginRequired:()=>u(!0),onError:L,className:s.editor}),b.jsx(Tc,{comments:p,loading:y,loadingMore:v,hasMore:S,error:E,relays:n,onReply:K,onLoginRequired:()=>u(!0),onLoadMore:M,onRetry:P,currentPubkey:l==null?void 0:l.pubkey,className:s.list}),b.jsx(Uc,{isOpen:d,onClose:()=>u(!1),enabledSigners:o,className:s.loginModal})]})}function fg({locale:t,translations:e,theme:n="auto",headless:r=!1,...o}){return j.useEffect(()=>{r||dg()},[r]),b.jsx(kc,{locale:t,translations:e,children:b.jsx("div",{className:"nostr-comments","data-theme":n,"data-headless":r?"true":void 0,children:b.jsx(hg,{...o})})})}const Oo=7;function mg(t){const{eventIds:e,relays:n,onEvent:r,onEose:o}=t;return e.length===0?(o==null||o(),()=>{}):To(n,{kinds:[Oo],"#e":e},r,o)}async function pg(t){const{eventIds:e,relays:n}=t;return e.length===0?[]:$o(n,{kinds:[Oo],"#e":e})}function Dc(t,e="+"){return{kind:Oo,content:e,tags:[["e",t.id],["p",t.pubkey]],created_at:Math.floor(Date.now()/1e3)}}async function gg(t,e,n,r="+"){const o=Dc(n,r),s=await t.signEvent(o);return await Kn(e,s),s}function yg(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 bg(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==="")})}exports.Avatar=jn;exports.BunkerSigner=Pn;exports.CommentEditor=$c;exports.CommentItem=Uo;exports.CommentList=Tc;exports.I18nProvider=kc;exports.LoginModal=Uc;exports.Nip07Signer=en;exports.NostrComments=fg;exports.TempSigner=_t;exports.Username=jt;exports.buildCommentTree=wc;exports.buildReactionEvent=Dc;exports.buildReplyComment=fc;exports.buildWebComment=hc;exports.countLikes=yg;exports.en=bt;exports.fetchComments=gc;exports.fetchReactions=pg;exports.generateAvatarSvg=Rc;exports.getAvatarDataUrl=Mr;exports.getColorFromPubkey=Ic;exports.getDefaultRelays=uc;exports.getParentId=Pt;exports.getRootUrl=$p;exports.hasLiked=bg;exports.isLoggedIn=dm;exports.isReply=Rp;exports.publishComment=yc;exports.publishEvent=Kn;exports.publishReaction=gg;exports.publishReply=bc;exports.queryEvents=$o;exports.subscribeComments=pc;exports.subscribeEvents=To;exports.subscribeReactions=mg;exports.useComments=Oc;exports.useI18n=Qe;exports.useProfile=Po;exports.useSigner=Ct;exports.zhCN=on;