dns-worker 1.2.3 → 1.2.4-alpha.3589b5b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/serverfull.mjs +197 -168
  2. package/dist/serverfull.mjs.map +4 -4
  3. package/migrations/0070_add_list_stats_metadata.sql +2 -0
  4. package/package.json +3 -3
  5. package/static/assets/AccountView-BzF-OQbX.js +4 -0
  6. package/static/assets/AnalyticsView-DD11Zq43.js +2 -0
  7. package/static/assets/{DestinationMap-B73shd80.js → DestinationMap-zUrVN9JO.js} +1 -1
  8. package/static/assets/FilteringView-Bc1DKKnM.js +1 -0
  9. package/static/assets/{LogsView-MMcmRNXh.js → LogsView-DfPd4O1o.js} +4 -4
  10. package/static/assets/{RulesView-CmwljEkA.js → RulesView-R7BRfMMX.js} +1 -1
  11. package/static/assets/SettingsView-CFWDSurj.js +1 -0
  12. package/static/assets/SetupView-Bns051cH.js +1 -0
  13. package/static/assets/{SwipeableDrawer-UY1QWnPj.js → SwipeableDrawer-BwkmSnIu.js} +1 -1
  14. package/static/assets/SystemView-1PEI-Mww.js +1 -0
  15. package/static/assets/{TrendChart-CXDNW2TF.js → TrendChart-D5dO6qGF.js} +3 -3
  16. package/static/assets/allPaths-a_Gma8ca.js +1 -0
  17. package/static/assets/allPathsLoader-sY5nfYNE.js +1 -0
  18. package/static/assets/browser-C2GXluhp.js +1 -0
  19. package/static/assets/date-DocXn1tb.js +1 -0
  20. package/static/assets/de-DE-sdqvOhE2.js +25 -0
  21. package/static/assets/es-ES-CZMRaxMw.js +25 -0
  22. package/static/assets/fr-FR-2IQyivXi.js +25 -0
  23. package/static/assets/index-COgoDNJK.css +2 -0
  24. package/static/assets/index-DjF2nGtC.js +30 -0
  25. package/static/assets/ja-JP-CuCkEZDz.js +25 -0
  26. package/static/assets/ko-KR-CWUU7L79.js +25 -0
  27. package/static/assets/ru-RU-DnuUcJXU.js +25 -0
  28. package/static/assets/services-69FnfH_j.js +1 -0
  29. package/static/assets/splitPathsBySizeLoader-CagJEoij.js +1 -0
  30. package/static/assets/{sqlite.worker-D8vG3D1o.js → sqlite.worker-BQk-r3bK.js} +1 -1
  31. package/static/assets/{useLogsE2ee-Cx0hNUll.js → useLogsE2ee-AUTsYY-1.js} +1 -1
  32. package/static/assets/vendor-i18next-J2aoF7F1.js +1 -0
  33. package/static/assets/{vendor-icons-other-BTYC6Wvz.js → vendor-icons-other-kRhgWBno.js} +2 -2
  34. package/static/assets/vendor-react-DjiBOEpO.js +11 -0
  35. package/static/assets/vendor-ui-core-DILHJ_S5.js +1 -0
  36. package/static/assets/{vendor-utils-Bab4qB3W.js → vendor-utils-b59hZvGS.js} +1 -1
  37. package/static/assets/vi-VN-Cyv4XVb4.js +25 -0
  38. package/static/assets/zh-CN-BFVuQTvF.js +25 -0
  39. package/static/assets/zh-TW-y_EkxxXD.js +25 -0
  40. package/static/index.html +7 -7
  41. package/static/sw.js +1 -1
  42. package/static/assets/AccountView-7A1LrZP1.js +0 -4
  43. package/static/assets/AnalyticsView-cLBzGH9O.js +0 -2
  44. package/static/assets/FilteringView-DG4K76CF.js +0 -1
  45. package/static/assets/SettingsView-BTUV9wtX.js +0 -1
  46. package/static/assets/SetupView-CrUDJ82c.js +0 -1
  47. package/static/assets/SystemView-CHXZLOqB.js +0 -1
  48. package/static/assets/allPaths-ZKIw3HqD.js +0 -1
  49. package/static/assets/allPathsLoader-CvGx1ejI.js +0 -1
  50. package/static/assets/browser-D1bxqOmO.js +0 -1
  51. package/static/assets/date-DXvnvmPh.js +0 -1
  52. package/static/assets/de-DE-B5QHxkUz.js +0 -12
  53. package/static/assets/es-ES-DVG_43hu.js +0 -12
  54. package/static/assets/fr-FR-C_o9fNbs.js +0 -12
  55. package/static/assets/index-2Pr9miFC.js +0 -17
  56. package/static/assets/index-Dya4nLaI.css +0 -2
  57. package/static/assets/ja-JP-h0clNIRK.js +0 -12
  58. package/static/assets/ko-KR-Rr4R4ErI.js +0 -12
  59. package/static/assets/ru-RU-BKC7ewDw.js +0 -12
  60. package/static/assets/services-DxQAF3Be.js +0 -1
  61. package/static/assets/splitPathsBySizeLoader-htHoS0DT.js +0 -1
  62. package/static/assets/vendor-i18next-DlmslyBB.js +0 -1
  63. package/static/assets/vendor-react-DYK5a2J9.js +0 -11
  64. package/static/assets/vendor-ui-core-CodM8CpF.js +0 -1
  65. package/static/assets/vi-VN-DO0is0TQ.js +0 -12
  66. package/static/assets/zh-CN-D9qLjfXt.js +0 -12
  67. package/static/assets/zh-TW-qJFPjt4I.js +0 -12
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{$t as t,Gt as n,Ht as r,Jt as i,Kt as a,Qt as o,Ut as s,Vt as c,Wt as l,Xt as u,Yt as d,Zt as f,an as p,en as m,nn as h,on as g,qt as _,tn as v}from"./vendor-react-DjiBOEpO.js";import{S as y,a as b,b as x,c as ee,d as S,f as C,g as w,h as T,i as E,l as te,m as D,o as ne,p as re,r as O,s as k,u as ie,v as A,y as j}from"./vendor-icons-other-kRhgWBno.js";const M={CENTER:`center`,END:`end`,LEFT:`left`,RIGHT:`right`,START:`start`},N={ZERO:0,ONE:1,TWO:2,THREE:3,FOUR:4},P={NONE:`none`,PRIMARY:`primary`,SUCCESS:`success`,WARNING:`warning`,DANGER:`danger`},F={BOTTOM:`bottom`,BOTTOM_LEFT:`bottom-left`,BOTTOM_RIGHT:`bottom-right`,LEFT:`left`,LEFT_BOTTOM:`left-bottom`,LEFT_TOP:`left-top`,RIGHT:`right`,RIGHT_BOTTOM:`right-bottom`,RIGHT_TOP:`right-top`,TOP:`top`,TOP_LEFT:`top-left`,TOP_RIGHT:`top-right`};function I(e){return e===F.TOP||e===F.TOP_LEFT||e===F.TOP_RIGHT||e===F.BOTTOM||e===F.BOTTOM_LEFT||e===F.BOTTOM_RIGHT}function L(e){return e===F.TOP||e===F.TOP_LEFT||e===F.TOP_RIGHT?F.TOP:e===F.BOTTOM||e===F.BOTTOM_LEFT||e===F.BOTTOM_RIGHT?F.BOTTOM:e===F.LEFT||e===F.LEFT_TOP||e===F.LEFT_BOTTOM?F.LEFT:F.RIGHT}var R=`bp6`;typeof BLUEPRINT_NAMESPACE<`u`?R=BLUEPRINT_NAMESPACE:typeof REACT_APP_BLUEPRINT_NAMESPACE<`u`&&(R=REACT_APP_BLUEPRINT_NAMESPACE);const z=`${R}-active`,ae=`${R}-align-left`,oe=`${R}-align-right`,B=`${R}-compact`,se=`${R}-dark`,ce=`${R}-theme-root`,V=`${R}-disabled`,H=`${R}-fill`;`${R}`;const le=`${R}-fixed-top`,ue=`${R}-inline`,de=`${R}-interactive`,U=`${R}-large`,fe=`${R}-loading`,pe=`${R}-minimal`,me=`${R}-outlined`,he=`${R}-padded`;`${R}`;const ge=`${R}-read-only`,_e=`${R}-round`,ve=`${R}-selected`,ye=`${R}-small`,be=`${R}-vertical`;or(F.TOP),or(F.BOTTOM),or(F.LEFT),or(F.RIGHT),ir(N.ZERO),ir(N.ONE),ir(N.TWO),ir(N.THREE),ir(N.FOUR),G(P.PRIMARY),G(P.SUCCESS),G(P.WARNING),G(P.DANGER);const xe=`${R}-focus-disabled`;`${R}`,`${R}`,`${R}`,`${R}`,`${R}`,`${R}`;const Se=`${R}-text-muted`;`${R}`;const Ce=`${R}-text-overflow-ellipsis`,we=`${R}-blockquote`,Te=`${R}-code`,Ee=`${R}-code-block`,De=`${R}-heading`,Oe=`${R}-list`;`${R}`,`${R}`;const ke=`${R}-alert`,Ae=`${ke}-body`,je=`${ke}-contents`,Me=`${ke}-footer`,Ne=`${R}-breadcrumb`;`${Ne}`,`${Ne}`,`${Ne}`;const Pe=`${R}-button`,Fe=`${Pe}-group`,Ie=`${Pe}-spinner`,Le=`${Pe}-text`,Re=`${R}-callout`,ze=`${Re}-has-body-content`,Be=`${Re}-icon`,Ve=`${R}-card`;`${R}`,`${R}`,`${R}`,`${R}`,`${R}`;const He=`${R}-collapse`,Ue=`${He}-body`,We=`${R}-context-menu`;`${We}`,`${We}`,`${We}`,`${R}`;const Ge=`${R}-dialog`,Ke=`${Ge}-container`,qe=`${Ge}-header`,Je=`${Ge}-body`,Ye=`${Ge}-body-scroll-container`,Xe=`${Ge}-close-button`,Ze=`${Ge}-footer`,Qe=`${Ge}-footer-fixed`,$e=`${Ge}-footer-main-section`,et=`${Ge}-footer-actions`,tt=`${R}-dialog-step`;`${tt}`,`${tt}`,`${tt}`,`${tt}`;const nt=`${R}-divider`,rt=`${R}-drawer`;`${rt}`,`${rt}`;const it=`${rt}-header`,at=`${R}-editable-text`;`${at}`,`${at}`,`${at}`,`${at}`;const ot=`${R}-entity-title`;`${R}`,`${ot}`,`${ot}`,`${ot}`,`${ot}`,`${ot}`,`${ot}`,`${ot}`,`${R}`;const st=`${R}-html-select`,ct=`${R}-html-table`,lt=`${ct}-bordered`,ut=`${ct}-striped`,dt=`${R}-input`;`${dt}`;const ft=`${dt}-group`,pt=`${dt}-left-container`,mt=`${dt}-action`;`${R}`,`${R}`;const ht=`${R}-control`,gt=`${ht}-input`,_t=`${ht}-indicator`,vt=`${_t}-child`,yt=`${R}-checkbox`,bt=`${R}-radio`;`${R}`;const xt=`${R}-switch`,St=`${xt}-inner-text`;`${R}`,`${R}`,`${R}`,`${R}`,`${R}`,`${R}`;const Ct=`${R}-hotkey`;`${Ct}`,`${Ct}`,`${Ct}`;const wt=`${R}-label`,Tt=`${R}-form-group`,Et=`${R}-form-content`,Dt=`${R}-form-helper-text`,Ot=`${R}-form-group-sub-label`,kt=`${R}-link`;`${kt}`,`${kt}`,`${kt}`,`${kt}`;const At=`${R}-menu`,jt=`${At}-item`,Mt=`${jt}-is-selectable`,Nt=`${jt}-selected-icon`,Pt=`${jt}-icon`,Ft=`${jt}-label`,It=`${R}-submenu`,Lt=`${It}-icon`,Rt=`${At}-divider`,zt=`${At}-header`,Bt=`${R}-multistep-dialog`;`${Bt}`,`${Bt}`,`${Bt}`,`${Bt}`,`${Bt}`;const Vt=`${R}-section`,Ht=`${Vt}-collapsed`,Ut=`${Vt}-header`,Wt=`${Ut}-left`,Gt=`${Ut}-title`,Kt=`${Ut}-sub-title`;`${Ut}`,`${Ut}`;const qt=`${Ut}-right`,Jt=`${Ut}-collapse-caret`,Yt=`${Vt}-card`,Xt=`${R}-navbar`,Zt=`${Xt}-group`,Qt=`${Xt}-heading`,$t=`${Xt}-divider`,en=`${R}-non-ideal-state`,tn=`${en}-visual`,nn=`${en}-text`;`${R}`,`${R}`;const rn=`${R}-overlay`,an=`${rn}-backdrop`,on=`${rn}-container`,sn=`${rn}-content`,cn=`${rn}-inline`,ln=`${rn}-open`,un=`${rn}-scroll-container`,dn=`${rn}-start-focus-trap`,fn=`${rn}-end-focus-trap`,pn=`${R}-panel-stack2`;`${pn}`,`${pn}`,`${pn}`;const W=`${R}-popover`,mn=`${W}-arrow`,hn=`${W}-backdrop`,gn=`${W}-capturing-dismiss`,_n=`${W}-content`,vn=`${W}-placement`;`${_n}`;const yn=`${W}-dismiss`,bn=`${yn}-override`,xn=`${W}-match-target-width`,Sn=`${W}-open`,Cn=`${W}-popper-escaped`,wn=`${W}-reference-hidden`,Tn=`${W}-target`,En=`${W}-transition-container`,Dn=`${W}-minimal-animation`;`${W}`,`${R}`,`${R}`,`${R}`,`${R}`;const On=`${R}-portal`;`${R}`;const kn=`${R}-slider`;`${kn}`,`${kn}`,`${kn}`,`${kn}`,`${kn}`,`${R}`,`${R}`;const An=`${R}-spinner`,jn=`${An}-animation`,Mn=`${An}-head`,Nn=`${R}-no-spin`,Pn=`${An}-track`;`${R}`;const Fn=`${R}-tab`,In=`${Fn}-icon`,Ln=`${Fn}-tag`,Rn=`${Fn}-indicator`,zn=`${Rn}-wrapper`,Bn=`${Fn}-list`,Vn=`${Fn}-panel`,Hn=`${Fn}s`,Un=`${R}-tag`,Wn=`${Un}-remove`,Gn=`${R}-compound-tag`;`${Gn}`,`${Gn}`,`${Gn}`,`${Gn}`;const Kn=`${R}-tag-input`;`${Kn}`,`${Kn}`;const qn=`${R}-toast`,Jn=`${qn}-container`,Yn=`${qn}-message`,Xn=`${R}-tooltip`;`${Xn}`,`${R}`;const Zn=`${R}-tree-node`,Qn=`${Zn}-caret`;`${Qn}`,`${Qn}`,`${Qn}`,`${Zn}`,`${Zn}`,`${Zn}`,`${Zn}`,`${Zn}`,`${Zn}`,`${Zn}`,`${R}`;const $n=`${R}-icon`,er=`${$n}-standard`,tr=`${$n}-large`,nr=`${$n}-muted`;function rr(e){switch(e){case M.LEFT:case M.START:return ae;case M.RIGHT:case M.END:return oe;default:return}}function ir(e){if(e!==void 0)return`${R}-elevation-${e}`}function ar(e){if(e!=null)return e.indexOf(`${R}-icon-`)===0?e:`${R}-icon-${e}`}function G(e){if(!(e==null||e===P.NONE))return`${R}-intent-${e.toLowerCase()}`}function or(e){if(e!==void 0)return`${R}-position-${e}`}function sr(e,t){if(e===`small`)return ye;if(e===`large`)return U;let{large:n=!1,small:r=!1}=t;return{[U]:n,[ye]:r}}function cr(e,t){if(e===`outlined`)return me;if(e===`minimal`)return pe;let{minimal:n=!1,outlined:r=!1}=t;return{[pe]:n,[me]:r}}var lr=class{container;className;isRunning=!1;constructor(e,t){this.container=e,this.className=t}isActive(){return this.isRunning}start(){this.container.addEventListener(`mousedown`,this.handleMouseDown),this.isRunning=!0}stop(){this.reset(),this.isRunning=!1}reset(){this.container.classList.remove(this.className),this.container.removeEventListener(`keydown`,this.handleKeyDown),this.container.removeEventListener(`mousedown`,this.handleMouseDown)}handleKeyDown=e=>{e.key===`Tab`&&(this.reset(),this.container.addEventListener(`mousedown`,this.handleMouseDown))};handleMouseDown=()=>{this.reset(),this.container.classList.add(this.className),this.container.addEventListener(`keydown`,this.handleKeyDown)}},ur=typeof document<`u`?new lr(document.documentElement,xe):{isActive:()=>!0,start:()=>!0,stop:()=>!0};const dr={alwaysShowFocus:()=>ur.stop(),isActive:()=>ur.isActive(),onlyShowFocusOnTabs:()=>ur.start()};function fr(e,t,n=(e,t)=>e===t){return e==null&&t==null?!0:e==null||t==null||e.length!==t.length?!1:e.every((e,r)=>n(e,t[r]))}function pr(e,t,n){if(e==null&&t==null)return!0;if(e==null||t==null||Array.isArray(e)||Array.isArray(t))return!1;if(n!=null)return mr(e,t,n);{let n=Object.keys(e),r=Object.keys(t);return mr(e,t,{include:n})&&mr(e,t,{include:r})}}function mr(e,t,n){return hr(e,t,n).every(n=>e.hasOwnProperty(n)===t.hasOwnProperty(n)&&e[n]===t[n])}function hr(e,t,n){if(gr(n))return n.include;if(_r(n)){let r=Object.keys(e),i=Object.keys(t),a=vr(r.concat(i));return n.exclude.forEach(e=>delete a[e]),Object.keys(a)}return[]}function gr(e){return e!=null&&e.include!=null}function _r(e){return e!=null&&e.exclude!=null}function vr(e){return e.reduce((e,t)=>(e[t]=!0,e),{})}function yr(){return typeof window<`u`&&window.document!=null}function br(e,t){return e===t||e.contains(t)}function xr(e){if(e==null||e.closest==null)return!1;let t=e.closest(`input, textarea, [contenteditable=true]`);if(t==null)return!1;if(t.tagName.toLowerCase()===`input`){let e=t.type;if(e===`checkbox`||e===`radio`)return!1}return!t.readOnly}function Sr(e,t){let n=(e?.getRootNode(t)??document).activeElement;return n instanceof HTMLElement?n:null}function Cr(e){return t=>{e.some(e=>t.key===e)&&(xr(t.target)||t.preventDefault(),t.target.dispatchEvent(new MouseEvent(`click`,{...t,view:void 0})))}}var wr=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`details:not([tabindex="-1"])`,`input:not([disabled]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Tr(e){return Array.from(e.querySelectorAll(wr))}function Er(e){return typeof e==`function`}var Dr=`[Blueprint]`;const Or=`${Dr} <Popover> requires renderTarget prop or a child element.`,kr=`${Dr} <Popover hasBackdrop={true}> requires interactionKind="click".`,Ar=`${Dr} <Popover> supports only one child which is rendered as its target; additional children are ignored.`,jr=`[Blueprint] <Dialog> iconName is ignored if title is omitted.`,Mr=`[Blueprint] <Dialog> isCloseButtonShown prop is ignored if title is omitted.`;var K=e(y());function Nr(e){return typeof NODE_ENV<`u`&&NODE_ENV===e}function Pr(e,t,n){if(e==null)return e;if(n<t)throw Error(`[Blueprint] clamp: max cannot be less than min`);return Math.min(Math.max(e,t),n)}var Fr=new Map;function Ir(e){let t=Fr.get(e)??0;return Fr.set(e,t+1),`${e}-${t}`}function Lr(e){return typeof e==`string`&&e.trim().length===0}const q=`Blueprint6`;var Rr=`active.alignText.asyncControl.containerRef.current.elementRef.ellipsizeText.endIcon.fill.icon.iconSize.inputClassName.inputRef.intent.inline.large.loading.leftElement.leftIcon.minimal.onRemove.outlined.panel.panelClassName.popoverProps.rightElement.rightIcon.round.selectedValue.size.small.tagName.text.textClassName.variant`.split(`.`);function zr(e,t=Rr,n=!1){return n&&(t=t.concat(Rr)),t.reduce((e,t)=>(t.indexOf(`-`)===-1&&e.hasOwnProperty(t)&&delete e[t],e),{...e})}function Br(e,t=!1){return e==null||e===``||e===!1||!t&&Array.isArray(e)&&(e.length===0||e.every(e=>Br(e,!0)))}function Vr(e,t=`span`,n={}){if(!(e==null||typeof e==`boolean`||Lr(e)))return typeof e==`string`||typeof e==`number`||Ur(e)||Wr(e)?(0,K.createElement)(t,n,e):Hr(e)?Object.keys(n).length>0?(0,K.cloneElement)(e,n):e:void 0}function Hr(e){return typeof e==`object`&&e.type!==void 0&&e.props!==void 0}function Ur(e){return typeof e.type==`symbol`}function Wr(e){return Array.isArray(e)}function Gr(e,t){return e!=null&&e.type!=null&&e.type.displayName!=null&&e.type.displayName===t.displayName}var Kr=`${q}.Icon.`;function qr(e){if(!(0,K.isValidElement)(e))return!1;let{type:t}=e;if(typeof t==`string`)return!1;let{displayName:n}=t;return typeof n==`string`&&n.startsWith(Kr)}function Jr(e){return e.key===`Enter`||e.key===` `}function Yr(e,t,n){if(t.includes(e.key))return-1;if(n.includes(e.key))return 1}function Xr(e){return e!=null&&typeof e!=`function`}function Zr(e){return typeof e==`function`}function Qr(e,t){Xr(e)?e.current=t:Zr(e)&&e(t)}function $r(...e){return t=>{e.forEach(e=>{Qr(e,t)})}}function J(e){return e===null?null:e.current===void 0?e:e.current}var ei=class extends K.PureComponent{componentWillUpdate;componentWillReceiveProps;componentWillMount;getDerivedStateFromProps;displayName;timeoutIds=[];requestIds=[];constructor(e){super(e),Nr(`production`)||this.validateProps(this.props)}componentDidUpdate(e,t,n){Nr(`production`)||this.validateProps(this.props)}componentWillUnmount(){this.clearTimeouts(),this.cancelAnimationFrames()}requestAnimationFrame(e){let t=window.requestAnimationFrame(e);return this.requestIds.push(t),()=>window.cancelAnimationFrame(t)}setTimeout(e,t){let n=window.setTimeout(e,t);return this.timeoutIds.push(n),()=>window.clearTimeout(n)}clearTimeouts=()=>{if(this.timeoutIds.length>0){for(let e of this.timeoutIds)window.clearTimeout(e);this.timeoutIds=[]}};cancelAnimationFrames=()=>{if(this.requestIds.length>0){for(let e of this.requestIds)window.cancelAnimationFrame(e);this.requestIds=[]}};validateProps(e){}};function ti(e,t=[]){(0,K.useEffect)(()=>{Nr(`production`)||e()},t)}var ni={defaultTabIndex:void 0,disabledTabIndex:-1};function ri(e,t,n,r=ni){let{defaultTabIndex:i,disabledTabIndex:a}=r,{active:o,onClick:s,onFocus:c,onKeyDown:l,onKeyUp:u,onBlur:d,tabIndex:f=i}=t,[p,m]=(0,K.useState)(),[h,g]=(0,K.useState)(!1),_=(0,K.useRef)(null),v=(0,K.useCallback)(e=>{h&&g(!1),d?.(e)},[h,d]),y=(0,K.useCallback)(e=>{Jr(e)&&(e.preventDefault(),e.key!==p&&g(!0)),m(e.key),l?.(e)},[p,l]),b=(0,K.useCallback)(e=>{Jr(e)&&(g(!1),_.current?.click()),m(void 0),u?.(e)},[u,_]);return[e&&(o||h),{onBlur:v,onClick:e?s:void 0,onFocus:e?c:void 0,onKeyDown:y,onKeyUp:b,ref:$r(_,n),tabIndex:e?f:a}]}var Y=e(x()),ii=e(j());const X=(0,K.forwardRef)((e,t)=>{let{autoLoad:n=!0,className:r,color:i,icon:a,intent:o,tagName:s=`span`,svgProps:c,title:l,htmlTitle:u,...d}=e,f=e.size??A.STANDARD,[p,m]=(0,K.useState)(()=>typeof a==`string`?w.getPaths(a,f):void 0);if((0,K.useEffect)(()=>{let e=!1;if(typeof a==`string`){let t=w.getPaths(a,f);t===void 0?n?w.load(a,f).then(()=>{e||m(w.getPaths(a,f))}).catch(e=>{console.error(`[Blueprint] Icon '${a}' (${f}px) could not be loaded.`,e)}):console.error(`[Blueprint] Icon '${a}' (${f}px) is not loaded yet and autoLoad={false}, did you call Icons.load('${a}', ${f})?`):m(t)}return()=>{e=!0}},[n,a,f]),a==null||typeof a==`boolean`)return null;if(typeof a!=`string`){if((0,K.isValidElement)(a)){let t=(0,ii.default)(a.props.className,r,G(o));if(qr(a)){let n={...zr(d),className:t},r=a.props.size??e.size;r!=null&&(n.size=r);let o=a.props.color??i;return o!=null&&(n.color=o),(0,K.cloneElement)(a,n)}return(0,K.cloneElement)(a,{className:t})}return a}if(p==null){let e=f===A.STANDARD?er:f===A.LARGE?tr:void 0;return(0,K.createElement)(s||`span`,{"aria-hidden":l?void 0:!0,...zr(d),className:(0,ii.default)($n,e,ar(a),G(o),r),"data-icon":a,ref:t,title:u})}else return(0,Y.jsx)(T,{children:p.map((e,t)=>(0,Y.jsx)(`path`,{d:e,fillRule:`evenodd`},t)),className:(0,ii.default)(G(o),r),color:i,htmlTitle:u,iconName:a,ref:t,size:f,svgProps:c,tagName:s,title:l,...zr(d)})});X.displayName=`${q}.Icon`;var ai=e(j()),oi;(function(e){e[e.SMALL=20]=`SMALL`,e[e.STANDARD=50]=`STANDARD`,e[e.LARGE=100]=`LARGE`})(oi||={});var si=45,ci=`M 50,50 m 0,-${si} a ${si},${si} 0 1 1 0,${si*2} a ${si},${si} 0 1 1 0,-${si*2}`,li=280,ui=10,di=4,fi=16;const pi=e=>{let{className:t=``,intent:n,value:r,tagName:i=`div`,size:a,...o}=e;ti(()=>{let e=a!=null,n=t.indexOf(ye)>=0||t.indexOf(U)>=0;e&&n&&console.warn(`[Blueprint] <Spinner> Classes.SMALL/LARGE are ignored if size prop is set.`)},[t,a]);let s=mi(a,t),c=Math.min(fi,di*oi.LARGE/s),l=li-li*(r==null?.25:Pr(r,0,1)),u=(0,ai.default)(An,G(n),{[Nn]:r!=null},t);return(0,K.createElement)(i,{"aria-label":`loading`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":r===void 0?void 0:r*100,className:u,role:`progressbar`,...o},(0,K.createElement)(i,{className:jn},(0,Y.jsxs)(`svg`,{width:s,height:s,strokeWidth:c.toFixed(2),viewBox:hi(c),children:[(0,Y.jsx)(`path`,{className:Pn,d:ci}),(0,Y.jsx)(`path`,{className:Mn,d:ci,pathLength:li,strokeDasharray:`${li} ${li}`,strokeDashoffset:l})]})))};pi.displayName=`${q}.Spinner`;var mi=(e,t)=>e==null?t.indexOf(ye)>=0?oi.SMALL:t.indexOf(U)>=0?oi.LARGE:oi.STANDARD:Math.max(ui,e),hi=e=>{let t=si+e/2,n=(50-t).toFixed(2),r=(t*2).toFixed(2);return`${n} ${n} ${r} ${r}`};const gi=yr()?K.useLayoutEffect:K.useEffect;var _i=e(j());const vi=(0,K.forwardRef)(({children:e,tagName:t=`div`,title:n,className:r,ellipsize:i=!1,...a},o)=>{let s=(0,K.useRef)(),c=(0,K.useMemo)(()=>$r(s,o),[o]),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)();return gi(()=>{s.current?.textContent!=null&&(f(i&&s.current.scrollWidth>s.current.clientWidth),u(s.current.textContent))},[s,e,i]),(0,K.createElement)(t,{...a,className:(0,_i.default)({[Ce]:i},r),ref:c,title:n??(d?l:void 0)},e)});vi.displayName=`${q}.Text`;var yi=e(j());const bi=(0,K.forwardRef)((e,t)=>{let n=Si(e,t);return(0,Y.jsx)(`button`,{type:`button`,...zr(e),...n,children:Ci(e)})});bi.displayName=`${q}.Button`;const xi=(0,K.forwardRef)((e,t)=>{let{href:n}=e,r=Si(e,t,{defaultTabIndex:0,disabledTabIndex:-1});return(0,Y.jsx)(`a`,{role:`button`,...zr(e),...r,"aria-disabled":r.disabled,href:r.disabled?void 0:n,children:Ci(e)})});xi.displayName=`${q}.AnchorButton`;function Si(e,t,n){let{alignText:r,fill:i,large:a,loading:o=!1,minimal:s,outlined:c,size:l=`medium`,small:u,variant:d=`solid`}=e,f=e.disabled||o,[p,m]=ri(!f,e,t,n),h=(0,yi.default)(Pe,{[z]:p,[V]:f,[H]:i,[fe]:o},rr(r),G(e.intent),sr(l,{large:a,small:u}),cr(d,{minimal:s,outlined:c}),e.className);return{...m,className:h,disabled:f}}function Ci(e){let{children:t,ellipsizeText:n,endIcon:r,icon:i,loading:a,rightIcon:o,text:s,textClassName:c}=e,l=!Br(s)||!Br(t);return(0,Y.jsxs)(Y.Fragment,{children:[a&&(0,Y.jsx)(pi,{className:Ie,size:oi.SMALL}),(0,Y.jsx)(X,{icon:i}),l&&(0,Y.jsxs)(vi,{className:(0,yi.default)(Le,c),ellipsize:n,tagName:`span`,children:[s,t]}),(0,Y.jsx)(X,{icon:r??o})]})}var wi=e(j());function Z(e,t){return(0,K.forwardRef)((n,r)=>{let{className:i,children:a,...o}=n;return(0,K.createElement)(e,{...o,className:(0,wi.default)(t,i),ref:r},a)})}Z(`h1`,De);const Ti=Z(`h2`,De),Ei=Z(`h3`,De),Di=Z(`h4`,De),Oi=Z(`h5`,De),ki=Z(`h6`,De);Z(`blockquote`,we),Z(`code`,Te),Z(`pre`,Ee),Z(`label`,wt),Z(`ol`,Oe),Z(`ul`,Oe);const Ai=(0,K.createContext)({hasProvider:!1,stack:{current:[]}}),ji=({children:e})=>{let t=(0,K.useRef)([]),n=(0,K.useMemo)(()=>({hasProvider:!0,stack:t}),[t]);return(0,Y.jsx)(Ai.Provider,{value:n,children:e})};var Mi=[],Ni=[];const Pi=e=>{e(Mi),Ni.forEach(e=>e())};var Fi={getSnapshot:()=>Mi,subscribe:e=>(Ni.push(e),()=>{let t=Ni.indexOf(e);Ni.splice(t,1)})};function Ii(){let e=(0,K.useSyncExternalStore)(Fi.subscribe,Fi.getSnapshot,Fi.getSnapshot),t=(0,K.useCallback)(()=>e[e.length-1],[e]),n=(0,K.useCallback)(t=>{let n=e.findIndex(e=>e.id===t);return e.slice(n)},[e]),r=(0,K.useCallback)(()=>{Pi(e=>e.splice(0,e.length))},[]),i=(0,K.useCallback)(e=>{Mi.push(e),e.props.usePortal&&e.props.hasBackdrop&&document.body?.classList.add(ln)},[]);return{closeOverlay:(0,K.useCallback)(t=>{let n=e.filter(e=>e.props.usePortal&&e.props.hasBackdrop&&e.id!==t),r=Mi.findIndex(e=>e.id===t);r>-1&&Mi.splice(r,1),n.length===0&&document.body?.classList.remove(ln)},[e]),getLastOpened:t,getThisOverlayAndDescendants:n,openOverlay:i,resetStack:r}}function Li(){let{stack:e,hasProvider:t}=(0,K.useContext)(Ai),n=Ii(),r=(0,K.useCallback)(()=>e.current[e.current.length-1],[e]),i=(0,K.useCallback)(t=>{let n=e.current.findIndex(e=>e.id===t);return n===-1?[]:e.current.slice(n)},[e]),a=(0,K.useCallback)(()=>{e.current=[]},[e]),o=(0,K.useCallback)(t=>{e.current.push(t),t.props.usePortal&&t.props.hasBackdrop&&document.body?.classList.add(ln)},[e]),s=(0,K.useCallback)(t=>{let n=e.current.filter(e=>e.props.usePortal&&e.props.hasBackdrop&&e.id!==t),r=e.current.findIndex(e=>e.id===t);r>-1&&e.current.splice(r,1),n.length===0&&document.body?.classList.remove(ln)},[e]);return t?{closeOverlay:s,getLastOpened:r,getThisOverlayAndDescendants:i,openOverlay:o,resetStack:a}:(Nr(`development`)&&console.error(`[Blueprint] <Overlay2> was used outside of a <OverlaysProvider> context. This will no longer be supported in Blueprint v6. See https://github.com/palantir/blueprint/wiki/Overlay2-migration`),n)}function Ri(e){let t=(0,K.useRef)();return(0,K.useEffect)(()=>{t.current=e},[e]),t.current}function zi(e){let t=J(e);return(t==null?[]:Tr(t)).filter(e=>!e.classList.contains(dn)&&!e.classList.contains(fn))}const Bi=(0,K.createContext)({});var Vi=g();function Hi({className:e,stopPropagationEvents:t,container:n,onChildrenMount:r,children:i}){let a=(0,K.useContext)(Bi),o=n??a.portalContainer??(typeof document<`u`?document.body:void 0),[s,c]=(0,K.useState)();gi(()=>{if(s==null)return;let e=Object.entries(a.portalTheme??{}).map(([e,t])=>{let n=s.style.getPropertyValue(e),r=s.style.getPropertyPriority(e);return s.style.setProperty(e,t),{name:e,previousValue:n,priority:r}});return()=>{e.forEach(({name:e,previousValue:t,priority:n})=>{t===``?s.style.removeProperty(e):s.style.setProperty(e,t,n)})}},[a.portalTheme,s]);let l=(0,K.useCallback)(()=>{let n=document.createElement(`div`);return n.classList.add(On,ce),Wi(n.classList,e),Wi(n.classList,a.portalClassName),Gi(n,t),n},[e,a.portalClassName,t]);return(0,K.useEffect)(()=>{if(o==null)return;let e=l();return o.appendChild(e),c(e),()=>{Ki(e,t),e.remove(),c(void 0)}},[o,l,t]),(0,K.useEffect)(()=>{s!=null&&r?.()},[s,r]),(0,K.useEffect)(()=>{if(s!=null)return Wi(s.classList,e),()=>Ui(s.classList,e)},[e,s]),(0,K.useEffect)(()=>{if(s!=null)return Gi(s,t),()=>Ki(s,t)},[s,t]),typeof document>`u`||s==null?null:(0,Vi.createPortal)(i,s)}Hi.displayName=`${q}.Portal`;function Ui(e,t){t!=null&&t!==``&&e.remove(...t.split(` `))}function Wi(e,t){t!=null&&t!==``&&e.add(...t.split(` `))}function Gi(e,t){t?.forEach(t=>e.addEventListener(t,qi))}function Ki(e,t){t?.forEach(t=>e.removeEventListener(t,qi))}function qi(e){e.stopPropagation()}var Ji=e(j());const Yi=(0,K.forwardRef)((e,t)=>{let{autoFocus:n=!0,backdropClassName:r,backdropProps:i={},canEscapeKeyClose:a=!0,canOutsideClickClose:o=!0,childRef:s,childRefs:c,children:l,className:u,enforceFocus:d=!0,hasBackdrop:f=!0,isOpen:p=!1,lazy:m=yr(),onClose:g,onClosed:_,onClosing:y,onOpened:b,onOpening:x,portalClassName:ee,portalContainer:S,shouldReturnFocusOnClose:C=!0,transitionDuration:w=300,transitionName:T=rn,usePortal:E=!0}=e;Xi(e);let{closeOverlay:te,getLastOpened:D,getThisOverlayAndDescendants:ne,openOverlay:re}=Li(),[O,k]=(0,K.useState)(!1),[ie,A]=(0,K.useState)(!1),[j,M]=(0,K.useState)(!1),N=(0,K.useRef)(null),P=(0,K.useRef)(null),F=(0,K.useRef)(null),I=(0,K.useRef)(null),L=(0,K.useRef)(null),R=(0,K.useRef)(null),z=(0,K.useCallback)(e=>requestAnimationFrame(()=>{let t=e??J(P),n=Sr(t);t==null||n==null||t.contains(n)||(J(I)?.focus({preventScroll:!0}),k(!1))}),[]),ae=(0,K.useCallback)(e=>{e!=null&&j&&(M(!1),k(!0),z(e))},[z,j]),oe=(0,K.useMemo)(()=>$r(P,ae),[ae]),B=Zi(),se=(0,K.useRef)(null),ce=(0,K.useCallback)(e=>{let t=e.composed?e.composedPath()[0]:e.target,n=J(P);n!=null&&t instanceof Node&&!n.contains(t)&&(e.preventDefault(),e.stopImmediatePropagation(),z())},[z]),V=(0,K.useCallback)(e=>{let t=e.composed?e.composedPath()[0]:e.target;ne(B).some(({containerElement:e})=>{let n=J(e);return n?.contains(t)&&!n.isSameNode(t)})||g?.(e)},[ne,B,g]),H=(0,K.useCallback)(e=>{e.key===`Escape`&&a&&D()?.id===B&&(g?.(e),e.stopPropagation(),e.preventDefault())},[a,D,B,g]);(0,K.useImperativeHandle)((0,K.useMemo)(()=>$r(t,se),[t]),()=>({bringFocusInsideOverlay:z,containerElement:P,handleDocumentFocus:ce,handleDocumentMousedown:V,id:B,props:{autoFocus:n,enforceFocus:d,hasBackdrop:f,usePortal:E}}),[n,z,d,ce,V,f,B,E]);let le=(0,K.useCallback)(e=>{e.key===`Escape`&&a&&(g?.(e),e.stopPropagation(),e.preventDefault())},[a,g]),ue=(0,K.useCallback)(()=>{if(se.current==null)return;let e=D();e?.handleDocumentFocus!==void 0&&document.removeEventListener(`focus`,e.handleDocumentFocus,!0),re(se.current),n&&(J(P)==null?M(!0):(k(!0),z())),Qr(N,Sr(J(P)))},[n,z,D,re]),de=(0,K.useCallback)(()=>{document.removeEventListener(`focus`,ce,!0),document.removeEventListener(`mousedown`,V),te(B);let e=D();e!==void 0&&e.props.autoFocus&&e.props.enforceFocus&&(e.bringFocusInsideOverlay?.(),e.handleDocumentFocus!==void 0&&document.addEventListener(`focus`,e.handleDocumentFocus,!0))},[te,D,ce,V,B]),U=Ri(p)??!1;(0,K.useEffect)(()=>{p&&A(!0),!U&&p&&ue(),U&&!p&&de()},[p,ue,de,U]),(0,K.useEffect)(()=>{if(!(!p||!(o&&!f)))return document.addEventListener(`mousedown`,V),()=>{document.removeEventListener(`mousedown`,V)}},[V,p,o,f]),(0,K.useEffect)(()=>{if(!(!p||n!==!1||!a))return document.addEventListener(`keydown`,H),()=>{document.removeEventListener(`keydown`,H)}},[H,p,n,a]),(0,K.useEffect)(()=>{if(!(!p||!d)&&D()?.id===B)return document.addEventListener(`focus`,ce,!0),()=>{document.removeEventListener(`focus`,ce,!0)}},[ce,d,p,D,B]);let fe=(0,K.useRef)(de);fe.current=de,(0,K.useEffect)(()=>()=>{fe.current()},[]);let pe=(0,K.useCallback)(e=>{let t=J(N);C&&t instanceof HTMLElement&&t.focus(),_?.(e)},[_,C]),me=(0,K.useCallback)(()=>{},[]),he=(0,K.useCallback)(e=>{if(s!=null)return s;if(c!=null){let t=e.key;if(t==null){Nr(`production`)||console.error(`[Blueprint] <Overlay2> requires each child element to have a unique key prop when childRefs is used`);return}return c[t]}},[s,c]),ge=(0,K.useCallback)(e=>{if(e==null||Lr(e))return null;let t=he(e),r=Vr(e,`span`,{className:(0,Ji.default)((Hr(e)?e.props:{}).className,sn),ref:t===void 0?R:void 0,tabIndex:d||n?0:void 0}),i=t??R;return(0,Y.jsx)(h,{addEndListener:me,classNames:T,nodeRef:i,onEntered:Qi(b,i),onEntering:Qi(x,i),onExited:Qi(pe,i),onExiting:Qi(y,i),timeout:w,children:r})},[n,d,he,me,pe,y,b,x,w,T]),_e=(0,K.useCallback)(e=>{o&&g?.(e),d&&z(),i?.onMouseDown?.(e)},[i,z,o,d,g]),ve=(0,K.useCallback)((e,t)=>(0,Y.jsx)(h,{addEndListener:me,classNames:T,nodeRef:t.ref,timeout:w,unmountOnExit:!0,children:(0,Y.jsx)(`div`,{tabIndex:0,...t})},e),[me,w,T]),ye=(0,K.useCallback)(e=>{if(!d||O)return;let t=J(P),n=J(L);e.relatedTarget!=null&&t?.contains(e.relatedTarget)&&e.relatedTarget!==n&&n?.focus({preventScroll:!0})},[d,O]),be=(0,K.useCallback)(e=>{if(d&&e.shiftKey&&e.key===`Tab`){let e=zi(P).pop();e==null?J(L)?.focus({preventScroll:!0}):e.focus()}},[d]),xe=(0,K.useCallback)(e=>{let t=J(I);if(e.relatedTarget!=null&&J(P)?.contains(e.relatedTarget)&&e.relatedTarget!==t){let n=zi(P).shift();!O&&n!=null&&n!==e.relatedTarget?n.focus():t?.focus({preventScroll:!0})}else{let e=zi(P).pop();e==null?t?.focus({preventScroll:!0}):e.focus()}},[O]),Se=(0,K.useMemo)(()=>f&&p?(0,Y.jsx)(h,{classNames:T,nodeRef:F,timeout:w,addEndListener:me,children:(0,Y.jsx)(`div`,{...i,className:(0,Ji.default)(an,r,i?.className),onMouseDown:_e,ref:F})},`__backdrop`):null,[r,i,_e,me,f,p,w,T]);if(m&&!ie)return null;let Ce=p?K.Children.map(l,ge)??[]:[];Se!==null&&Ce.unshift(Se),p&&(n||d)&&Ce.length>0&&(Ce.unshift(ve(`__start`,{className:dn,onFocus:ye,onKeyDown:be,ref:I})),d&&Ce.push(ve(`__end`,{className:fn,onFocus:xe,ref:L})));let we=(0,Y.jsx)(`div`,{"aria-live":`polite`,className:(0,Ji.default)(rn,{[ln]:p,[cn]:!E},u),onKeyDown:le,ref:oe,children:(0,Y.jsx)(v,{appear:!0,component:null,children:Ce})});return E?(0,Y.jsx)(Hi,{className:ee,container:S,children:we}):we});Yi.displayName=`${q}.Overlay2`;function Xi({childRef:e,childRefs:t,children:n}){let r=K.Children.count(n);(0,K.useEffect)(()=>{Nr(`production`)||(e!=null&&t!=null&&console.error(`[Blueprint] <Overlay2> cannot use childRef and childRefs props simultaneously`),r>1&&t==null&&console.error(`[Blueprint] <Overlay2> requires childRefs prop when rendering multiple child elements`))},[e,t,r])}function Zi(){let e=(0,K.useId)();return`${Yi.displayName}-${e}`}function Qi(e,t){return()=>{t?.current!=null&&e?.(t.current)}}var $i=e(j());const ea=e=>{let{canOutsideClickClose:t=!0,children:n,className:r,containerRef:i,icon:a,isCloseButtonShown:o,isOpen:s=!1,onClose:c,role:l=`dialog`,style:u,title:d,titleTagName:f=Ti,...p}=e,m=(0,K.useRef)(null),h=(0,K.useMemo)(()=>`title-${Ir(`bp-dialog`)}`,[]);return ti(()=>{d??(e.icon!=null&&console.warn(jr),e.isCloseButtonShown!=null&&console.warn(Mr))},[d,e.icon,e.isCloseButtonShown]),(0,Y.jsx)(Yi,{...p,isOpen:s,canOutsideClickClose:t,className:un,childRef:m,hasBackdrop:!0,onClose:c,children:(0,Y.jsx)(`div`,{className:Ke,ref:$r(i,m),children:(0,Y.jsxs)(`div`,{"aria-describedby":p[`aria-describedby`],"aria-labelledby":p[`aria-labelledby`]||(d==null?void 0:h),"aria-modal":p.enforceFocus??!0,className:(0,$i.default)(Ge,r),role:l,style:u,children:[d!=null&&(0,Y.jsxs)(`div`,{className:qe,children:[(0,Y.jsx)(X,{icon:a,size:A.STANDARD,"aria-hidden":!0,tabIndex:-1}),(0,Y.jsx)(f,{id:h,children:d}),o!==!1&&(0,Y.jsx)(bi,{"aria-label":`Close`,className:Xe,icon:(0,Y.jsx)(E,{size:A.STANDARD}),onClick:c,variant:`minimal`})]}),n]})})})};ea.displayName=`${q}.Dialog`;var ta=e(j());const na=e=>{let{cancelButtonText:t,canEscapeKeyCancel:n=!1,canOutsideClickCancel:r=!1,children:i,className:a,confirmButtonText:o=`OK`,icon:s,intent:c,isOpen:l=!1,loading:u=!1,onCancel:d,onClose:f,onConfirm:p,...m}=e;ti(()=>{f==null&&t==null!=(d==null)&&console.warn(`[Blueprint] <Alert> cancelButtonText and onCancel should be set together.`);let e=d!=null||f!=null;n&&!e&&console.warn(`[Blueprint] <Alert> canEscapeKeyCancel enabled without onCancel or onClose handler.`),r&&!e&&console.warn(`[Blueprint] <Alert> canOutsideClickCancel enabled without onCancel or onClose handler.`)},[n,r,t,d,f]);let h=(0,K.useCallback)((e,t)=>{(e?p:d)?.(t),f?.(e,t)},[d,f,p]),g=(0,K.useCallback)(e=>h(!1,e),[h]),_=(0,K.useCallback)(e=>h(!0,e),[h]);return(0,Y.jsxs)(ea,{...m,role:`alertdialog`,className:(0,ta.default)(ke,a),canEscapeKeyClose:n,canOutsideClickClose:r,isOpen:l,onClose:g,children:[(0,Y.jsxs)(`div`,{className:Ae,children:[(0,Y.jsx)(X,{icon:s,size:40,intent:c}),(0,Y.jsx)(`div`,{className:je,children:i})]}),(0,Y.jsxs)(`div`,{className:Me,children:[(0,Y.jsx)(bi,{loading:u,intent:c,text:o,onClick:_}),t&&(0,Y.jsx)(bi,{text:t,disabled:u,onClick:g})]})]})};na.displayName=`${q}.Alert`;var ra=e(j());const ia=e=>{let{className:t,children:n,large:r,size:i=`medium`,small:a,ulRef:o,...s}=e;return(0,Y.jsx)(`ul`,{role:`menu`,...s,className:(0,ra.default)(t,At,sr(i,{large:r,small:a})),ref:o,children:n})};ia.displayName=`${q}.Menu`;function aa(e){return e.split(`-`)[0]}function oa(e){return[`left`,`right`].indexOf(e)!==-1}function sa(e){switch(e){case`top`:return`bottom`;case`left`:return`right`;case`bottom`:return`top`;default:return`left`}}function ca(e){switch(e.split(`-`)[1]){case`start`:return`left`;case`end`:return`right`;default:return`center`}}function la(e,t){let n=aa(e);return t===void 0?oa(n)?`${sa(n)} ${ca(n)}`:`${ca(n)} ${sa(n)}`:oa(n)?`${sa(n)} ${parseInt(t.top,10)+15}px`:`${parseInt(t.left,10)+15}px ${sa(n)}`}var ua=`M8.11 6.302c1.015-.936 1.887-2.922 1.887-4.297v26c0-1.378-.868-3.357-1.888-4.297L.925 17.09c-1.237-1.14-1.233-3.034 0-4.17L8.11 6.302z`,da=`M8.787 7.036c1.22-1.125 2.21-3.376 2.21-5.03V0v30-2.005c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z`,fa=4;function pa(e){if(e==null)return 0;switch(aa(e)){case`top`:return-90;case`left`:return 180;case`bottom`:return 90;default:return 0}}function ma(e){let t=30/2-fa;switch(aa(e)){case`top`:return{bottom:-t};case`left`:return{right:-t};case`bottom`:return{top:-t};default:return{left:-t}}}const ha=({arrowProps:{ref:e,style:t},placement:n})=>(0,Y.jsx)(`div`,{"aria-hidden":!0,className:mn,"data-popper-arrow":!0,ref:e,style:{...t,...ma(n)},children:(0,Y.jsxs)(`svg`,{viewBox:`0 0 30 30`,style:{transform:`rotate(${pa(n)}deg)`},children:[(0,Y.jsx)(`path`,{className:mn+`-border`,d:ua}),(0,Y.jsx)(`path`,{className:mn+`-fill`,d:da})]})});ha.displayName=`${q}.PopoverArrow`;const ga={CLICK:`click`,CLICK_TARGET_ONLY:`click-target`,HOVER:`hover`,HOVER_TARGET_ONLY:`hover-target`},_a={MINIMAL:`minimal`,SCALE:`scale`};function va(e){let n=[];return e.offset&&n.push(f(e.offset)),e.inline&&n.push(u(e.inline)),e.autoPlacement&&e.flip?(console.warn(`autoPlacement and flip are mutually exclusive. Using autoPlacement and ignoring flip.`),n.push(_(e.autoPlacement))):e.flip?n.push(i(e.flip)):n.push(_(e.autoPlacement)),e.shift&&n.push(o(e.shift)),e.size&&n.push(t(e.size)),e.arrow&&e.arrow.element&&n.push(a({element:e.arrow.element,padding:e.arrow.padding})),e.hide&&n.push(d(e.hide)),n}function ya({autoUpdateOptions:e,disabled:t=!1,isControlled:n=!1,isHoverInteractionKind:i=!1,isOpen:a=!1,middleware:o,placement:u,positioningStrategy:d=`absolute`,onOpenChange:f}={}){let[p,h]=(0,K.useState)(a);(0,K.useEffect)(()=>{h(a)},[a]);let g=(0,K.useCallback)((e,t)=>{n||h(e),f&&f(e,t)},[f,n]),_=(0,K.useRef)(e);_.current=e;let v=s({middleware:o,onOpenChange:g,open:p,placement:u,strategy:d,whileElementsMounted:(0,K.useMemo)(()=>e==null?m:(e,t,n)=>m(e,t,n,_.current),[e!=null])}),{context:y}=v,b=l([c(y,{enabled:!t&&!i,keyboardHandlers:!1}),r(y,{escapeKey:!1,outsidePress:!1})]);return(0,K.useMemo)(()=>({isOpen:p,setIsOpen:h,...b,...v}),[v,b,p])}const ba=_a.SCALE;var xa=e(j());function Sa(e){let{animation:t=ba,arrow:r=!0,arrowRef:i,autoFocus:a,backdropProps:o,canEscapeKeyClose:s,captureDismiss:c=!1,content:l,enforceFocus:u=!0,floatingData:d,handleMouseEnter:f,handleMouseLeave:p,handleOverlayClose:m,handlePopoverClick:h,hasBackdrop:g=!1,hasDarkParent:_,inheritDarkTheme:v=!0,interactionKind:y=ga.CLICK,isClosingViaEscapeKeypress:b,isHoverInteractionKind:x,lazy:ee=!1,matchTargetWidth:S=!1,onClosed:C,onClosing:w,onOpened:T,onOpening:E,popoverClassName:te,popoverRef:D,portalClassName:ne,portalContainer:re,transitionDuration:O=300,usePortal:k=!0}=e,ie=(0,K.useRef)(null),A={left:d.middlewareData.arrow?.x,position:`absolute`,top:d.middlewareData.arrow?.y},j=d.context.middlewareData.hide?.referenceHidden??!1,M=d.context.middlewareData.hide?.escaped??!1,N=la(d.placement,r?{left:Ca(A.left),top:Ca(A.top)}:void 0),P={onClick:h,onKeyDown:e=>Jr(e)&&h(e)};(y===ga.HOVER||!k&&y===ga.HOVER_TARGET_ONLY)&&(P.onMouseEnter=f,P.onMouseLeave=p);let F=aa(d.placement),I=(0,xa.default)(W,{[se]:v&&_,[Dn]:t===_a.MINIMAL,[gn]:c,[xn]:S,[wn]:j,[Cn]:M},`${vn}-${F}`,te),L=x?!1:void 0,R=x?!1:b||e.shouldReturnFocusOnClose,z=n([d.refs.setFloating,ie]);return(0,Y.jsx)(Yi,{autoFocus:a??L,backdropClassName:hn,backdropProps:o,canEscapeKeyClose:s,canOutsideClickClose:y===ga.CLICK,childRef:ie,enforceFocus:u,hasBackdrop:g,isOpen:d.isOpen,lazy:ee,onClose:m,onClosed:C,onClosing:w,onOpened:T,onOpening:E,portalClassName:ne,portalContainer:re,shouldReturnFocusOnClose:R,transitionDuration:O,transitionName:W,usePortal:k,children:(0,Y.jsx)(`div`,{className:En,style:d.floatingStyles,ref:z,...P,children:(0,Y.jsxs)(`div`,{className:I,ref:D,style:{transformOrigin:N},children:[r&&(0,Y.jsx)(ha,{arrowProps:{ref:i,style:A},placement:d.placement}),(0,Y.jsx)(`div`,{className:_n,children:l})]})})})}function Ca(e){return e===``?e:e==null||isNaN(Number(e))?``:`${e}px`}var wa=e(j());const Ta=(0,K.forwardRef)((e,t)=>{let{children:r,className:i,floatingData:a,disabled:o=!1,fill:s=!1,handleMouseEnter:c,handleMouseLeave:l,handleTargetBlur:u,handleTargetContextMenu:d,handleTargetFocus:f,interactionKind:p,isContentEmpty:m,isControlled:h,isHoverInteractionKind:g,openOnTargetFocus:_=!0,popupKind:v,renderTarget:y=void 0,targetProps:b,targetTagName:x=`span`}=e,ee=s?`div`:x,{isOpen:S}=a,C=n([a.refs.setReference,t]),w=(0,K.useCallback)(e=>{if(!Jr(e)||e.repeat)return;let t=e.target;if(!Da(t)){if(e.key===` `){if(t.closest(`button`)!=null)return;e.preventDefault()}else if(e.key===`Enter`&&t.closest(`button, a`)!=null)return;e.currentTarget.click()}},[]),T=g?{onBlur:u,onContextMenu:d,onFocus:f,onMouseEnter:c,onMouseLeave:l}:{},E=!m&&!o&&_&&g?0:void 0,te=g?{}:a.getReferenceProps({onKeyDown:w}),D={className:(0,wa.default)(i,Tn,{[Sn]:S,[z]:S&&!h&&!g,[H]:s}),ref:C,...T},ne={"aria-expanded":g?void 0:S,"aria-haspopup":p===ga.HOVER_TARGET_ONLY?void 0:v??`menu`},re={[z]:S&&!h&&!g,[H]:s},O;if(y!==void 0)O=y({...D,...ne,...te,className:(0,wa.default)(D.className,re),isOpen:S,tabIndex:E});else{let e=Vr(K.Children.toArray(r)[0]);if(e===void 0)return null;let t=(0,K.cloneElement)(e,{...ne,className:(0,wa.default)(e.props.className,re),disabled:S&&Ea(e)||e.props.disabled,tabIndex:e.props.tabIndex??E});O=(0,K.createElement)(ee,{...D,...b,...te},t)}return O});Ta.displayName=`${q}.PopoverTarget`;function Ea(e){return e?.type!=null&&typeof e.type!=`string`&&typeof e.type==`function`&&`displayName`in e.type&&e.type.displayName===`Blueprint6.Tooltip`}function Da(e){let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable}const Oa=(0,K.forwardRef)((e,t)=>{let{animation:n=ba,autoUpdateOptions:r,arrow:i=!0,boundary:a=`clippingAncestors`,children:o,content:s,defaultIsOpen:c=!1,disabled:l=!1,hasBackdrop:u=!1,hoverCloseDelay:d=300,hoverOpenDelay:f=150,interactionKind:p=ga.CLICK,isOpen:m,matchTargetWidth:h=!1,middleware:g,onClose:_,onInteraction:v,openOnTargetFocus:y=!0,popoverRef:b,placement:x,positioningStrategy:ee=`absolute`,renderTarget:S,rootBoundary:C,shouldReturnFocusOnClose:w=!0,targetProps:T,usePortal:E=!0}=e;ti(()=>{m==null&&v!=null&&console.warn(`[Blueprint] <Popover> onInteraction is ignored when uncontrolled.`),u&&!E&&console.warn(`[Blueprint] <Popover usePortal={false}> ignores hasBackdrop`),u&&p!==ga.CLICK&&console.warn(kr);let e=K.Children.count(o),t=S!==void 0,n=T!==void 0;e===0&&!t&&console.warn(Or),e>1&&console.warn(Ar),e>0&&t&&console.warn(`[Blueprint] <Popover> with children ignores renderTarget prop; use either prop or children.`),t&&n&&console.warn(`[Blueprint] <Popover> targetProps value is ignored when renderTarget API is used.`)},[i,o,u,p,m,v,x,S,T,E]);let[te,D]=(0,K.useState)(!1),[ne,re]=(0,K.useState)(!1),O=(0,K.useRef)(null),k=(0,K.useRef)(void 0),ie=(0,K.useRef)(!1),A=(0,K.useRef)(!0),j=(0,K.useRef)(null),M=(0,K.useRef)([]),N=m!==void 0,P=s==null||Lr(s),F=l?!1:m??c,I=p===ga.HOVER||p===ga.HOVER_TARGET_ONLY,L=ya({autoUpdateOptions:r,disabled:l,isControlled:N,isHoverInteractionKind:I,isOpen:F,middleware:(0,K.useMemo)(()=>va({...x===void 0?{autoPlacement:{boundary:a,rootBoundary:C}}:{flip:{boundary:a,rootBoundary:C}},...i?{arrow:{element:O},offset:{mainAxis:30/2}}:{},shift:{boundary:a,rootBoundary:C},size:h?{apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}}:void 0,...g}),[x,a,C,i,O,h,g]),onOpenChange:(e,t)=>{B(e,t)},placement:x,positioningStrategy:ee});(0,K.useImperativeHandle)(t,()=>({reposition:()=>{L.update()}}),[L]);let R=L.refs.floating.current,z=(0,K.useCallback)(()=>R?.querySelector(`.${W}`),[R]),ae=(0,K.useCallback)(e=>z()?.contains(e)??!1,[z]),oe=(0,K.useCallback)((e,t)=>{let n=window.setTimeout(e,t);return M.current.push(n),()=>window.clearTimeout(n)},[]),B=(0,K.useCallback)((e,t,n)=>{k.current?.(),n!==void 0&&n>0?(t?.persist(),k.current=oe(()=>{B(e,t)},n)):(m==null?L.setIsOpen(e):v?.(e,t),e||(_?.(t),re(ka(t?.nativeEvent))))},[L,m,v,_,oe]),ce=(0,K.useCallback)(e=>{e.defaultPrevented&&B(!1,e)},[B]),H=(0,K.useCallback)(e=>{ie.current=!1,e.persist(),oe(()=>{ie.current||B(!1,e,d)})},[d,B,oe]),le=(0,K.useCallback)(e=>{ie.current=!0,!E&&ae(e.target)&&p===ga.HOVER_TARGET_ONLY&&!y?H(e):l||B(!0,e,f)},[l,H,f,p,ae,y,B,E]),ue=(0,K.useCallback)(e=>{if(y&&I){if(e.relatedTarget==null&&!A.current)return;le(e)}},[le,I,y]),de=(0,K.useCallback)(e=>{y&&I&&(e.relatedTarget==null||e.relatedTarget!==R&&!ae(e.relatedTarget))&&H(e),A.current=e.relatedTarget!=null},[H,ae,I,y,R]),U=(0,K.useCallback)(e=>{let t=e.target,n=t.closest(`.${W}`),r=n===z(),i=n?.classList.contains(gn)??!1,a=t.closest(`.${yn}, .${bn}`)?.classList.contains(yn)??!1,o=t.closest(`:disabled, .${V}`)!=null;a&&!o&&(!i||r)&&B(!1,e)},[z,B]),fe=(0,K.useCallback)(e=>{if(j.current==null||e===void 0)return;let t=e.nativeEvent??e,n=t.composed?t.composedPath()[0]:t.target;(!br(j.current,n)||e.nativeEvent instanceof KeyboardEvent)&&B(!1,e)},[B,j]),pe=(0,K.useCallback)(()=>{E&&L.isOpen&&D(j.current?.closest(`.${se}`)!=null)},[L.isOpen,j,E]);return(0,K.useEffect)(()=>{pe(),m!=null&&F!==L.isOpen?B(F):l&&L.isOpen&&m==null&&B(!1),P&&!l&&F!==!1&&!Nr(`production`)&&console.warn(`[Blueprint] Disabling <Popover> with empty/whitespace content...`)},[F,l,L,P,m,B,pe]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ta,{floatingData:L,handleMouseEnter:le,handleMouseLeave:H,handleTargetBlur:de,handleTargetContextMenu:ce,handleTargetFocus:ue,isContentEmpty:P,isControlled:N,isHoverInteractionKind:I,openOnTargetFocus:y,ref:j,...e,children:o}),!P&&(0,Y.jsx)(Sa,{animation:n,arrowRef:O,floatingData:L,handleMouseEnter:le,handleMouseLeave:H,handleOverlayClose:fe,handlePopoverClick:U,hasDarkParent:te,isClosingViaEscapeKeypress:ne,isHoverInteractionKind:I,popoverRef:b,shouldReturnFocusOnClose:w,...e})]})});Oa.displayName=`${q}.PopoverNext`;function ka(e){return e instanceof KeyboardEvent&&e.key===`Escape`}const Q={...F,AUTO:`auto`,AUTO_END:`auto-end`,AUTO_START:`auto-start`};function Aa(e){switch(e){case Q.TOP_LEFT:return`top-start`;case Q.TOP:return`top`;case Q.TOP_RIGHT:return`top-end`;case Q.RIGHT_TOP:return`right-start`;case Q.RIGHT:return`right`;case Q.RIGHT_BOTTOM:return`right-end`;case Q.BOTTOM_RIGHT:return`bottom-end`;case Q.BOTTOM:return`bottom`;case Q.BOTTOM_LEFT:return`bottom-start`;case Q.LEFT_BOTTOM:return`left-end`;case Q.LEFT:return`left`;case Q.LEFT_TOP:return`left-start`;case`auto`:case`auto-start`:case`auto-end`:return e;default:return ja(e)}}function ja(e){throw Error(`Unexpected position: `+e)}function Ma(e){let t={};if(e.flip&&e.flip.enabled!==!1){let{options:n}=e.flip;t.flip={...n?.boundary==null?{}:{boundary:Pa(n.boundary)},...n?.rootBoundary==null?{}:{rootBoundary:n.rootBoundary},...n?.padding==null?{}:{padding:n.padding},...n?.fallbackPlacements==null?{}:{fallbackPlacements:n.fallbackPlacements},...n?.flipVariations==null?{}:{flipAlignment:n.flipVariations},...n?.mainAxis==null?{}:{mainAxis:n.mainAxis},...n?.altAxis==null?{}:{crossAxis:n.altAxis}}}if(e.preventOverflow&&e.preventOverflow.enabled!==!1){let{options:n}=e.preventOverflow;t.shift={...n?.boundary==null?{}:{boundary:Pa(n.boundary)},...n?.rootBoundary==null?{}:{rootBoundary:n.rootBoundary},...n?.padding==null?{}:{padding:n.padding},...n?.mainAxis==null?{}:{mainAxis:n.mainAxis},...n?.altAxis==null?{}:{crossAxis:n.altAxis}}}if(e.offset&&e.offset.enabled!==!1){let{options:n}=e.offset;if(n?.offset!=null)if(typeof n.offset==`function`)console.warn("popperModifiersToNextMiddleware: The Popper.js `offset` function cannot be automatically converted to a Floating UI middleware config. Migrate it manually to a `{ mainAxis, crossAxis }` object in the `middleware` prop.");else{let[e,r]=n.offset;t.offset={...e==null?{}:{crossAxis:e},...r==null?{}:{mainAxis:r}}}else t.offset={mainAxis:30/2}}if(e.arrow&&e.arrow.enabled!==!1){let{options:n}=e.arrow;n?.element!=null&&typeof n.element!=`string`&&(t.arrow={element:n.element,...n.padding!=null&&typeof n.padding!=`function`?{padding:n.padding}:{}})}return e.hide&&e.hide.enabled!==!1&&(t.hide={}),t}function Na(e){let{boundary:t,minimal:n,modifiers:r,modifiersCustom:i,onClose:a,placement:o,popoverRef:s,portalStopPropagationEvents:c,position:l,shouldReturnFocusOnClose:u,...d}=e??{};Nr(`production`)||(i!==void 0&&console.warn("[Blueprint] popoverPropsToNextProps: `modifiersCustom` has no equivalent in PopoverNext and will be dropped. Migrate to the `middleware` prop manually."),c!==void 0&&console.warn("[Blueprint] popoverPropsToNextProps: `portalStopPropagationEvents` has no equivalent in PopoverNext and will be dropped."),o!==void 0&&l!==void 0&&console.warn(`[Blueprint] <Popover> supports either placement or position prop, not both.`));let f={...d};return t!==void 0&&(f.boundary=Pa(t)),o===void 0?l!==void 0&&(f.placement=Ia(l)):f.placement=Fa(o),r!==void 0&&(f.middleware=Ma(r)),n!=null&&(f.animation??=n?_a.MINIMAL:ba,f.arrow??=!n),a!==void 0&&(f.onClose=e=>{e!==void 0&&a(e)}),s!==void 0&&(f.popoverRef=s),f.shouldReturnFocusOnClose=u??!1,f}function Pa(e){return e===`clippingParents`?`clippingAncestors`:e}function Fa(e){switch(e){case`auto`:case`auto-start`:case`auto-end`:return;default:return e}}function Ia(e){return Fa(Aa(e))}var La=e(j());const Ra=(0,K.forwardRef)((e,t)=>{let{active:n=!1,className:r,children:i,disabled:a=!1,icon:o,intent:s,labelClassName:c,labelElement:l,multiline:u=!1,popoverProps:d={},roleStructure:f=`menuitem`,selected:p,shouldDismissPopover:m=!0,submenuProps:h,text:g=``,textClassName:_,tagName:v=`a`,htmlTitle:y,...b}=e,[x,C,w]=f===`listoption`?[`option`,void 0,!!p]:f===`menuitem`?[`none`,`menuitem`,void 0]:f===`none`?[`none`,void 0,void 0]:[void 0,void 0,void 0],T=f===`listoption`,E=T&&p,te=o!=null,D=i!=null,ne=G(s),re=(0,La.default)(jt,ne,{[z]:n,[V]:a,[yn]:m&&!a&&!D,[Mt]:T,[ve]:E},r),O=e.label==null&&l==null?null:(0,Y.jsxs)(`span`,{className:(0,La.default)(Ft,c),children:[e.label,l]}),k=zr(b),ie=(0,K.createElement)(v,{onKeyDown:Cr([`Enter`,` `]),role:D?`none`:C,...k,tabIndex:D?-1:k.tabIndex==null?0:k.tabIndex,...a?Ba:{},className:re},E?(0,Y.jsx)(ee,{className:Nt}):void 0,te?(0,Y.jsx)(`span`,{className:Pt,"aria-hidden":!0,children:(0,Y.jsx)(X,{icon:o,tabIndex:-1})}):void 0,(0,Y.jsx)(vi,{className:(0,La.default)(H,_),ellipsize:!u,title:y,children:g}),O,D?(0,Y.jsx)(S,{className:Lt,title:`Open sub menu`}):void 0),A=(0,La.default)({[It]:D}),j=Na(d);return(0,Y.jsx)(`li`,{className:A,ref:t,role:x,"aria-selected":w,children:i==null?ie:(0,Y.jsx)(Oa,{autoFocus:!1,captureDismiss:!1,disabled:a,enforceFocus:!1,hoverCloseDelay:0,interactionKind:`hover`,targetProps:{role:C,tabIndex:0},placement:`right-start`,usePortal:!1,...j,middleware:{...za,...j.middleware},content:(0,Y.jsx)(ia,{...h,children:i}),animation:`minimal`,arrow:!1,popoverClassName:(0,La.default)(It,d?.popoverClassName),children:ie})})});Ra.displayName=`${q}.MenuItem`;var za={flip:{padding:20,rootBoundary:`viewport`},offset:{crossAxis:-5},shift:{padding:20,rootBoundary:`viewport`}},Ba={"aria-disabled":!0,href:void 0,onClick:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,tabIndex:-1},Va=e(j());const Ha=(0,K.forwardRef)((e,t)=>{let{alignText:n,className:r,fill:i,minimal:a,outlined:o,large:s,size:c=`medium`,variant:l=`solid`,vertical:u,...d}=e,f=(0,Va.default)(Fe,{[H]:i,[be]:u},rr(n),sr(c,{large:s}),cr(l,{minimal:a,outlined:o}),r);return(0,Y.jsx)(`div`,{...d,ref:t,className:f,children:e.children})});Ha.displayName=`${q}.ButtonGroup`;var Ua=e(j());const Wa=e=>{let{className:t,children:n,icon:r,intent:i,title:a,compact:o,minimal:s=!1,...c}=e,l=Ga(r,i);return(0,Y.jsxs)(`div`,{className:(0,Ua.default)(Re,G(i),t,{[ze]:!Br(n),[Be]:l!=null,[B]:o,[pe]:s}),...c,children:[l,a&&(0,Y.jsx)(Oi,{children:a}),n]})};Wa.displayName=`${q}.Callout`;var Ga=(e,t)=>{if(e===null||e===!1)return;let n={"aria-hidden":!0,tabIndex:-1};if(e!==void 0)return(0,Y.jsx)(X,{icon:e,...n});switch(t){case P.DANGER:return(0,Y.jsx)(k,{...n});case P.PRIMARY:return(0,Y.jsx)(ne,{...n});case P.WARNING:return(0,Y.jsx)(b,{...n});case P.SUCCESS:return(0,Y.jsx)(te,{...n});default:return}},Ka=e(j());const qa=(0,K.forwardRef)((e,t)=>{let{className:n,elevation:r=N.ZERO,interactive:i=!1,selected:a,compact:o,...s}=e;return(0,Y.jsx)(`div`,{className:(0,Ka.default)(n,Ve,ir(r),{[de]:i,[B]:o,[ve]:a}),ref:t,...s})});qa.displayName=`${q}.Card`;var Ja=e(j()),$;(function(e){e[e.OPEN_START=0]=`OPEN_START`,e[e.OPENING=1]=`OPENING`,e[e.OPEN=2]=`OPEN`,e[e.CLOSING_START=3]=`CLOSING_START`,e[e.CLOSING=4]=`CLOSING`,e[e.CLOSED=5]=`CLOSED`})($||={});const Ya=({children:e,className:t,component:n=`div`,isOpen:r=!1,keepChildrenMounted:i=!1,transitionDuration:a=200})=>{let[o,s]=(0,K.useState)(r?$.OPEN:$.CLOSED),[c,l]=(0,K.useState)(r?`auto`:`0px`),[u,d]=(0,K.useState)(void 0),[f,p]=(0,K.useState)(r),m=(0,K.useRef)(r);m.current=r;let h=(0,K.useRef)(null),g=(0,K.useRef)(o);g.current=o;let _=(0,K.useRef)(),v=(0,K.useCallback)(()=>{switch(g.current){case $.OPENING:s($.OPEN),l(`auto`);break;case $.CLOSING:s($.CLOSED);break;default:break}},[]);if(r!==f)if(p(r),r)switch(o){case $.OPEN:case $.OPENING:break;default:s($.OPEN_START)}else switch(o){case $.CLOSED:case $.CLOSING:break;default:s($.CLOSING_START),l(`${u}px`)}(0,K.useEffect)(()=>()=>{_.current!=null&&clearTimeout(_.current)},[]),(0,K.useEffect)(()=>{if(h.current)switch(o){case $.OPEN_START:{let e=h.current.clientHeight;s($.OPENING),l(`${e}px`),d(e),clearTimeout(_.current),_.current=setTimeout(v,a);break}case $.CLOSING_START:{let e=h.current.clientHeight,t=setTimeout(()=>{s($.CLOSING),l(`0px`),d(e)});return clearTimeout(_.current),_.current=setTimeout(v,a),()=>clearTimeout(t)}default:break}},[o,a,v]);let y=(0,K.useCallback)(e=>{if(h.current=e,h.current!=null){let e=h.current.clientHeight;s(m.current?$.OPEN:$.CLOSED),l(e===0?void 0:`${e}px`),d(e===0?void 0:e)}},[]),b=o!==$.CLOSED,x=b||i,ee=b&&o!==$.CLOSING,S=o===$.OPEN?`auto`:c,C=S===`auto`,w={height:b?S:void 0,overflowY:C?`visible`:void 0,transition:C?`none`:void 0},T={transform:ee?`translateY(0)`:`translateY(-${u}px)`,transition:C?`none`:void 0};return(0,K.createElement)(n,{className:(0,Ja.default)(He,t),style:w},(0,Y.jsx)(`div`,{className:Ue,ref:y,style:T,"aria-hidden":!b,children:x?e:null}))};Ya.displayName=`${q}.Collapse`;const Xa=(0,K.createContext)([{},()=>null]);var Za=(e,t)=>{switch(t.type){case`FORCE_DISABLED_STATE`:return{forceDisabled:!0};case`RESET_DISABLED_STATE`:return{};default:return e}};const Qa=({children:e,forceDisable:t})=>{let[n,r]=(0,K.useReducer)(Za,{}),i=(0,K.useMemo)(()=>[n,r],[n,r]);return(0,K.useEffect)(()=>{r(t?{type:`FORCE_DISABLED_STATE`}:{type:`RESET_DISABLED_STATE`})},[t]),(0,Y.jsx)(Xa.Provider,{value:i,children:typeof e==`function`?e(n):e})};var $a=e(j());const eo=(0,K.forwardRef)((e,t)=>{let{children:n,className:r,useOverflowScrollContainer:i=!0,...a}=e;return(0,Y.jsx)(`div`,{...a,className:(0,$a.default)(Je,r,{[Ye]:i}),ref:t,children:n})});eo.displayName=`${q}.DialogBody`;var to=e(j());const no=(0,K.forwardRef)((e,t)=>{let{actions:n,children:r,className:i,minimal:a=!1,...o}=e;return(0,Y.jsxs)(`div`,{...o,className:(0,to.default)(Ze,i,{[Qe]:!a}),ref:t,children:[(0,Y.jsx)(`div`,{className:$e,children:r}),n!=null&&(0,Y.jsx)(`div`,{className:et,children:n})]})});no.displayName=`${q}.DialogFooter`;var ro=e(j()),io=class extends ei{static displayName=`${q}.Tooltip`;static defaultProps={compact:!1,hoverCloseDelay:0,hoverOpenDelay:100,interactionKind:`hover-target`,minimal:!1,transitionDuration:100};popoverRef=(0,K.createRef)();render(){return(0,Y.jsx)(Xa.Consumer,{children:([e])=>(0,Y.jsx)(Qa,{...e,children:this.renderPopover})})}reposition(){this.popoverRef.current?.reposition()}renderPopover=e=>{let{children:t,compact:n,disabled:r,intent:i,popoverClassName:a,...o}=this.props,s=(0,ro.default)(Xn,G(i),a,{[B]:n}),c=Na(o);return(0,Y.jsx)(Oa,{...c,middleware:{offset:{mainAxis:22/2},...c.middleware},autoFocus:!1,disabled:e.forceDisabled??r,enforceFocus:!1,lazy:!0,popoverClassName:s,portalContainer:this.props.portalContainer,ref:this.popoverRef,children:t})}},ao=e(j());const oo=({className:e,compact:t=!1,tagName:n=`div`,...r})=>{let i=(0,ao.default)(nt,{[B]:t},e);return(0,K.createElement)(n,{...r,className:i})};oo.displayName=`${q}.Divider`;var so=e(j()),co;(function(e){e.SMALL=`360px`,e.STANDARD=`50%`,e.LARGE=`90%`})(co||={});var lo=class extends ei{static displayName=`${q}.Drawer`;static defaultProps={canOutsideClickClose:!0,isOpen:!1,position:`right`,style:{}};render(){let{hasBackdrop:e,size:t,style:n,position:r}=this.props,{className:i,children:a,...o}=this.props,s=L(r),c=(0,so.default)(rt,{[or(s)??``]:!0},i),l=t==null?n:{...n,[I(s)?`height`:`width`]:t};return(0,Y.jsx)(Yi,{...o,className:(0,so.default)({[on]:e}),children:(0,Y.jsxs)(`div`,{className:c,style:l,children:[this.maybeRenderHeader(),a]})})}validateProps(e){e.title??(e.icon!=null&&console.warn(jr),e.isCloseButtonShown!=null&&console.warn(Mr)),e.position!=null&&e.position!==L(e.position)&&console.warn(`[Blueprint] <Drawer> all angle positions are casted into pure position (TOP, BOTTOM, LEFT or RIGHT)`)}maybeRenderCloseButton(){return this.props.isCloseButtonShown===!1?null:(0,Y.jsx)(bi,{"aria-label":`Close`,className:Xe,icon:(0,Y.jsx)(E,{size:A.LARGE}),onClick:this.props.onClose,variant:`minimal`})}maybeRenderHeader(){let{icon:e,title:t}=this.props;return t==null?null:(0,Y.jsxs)(`div`,{className:it,children:[(0,Y.jsx)(X,{icon:e,size:A.LARGE}),(0,Y.jsx)(Di,{children:t}),this.maybeRenderCloseButton()]})}},uo=e(j()),fo=(0,K.forwardRef)((e,t)=>{let{alignIndicator:n,children:r,className:i,indicatorChildren:a,inline:o,inputRef:s,label:c,labelElement:l,large:u,size:d=`medium`,style:f,type:p,typeClassName:m,tagName:h=`label`,...g}=e;return(0,K.createElement)(h,{className:(0,uo.default)(ht,m,{[V]:g.disabled,[ue]:o},rr(n),sr(d,{large:u}),i),ref:t,style:f},(0,Y.jsx)(`input`,{className:gt,...g,ref:s,type:p}),(0,Y.jsx)(`span`,{className:_t,children:a}),c,l,r)});fo.displayName=`${q}.Control`;const po=(0,K.forwardRef)((e,t)=>{let{innerLabelChecked:n,innerLabel:r,...i}=e,a=r||n?[(0,Y.jsx)(`div`,{className:vt,children:(0,Y.jsx)(`div`,{className:St,children:n||r})},`checked`),(0,Y.jsx)(`div`,{className:vt,children:(0,Y.jsx)(`div`,{className:St,children:r})},`unchecked`)]:null;return(0,Y.jsx)(fo,{...i,indicatorChildren:a,ref:t,type:`checkbox`,typeClassName:xt})});po.displayName=`${q}.Switch`;const mo=(0,K.forwardRef)((e,t)=>(0,Y.jsx)(fo,{...e,ref:t,type:`radio`,typeClassName:bt}));mo.displayName=`${q}.Radio`;const ho=(0,K.forwardRef)((e,t)=>{let{defaultIndeterminate:n,indeterminate:r,onChange:i,...a}=e,[o,s]=(0,K.useState)(r||n||!1),c=(0,K.useRef)(null),l=$r(e.inputRef,c),u=(0,K.useCallback)(e=>{r===void 0&&s(e.target.indeterminate),i?.(e)},[r,i]);return(0,K.useEffect)(()=>{r!==void 0&&s(r)},[r]),(0,K.useEffect)(()=>{c.current!=null&&(c.current.indeterminate=o)},[c,o]),(0,Y.jsx)(fo,{...a,inputRef:l,onChange:u,ref:t,type:`checkbox`,typeClassName:yt})});ho.displayName=`${q}.Checkbox`;var go=e(j());const _o=e=>{let{children:t,className:n,contentClassName:r,disabled:i,fill:a,helperText:o,inline:s,intent:c,label:l,labelFor:u,labelInfo:d,style:f,subLabel:p,...m}=e;return(0,Y.jsxs)(`div`,{className:(0,go.default)(Tt,G(c),{[V]:i,[H]:a,[ue]:s},n),style:f,...m,children:[l&&(0,Y.jsxs)(`label`,{className:wt,htmlFor:u,children:[l,` `,(0,Y.jsx)(`span`,{className:Se,children:d})]}),p&&(0,Y.jsx)(`div`,{className:Ot,children:p}),(0,Y.jsxs)(`div`,{className:(0,go.default)(Et,r),children:[t,o&&(0,Y.jsx)(`div`,{className:Dt,children:o})]})]})};_o.displayName=`${q}.FormGroup`;var vo=class e extends ei{static displayName=`${q}.AsyncControllableInput`;static COMPOSITION_END_DELAY=10;state={hasPendingUpdate:!1,isComposing:!1,nextValue:this.props.value,value:this.props.value};cancelPendingCompositionEnd=null;static getDerivedStateFromProps(e,t){return t.isComposing||e.value===void 0?null:t.nextValue===t.value?{hasPendingUpdate:!1,nextValue:e.value,value:e.value}:e.value===t.nextValue?t.hasPendingUpdate?{hasPendingUpdate:!1,value:e.value}:{value:t.nextValue}:e.value===t.value?{hasPendingUpdate:!0}:{hasPendingUpdate:!1,nextValue:e.value,value:e.value}}render(){let{isComposing:e,hasPendingUpdate:t,value:n,nextValue:r}=this.state,{inputRef:i,...a}=this.props;return(0,Y.jsx)(`input`,{...a,ref:i,value:e||t?r:n,onCompositionStart:this.handleCompositionStart,onCompositionEnd:this.handleCompositionEnd,onChange:this.handleChange})}handleCompositionStart=e=>{this.cancelPendingCompositionEnd?.(),this.setState({isComposing:!0}),this.props.onCompositionStart?.(e)};handleCompositionEnd=t=>{this.cancelPendingCompositionEnd=this.setTimeout(()=>this.setState({isComposing:!1}),e.COMPOSITION_END_DELAY),this.props.onCompositionEnd?.(t)};handleChange=e=>{let{value:t}=e.target;this.setState({nextValue:t}),this.props.onChange?.(e)}},yo=e(j()),bo=[`inputSize`,`onValueChange`],xo=class extends ei{static displayName=`${q}.InputGroup`;state={};leftElement=null;rightElement=null;refHandlers={leftElement:e=>this.leftElement=e,rightElement:e=>this.rightElement=e};render(){let{asyncControl:e=!1,className:t,disabled:n,fill:r,inputClassName:i,inputRef:a,inputSize:o,intent:s,large:c,readOnly:l,round:u,size:d=`medium`,small:f,tagName:p=`div`}=this.props,m=(0,yo.default)(ft,G(s),{[V]:n,[ge]:l,[H]:r,[_e]:u},sr(d,{large:c,small:f}),t),h={...this.props.style,paddingLeft:this.state.leftElementWidth,paddingRight:this.state.rightElementWidth},g={type:`text`,...zr(this.props,bo,!0),"aria-disabled":n,className:(0,yo.default)(dt,i),onChange:this.handleInputChange,size:o,style:h},_=e?(0,Y.jsx)(vo,{...g,inputRef:a}):(0,Y.jsx)(`input`,{...g,ref:a});return(0,K.createElement)(p,{className:m},this.maybeRenderLeftElement(),_,this.maybeRenderRightElement())}componentDidMount(){this.updateInputWidth()}componentDidUpdate(e){let{leftElement:t,rightElement:n}=this.props;(e.leftElement!==t||e.rightElement!==n)&&this.updateInputWidth()}validateProps(e){e.leftElement!=null&&e.leftIcon!=null&&console.warn(`[Blueprint] <InputGroup> leftElement and leftIcon prop are mutually exclusive, with leftElement taking priority.`)}handleInputChange=e=>{let t=e.target.value;this.props.onChange?.(e),this.props.onValueChange?.(t,e.target)};maybeRenderLeftElement(){let{leftElement:e,leftIcon:t}=this.props;if(e!=null)return(0,Y.jsx)(`span`,{className:pt,ref:this.refHandlers.leftElement,children:e});if(t!=null)return(0,Y.jsx)(X,{icon:t,"aria-hidden":!0,tabIndex:-1})}maybeRenderRightElement(){let{rightElement:e}=this.props;if(e!=null)return(0,Y.jsx)(`span`,{className:mt,ref:this.refHandlers.rightElement,children:e})}updateInputWidth(){let{leftElementWidth:e,rightElementWidth:t}=this.state;if(this.leftElement!=null){let{clientWidth:t}=this.leftElement;(e===void 0||Math.abs(t-e)>2)&&this.setState({leftElementWidth:t})}else this.setState({leftElementWidth:void 0});if(this.rightElement!=null){let{clientWidth:e}=this.rightElement;(t===void 0||Math.abs(e-t)>2)&&this.setState({rightElementWidth:e})}else this.setState({rightElementWidth:void 0})}},So=e(j());const Co=(0,K.forwardRef)((e,t)=>{let{className:n,children:r,disabled:i,fill:a,iconName:o=`double-caret-vertical`,iconProps:s,large:c,minimal:l,options:u=[],value:d,...f}=e,p=(0,So.default)(st,{[V]:i,[H]:a,[U]:c,[pe]:l},n),m=`Open dropdown`,h=o===`double-caret-vertical`?(0,Y.jsx)(ie,{title:m,...s}):(0,Y.jsx)(C,{title:m,...s}),g=u.map(e=>{let t=typeof e==`object`?e:{value:e};return(0,K.createElement)(`option`,{...t,key:t.value,children:t.label||t.value})});return(0,Y.jsxs)(`div`,{className:p,children:[(0,Y.jsxs)(`select`,{disabled:i,ref:t,value:d,...f,multiple:!1,children:[g,r]}),h]})});Co.displayName=`${q}.HTMLSelect`;var wo=e(j());const To=(0,K.forwardRef)((e,t)=>{let{bordered:n,className:r,compact:i,interactive:a,striped:o,...s}=e,c=(0,wo.default)(ct,{[B]:i,[lt]:n,[ut]:o,[de]:a},r);return(0,Y.jsx)(`table`,{...s,ref:t,className:c})});To.displayName=`${q}.HTMLTable`;var Eo=e(j());const Do=({className:e,title:t,titleId:n})=>(0,Y.jsx)(`li`,{className:(0,Eo.default)(t?zt:Rt,e),role:`separator`,children:t&&(0,Y.jsx)(ki,{id:n,children:t})});Do.displayName=`${q}.MenuDivider`;var Oo=e(j());const ko=({className:e,...t})=>(0,Y.jsx)(`div`,{className:(0,Oo.default)($t,e),...t});ko.displayName=`${q}.NavbarDivider`;var Ao=e(j());const jo=({align:e=M.START,children:t,className:n,...r})=>{let i=(0,Ao.default)(Zt,rr(e),n);return ti(()=>{e===M.CENTER&&console.warn(`[Blueprint] <NavbarGroup> does not support align="center". Only "left" or "right" alignment is allowed, and align="center" will be ignored.`)},[e]),(0,Y.jsx)(`div`,{className:i,...r,children:t})};jo.displayName=`${q}.NavbarGroup`;var Mo=e(j());const No=({children:e,className:t,...n})=>(0,Y.jsx)(`div`,{className:(0,Mo.default)(Qt,t),...n,children:e});No.displayName=`${q}.NavbarHeading`;var Po=e(j());const Fo=e=>{let{children:t,className:n,fixedToTop:r,...i}=e;return(0,Y.jsx)(`div`,{className:(0,Po.default)(Xt,{[le]:r},n),...i,children:t})};Fo.displayName=`${q}.Navbar`,Fo.Divider=ko,Fo.Group=jo,Fo.Heading=No;var Io=e(j()),Lo;(function(e){e[e.STANDARD=48]=`STANDARD`,e[e.SMALL=32]=`SMALL`,e[e.EXTRA_SMALL=20]=`EXTRA_SMALL`})(Lo||={});const Ro=e=>{let{action:t,children:n,className:r,description:i,icon:a,iconMuted:o=!0,iconSize:s=Lo.STANDARD,layout:c=`vertical`,title:l}=e;return(0,Y.jsxs)(`div`,{className:(0,Io.default)(en,`${en}-${c}`,r),children:[a==null?void 0:(0,Y.jsx)(`div`,{className:tn,style:{fontSize:`${s}px`,lineHeight:`${s}px`},children:(0,Y.jsx)(X,{className:(0,Io.default)({[nr]:o}),icon:a,size:s,"aria-hidden":!0,tabIndex:-1})}),l==null&&i==null?void 0:(0,Y.jsxs)(`div`,{className:nn,children:[l&&(0,Y.jsx)(Di,{children:l}),i&&Vr(i,`div`)]}),t,n]})};Ro.displayName=`${q}.NonIdealState`;var zo=e(j());const Bo=(0,K.forwardRef)((e,t)=>{let{children:n,className:r,collapseProps:i,collapsible:a,compact:o=!1,elevation:s=N.ZERO,icon:c,rightElement:l,subtitle:u,title:d,titleRenderer:f=ki,...p}=e,m=i?.isOpen!=null,[h,g]=(0,K.useState)(!(i?.defaultIsOpen??!0)),_=m?!i?.isOpen:h,v=(0,K.useCallback)(()=>{m?i?.onToggle?.():g(!_)},[i,_,m]),y=l!=null||a,b=Ir(`section`),x=d?Ir(`section-title`):void 0;return(0,Y.jsxs)(qa,{className:(0,zo.default)(r,Vt,{[B]:o,[Ht]:a&&_||Br(n)}),elevation:s,ref:t,"aria-labelledby":x,...p,id:b,children:[d&&(0,Y.jsxs)(`div`,{className:(0,zo.default)(Ut,{[de]:a}),onClick:a?v:void 0,children:[(0,Y.jsxs)(`div`,{className:Wt,children:[c&&(0,Y.jsx)(X,{icon:c,"aria-hidden":!0,tabIndex:-1,className:Se}),(0,Y.jsxs)(`div`,{children:[(0,K.createElement)(f,{className:Gt,id:x},d),u&&(0,Y.jsx)(`div`,{className:(0,zo.default)(Se,Kt),children:u})]})]}),y&&(0,Y.jsxs)(`div`,{className:qt,children:[l,a&&(0,Y.jsx)(`span`,{role:`button`,tabIndex:0,"aria-pressed":_,"aria-expanded":_,"aria-controls":b,"aria-label":_?`expand section`:`collapse section`,onKeyDown:Cr([`Enter`,` `]),className:(0,zo.default)(Se,Jt),children:_?(0,Y.jsx)(D,{}):(0,Y.jsx)(re,{})})]})]}),a?(0,Y.jsx)(Ya,{...i,isOpen:!_,children:n}):n]})});Bo.displayName=`${q}.Section`;var Vo=e(j());const Ho=(0,K.forwardRef)((e,t)=>{let{className:n,children:r,padded:i=!0,...a}=e;return(0,Y.jsx)(`div`,{className:(0,Vo.default)(Yt,{[he]:i},n),ref:t,...a,children:r})});Ho.displayName=`${q}.SectionCard`;var Uo=e(j()),Wo=class extends ei{static defaultProps={disabled:!1};static displayName=`${q}.Tab`;render(){let{className:e,panel:t}=this.props;return(0,Y.jsx)(`div`,{className:(0,Uo.default)(Vn,e),role:`tablist`,children:Er(t)?t({tabPanelId:``,tabTitleId:``}):t})}};const Go=e=>{let{className:t,large:n,onRemove:r,size:i,tabIndex:a}=e,o=n||i===`large`||t?.includes(U),s=(0,K.useCallback)(t=>{r?.(t,e)},[r,e]);return(0,Y.jsx)(`button`,{"aria-label":`Remove tag`,type:`button`,className:Wn,onClick:s,tabIndex:a,children:(0,Y.jsx)(O,{size:o?A.LARGE:A.STANDARD})})};Go.displayName=`${q}.TagRemoveButton`;var Ko=e(j());const qo=(0,K.forwardRef)((e,t)=>{let{children:n,className:r,endIcon:i,fill:a=!1,icon:o,intent:s,interactive:c,large:l=!1,minimal:u=!1,multiline:d,onRemove:f,rightIcon:p,round:m=!1,size:h=`medium`,tabIndex:g=0,htmlTitle:_,...v}=e,y=Er(f),b=c??v.onClick!=null,[x,ee]=ri(b,e,t,{defaultTabIndex:0,disabledTabIndex:void 0}),S=(0,Ko.default)(Un,G(s),sr(h,{large:l}),{[z]:x,[H]:a,[de]:b,[pe]:u,[_e]:m},r);return(0,Y.jsxs)(`span`,{...zr(v),...ee,className:S,role:b?`button`:void 0,children:[(0,Y.jsx)(X,{icon:o}),!Br(n)&&(0,Y.jsx)(vi,{className:H,ellipsize:!d,tagName:`span`,title:_,children:n}),(0,Y.jsx)(X,{icon:i??p}),y&&(0,Y.jsx)(Go,{...e})]})});qo.displayName=`${q}.Tag`;var Jo=e(j()),Yo=class extends ei{static displayName=`${q}.TabTitle`;render(){let{className:e,children:t,disabled:n,id:r,parentId:i,selected:a,title:o,icon:s,tagContent:c,tagProps:l,...u}=this.props,d=a?P.PRIMARY:P.NONE,{tabPanelId:f,tabTitleId:p}=Xo(i,r);return(0,Y.jsxs)(`div`,{...zr(u),"aria-controls":f,"aria-disabled":n,"aria-expanded":a,"aria-selected":a,className:(0,Jo.default)(Fn,e),"data-tab-id":r,id:p,onClick:n?void 0:this.handleClick,role:`tab`,tabIndex:n?void 0:a?0:-1,children:[s!=null&&(0,Y.jsx)(X,{icon:s,className:In}),o,t,c!=null&&(0,Y.jsx)(qo,{minimal:!0,intent:d,...l,className:(0,Jo.default)(Ln,l?.className),children:c})]})}handleClick=e=>this.props.onClick(this.props.id,e)};function Xo(e,t){return{tabPanelId:`${Vn}_${e}_${t}`,tabTitleId:`${Fn}-title_${e}_${t}`}}var Zo=e(j()),Qo=class extends ei{render(){let{className:e,id:t,parentId:n,selectedTabId:r,panel:i,renderActiveTabPanelOnly:a}=this.props,o=t===r;if(i===void 0||a&&!o)return;let{tabTitleId:s,tabPanelId:c}=Xo(n,t);return(0,Y.jsx)(`div`,{"aria-labelledby":s,"aria-hidden":!o,className:(0,Zo.default)(Vn,e),id:c,role:`tabpanel`,children:Er(i)?i({tabPanelId:c,tabTitleId:s}):i})}},$o=e(j()),es=`.${Fn}`,ts=class extends ei{static Tab=Wo;static defaultProps={animate:!0,fill:!1,large:!1,renderActiveTabPanelOnly:!1,size:`medium`,vertical:!1};static displayName=`${q}.Tabs`;static getDerivedStateFromProps({selectedTabId:e}){return e===void 0?null:{selectedTabId:e}}tablistElement=null;refHandlers={tablist:e=>this.tablistElement=e};constructor(e){super(e),this.state={selectedTabId:this.getInitialSelectedTabId()}}render(){let{animate:e,children:t,className:n,fill:r,large:i,renderActiveTabPanelOnly:a,size:o=`medium`,vertical:s}=this.props,{indicatorWrapperStyle:c,selectedTabId:l}=this.state,u=K.Children.map(t,this.renderTabTitle),d=this.getTabChildren().filter(a?e=>e.props.id===l:()=>!0).map(this.renderTabPanel),f=e?(0,Y.jsx)(`div`,{className:zn,style:c,children:(0,Y.jsx)(`div`,{className:Rn})}):null;return(0,Y.jsxs)(`div`,{className:(0,$o.default)(Hn,n,{[be]:s,[H]:r}),children:[(0,Y.jsxs)(`div`,{className:(0,$o.default)(Bn,sr(o,{large:i})),onKeyDown:this.handleKeyDown,onKeyPress:this.handleKeyPress,ref:this.refHandlers.tablist,role:`tablist`,children:[f,u]}),d]})}componentDidMount(){this.moveSelectionIndicator(!1)}componentDidUpdate(e,t){this.state.selectedTabId===t.selectedTabId?t.selectedTabId!=null&&(fr(this.getTabChildrenProps(e),this.getTabChildrenProps(),pr)||this.moveSelectionIndicator()):this.moveSelectionIndicator()}getInitialSelectedTabId(){let{defaultSelectedTabId:e,selectedTabId:t}=this.props;if(t!==void 0)return t;if(e!==void 0)return e;{let e=this.getTabChildren();return e.length===0?void 0:e[0].props.id}}getTabChildrenProps(e=this.props){return this.getTabChildren(e).map(e=>e.props)}getTabChildren(e=this.props){return K.Children.toArray(e.children).filter(ns)}getTabElements(e=``){return this.tablistElement==null?[]:Array.from(this.tablistElement.querySelectorAll(es+e))}handleKeyDown=e=>{let t=Yr(e,[`ArrowLeft`,`ArrowUp`],[`ArrowRight`,`ArrowDown`]);if(t===void 0)return;let n=Sr(this.tablistElement)?.closest(es);if(!n)return;let r=this.getTabElements(`[aria-disabled="false"]`),i=r.indexOf(n);if(i<0)return;e.preventDefault();let{length:a}=r;r[(i+t+a)%a].focus()};handleKeyPress=e=>{let t=e.target.closest(es);t!=null&&Jr(e)&&(e.preventDefault(),t.click())};handleTabClick=(e,t)=>{this.props.onChange?.(e,this.state.selectedTabId,t),this.props.selectedTabId===void 0&&this.setState({selectedTabId:e})};moveSelectionIndicator(e=!0){if(this.tablistElement==null||!this.props.animate)return;let t=`${es}[data-tab-id="${this.state.selectedTabId}"]`,n=this.tablistElement.querySelector(t),r={display:`none`};if(n!=null){let{clientHeight:t,clientWidth:i,offsetLeft:a,offsetTop:o}=n;r={height:t,transform:`translateX(${Math.floor(a)}px) translateY(${Math.floor(o)}px)`,width:i},e||(r.transition=`none`)}this.setState({indicatorWrapperStyle:r})}renderTabPanel=e=>{let{className:t,panel:n,id:r,panelClassName:i}=e.props;if(n!==void 0)return(0,K.createElement)(Qo,{...e.props,key:r,className:(0,$o.default)(t,i),parentId:this.props.id,selectedTabId:this.state.selectedTabId})};renderTabTitle=e=>{if(ns(e)){let{id:t}=e.props;return(0,Y.jsx)(Yo,{...e.props,parentId:this.props.id,onClick:this.handleTabClick,selected:t===this.state.selectedTabId})}return e}};function ns(e){return Gr(e,Wo)}function rs(e,t){let n=(0,K.useRef)(e);gi(()=>{n.current=e},[e]),(0,K.useEffect)(()=>{if(!t&&t!==0)return;let e=setTimeout(()=>n.current(),t);return()=>clearTimeout(e)},[t])}var is=e(j());const as=(0,K.forwardRef)((e,t)=>{let{action:n,className:r,icon:i,intent:a,isCloseButtonShown:o=!0,message:s,onDismiss:c,timeout:l=5e3}=e,[u,d]=(0,K.useState)(!1),f=(0,K.useCallback)(()=>d(!0),[]),p=(0,K.useCallback)(()=>d(!1),[]),m=l!=null&&l>0;rs(()=>{h(!0)},u&&m?l:null),(0,K.useEffect)(()=>(m?f():p(),p),[p,f,m,l]);let h=(0,K.useCallback)(e=>{p(),c?.(e)},[p,c]),g=(0,K.useCallback)(()=>h(!1),[h]),_=(0,K.useCallback)(e=>{n?.onClick?.(e),h(!1)},[n,h]);return(0,Y.jsxs)(`div`,{className:(0,is.default)(qn,G(a),r),onBlur:f,onFocus:p,onMouseEnter:p,onMouseLeave:f,ref:t,tabIndex:0,children:[(0,Y.jsx)(X,{icon:i}),(0,Y.jsx)(`span`,{className:Yn,role:`alert`,children:s}),(0,Y.jsxs)(Ha,{variant:`minimal`,children:[n&&(0,Y.jsx)(xi,{...n,intent:void 0,onClick:_}),o&&(0,Y.jsx)(bi,{"aria-label":`Close`,icon:(0,Y.jsx)(E,{}),onClick:g})]})]})});as.displayName=`${q}.Toast`;var os=e(j()),ss=p(),cs=(e,t)=>{(0,ss.createRoot)(t).render(e)},ls=class e extends ei{static displayName=`${q}.OverlayToaster`;static defaultProps={autoFocus:!1,canEscapeKeyClear:!0,position:F.TOP,usePortal:!0};static create(t,n={}){t!=null&&t.usePortal!=null&&!Nr(`production`)&&console.warn(`[Blueprint] OverlayToaster.create() ignores inline prop as it always creates a new element.`);let{container:r=document.body,domRenderer:i=cs}=n,a=document.createElement(`div`);return r.appendChild(a),new Promise((n,r)=>{try{i((0,Y.jsx)(e,{...t,ref:o,usePortal:!1}),a)}catch(e){r(e)}function o(e){if(e==null){r(Error(`[Blueprint] OverlayToaster.create() is not supported inside React lifecycle methods in React 16. See usage example on the docs site. https://blueprintjs.com/docs/#core/components/toast.example`));return}n(e)}})}static createAsync(t,n){return e.create(t,n)}state={toastRefs:{},toasts:[]};queue={cancel:void 0,isRunning:!1,toasts:[]};toastId=0;toastRefs={};getToastRefs=e=>e.reduce((e,t)=>(e[t.key]=(0,K.createRef)(),e),{});show(e,t){let n=this.createToastOptions(e,t);return this.maybeUpdateExistingToast(n,t)||(this.queue.isRunning?this.queue.toasts.push(n):(this.immediatelyShowToast(n),this.startQueueTimeout())),n.key}maybeUpdateExistingToast(e,t){return t==null?!1:this.queue.toasts.some(e=>e.key===t)?(this.queue.toasts=this.queue.toasts.map(n=>n.key===t?e:n),!0):this.state.toasts.some(e=>e.key===t)?(this.updateToastsInState(n=>n.map(n=>n.key===t?e:n)),!0):!1}immediatelyShowToast(e){this.props.maxToasts&&this.dismissIfAtLimit(),this.updateToastsInState(t=>[e,...t])}startQueueTimeout(){this.queue.isRunning=!0,this.queue.cancel=this.setTimeout(this.handleQueueTimeout,50)}handleQueueTimeout=()=>{let e=this.queue.toasts.shift();e==null?this.queue.isRunning=!1:(this.immediatelyShowToast(e),this.startQueueTimeout())};updateToastsInState(e){this.setState(t=>{let n=e(t.toasts);return{toastRefs:this.getToastRefs(n),toasts:n}})}dismiss(e,t=!1){this.setState(n=>{let r=n.toasts.filter(n=>{let r=n.key===e;return r&&n.onDismiss?.(t),!r});return{toastRefs:this.getToastRefs(r),toasts:r}})}clear(){this.queue.cancel?.(),this.queue={cancel:void 0,isRunning:!1,toasts:[]},this.state.toasts.forEach(e=>e.onDismiss?.(!1)),this.setState({toastRefs:{},toasts:[]})}getToasts(){return this.state.toasts}render(){let e=(0,os.default)(Jn,this.getPositionClasses(),this.props.className);return(0,Y.jsxs)(Yi,{autoFocus:this.props.autoFocus,canEscapeKeyClose:this.props.canEscapeKeyClear,canOutsideClickClose:!1,className:e,childRefs:this.toastRefs,enforceFocus:!1,hasBackdrop:!1,isOpen:this.state.toasts.length>0||K.Children.count(this.props.children)>0,onClose:this.handleClose,shouldReturnFocusOnClose:!1,transitionDuration:350,transitionName:qn,usePortal:this.props.usePortal,children:[this.state.toasts.map(this.renderToast,this),this.props.children]})}validateProps({maxToasts:e}){if(e!==void 0&&e<1)throw Error(`[Blueprint] <OverlayToaster> maxToasts is set to an invalid number, must be greater than 0`)}dismissIfAtLimit(){this.state.toasts.length===this.props.maxToasts&&this.dismiss(this.state.toasts[this.state.toasts.length-1].key)}renderToast=e=>{let{key:t,...n}=e;return(0,Y.jsx)(as,{...n,onDismiss:this.getDismissHandler(e)},t)};createToastOptions(e,t=`toast-${this.toastId++}`){return{...e,key:t}}getPositionClasses(){return[...this.props.position.split(`-`).map(e=>`${Jn}-${e.toLowerCase()}`),`${Jn}-${this.props.usePortal?`in-portal`:`inline`}`]}getDismissHandler=e=>t=>{this.dismiss(e.key,t)};handleClose=e=>{e.key===`Escape`&&this.clear()}};export{ji as A,et as B,Wa as C,ia as D,Oa as E,pi as F,P as H,X as I,dr as L,Di as M,Oi as N,na as O,bi as P,Je as R,qa as S,Ra as T,N as U,F as V,M as W,oo as _,Ho as a,eo as b,Fo as c,Co as d,xo as f,lo as g,po as h,Wo as i,Ei as j,ea as k,Do as l,ho as m,ts as n,Bo as o,_o as p,qo as r,Ro as s,ls as t,To as u,io as v,Ha as w,Ya as x,no as y,Ze as z};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./rolldown-runtime-C4Xdq4VV.js";import{a as n,c as r,h as i,l as a,o,s}from"./vendor-react-DYK5a2J9.js";import{S as c}from"./vendor-icons-other-BTYC6Wvz.js";function l(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var u=e=>e?`"${e}" `:``;function d(e,t=``){if(typeof e!=`number`)throw TypeError(u(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(u(t)+`expected integer >= 0, got `+e);return e}function f(e,t=``){if(typeof e!=`boolean`)throw TypeError(u(t)+`expected boolean, got type=`+typeof e);return e}function p(e,t,n=``){if(l(e)&&(t===void 0||e.length===t))return e;t!==void 0&&d(t,`length`);let r=l(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=u(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function m(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(d(e.outputLen),d(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var h=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},g=(e,t)=>{h(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function _(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function v(e,t){p(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function y(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function b(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function x(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function S(e,t){return e<<32-t|e>>>t}const C=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function w(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T(e){for(let t=0;t<e.length;t++)e[t]=w(e[t]);return e}const E=C?e=>e:T;var D=(()=>typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`)(),O=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function k(e){if(p(e),D)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=O[e[n]];return t}function A(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function j(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(D)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=A(e.charCodeAt(i)),a=A(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function M(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];p(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function N(e,t,n=`opts`){return g(e,`defaults`),t!==void 0&&g(t,n),Object.assign(Object.create(null),e,t)}function ee(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=N({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function te(e=32){d(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const ne=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function re(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const P=(e,t,n)=>p(e,t,n),ie=d;function ae(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function oe(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function se(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const ce=k,le=(...e)=>M(...e),ue=e=>j(e),de=l,fe=e=>te(e);var pe=BigInt(0),me=BigInt(1),he=e=>e?`"${e}" `:``;function ge(e,t=``){if(typeof e!=`boolean`)throw TypeError(he(t)+`expected boolean, got type=`+typeof e);return e}function _e(e){if(typeof e==`bigint`){if(!De(e))throw RangeError(`positive bigint expected, got `+e)}else ie(e);return e}function ve(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function ye(e){let t=_e(e).toString(16);return t.length&1?`0`+t:t}function be(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?pe:BigInt(`0x`+e)}function xe(e){return be(k(e))}function Se(e){return be(k(Te(p(e)).reverse()))}function Ce(e,t){if(d(t),t===0)throw Error(`zero output length is invalid`);e=_e(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return j(r.padStart(n,`0`))}function we(e,t){return Ce(e,t).reverse()}function Te(e){return Uint8Array.from(P(e))}function Ee(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function De(e){return typeof e==`bigint`&&pe<=e}function Oe(e,t,n){return De(e)&&De(t)&&De(n)&&t<=e&&e<n}function ke(e,t,n,r){if(!Oe(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Ae(e){if(e<pe)throw Error(`expected non-negative bigint, got `+e);return e===pe?0:e.toString(2).length}const je=e=>(ve(e,`n`),(me<<BigInt(e))-me);function Me(e,t,n){if(d(e,`hashLen`),d(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},f=(...e)=>n(c,le(s,...e)),p=(e=i)=>{c=f(a,e),s=f(),e.length!==0&&(c=f(o,e),s=f())},m=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=f();let t=s.slice();n.push(t),e+=s.length}return le(...n)};return(e,t)=>{u(),p(e);let n;for(;(n=t(m()))===void 0;)p();return u(),n}}function Ne(e,t={},n={},r=`object`){oe(e,r),oe(t,`fields`),oe(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var F=BigInt(0),I=BigInt(1),Pe=BigInt(2),Fe=BigInt(3),Ie=BigInt(4),Le=BigInt(5),Re=BigInt(7),ze=BigInt(8),Be=BigInt(9),Ve=BigInt(15),He=BigInt(16),Ue=BigInt(`0x10000000000000000`);function L(e,t){if(t<=F)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=F?n:t+n}function We(e,t,n){if(n<=I)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<F)throw Error(`invalid exponent, negatives unsupported`);if(t===F)return I;if(t===I)return e;let r=e%n;if(r<F&&(r+=n),t<Ue){let e=I;for(;t>F;)t&I&&(e=e*r%n),r=r*r%n,t>>=I;return e}let i=[];for(;t>F;)i.push(Number(t&Ve)),t>>=Ie;let a=Array(16);a[0]=I,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function Ge(e,t){if(e===F)throw Error(`invert: expected non-zero number`);if(t<=I)throw Error(`invert: expected modulus > 1, got `+t);let n=L(e,t),r=t,i=F,a=I;for(;n!==F;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==I)throw Error(`invert: does not exist`);return L(i,t)}function Ke(e,t){if(t<=I)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=L(e,t);if(n===F)throw Error(`invertCt: expected non-zero number`);let r=We(n,t-Pe,t);if(L(n*r,t)!==I)throw Error(`invertCt: does not exist`);return r}function qe(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Je(e,t){if((e&I)===F)throw Error(t+`: expected odd modulus, got `+e)}function Ye(e,t){let n=e,r=(n.ORDER+I)/Ie,i=n.pow(t,r);return qe(n,i,t),i}function Xe(e,t){let n=e,r=(n.ORDER-Le)/ze,i=n.mul(t,Pe),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Pe),a),c=n.mul(o,n.sub(s,n.ONE));return qe(n,c,t),c}function Ze(e){let t=st(e),n=Qe(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Re)/He;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return qe(n,m,t),m})}function Qe(e){if(e<Fe)throw Error(`sqrt is not defined for small field`);Je(e,`tonelliShanks`);let t=e-I,n=0;for(;t%Pe===F;)t/=Pe,n++;let r=Pe,i=st(e);for(;rt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Ye;let a=i.pow(r,t),o=(t+I)/Pe;return function(e,r){let i=e;if(i.is0(r))return r;if(rt(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=I<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function $e(e){return Je(e,`Fp.sqrt`),e%Ie===Fe?Ye:e%ze===Le?Xe:e%He===Be?Ze(e):Qe(e)}var et=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function tt(e){if(oe(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);ve(e.BYTES,`BYTES`),ve(e.BITS,`BITS`);for(let t of et)se(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=I)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function nt(e,t,n=!1){tt(e),re(t,`nums`),ge(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function rt(e,t){tt(e);let n=e;Je(n.ORDER,`FpLegendre`);let r=(n.ORDER-I)/Pe,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function it(e,t){if(t!==void 0&&ie(t),e<=F)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Ae(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var at=new WeakMap,ot=class{ORDER;BITS;BYTES;isLE;ZERO=F;ONE=I;_lengths;_mod;constructor(e,t={}){if(e<=I)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,`sqrt`,{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=it(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return L(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return F<=e&&e<this.ORDER}is0(e){return e===F}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&I)===I}neg(e){return L(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return L(e*e,this.ORDER)}add(e,t){return L(e+t,this.ORDER)}sub(e,t){return L(e-t,this.ORDER)}mul(e,t){return L(e*t,this.ORDER)}pow(e,t){return We(e,t,this.ORDER)}div(e,t){return L(e*Ge(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Ge(e,this.ORDER)}sqrt(e){let t=at.get(this);return t||at.set(this,t=$e(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?we(e,this.BYTES):Ce(e,this.BYTES)}fromBytes(e,t=!1){P(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Se(e):xe(e);if(o&&(s=L(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return nt(this,e,!0)}cmov(e,t,n){return ge(n,`condition`),n?t:e}};function st(e,t={}){return Object.freeze(ot.prototype),new ot(e,t)}function ct(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=I)throw Error(`field order must be greater than 1`);let t=Ae(e-I);return Math.ceil(t/8)}function lt(e){let t=ct(e);return t+Math.ceil(t/2)}function ut(e,t,n=!1){P(e);let r=e.length,i=ct(t),a=Math.max(lt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=L(n?Se(e):xe(e),t-I)+I;return n?we(o,i):Ce(o,i)}var dt=BigInt(0),ft=BigInt(1),pt=BigInt(4),mt=16,ht=128,gt=5,_t=(()=>2**31)();function vt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);se(t.fromAffine,`Point.fromAffine`),se(t.fromBytes,`Point.fromBytes`),se(t.fromHex,`Point.fromHex`),oe(t.BASE,`Point.BASE`),oe(t.ZERO,`Point.ZERO`),tt(t.Fp),tt(t.Fn)}function yt(e,t){vt(e),Ct(t,e);let n=nt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function bt(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function xt(e,t){let n=e*(4*t+128);if(n>_t)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+_t/2**20+` MiB`)}function St(e,t){if(e!==void 0){se(e,`randomBytes`);try{let n=e(t);if(!de(n)||n.length!==t)return}catch{return}return e}}function Ct(e,t){re(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function wt(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):De(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Tt=new WeakMap;function Et(e){return Tt.get(e)||1}function Dt(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function Ot(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>dt;){let t=0;e&ft&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=ft}return a}function kt(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=ft),s.push(t)}if(e!==dt)throw Error(`invalid wnaf`);return s}function At(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var jt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){vt(e),this.randomBytes=St(t,mt),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=kt(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Oe(t,ft,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Et(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+ht,i=this.randomBytes(mt);if(!de(i)||i.length!==mt)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+xe(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=gt,i=1<<r,a=je(r),o=Array(i);o[0]=this.ZERO;for(let t=1;t<i;t++)o[t]=o[t-1].add(e);let s=Math.ceil(n/r),c=this.ZERO;for(let e=s-1;e>=0;e--){if(e!==s-1)for(let e=0;e<r;e++)c=c.double();let n=Number(t>>BigInt(e*r)&a),l=o[0];for(let e=1;e<i;e++)l=e===n?o[e]:l;c=c.add(l)}return{p:c,f:c}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===ft?!0:e===this.BASE?(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded):!1}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!De(t))throw Error(`invalid scalar`);let r=Et(e);if(r===1||t>=this.Point.Fn.ORDER)return Mt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),bt(t,this.bits),xt((Math.ceil((this.bits+ht)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Tt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Et(e)!==1}};function Mt(e,t,n,r=!1){if(vt(e),Ct(t,e),ge(r,`allowOversized`),wt(n,e.Fn,r?e.Fn.ORDER**pt:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Dt(e,4)),a=n.map(e=>Ot(e,4));return At(e.ZERO,i,a)}function Nt(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return tt(t),t}else return st(e,{isLE:n})}function Pt(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Ne(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(De(n)&&n!==dt))throw Error(`CURVE.${e} must be positive bigint`)}let i=Nt(t.p,n.Fp,r),a=Nt(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Ft(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var It=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(m(e),p(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),b(r)}update(e){return _(this),this.iHash.update(e),this}digestInto(e){_(this),v(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Lt=(()=>{let e=((e,t,n)=>new It(e,t).update(n).digest());return e.create=(e,t)=>new It(e,t),e})();var Rt=BigInt(0),zt={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=zt;if(ve(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(ae(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=ye(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?ye(i.length/2|128):``;return ye(e)+a+i+t},decode(e,t){let{Err:n}=zt;t=P(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=zt;if(_e(e),e<Rt)throw new t(`integer: negative integers are not allowed`);let n=ye(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=zt;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return xe(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=zt;if(t!==void 0&&(ve(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=P(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=zt;Ne(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};const Bt=(()=>(Object.freeze(zt._tlv),Object.freeze(zt._int),Object.freeze(zt)))();var Vt=(e,t)=>(e+(e>=0?t:-t)/qt)/t;function Ht(e,t,n){ke(`scalar`,e,Gt,n);let[[r,i],[a,o]]=t,s=Vt(o*e,n),c=Vt(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Gt,f=u<Gt;d&&(l=-l),f&&(u=-u);let p=je(Math.ceil(Ae(n)/2))+Kt;if(l<Gt||l>=p||u<Gt||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Ut(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Wt(e,t){Ne(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ge(n.lowS,`lowS`),ge(n.prehash,`prehash`),n.format!==void 0&&Ut(n.format),n}var Gt=BigInt(0),Kt=BigInt(1),qt=BigInt(2),Jt=BigInt(3),Yt=BigInt(4);function Xt(e,t={}){let n=Pt(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Ne(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?fe:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=Qt(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ge(n,`isCompressed`),n?(_(),le(Zt(!r.isOdd(a)),o)):le(Uint8Array.of(4),o,r.toBytes(a))}function y(e){P(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=w(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!T(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let b=p===void 0?v:p,x=f===void 0?y:f,S=r.mul(a.b,Jt),C=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function w(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function T(e,t){let n=r.sqr(t),i=w(e);return r.eql(n,i)}if(!T(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let E=r.mul(r.pow(a.a,Jt),Yt),D=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(E,D)))throw Error(`bad curve params: a or b`);function O(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function k(e){if(!(e instanceof N))throw Error(`Weierstrass Point expected`)}function A(e){if(!h||!h.basises)throw Error(`no endo`);return Ht(e,h.basises,i.ORDER)}function j(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=A(a),l=new N(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let M=new WeakSet;class N{static BASE=new N(a.Gx,a.Gy,r.ONE);static ZERO=new N(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=O(`x`,e),this.Y=O(`y`,t,!0),this.Z=O(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof N)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?N.ZERO:new N(t,n,r.ONE)}static fromBytes(e){let t=N.fromAffine(x(P(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return N.fromBytes(ue(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return te.setWindowSize(this,e),t||this.multiply(Jt),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(M.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!T(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);M.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new N(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=C(o),a=r.mul(S,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(S,o),l=C(l),u=r.sub(s,l),u=C(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new N(i,a,o)}add(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=C(h),c=r.mul(S,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=C(p),h=r.mul(S,h),f=r.add(f,p),p=r.sub(d,p),p=C(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new N(c,l,u)}subtract(e){return k(e),this.add(e.negate())}is0(){return this.equals(N.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=te.mulSecret(this,e,o,ee);return ee([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===Gt||t.is0())return N.ZERO;if(n===Kt)return t;if(te.hasWindowSize(this))return te.mulUnsafe(t,n,ee);let r=[],a=[];return j(r,a,t,n),Mt(N,r,a)}mulAddUnsafe(e,t,n){k(t);let r=[],i=[];return j(r,i,this,e),j(r,i,t,n),Mt(N,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===Kt?!0:d?d(N,this):te.mulUnsafe(this,s).is0()}clearCofactor(){return o===Kt?this:u?u(N,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Kt?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return ge(e,`isCompressed`),this.assertValidity(),b(N,this,e)}toHex(e=!0){return ce(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ee=e=>yt(N,e),te=new jt(N,m);return te.bits>=6&&N.BASE.precompute(6),Object.freeze(N.prototype),Object.freeze(N),N}function Zt(e){return Uint8Array.of(e?2:3)}function Qt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function $t(e,t={}){vt(e);let{Fn:n}=e,r=t.randomBytes===void 0?fe:t.randomBytes,i=Object.assign(Qt(e.Fp,n),{seed:Math.max(lt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,ut(P(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!de(e))return;let s=P(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Ft(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function en(e,t,n={}){vt(e);let r=t;m(r),Ne(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?fe:i.randomBytes,o=i.hmac===void 0?(e,t)=>Lt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=lt(l),f=St(a,d),{keygen:p,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v}=$t(e,i),y={prehash:!0,lowS:typeof i.lowS==`boolean`?i.lowS:!0,format:`compact`,extraEntropy:!1},b=l*qt+Kt<s.ORDER;function x(e){return e>l>>Kt}function S(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function C(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function w(e,t,n){return C(),(e===n?0:2)|Number(s.isOdd(t))}function T(){if(b)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function E(e,t){Ut(t);let n=v.signature;return P(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class D{r;s;recovery;constructor(e,t,n){if(this.r=S(`r`,e),this.s=S(`s`,t),n!=null){if(T(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=y.format){E(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Bt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Bt.toSig(P(e),c.BYTES+1);return new D(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=v.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new D(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(ue(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new D(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(le(Zt((i&1)==0),o)),d=c.inv(a),f=k(P(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return x(this.s)}toBytes(e=y.format){if(Ut(e),e===`der`)return ue(Bt.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(T(),le(Uint8Array.of(this.assertRecovery()),r,i)):le(r,i)}toHex(e){return ce(this.toBytes(e))}}Object.freeze(D.prototype),Object.freeze(D);let O=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=xe(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,k=i.bits2int_modN===void 0?function(e){return c.create(O(e))}:i.bits2int_modN,A=je(u);function j(e){return ke(`num < 2^`+u,e,Gt,A),c.toBytes(e)}function M(e,t){return P(e,void 0,`message`),t?P(r(e),void 0,`prehashed message`):e}function N(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Wt(r,y);t=M(t,o);let u=k(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[j(p),j(u)];if(s!=null&&s!==!1){let e=s===!0?a(v.secretKey):s;m.push(P(e,void 0,`extraEntropy`))}let h=le(...m),g=u;function _(t){let n=O(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===Gt)return;let o;if(f!==void 0){let e=xe(ut(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=Ke(n,l);o=c.create(e*c.create(g+a*p))}if(o===Gt)return;let s=w(r.x,r.y,a),u=o;return i&&x(o)&&(u=c.neg(o),s^=1),new D(a,u,b?void 0:s)}return{seed:h,k2sig:_}}function ee(e,t,n={}){let{seed:i,k2sig:a}=N(e,t,n);return Me(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function te(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Wt(i,y);if(r=P(r,void 0,`publicKey`),n=M(n,o),!de(t)){let e=t instanceof D?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}E(t,s);try{let i=D.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=k(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==w(g.x,g.y,l))}catch{return!1}}function ne(e,t,n={}){let{prehash:r}=Wt(n,y);return t=M(t,r),D.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v,Point:e,sign:ee,verify:te,recoverPublicKey:ne,Signature:D,hash:r})}var tn=(()=>BigInt(2**32-1))(),nn=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&tn),l:Number(e>>nn&tn)}:{h:Number(e>>nn&tn)|0,l:Number(e&tn)|0}}function an(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=rn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var on=e=>e/2**32|0,sn=e=>e>>>0;function cn(e,t,n,r){let i=on(n),a=sn(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function ln(e,t,n){return e&t^~e&n}function un(e,t,n){return e&t^e&n^t&n}var dn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=x(this.buffer)}update(e){_(this),p(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=x(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){_(this),v(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),cn(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:x(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const fn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var pn=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]),mn=new Uint32Array(64),hn=class extends dn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)mn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=mn[e-15],n=mn[e-2],r=S(t,7)^S(t,18)^t>>>3;mn[e]=(S(n,17)^S(n,19)^n>>>10)+mn[e-7]+r+mn[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=S(o,6)^S(o,11)^S(o,25),u=l+t+ln(o,s,c)+pn[e]+mn[e]|0,d=(S(n,2)^S(n,13)^S(n,22))+un(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){b(mn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),b(this.buffer)}},gn=class extends hn{constructor(){super(32,fn)}};const _n=ee(()=>new gn,ne(1));function vn(e,t=`n`){if(typeof e!=`number`)throw TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function yn(e){return vn(e,`x`),(e&e-1)==0&&e!==0}function bn(e,t){if(vn(e),typeof t!=`number`)throw TypeError(`"bits" expected number, got type=`+typeof t);if(!Number.isSafeInteger(t)||t<0||t>32)throw Error(`expected integer 0 <= bits <= 32, got ${t}`);let n=0;for(let r=0;r<t;r++,e>>>=1)n=n<<1|e&1;return n>>>0}function xn(e){return vn(e),31-Math.clz32(e)}function Sn(e){if(!e||typeof e!=`object`||typeof e.length!=`number`)throw TypeError(`"values" expected array-like, got type=`+typeof e);let t=e.length;if(!yn(t))throw Error(`expected positive power-of-two length, got `+t);let n=xn(t);for(let r=0;r<t;r++){let t=bn(r,n);if(r<t){let n=e[r];e[r]=e[t],e[t]=n}}return e}const Cn=(e,t)=>{Ne(t,{N:`number`,roots:`object`,dit:`boolean`},{invertButterflies:`boolean`,skipStages:`number`,brp:`boolean`},`coreOpts`);let{N:n,roots:r,dit:i,invertButterflies:a=!1,skipStages:o=0,brp:s=!0}=t;vn(n,`coreOpts.N`);let c=xn(n);if(!yn(n))throw Error(`FFT: Polynomial size should be power of two`);vn(o,`coreOpts.skipStages`);let l=c===0?0:c-1;if(o>l)throw Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${l}`);if(r.length!==n)throw Error(`FFT: wrong roots length: expected ${n}, got ${r.length}`);let u=i!==a;return t=>{if(t.length!==n)throw Error(`FFT: wrong Polynomial length`);i&&s&&Sn(t);for(let s=0,l=1;s<c-o;s++){let d=i?s+1+o:c-s,f=1<<d,p=f>>1,m=n>>d;for(let o=0;o<n;o+=f)for(let s=0,c=l++;s<p;s++){let l=a?i?n-c:c:s*m,d=o+s,f=o+s+p,h=r[l],g=t[f],_=t[d];if(u){let n=e.mul(g,h);t[d]=e.add(_,n),t[f]=e.sub(_,n)}else a?(t[d]=e.add(g,_),t[f]=e.mul(e.sub(g,_),h)):(t[d]=e.add(_,g),t[f]=e.mul(e.sub(_,g),h))}}return!i&&s&&Sn(t),t}},wn=en(Xt((()=>({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}))()),_n);var Tn=BigInt(0),En=BigInt(1),Dn=BigInt(2),On=BigInt(7),kn=BigInt(256),An=BigInt(113),jn=[],Mn=[],Nn=[];for(let e=0,t=En,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],jn.push(2*(5*r+n)),Mn.push((e+1)*(e+2)/2%64);let i=Tn;for(let e=0;e<7;e++)t=(t<<En^(t>>On)*An)%kn,t&Dn&&(i^=En<<(En<<BigInt(e))-En);Nn.push(i)}var Pn=an(Nn,!0),Fn=Pn[0],In=Pn[1],Ln=(e,t,n)=>e<<n|t>>>32-n,Rn=(e,t,n)=>t<<n|e>>>32-n,zn=(e,t,n)=>t<<n-32|e>>>64-n,Bn=(e,t,n)=>e<<n-32|t>>>64-n,Vn=(e,t,n)=>n>32?zn(e,t,n):Ln(e,t,n),Hn=(e,t,n)=>n>32?Bn(e,t,n):Rn(e,t,n),Un=new Uint32Array(10);function Wn(e,t=24){if(!(e instanceof Uint32Array))throw TypeError(`"s" expected Uint32Array(50), got type=`+typeof e);if(e.length!==50)throw RangeError(`"s" expected Uint32Array(50), got length=`+e.length);if(d(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)Un[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,r=(t+2)%10,i=Un[r],a=Un[r+1],o=Vn(i,a,1)^Un[n],s=Hn(i,a,1)^Un[n+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=s}let t=e[2],r=e[3];for(let n=0;n<24;n++){let i=Mn[n],a=Vn(t,r,i),o=Hn(t,r,i),s=jn[n];t=e[s],r=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=Fn[n],e[1]^=In[n]}b(Un)}var Gn=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(d(e,`blockLen`),d(t,`suffix`),d(i,`rounds`),f(r,`enableXOF`),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,d(n,`outputLen`),!(0<e&&e<200))throw Error(`"blockLen" must be 1..199`);this.state=new Uint8Array(200),this.state32=y(this.state)}clone(){return this._cloneInto()}keccak(){E(this.state32),Wn(this.state32,this.rounds),E(this.state32),this.posOut=0,this.pos=0}update(e){_(this),p(e);let{blockLen:t,state:n,state32:r}=this,i=e.length,a=t%4==0&&e.byteOffset%4==0,o=t/4,s=a&&i>=t?y(e):void 0;for(let a=0;a<i;){if(s!==void 0&&this.pos===0&&a%4==0&&i-a>=t){for(let e=0,t=a/4;e<o;e++)r[e]^=s[t+e];a+=t,this.pos=t,this.keccak();continue}let c=Math.min(t-this.pos,i-a);for(let t=0;t<c;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){_(this,!1),p(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not enabled`);return this.writeInto(e)}xof(e){return d(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(v(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,b(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},Kn=(e,t,n,r={})=>ee(()=>new Gn(t,e,n),r);const qn=Kn(6,136,32,ne(8)),Jn=Kn(6,72,64,ne(10));var Yn=(e,t,n,r={})=>ee((r={})=>(r=N({},r),new Gn(t,e,r.dkLen===void 0?n:r.dkLen,!0)),r);const Xn=Yn(31,168,16,ne(11)),Zn=Yn(31,136,32,ne(12));var Qn=p;const $n=te;function er(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function tr(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function nr(e,t){if(e=p(e),t=p(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function rr(e){return new Uint8Array(p(e))}function ir(e,...t){let n=e=>typeof e==`number`?e:e.bytesLen,r=t.reduce((e,t)=>e+n(t),0);return{bytesLen:r,encode:i=>{let a=new Uint8Array(r);for(let r=0,o=0;r<t.length;r++){let s=t[r],c=n(s),l=typeof s==`number`?i[r]:s.encode(i[r]);p(l,c,e),a.set(l,o),typeof s!=`number`&&l.fill(0),o+=c}return a},decode:i=>{p(i,r,e);let a=[];for(let e of t){let t=n(e),r=i.subarray(0,t);a.push(typeof e==`number`?r:e.decode(r)),i=i.subarray(t)}return a}}}function ar(e,t){let n=e,r=t*n.bytesLen;return{bytesLen:r,encode:e=>{let i=er(e,`u`);if(i.length!==t)throw RangeError(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let a=new Uint8Array(r);for(let e=0,t=0;e<i.length;e++){let r=n.encode(i[e]);a.set(r,t),r.fill(0),t+=r.length}return a},decode:e=>{p(e,r);let t=[];for(let r=0;r<e.length;r+=n.bytesLen)t.push(n.decode(e.subarray(r,r+n.bytesLen)));return t}}}function R(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function or(e){if(d(e,`bits`),e>32)throw RangeError(`"bits" expected <= 32, got `+e);return e===32?4294967295:~(-1<<e)>>>0}const sr=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=bn(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=e=>{throw Error(`not implemented`)},p=s?{add:(e,t)=>{let n=e+t|0;return n>=r?n-r|0:n},sub:(e,t)=>{let n=e-t|0;return n<0?n+r|0:n},mul:(e,t)=>c((e|0)*(t|0))|0,inv:f}:{add:(e,t)=>c((e|0)+(t|0))|0,sub:(e,t)=>c((e|0)-(t|0))|0,mul:(e,t)=>c((e|0)*(t|0))|0,inv:f},m={N:n,roots:d,invertButterflies:!0,skipStages:s?1:0,brp:!1},h=Cn(p,{dit:!1,...m}),g=Cn(p,{dit:!0,...m}),_={encode:e=>h(e),decode:e=>{g(e);for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}};return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>_.encode(e),decode:e=>_.decode(e)},bitsCoder:(e,r)=>{for(let t=0,r=0;t<n;t++)r+=e,r>32&&or(r),r%=8;let i=or(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=t,o=new Uint8Array(a);for(let t=0,a=0,s=0,c=0;t<n.length;t++)for(a|=(r.encode(n[t])&i)<<s,s+=e;s>=8;s-=8,a>>=8)o[c++]=a&255;return o},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},cr=(e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),R(a,r)}}})(Xn);var z=256,B=3329,V=sr({N:z,Q:B,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0});const lr=(()=>Object.freeze({512:Object.freeze({N:z,Q:B,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128}),768:Object.freeze({N:z,Q:B,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}),1024:Object.freeze({N:z,Q:B,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256})}))();var ur=e=>{if(e>=12)return{encode:e=>e,decode:e=>e>=B?e-B:e};let t=2**(e-1);return{encode:t=>((t<<e)+B/2)/B,decode:n=>n*B+t>>>e}},dr=e=>V.bitsCoder(e,e===12?{encode:e=>e,decode:e=>e>=B?e-B:e}:{encode:e=>e,decode:e=>e}),fr=e=>e===12?dr(12):V.bitsCoder(e,ur(e));function pr(e,t){let n=e,r=t;for(let e=0;e<z;e++){let t=n[e]+r[e];n[e]=t>=B?t-B:t}}function mr(e,t){let n=e,r=t;for(let e=0;e<z;e++){let t=n[e]-r[e];n[e]=t<0?t+B:t}}function hr(e,t,n,r,i){return{c0:V.mod(V.mod(t*r)*i+e*n),c1:V.mod(e*r+t*n)}}function gr(e,t){let n=e,r=t;for(let e=0;e<z/2;e++){let t=V.nttZetas[64+(e>>1)];e&1&&(t=-t);let{c0:i,c1:a}=hr(n[2*e+0],n[2*e+1],r[2*e+0],r[2*e+1],t);n[2*e+0]=i,n[2*e+1]=a}return n}function _r(e){let t=e,n=new Uint16Array(z);for(let e=0;e<z;){let r=t();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let t=0;e<z&&t+3<=r.length;t+=3){let i=(r[t+0]>>0|r[t+1]<<8)&4095,a=(r[t+1]>>4|r[t+2]<<4)&4095;i<B&&(n[e++]=i),e<z&&a<B&&(n[e++]=a)}}return n}var vr=(e,t)=>{let n=new Uint16Array(z),r=y(e);E(r);let i=0;for(let e=0,a=0,o=0,s=0;e<r.length;e++){let c=r[e];for(let e=0;e<32;e++)o+=c&1,c>>=1,i+=1,i===t?(s=o,o=0):i===2*t&&(n[a++]=V.mod(s-o),o=0,i=0)}if(E(r),i)throw Error(`sampleCBD: leftover bits: ${i}`);return n};function yr(e,t,n,r){return vr(e(r*z/4,t,n),r)}var br=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=fr(1),u=fr(c),d=fr(s),f=ir(`publicKey`,ar(fr(12),t),32),p=ar(fr(12),t),m=ir(`ciphertext`,ar(d,t),u),h=ir(`seed`,32,32),g=(e,r,i,s)=>{let c=[];for(let e=0;e<t;e++)c.push(V.NTT.encode(yr(n,s,e,a)));let u=new Uint16Array(z),d=[];for(let i=0;i<t;i++){let a=yr(n,s,t+i,o),l=new Uint16Array(z);for(let e=0;e<t;e++)pr(l,gr(r(i,e),c[e]));pr(a,V.NTT.decode(l)),d.push(a),pr(u,gr(e[i],c[i])),R(l)}let f=yr(n,s,2*t,o);pr(f,V.NTT.decode(u));let p=l.decode(i);return pr(p,f),R(e,c,u,f),m.encode([d,p])};return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:m.bytesLen},keygen:e=>{Qn(e,32,`seed`);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(V.NTT.encode(yr(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=V.NTT.encode(yr(n,l,t+e,a));for(let n=0;n<t;n++)pr(r,gr(_r(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return R(c,l,u,d,o,s),g},encrypt:(e,t,n)=>{let[i,a]=f.decode(e),o=r(a),s=g(i,(e,t)=>_r(o.get(e,t)),t,n);return o.clean(),s},prepare:e=>{let[n,i]=f.decode(e),a=r(i),o=[];for(let e=0;e<t;e++)for(let n=0;n<t;n++)o.push(_r(a.get(e,n)));return a.clean(),{encrypt:(e,r)=>g(n.map(e=>e.slice()),(e,n)=>o[e*t+n].slice(),e,r),clean:()=>R(n,o)}},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(z);for(let e=0;e<t;e++)pr(o,gr(a[e],V.NTT.encode(r[e])));mr(i,V.NTT.decode(o));let s=l.encode(i);return R(o,a,r,i),s}}};function xr(e){let t=e,n=br(t),{HASH256:r,HASH512:i,KDF:a}=t,{secretCoder:o,lengths:s}=n,c=ir(`secretKey`,s.secretKey,s.publicKey,32,32),l=(e,n)=>{let r=e.subarray(0,384*t.K),i=o.encode(o.decode(rr(r))),a=nr(i,r);if(R(i),!a)throw Error(`ML-KEM.${n}: wrong publicKey modulus`)},u=Object.freeze({...s,seed:64,msg:32,msgRand:32,secretKey:c.bytesLen});return Object.freeze({info:Object.freeze({type:`ml-kem`}),lengths:u,keygen:e=>{let t=e===void 0,i=t?$n(64):e,a,o;try{Qn(i,64,`seed`);let e=n.keygen(i.subarray(0,32)),t=e.publicKey;return a=e.secretKey,o=r(t),{publicKey:t,secretKey:c.encode([a,t,o,i.subarray(32)])}}finally{a!==void 0&&R(a),o!==void 0&&R(o),t&&R(i)}},getPublicKey:e=>{let[t,n,r,i]=c.decode(e);return Uint8Array.from(n)},encapsulate:(e,t)=>{let a=t===void 0,o=a?$n(32):t,c;try{return Qn(e,s.publicKey,`publicKey`),Qn(o,32,`message`),l(e,`encapsulate`),c=i.create().update(o).update(r(e)).digest(),{cipherText:n.encrypt(e,o,c.subarray(32,64)),sharedSecret:c.subarray(0,32)}}finally{c!==void 0&&R(c.subarray(32)),a&&R(o)}},decapsulate:(e,t)=>{Qn(t,c.bytesLen,`secretKey`),Qn(e,s.cipherText,`cipherText`);let o=c.bytesLen-96,l=o+32;if(!nr(r(t.subarray(o/2,l)),t.subarray(l,l+32)))throw Error(`invalid secretKey: hash check failed`);let[u,d,f,p]=c.decode(t),m=n.decrypt(e,u),h=i.create().update(m).update(f).digest(),g=h.subarray(0,32),_=n.encrypt(d,m,h.subarray(32,64)),v=nr(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return R(m,_,h.subarray(32),v?y:g),v?g:y},prepare:e=>{Qn(e,s.publicKey,`publicKey`),l(e,`prepare`);let t=rr(e),o=r(t),u=n.prepare(t);return Object.freeze({publicKey:t,encapsulate:e=>{let t=e===void 0,n=t?$n(32):e,r;try{return Qn(n,32,`message`),r=i.create().update(n).update(o).digest(),{cipherText:u.encrypt(n,r.subarray(32,64)),sharedSecret:r.subarray(0,32)}}finally{r!==void 0&&R(r.subarray(32)),t&&R(n)}},decapsulate:(e,r)=>{Qn(r,c.bytesLen,`secretKey`),Qn(e,s.cipherText,`cipherText`);let[l,d,f,p]=c.decode(r);if(!nr(d,t)||!nr(f,o))throw Error(`ML-KEM.decapsulate: secretKey does not match prepared publicKey`);let m=n.decrypt(e,l),h=i.create().update(m).update(o).digest(),g=h.subarray(0,32),_=u.encrypt(m,h.subarray(32,64)),v=nr(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return R(m,_,h.subarray(32),v?y:g),v?g:y},clean:u.clean})}})}function Sr(e,t,n){return Zn.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Cr=(()=>({HASH256:qn,HASH512:Jn,KDF:Zn,XOF:cr,PRF:Sr}))(),wr=e=>xr({...Cr,...e});const Tr=(()=>wr(lr[768]))();var Er=(e,t)=>{let n=tr(e,t);return tr(n.lengths,`${t}.lengths`),se(n.keygen,`${t}.keygen`),se(n.getPublicKey,`${t}.getPublicKey`),se(n.encapsulate,`${t}.encapsulate`),se(n.decapsulate,`${t}.decapsulate`),n};function Dr(e,t){let n=d(e,t);if(n===0)throw RangeError(`"${t}" expected integer greater than 0, got 0`);return n}function Or(e,t){let n=ir(t,...e.map(e=>{if(typeof e.lengths[t]!=`number`)throw Error(`wrong length: `+t);return Dr(e.lengths[t],t)}));return Dr(n.bytesLen,t),n}function kr(e,t,...n){let r=t,i=n,a=Or(i,`seed`),o=Or(i,`publicKey`),s=Dr(e===void 0?a.bytesLen:e,`realSeedLen`);function c(e){p(e,s);let t=r(e,a.bytesLen),n=t.buffer===e.buffer?rr(t):t,o=[],c=[],l=[],u=[],d=!1;try{for(let e of a.decode(n))o.push(rr(e));for(let e=0;e<i.length;e++){let t=i[e].keygen(o[e]);c.push(t.secretKey),l.push(rr(t.secretKey)),u.push(t.publicKey)}return d=!0,{secretKey:l,publicKey:u}}finally{R(n,o,c),d||R(l)}}let l=e=>{let t=e===void 0?$n(s):rr(e),n;try{let{publicKey:e,secretKey:r}=c(t);try{n={secretKey:t,publicKey:o.encode(e)}}finally{R(e,r)}return n}finally{n||R(t)}};return{info:{lengths:{seed:s,publicKey:o.bytesLen,secretKey:s}},getPublicKey:e=>{let t=l(e);return R(t.secretKey),t.publicKey},keygen:l,expandDecapsulationKey:c,realSeedLen:s}}function Ar(e,t,n,r,...i){if(e!==void 0&&Dr(e,`realSeedLen`),t!==void 0&&Dr(t,`realMsgLen`),typeof n!=`function`)throw TypeError(`"expandSeed" expected function, got type=`+typeof n);if(typeof r!=`function`)throw TypeError(`"combiner" expected function, got type=`+typeof r);let a=r,o=i;if(o.length===0)throw RangeError(`combineKEMS requires at least one KEM`);for(let e=0;e<o.length;e++)Er(o[e],`kems[${e}]`);let s=kr(e,n,...o),c=Or(o,`cipherText`),u=Or(o,`publicKey`),d=Or(o,`msg`),f=Dr(t===void 0?d.bytesLen:t,`realMsgLen`),m=Object.freeze({...s.info.lengths,msg:f,msgRand:d.bytesLen,cipherText:c.bytesLen}),h=(e,t,n)=>{let r=a(e,t,n);try{return rr(p(r,f,`sharedSecret`))}catch(n){if(l(r)){let n=e=>r.buffer===e.buffer&&r.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<r.byteOffset+r.byteLength;e.some(n)||t.some(n)||R(r)}throw n}};return Object.freeze({lengths:m,getPublicKey:s.getPublicKey,keygen:s.keygen,encapsulate(e,t=$n(d.bytesLen)){let n=u.decode(e),r=d.decode(t),i=[],a=[];try{for(let e=0;e<o.length;e++){let t=o[e].encapsulate(n[e],r[e]);i.push(t.sharedSecret),a.push(t.cipherText)}let e=c.encode(a);return{sharedSecret:h(n,a,i),cipherText:e}}finally{R(i,a)}},decapsulate(e,t){let n=c.decode(e),{publicKey:r,secretKey:i}=s.expandDecapsulationKey(t),a=[];try{for(let e=0;e<o.length;e++)a.push(o[e].decapsulate(n[e],i[e]));return h(r,n,a)}finally{R(i,a)}}})}function jr(e,t,n,r){let i=e.Point.Fn;if(!i)throw Error(`no Point.Fn`);function a(n){let r;for(let e=0,a=t;;e=a,a+=t){if(a>n.length)throw Error(`rejection sampling failed`);if(r=i.fromBytes(n.subarray(e,a),!0),i.isValidNot0(r))break}let a=i.toBytes(i.create(r));return{secretKey:a,publicKey:e.getPublicKey(a,!1)}}let o=(t,n)=>e.getSharedSecret(n,t).subarray(1);return{lengths:{secretKey:t,publicKey:n,seed:r,msg:r,cipherText:n},keygen(e=$n(r)){return p(e,r,`seed`),a(e)},getPublicKey(t){return e.getPublicKey(t,!1)},encapsulate(t,n=$n(r)){p(n,r,`rand`);let i;try{return i=a(n).secretKey,{sharedSecret:o(t,i),cipherText:e.getPublicKey(i,!1)}}finally{i&&R(i)}},decapsulate:o}}function Mr(e,t,n,r){let{secretKey:i,publicKeyUncompressed:a}=n.lengths;if(!i||!a)throw Error(`wrong curve`);let o=jr(n,i,a,r),s=64+r;return Ar(32,32,e=>(p(e,32),Zn(e,{dkLen:s})),(t,n,r)=>qn(le(r[0],r[1],n[1],t[1],Ee(e))),t,o)}const Nr=(()=>Mr(`MLKEM768-P256`,Tr,wn,128))();function Pr(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Pr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Fr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Pr(e))&&(r&&(r+=` `),r+=t);return r}var Ir=Fr,Lr=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Rr=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),zr=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Br=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Vr=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Hr=t((e=>{var t=Rr().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Ur=t((e=>{var t=Rr().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Wr=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Gr=t((e=>{var t=zr(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Kr=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),qr=t((e=>{var t=Kr();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Jr=t(((e,t)=>{var n=qr();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Yr=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Xr=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{i as e,t}from"./rolldown-runtime-C4Xdq4VV.js";import{a as n,c as r,h as i,l as a,o,s}from"./vendor-react-DjiBOEpO.js";import{S as c}from"./vendor-icons-other-kRhgWBno.js";function l(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var u=e=>e?`"${e}" `:``;function d(e,t=``){if(typeof e!=`number`)throw TypeError(u(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(u(t)+`expected integer >= 0, got `+e);return e}function f(e,t=``){if(typeof e!=`boolean`)throw TypeError(u(t)+`expected boolean, got type=`+typeof e);return e}function p(e,t,n=``){if(l(e)&&(t===void 0||e.length===t))return e;t!==void 0&&d(t,`length`);let r=l(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=u(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function m(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(d(e.outputLen),d(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var h=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},g=(e,t)=>{h(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function _(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function v(e,t){p(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function y(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function b(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function x(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function S(e,t){return e<<32-t|e>>>t}const C=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function w(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T(e){for(let t=0;t<e.length;t++)e[t]=w(e[t]);return e}const E=C?e=>e:T;var D=(()=>typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`)(),O=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function k(e){if(p(e),D)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=O[e[n]];return t}function A(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function j(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(D)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=A(e.charCodeAt(i)),a=A(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function M(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];p(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function N(e,t,n=`opts`){return g(e,`defaults`),t!==void 0&&g(t,n),Object.assign(Object.create(null),e,t)}function ee(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=N({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function te(e=32){d(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const ne=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function re(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const P=(e,t,n)=>p(e,t,n),ie=d;function ae(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function oe(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function se(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const ce=k,le=(...e)=>M(...e),ue=e=>j(e),de=l,fe=e=>te(e);var pe=BigInt(0),me=BigInt(1),he=e=>e?`"${e}" `:``;function ge(e,t=``){if(typeof e!=`boolean`)throw TypeError(he(t)+`expected boolean, got type=`+typeof e);return e}function _e(e){if(typeof e==`bigint`){if(!De(e))throw RangeError(`positive bigint expected, got `+e)}else ie(e);return e}function ve(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function ye(e){let t=_e(e).toString(16);return t.length&1?`0`+t:t}function be(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?pe:BigInt(`0x`+e)}function xe(e){return be(k(e))}function Se(e){return be(k(Te(p(e)).reverse()))}function Ce(e,t){if(d(t),t===0)throw Error(`zero output length is invalid`);e=_e(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return j(r.padStart(n,`0`))}function we(e,t){return Ce(e,t).reverse()}function Te(e){return Uint8Array.from(P(e))}function Ee(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function De(e){return typeof e==`bigint`&&pe<=e}function Oe(e,t,n){return De(e)&&De(t)&&De(n)&&t<=e&&e<n}function ke(e,t,n,r){if(!Oe(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Ae(e){if(e<pe)throw Error(`expected non-negative bigint, got `+e);return e===pe?0:e.toString(2).length}const je=e=>(ve(e,`n`),(me<<BigInt(e))-me);function Me(e,t,n){if(d(e,`hashLen`),d(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},f=(...e)=>n(c,le(s,...e)),p=(e=i)=>{c=f(a,e),s=f(),e.length!==0&&(c=f(o,e),s=f())},m=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=f();let t=s.slice();n.push(t),e+=s.length}return le(...n)};return(e,t)=>{u(),p(e);let n;for(;(n=t(m()))===void 0;)p();return u(),n}}function Ne(e,t={},n={},r=`object`){oe(e,r),oe(t,`fields`),oe(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var F=BigInt(0),I=BigInt(1),Pe=BigInt(2),Fe=BigInt(3),Ie=BigInt(4),Le=BigInt(5),Re=BigInt(7),ze=BigInt(8),Be=BigInt(9),Ve=BigInt(15),He=BigInt(16),Ue=BigInt(`0x10000000000000000`);function L(e,t){if(t<=F)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=F?n:t+n}function We(e,t,n){if(n<=I)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<F)throw Error(`invalid exponent, negatives unsupported`);if(t===F)return I;if(t===I)return e;let r=e%n;if(r<F&&(r+=n),t<Ue){let e=I;for(;t>F;)t&I&&(e=e*r%n),r=r*r%n,t>>=I;return e}let i=[];for(;t>F;)i.push(Number(t&Ve)),t>>=Ie;let a=Array(16);a[0]=I,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function Ge(e,t){if(e===F)throw Error(`invert: expected non-zero number`);if(t<=I)throw Error(`invert: expected modulus > 1, got `+t);let n=L(e,t),r=t,i=F,a=I;for(;n!==F;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==I)throw Error(`invert: does not exist`);return L(i,t)}function Ke(e,t){if(t<=I)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=L(e,t);if(n===F)throw Error(`invertCt: expected non-zero number`);let r=We(n,t-Pe,t);if(L(n*r,t)!==I)throw Error(`invertCt: does not exist`);return r}function qe(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Je(e,t){if((e&I)===F)throw Error(t+`: expected odd modulus, got `+e)}function Ye(e,t){let n=e,r=(n.ORDER+I)/Ie,i=n.pow(t,r);return qe(n,i,t),i}function Xe(e,t){let n=e,r=(n.ORDER-Le)/ze,i=n.mul(t,Pe),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Pe),a),c=n.mul(o,n.sub(s,n.ONE));return qe(n,c,t),c}function Ze(e){let t=st(e),n=Qe(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Re)/He;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return qe(n,m,t),m})}function Qe(e){if(e<Fe)throw Error(`sqrt is not defined for small field`);Je(e,`tonelliShanks`);let t=e-I,n=0;for(;t%Pe===F;)t/=Pe,n++;let r=Pe,i=st(e);for(;rt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Ye;let a=i.pow(r,t),o=(t+I)/Pe;return function(e,r){let i=e;if(i.is0(r))return r;if(rt(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=I<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function $e(e){return Je(e,`Fp.sqrt`),e%Ie===Fe?Ye:e%ze===Le?Xe:e%He===Be?Ze(e):Qe(e)}var et=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function tt(e){if(oe(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);ve(e.BYTES,`BYTES`),ve(e.BITS,`BITS`);for(let t of et)se(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=I)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function nt(e,t,n=!1){tt(e),re(t,`nums`),ge(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function rt(e,t){tt(e);let n=e;Je(n.ORDER,`FpLegendre`);let r=(n.ORDER-I)/Pe,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function it(e,t){if(t!==void 0&&ie(t),e<=F)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Ae(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var at=new WeakMap,ot=class{ORDER;BITS;BYTES;isLE;ZERO=F;ONE=I;_lengths;_mod;constructor(e,t={}){if(e<=I)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,`sqrt`,{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=it(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return L(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return F<=e&&e<this.ORDER}is0(e){return e===F}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&I)===I}neg(e){return L(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return L(e*e,this.ORDER)}add(e,t){return L(e+t,this.ORDER)}sub(e,t){return L(e-t,this.ORDER)}mul(e,t){return L(e*t,this.ORDER)}pow(e,t){return We(e,t,this.ORDER)}div(e,t){return L(e*Ge(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Ge(e,this.ORDER)}sqrt(e){let t=at.get(this);return t||at.set(this,t=$e(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?we(e,this.BYTES):Ce(e,this.BYTES)}fromBytes(e,t=!1){P(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Se(e):xe(e);if(o&&(s=L(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return nt(this,e,!0)}cmov(e,t,n){return ge(n,`condition`),n?t:e}};function st(e,t={}){return Object.freeze(ot.prototype),new ot(e,t)}function ct(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=I)throw Error(`field order must be greater than 1`);let t=Ae(e-I);return Math.ceil(t/8)}function lt(e){let t=ct(e);return t+Math.ceil(t/2)}function ut(e,t,n=!1){P(e);let r=e.length,i=ct(t),a=Math.max(lt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=L(n?Se(e):xe(e),t-I)+I;return n?we(o,i):Ce(o,i)}var dt=BigInt(0),ft=BigInt(1),pt=BigInt(4),mt=16,ht=128,gt=5,_t=(()=>2**31)();function vt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);se(t.fromAffine,`Point.fromAffine`),se(t.fromBytes,`Point.fromBytes`),se(t.fromHex,`Point.fromHex`),oe(t.BASE,`Point.BASE`),oe(t.ZERO,`Point.ZERO`),tt(t.Fp),tt(t.Fn)}function yt(e,t){vt(e),Ct(t,e);let n=nt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function bt(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function xt(e,t){let n=e*(4*t+128);if(n>_t)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+_t/2**20+` MiB`)}function St(e,t){if(e!==void 0){se(e,`randomBytes`);try{let n=e(t);if(!de(n)||n.length!==t)return}catch{return}return e}}function Ct(e,t){re(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function wt(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):De(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Tt=new WeakMap;function Et(e){return Tt.get(e)||1}function Dt(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function Ot(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>dt;){let t=0;e&ft&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=ft}return a}function kt(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=ft),s.push(t)}if(e!==dt)throw Error(`invalid wnaf`);return s}function At(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var jt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){vt(e),this.randomBytes=St(t,mt),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=kt(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Oe(t,ft,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Et(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+ht,i=this.randomBytes(mt);if(!de(i)||i.length!==mt)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+xe(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=gt,i=1<<r,a=je(r),o=Array(i);o[0]=this.ZERO;for(let t=1;t<i;t++)o[t]=o[t-1].add(e);let s=Math.ceil(n/r),c=this.ZERO;for(let e=s-1;e>=0;e--){if(e!==s-1)for(let e=0;e<r;e++)c=c.double();let n=Number(t>>BigInt(e*r)&a),l=o[0];for(let e=1;e<i;e++)l=e===n?o[e]:l;c=c.add(l)}return{p:c,f:c}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===ft?!0:e===this.BASE?(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded):!1}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!De(t))throw Error(`invalid scalar`);let r=Et(e);if(r===1||t>=this.Point.Fn.ORDER)return Mt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),bt(t,this.bits),xt((Math.ceil((this.bits+ht)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Tt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Et(e)!==1}};function Mt(e,t,n,r=!1){if(vt(e),Ct(t,e),ge(r,`allowOversized`),wt(n,e.Fn,r?e.Fn.ORDER**pt:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Dt(e,4)),a=n.map(e=>Ot(e,4));return At(e.ZERO,i,a)}function Nt(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return tt(t),t}else return st(e,{isLE:n})}function Pt(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Ne(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(De(n)&&n!==dt))throw Error(`CURVE.${e} must be positive bigint`)}let i=Nt(t.p,n.Fp,r),a=Nt(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Ft(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var It=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(m(e),p(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),b(r)}update(e){return _(this),this.iHash.update(e),this}digestInto(e){_(this),v(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Lt=(()=>{let e=((e,t,n)=>new It(e,t).update(n).digest());return e.create=(e,t)=>new It(e,t),e})();var Rt=BigInt(0),zt={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=zt;if(ve(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(ae(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=ye(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?ye(i.length/2|128):``;return ye(e)+a+i+t},decode(e,t){let{Err:n}=zt;t=P(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=zt;if(_e(e),e<Rt)throw new t(`integer: negative integers are not allowed`);let n=ye(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=zt;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return xe(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=zt;if(t!==void 0&&(ve(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=P(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=zt;Ne(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};const Bt=(()=>(Object.freeze(zt._tlv),Object.freeze(zt._int),Object.freeze(zt)))();var Vt=(e,t)=>(e+(e>=0?t:-t)/qt)/t;function Ht(e,t,n){ke(`scalar`,e,Gt,n);let[[r,i],[a,o]]=t,s=Vt(o*e,n),c=Vt(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Gt,f=u<Gt;d&&(l=-l),f&&(u=-u);let p=je(Math.ceil(Ae(n)/2))+Kt;if(l<Gt||l>=p||u<Gt||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Ut(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Wt(e,t){Ne(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ge(n.lowS,`lowS`),ge(n.prehash,`prehash`),n.format!==void 0&&Ut(n.format),n}var Gt=BigInt(0),Kt=BigInt(1),qt=BigInt(2),Jt=BigInt(3),Yt=BigInt(4);function Xt(e,t={}){let n=Pt(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Ne(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?fe:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=Qt(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ge(n,`isCompressed`),n?(_(),le(Zt(!r.isOdd(a)),o)):le(Uint8Array.of(4),o,r.toBytes(a))}function y(e){P(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=w(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!T(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let b=p===void 0?v:p,x=f===void 0?y:f,S=r.mul(a.b,Jt),C=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function w(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function T(e,t){let n=r.sqr(t),i=w(e);return r.eql(n,i)}if(!T(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let E=r.mul(r.pow(a.a,Jt),Yt),D=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(E,D)))throw Error(`bad curve params: a or b`);function O(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function k(e){if(!(e instanceof N))throw Error(`Weierstrass Point expected`)}function A(e){if(!h||!h.basises)throw Error(`no endo`);return Ht(e,h.basises,i.ORDER)}function j(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=A(a),l=new N(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let M=new WeakSet;class N{static BASE=new N(a.Gx,a.Gy,r.ONE);static ZERO=new N(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=O(`x`,e),this.Y=O(`y`,t,!0),this.Z=O(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof N)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?N.ZERO:new N(t,n,r.ONE)}static fromBytes(e){let t=N.fromAffine(x(P(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return N.fromBytes(ue(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return te.setWindowSize(this,e),t||this.multiply(Jt),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(M.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!T(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);M.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new N(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=C(o),a=r.mul(S,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(S,o),l=C(l),u=r.sub(s,l),u=C(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new N(i,a,o)}add(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=C(h),c=r.mul(S,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=C(p),h=r.mul(S,h),f=r.add(f,p),p=r.sub(d,p),p=C(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new N(c,l,u)}subtract(e){return k(e),this.add(e.negate())}is0(){return this.equals(N.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=te.mulSecret(this,e,o,ee);return ee([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===Gt||t.is0())return N.ZERO;if(n===Kt)return t;if(te.hasWindowSize(this))return te.mulUnsafe(t,n,ee);let r=[],a=[];return j(r,a,t,n),Mt(N,r,a)}mulAddUnsafe(e,t,n){k(t);let r=[],i=[];return j(r,i,this,e),j(r,i,t,n),Mt(N,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===Kt?!0:d?d(N,this):te.mulUnsafe(this,s).is0()}clearCofactor(){return o===Kt?this:u?u(N,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Kt?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return ge(e,`isCompressed`),this.assertValidity(),b(N,this,e)}toHex(e=!0){return ce(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ee=e=>yt(N,e),te=new jt(N,m);return te.bits>=6&&N.BASE.precompute(6),Object.freeze(N.prototype),Object.freeze(N),N}function Zt(e){return Uint8Array.of(e?2:3)}function Qt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function $t(e,t={}){vt(e);let{Fn:n}=e,r=t.randomBytes===void 0?fe:t.randomBytes,i=Object.assign(Qt(e.Fp,n),{seed:Math.max(lt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,ut(P(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!de(e))return;let s=P(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Ft(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function en(e,t,n={}){vt(e);let r=t;m(r),Ne(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?fe:i.randomBytes,o=i.hmac===void 0?(e,t)=>Lt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=lt(l),f=St(a,d),{keygen:p,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v}=$t(e,i),y={prehash:!0,lowS:typeof i.lowS==`boolean`?i.lowS:!0,format:`compact`,extraEntropy:!1},b=l*qt+Kt<s.ORDER;function x(e){return e>l>>Kt}function S(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function C(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function w(e,t,n){return C(),(e===n?0:2)|Number(s.isOdd(t))}function T(){if(b)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function E(e,t){Ut(t);let n=v.signature;return P(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class D{r;s;recovery;constructor(e,t,n){if(this.r=S(`r`,e),this.s=S(`s`,t),n!=null){if(T(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=y.format){E(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Bt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Bt.toSig(P(e),c.BYTES+1);return new D(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=v.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new D(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(ue(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new D(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(le(Zt((i&1)==0),o)),d=c.inv(a),f=k(P(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return x(this.s)}toBytes(e=y.format){if(Ut(e),e===`der`)return ue(Bt.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(T(),le(Uint8Array.of(this.assertRecovery()),r,i)):le(r,i)}toHex(e){return ce(this.toBytes(e))}}Object.freeze(D.prototype),Object.freeze(D);let O=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=xe(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,k=i.bits2int_modN===void 0?function(e){return c.create(O(e))}:i.bits2int_modN,A=je(u);function j(e){return ke(`num < 2^`+u,e,Gt,A),c.toBytes(e)}function M(e,t){return P(e,void 0,`message`),t?P(r(e),void 0,`prehashed message`):e}function N(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Wt(r,y);t=M(t,o);let u=k(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[j(p),j(u)];if(s!=null&&s!==!1){let e=s===!0?a(v.secretKey):s;m.push(P(e,void 0,`extraEntropy`))}let h=le(...m),g=u;function _(t){let n=O(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===Gt)return;let o;if(f!==void 0){let e=xe(ut(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=Ke(n,l);o=c.create(e*c.create(g+a*p))}if(o===Gt)return;let s=w(r.x,r.y,a),u=o;return i&&x(o)&&(u=c.neg(o),s^=1),new D(a,u,b?void 0:s)}return{seed:h,k2sig:_}}function ee(e,t,n={}){let{seed:i,k2sig:a}=N(e,t,n);return Me(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function te(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Wt(i,y);if(r=P(r,void 0,`publicKey`),n=M(n,o),!de(t)){let e=t instanceof D?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}E(t,s);try{let i=D.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=k(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==w(g.x,g.y,l))}catch{return!1}}function ne(e,t,n={}){let{prehash:r}=Wt(n,y);return t=M(t,r),D.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v,Point:e,sign:ee,verify:te,recoverPublicKey:ne,Signature:D,hash:r})}var tn=(()=>BigInt(2**32-1))(),nn=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&tn),l:Number(e>>nn&tn)}:{h:Number(e>>nn&tn)|0,l:Number(e&tn)|0}}function an(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=rn(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var on=e=>e/2**32|0,sn=e=>e>>>0;function cn(e,t,n,r){let i=on(n),a=sn(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function ln(e,t,n){return e&t^~e&n}function un(e,t,n){return e&t^e&n^t&n}var dn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=x(this.buffer)}update(e){_(this),p(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=x(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){_(this),v(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),cn(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:x(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const fn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var pn=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]),mn=new Uint32Array(64),hn=class extends dn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)mn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=mn[e-15],n=mn[e-2],r=S(t,7)^S(t,18)^t>>>3;mn[e]=(S(n,17)^S(n,19)^n>>>10)+mn[e-7]+r+mn[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=S(o,6)^S(o,11)^S(o,25),u=l+t+ln(o,s,c)+pn[e]+mn[e]|0,d=(S(n,2)^S(n,13)^S(n,22))+un(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){b(mn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),b(this.buffer)}},gn=class extends hn{constructor(){super(32,fn)}};const _n=ee(()=>new gn,ne(1));function vn(e,t=`n`){if(typeof e!=`number`)throw TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function yn(e){return vn(e,`x`),(e&e-1)==0&&e!==0}function bn(e,t){if(vn(e),typeof t!=`number`)throw TypeError(`"bits" expected number, got type=`+typeof t);if(!Number.isSafeInteger(t)||t<0||t>32)throw Error(`expected integer 0 <= bits <= 32, got ${t}`);let n=0;for(let r=0;r<t;r++,e>>>=1)n=n<<1|e&1;return n>>>0}function xn(e){return vn(e),31-Math.clz32(e)}function Sn(e){if(!e||typeof e!=`object`||typeof e.length!=`number`)throw TypeError(`"values" expected array-like, got type=`+typeof e);let t=e.length;if(!yn(t))throw Error(`expected positive power-of-two length, got `+t);let n=xn(t);for(let r=0;r<t;r++){let t=bn(r,n);if(r<t){let n=e[r];e[r]=e[t],e[t]=n}}return e}const Cn=(e,t)=>{Ne(t,{N:`number`,roots:`object`,dit:`boolean`},{invertButterflies:`boolean`,skipStages:`number`,brp:`boolean`},`coreOpts`);let{N:n,roots:r,dit:i,invertButterflies:a=!1,skipStages:o=0,brp:s=!0}=t;vn(n,`coreOpts.N`);let c=xn(n);if(!yn(n))throw Error(`FFT: Polynomial size should be power of two`);vn(o,`coreOpts.skipStages`);let l=c===0?0:c-1;if(o>l)throw Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${l}`);if(r.length!==n)throw Error(`FFT: wrong roots length: expected ${n}, got ${r.length}`);let u=i!==a;return t=>{if(t.length!==n)throw Error(`FFT: wrong Polynomial length`);i&&s&&Sn(t);for(let s=0,l=1;s<c-o;s++){let d=i?s+1+o:c-s,f=1<<d,p=f>>1,m=n>>d;for(let o=0;o<n;o+=f)for(let s=0,c=l++;s<p;s++){let l=a?i?n-c:c:s*m,d=o+s,f=o+s+p,h=r[l],g=t[f],_=t[d];if(u){let n=e.mul(g,h);t[d]=e.add(_,n),t[f]=e.sub(_,n)}else a?(t[d]=e.add(g,_),t[f]=e.mul(e.sub(g,_),h)):(t[d]=e.add(_,g),t[f]=e.mul(e.sub(_,g),h))}}return!i&&s&&Sn(t),t}},wn=en(Xt((()=>({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}))()),_n);var Tn=BigInt(0),En=BigInt(1),Dn=BigInt(2),On=BigInt(7),kn=BigInt(256),An=BigInt(113),jn=[],Mn=[],Nn=[];for(let e=0,t=En,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],jn.push(2*(5*r+n)),Mn.push((e+1)*(e+2)/2%64);let i=Tn;for(let e=0;e<7;e++)t=(t<<En^(t>>On)*An)%kn,t&Dn&&(i^=En<<(En<<BigInt(e))-En);Nn.push(i)}var Pn=an(Nn,!0),Fn=Pn[0],In=Pn[1],Ln=(e,t,n)=>e<<n|t>>>32-n,Rn=(e,t,n)=>t<<n|e>>>32-n,zn=(e,t,n)=>t<<n-32|e>>>64-n,Bn=(e,t,n)=>e<<n-32|t>>>64-n,Vn=(e,t,n)=>n>32?zn(e,t,n):Ln(e,t,n),Hn=(e,t,n)=>n>32?Bn(e,t,n):Rn(e,t,n),Un=new Uint32Array(10);function Wn(e,t=24){if(!(e instanceof Uint32Array))throw TypeError(`"s" expected Uint32Array(50), got type=`+typeof e);if(e.length!==50)throw RangeError(`"s" expected Uint32Array(50), got length=`+e.length);if(d(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)Un[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,r=(t+2)%10,i=Un[r],a=Un[r+1],o=Vn(i,a,1)^Un[n],s=Hn(i,a,1)^Un[n+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=s}let t=e[2],r=e[3];for(let n=0;n<24;n++){let i=Mn[n],a=Vn(t,r,i),o=Hn(t,r,i),s=jn[n];t=e[s],r=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=Fn[n],e[1]^=In[n]}b(Un)}var Gn=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(d(e,`blockLen`),d(t,`suffix`),d(i,`rounds`),f(r,`enableXOF`),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,d(n,`outputLen`),!(0<e&&e<200))throw Error(`"blockLen" must be 1..199`);this.state=new Uint8Array(200),this.state32=y(this.state)}clone(){return this._cloneInto()}keccak(){E(this.state32),Wn(this.state32,this.rounds),E(this.state32),this.posOut=0,this.pos=0}update(e){_(this),p(e);let{blockLen:t,state:n,state32:r}=this,i=e.length,a=t%4==0&&e.byteOffset%4==0,o=t/4,s=a&&i>=t?y(e):void 0;for(let a=0;a<i;){if(s!==void 0&&this.pos===0&&a%4==0&&i-a>=t){for(let e=0,t=a/4;e<o;e++)r[e]^=s[t+e];a+=t,this.pos=t,this.keccak();continue}let c=Math.min(t-this.pos,i-a);for(let t=0;t<c;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){_(this,!1),p(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not enabled`);return this.writeInto(e)}xof(e){return d(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(v(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,b(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},Kn=(e,t,n,r={})=>ee(()=>new Gn(t,e,n),r);const qn=Kn(6,136,32,ne(8)),Jn=Kn(6,72,64,ne(10));var Yn=(e,t,n,r={})=>ee((r={})=>(r=N({},r),new Gn(t,e,r.dkLen===void 0?n:r.dkLen,!0)),r);const Xn=Yn(31,168,16,ne(11)),Zn=Yn(31,136,32,ne(12));var Qn=p;const $n=te;function er(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function tr(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function nr(e,t){if(e=p(e),t=p(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function rr(e){return new Uint8Array(p(e))}function ir(e,...t){let n=e=>typeof e==`number`?e:e.bytesLen,r=t.reduce((e,t)=>e+n(t),0);return{bytesLen:r,encode:i=>{let a=new Uint8Array(r);for(let r=0,o=0;r<t.length;r++){let s=t[r],c=n(s),l=typeof s==`number`?i[r]:s.encode(i[r]);p(l,c,e),a.set(l,o),typeof s!=`number`&&l.fill(0),o+=c}return a},decode:i=>{p(i,r,e);let a=[];for(let e of t){let t=n(e),r=i.subarray(0,t);a.push(typeof e==`number`?r:e.decode(r)),i=i.subarray(t)}return a}}}function ar(e,t){let n=e,r=t*n.bytesLen;return{bytesLen:r,encode:e=>{let i=er(e,`u`);if(i.length!==t)throw RangeError(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let a=new Uint8Array(r);for(let e=0,t=0;e<i.length;e++){let r=n.encode(i[e]);a.set(r,t),r.fill(0),t+=r.length}return a},decode:e=>{p(e,r);let t=[];for(let r=0;r<e.length;r+=n.bytesLen)t.push(n.decode(e.subarray(r,r+n.bytesLen)));return t}}}function R(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function or(e){if(d(e,`bits`),e>32)throw RangeError(`"bits" expected <= 32, got `+e);return e===32?4294967295:~(-1<<e)>>>0}const sr=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=bn(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=e=>{throw Error(`not implemented`)},p=s?{add:(e,t)=>{let n=e+t|0;return n>=r?n-r|0:n},sub:(e,t)=>{let n=e-t|0;return n<0?n+r|0:n},mul:(e,t)=>c((e|0)*(t|0))|0,inv:f}:{add:(e,t)=>c((e|0)+(t|0))|0,sub:(e,t)=>c((e|0)-(t|0))|0,mul:(e,t)=>c((e|0)*(t|0))|0,inv:f},m={N:n,roots:d,invertButterflies:!0,skipStages:s?1:0,brp:!1},h=Cn(p,{dit:!1,...m}),g=Cn(p,{dit:!0,...m}),_={encode:e=>h(e),decode:e=>{g(e);for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}};return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>_.encode(e),decode:e=>_.decode(e)},bitsCoder:(e,r)=>{for(let t=0,r=0;t<n;t++)r+=e,r>32&&or(r),r%=8;let i=or(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=t,o=new Uint8Array(a);for(let t=0,a=0,s=0,c=0;t<n.length;t++)for(a|=(r.encode(n[t])&i)<<s,s+=e;s>=8;s-=8,a>>=8)o[c++]=a&255;return o},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},cr=(e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),R(a,r)}}})(Xn);var z=256,B=3329,V=sr({N:z,Q:B,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0});const lr=(()=>Object.freeze({512:Object.freeze({N:z,Q:B,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128}),768:Object.freeze({N:z,Q:B,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}),1024:Object.freeze({N:z,Q:B,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256})}))();var ur=e=>{if(e>=12)return{encode:e=>e,decode:e=>e>=B?e-B:e};let t=2**(e-1);return{encode:t=>((t<<e)+B/2)/B,decode:n=>n*B+t>>>e}},dr=e=>V.bitsCoder(e,e===12?{encode:e=>e,decode:e=>e>=B?e-B:e}:{encode:e=>e,decode:e=>e}),fr=e=>e===12?dr(12):V.bitsCoder(e,ur(e));function pr(e,t){let n=e,r=t;for(let e=0;e<z;e++){let t=n[e]+r[e];n[e]=t>=B?t-B:t}}function mr(e,t){let n=e,r=t;for(let e=0;e<z;e++){let t=n[e]-r[e];n[e]=t<0?t+B:t}}function hr(e,t,n,r,i){return{c0:V.mod(V.mod(t*r)*i+e*n),c1:V.mod(e*r+t*n)}}function gr(e,t){let n=e,r=t;for(let e=0;e<z/2;e++){let t=V.nttZetas[64+(e>>1)];e&1&&(t=-t);let{c0:i,c1:a}=hr(n[2*e+0],n[2*e+1],r[2*e+0],r[2*e+1],t);n[2*e+0]=i,n[2*e+1]=a}return n}function _r(e){let t=e,n=new Uint16Array(z);for(let e=0;e<z;){let r=t();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let t=0;e<z&&t+3<=r.length;t+=3){let i=(r[t+0]>>0|r[t+1]<<8)&4095,a=(r[t+1]>>4|r[t+2]<<4)&4095;i<B&&(n[e++]=i),e<z&&a<B&&(n[e++]=a)}}return n}var vr=(e,t)=>{let n=new Uint16Array(z),r=y(e);E(r);let i=0;for(let e=0,a=0,o=0,s=0;e<r.length;e++){let c=r[e];for(let e=0;e<32;e++)o+=c&1,c>>=1,i+=1,i===t?(s=o,o=0):i===2*t&&(n[a++]=V.mod(s-o),o=0,i=0)}if(E(r),i)throw Error(`sampleCBD: leftover bits: ${i}`);return n};function yr(e,t,n,r){return vr(e(r*z/4,t,n),r)}var br=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=fr(1),u=fr(c),d=fr(s),f=ir(`publicKey`,ar(fr(12),t),32),p=ar(fr(12),t),m=ir(`ciphertext`,ar(d,t),u),h=ir(`seed`,32,32),g=(e,r,i,s)=>{let c=[];for(let e=0;e<t;e++)c.push(V.NTT.encode(yr(n,s,e,a)));let u=new Uint16Array(z),d=[];for(let i=0;i<t;i++){let a=yr(n,s,t+i,o),l=new Uint16Array(z);for(let e=0;e<t;e++)pr(l,gr(r(i,e),c[e]));pr(a,V.NTT.decode(l)),d.push(a),pr(u,gr(e[i],c[i])),R(l)}let f=yr(n,s,2*t,o);pr(f,V.NTT.decode(u));let p=l.decode(i);return pr(p,f),R(e,c,u,f),m.encode([d,p])};return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:m.bytesLen},keygen:e=>{Qn(e,32,`seed`);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(V.NTT.encode(yr(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=V.NTT.encode(yr(n,l,t+e,a));for(let n=0;n<t;n++)pr(r,gr(_r(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return R(c,l,u,d,o,s),g},encrypt:(e,t,n)=>{let[i,a]=f.decode(e),o=r(a),s=g(i,(e,t)=>_r(o.get(e,t)),t,n);return o.clean(),s},prepare:e=>{let[n,i]=f.decode(e),a=r(i),o=[];for(let e=0;e<t;e++)for(let n=0;n<t;n++)o.push(_r(a.get(e,n)));return a.clean(),{encrypt:(e,r)=>g(n.map(e=>e.slice()),(e,n)=>o[e*t+n].slice(),e,r),clean:()=>R(n,o)}},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(z);for(let e=0;e<t;e++)pr(o,gr(a[e],V.NTT.encode(r[e])));mr(i,V.NTT.decode(o));let s=l.encode(i);return R(o,a,r,i),s}}};function xr(e){let t=e,n=br(t),{HASH256:r,HASH512:i,KDF:a}=t,{secretCoder:o,lengths:s}=n,c=ir(`secretKey`,s.secretKey,s.publicKey,32,32),l=(e,n)=>{let r=e.subarray(0,384*t.K),i=o.encode(o.decode(rr(r))),a=nr(i,r);if(R(i),!a)throw Error(`ML-KEM.${n}: wrong publicKey modulus`)},u=Object.freeze({...s,seed:64,msg:32,msgRand:32,secretKey:c.bytesLen});return Object.freeze({info:Object.freeze({type:`ml-kem`}),lengths:u,keygen:e=>{let t=e===void 0,i=t?$n(64):e,a,o;try{Qn(i,64,`seed`);let e=n.keygen(i.subarray(0,32)),t=e.publicKey;return a=e.secretKey,o=r(t),{publicKey:t,secretKey:c.encode([a,t,o,i.subarray(32)])}}finally{a!==void 0&&R(a),o!==void 0&&R(o),t&&R(i)}},getPublicKey:e=>{let[t,n,r,i]=c.decode(e);return Uint8Array.from(n)},encapsulate:(e,t)=>{let a=t===void 0,o=a?$n(32):t,c;try{return Qn(e,s.publicKey,`publicKey`),Qn(o,32,`message`),l(e,`encapsulate`),c=i.create().update(o).update(r(e)).digest(),{cipherText:n.encrypt(e,o,c.subarray(32,64)),sharedSecret:c.subarray(0,32)}}finally{c!==void 0&&R(c.subarray(32)),a&&R(o)}},decapsulate:(e,t)=>{Qn(t,c.bytesLen,`secretKey`),Qn(e,s.cipherText,`cipherText`);let o=c.bytesLen-96,l=o+32;if(!nr(r(t.subarray(o/2,l)),t.subarray(l,l+32)))throw Error(`invalid secretKey: hash check failed`);let[u,d,f,p]=c.decode(t),m=n.decrypt(e,u),h=i.create().update(m).update(f).digest(),g=h.subarray(0,32),_=n.encrypt(d,m,h.subarray(32,64)),v=nr(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return R(m,_,h.subarray(32),v?y:g),v?g:y},prepare:e=>{Qn(e,s.publicKey,`publicKey`),l(e,`prepare`);let t=rr(e),o=r(t),u=n.prepare(t);return Object.freeze({publicKey:t,encapsulate:e=>{let t=e===void 0,n=t?$n(32):e,r;try{return Qn(n,32,`message`),r=i.create().update(n).update(o).digest(),{cipherText:u.encrypt(n,r.subarray(32,64)),sharedSecret:r.subarray(0,32)}}finally{r!==void 0&&R(r.subarray(32)),t&&R(n)}},decapsulate:(e,r)=>{Qn(r,c.bytesLen,`secretKey`),Qn(e,s.cipherText,`cipherText`);let[l,d,f,p]=c.decode(r);if(!nr(d,t)||!nr(f,o))throw Error(`ML-KEM.decapsulate: secretKey does not match prepared publicKey`);let m=n.decrypt(e,l),h=i.create().update(m).update(o).digest(),g=h.subarray(0,32),_=u.encrypt(m,h.subarray(32,64)),v=nr(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return R(m,_,h.subarray(32),v?y:g),v?g:y},clean:u.clean})}})}function Sr(e,t,n){return Zn.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Cr=(()=>({HASH256:qn,HASH512:Jn,KDF:Zn,XOF:cr,PRF:Sr}))(),wr=e=>xr({...Cr,...e});const Tr=(()=>wr(lr[768]))();var Er=(e,t)=>{let n=tr(e,t);return tr(n.lengths,`${t}.lengths`),se(n.keygen,`${t}.keygen`),se(n.getPublicKey,`${t}.getPublicKey`),se(n.encapsulate,`${t}.encapsulate`),se(n.decapsulate,`${t}.decapsulate`),n};function Dr(e,t){let n=d(e,t);if(n===0)throw RangeError(`"${t}" expected integer greater than 0, got 0`);return n}function Or(e,t){let n=ir(t,...e.map(e=>{if(typeof e.lengths[t]!=`number`)throw Error(`wrong length: `+t);return Dr(e.lengths[t],t)}));return Dr(n.bytesLen,t),n}function kr(e,t,...n){let r=t,i=n,a=Or(i,`seed`),o=Or(i,`publicKey`),s=Dr(e===void 0?a.bytesLen:e,`realSeedLen`);function c(e){p(e,s);let t=r(e,a.bytesLen),n=t.buffer===e.buffer?rr(t):t,o=[],c=[],l=[],u=[],d=!1;try{for(let e of a.decode(n))o.push(rr(e));for(let e=0;e<i.length;e++){let t=i[e].keygen(o[e]);c.push(t.secretKey),l.push(rr(t.secretKey)),u.push(t.publicKey)}return d=!0,{secretKey:l,publicKey:u}}finally{R(n,o,c),d||R(l)}}let l=e=>{let t=e===void 0?$n(s):rr(e),n;try{let{publicKey:e,secretKey:r}=c(t);try{n={secretKey:t,publicKey:o.encode(e)}}finally{R(e,r)}return n}finally{n||R(t)}};return{info:{lengths:{seed:s,publicKey:o.bytesLen,secretKey:s}},getPublicKey:e=>{let t=l(e);return R(t.secretKey),t.publicKey},keygen:l,expandDecapsulationKey:c,realSeedLen:s}}function Ar(e,t,n,r,...i){if(e!==void 0&&Dr(e,`realSeedLen`),t!==void 0&&Dr(t,`realMsgLen`),typeof n!=`function`)throw TypeError(`"expandSeed" expected function, got type=`+typeof n);if(typeof r!=`function`)throw TypeError(`"combiner" expected function, got type=`+typeof r);let a=r,o=i;if(o.length===0)throw RangeError(`combineKEMS requires at least one KEM`);for(let e=0;e<o.length;e++)Er(o[e],`kems[${e}]`);let s=kr(e,n,...o),c=Or(o,`cipherText`),u=Or(o,`publicKey`),d=Or(o,`msg`),f=Dr(t===void 0?d.bytesLen:t,`realMsgLen`),m=Object.freeze({...s.info.lengths,msg:f,msgRand:d.bytesLen,cipherText:c.bytesLen}),h=(e,t,n)=>{let r=a(e,t,n);try{return rr(p(r,f,`sharedSecret`))}catch(n){if(l(r)){let n=e=>r.buffer===e.buffer&&r.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<r.byteOffset+r.byteLength;e.some(n)||t.some(n)||R(r)}throw n}};return Object.freeze({lengths:m,getPublicKey:s.getPublicKey,keygen:s.keygen,encapsulate(e,t=$n(d.bytesLen)){let n=u.decode(e),r=d.decode(t),i=[],a=[];try{for(let e=0;e<o.length;e++){let t=o[e].encapsulate(n[e],r[e]);i.push(t.sharedSecret),a.push(t.cipherText)}let e=c.encode(a);return{sharedSecret:h(n,a,i),cipherText:e}}finally{R(i,a)}},decapsulate(e,t){let n=c.decode(e),{publicKey:r,secretKey:i}=s.expandDecapsulationKey(t),a=[];try{for(let e=0;e<o.length;e++)a.push(o[e].decapsulate(n[e],i[e]));return h(r,n,a)}finally{R(i,a)}}})}function jr(e,t,n,r){let i=e.Point.Fn;if(!i)throw Error(`no Point.Fn`);function a(n){let r;for(let e=0,a=t;;e=a,a+=t){if(a>n.length)throw Error(`rejection sampling failed`);if(r=i.fromBytes(n.subarray(e,a),!0),i.isValidNot0(r))break}let a=i.toBytes(i.create(r));return{secretKey:a,publicKey:e.getPublicKey(a,!1)}}let o=(t,n)=>e.getSharedSecret(n,t).subarray(1);return{lengths:{secretKey:t,publicKey:n,seed:r,msg:r,cipherText:n},keygen(e=$n(r)){return p(e,r,`seed`),a(e)},getPublicKey(t){return e.getPublicKey(t,!1)},encapsulate(t,n=$n(r)){p(n,r,`rand`);let i;try{return i=a(n).secretKey,{sharedSecret:o(t,i),cipherText:e.getPublicKey(i,!1)}}finally{i&&R(i)}},decapsulate:o}}function Mr(e,t,n,r){let{secretKey:i,publicKeyUncompressed:a}=n.lengths;if(!i||!a)throw Error(`wrong curve`);let o=jr(n,i,a,r),s=64+r;return Ar(32,32,e=>(p(e,32),Zn(e,{dkLen:s})),(t,n,r)=>qn(le(r[0],r[1],n[1],t[1],Ee(e))),t,o)}const Nr=(()=>Mr(`MLKEM768-P256`,Tr,wn,128))();function Pr(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Pr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Fr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Pr(e))&&(r&&(r+=` `),r+=t);return r}var Ir=Fr,Lr=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Rr=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),zr=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Br=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Vr=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Hr=t((e=>{var t=Rr().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Ur=t((e=>{var t=Rr().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Wr=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Gr=t((e=>{var t=zr(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Kr=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),qr=t((e=>{var t=Kr();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Jr=t(((e,t)=>{var n=qr();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Yr=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Xr=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Zr=t((e=>{var t=Yr(),n=Xr();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Qr=t((e=>{var t=Rr(),n=Gr(),r=zr(),i=Zr(),a=Yr(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),$r=t((e=>{var t=Rr(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ei=t(((e,t)=>{var n=Zr();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),ti=t(((e,t)=>{var n=Zr(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),ni=t(((e,t)=>{var n=Zr();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ri=t(((e,t)=>{var n=Zr(),r=Rr();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),ii=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),ai=t((e=>{var t=Zr(),n=ei(),r=ti(),i=ni(),a=ri(),o=Xr(),s=Rr(),c=ii();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),oi=t((e=>{var t=Rr(),n=zr(),r=Br(),i=Vr(),a=Hr(),o=Ur(),s=Wr(),c=Gr(),l=Jr(),u=Qr(),d=$r(),f=Zr(),p=ai();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`