friend-assistant 0.1.46 → 0.1.48
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.
- package/README.md +3 -0
- package/dist/BUILD.json +2 -2
- package/dist/friend.mjs +223 -20
- package/dist/web/assets/{index-CbiARSIY.js → index-DIYYoJUP.js} +23 -23
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ Error generating stack: `+e.message+`
|
|
|
8
8
|
`+e.stack}}var Ae=Object.prototype.hasOwnProperty,je=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,Pe=t.unstable_requestPaint,Fe=t.unstable_now,Ie=t.unstable_getCurrentPriorityLevel,Le=t.unstable_ImmediatePriority,Re=t.unstable_UserBlockingPriority,ze=t.unstable_NormalPriority,Be=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,He=t.log,Ue=t.unstable_setDisableYieldValue,We=null,Ge=null;function Ke(e){if(typeof He==`function`&&Ue(e),Ge&&typeof Ge.setStrictMode==`function`)try{Ge.setStrictMode(We,e)}catch{}}var qe=Math.clz32?Math.clz32:Xe,Je=Math.log,Ye=Math.LN2;function Xe(e){return e>>>=0,e===0?32:31-(Je(e)/Ye|0)|0}var Ze=256,Qe=262144,$e=4194304;function et(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function tt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=et(n))):i=et(o):i=et(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=et(n))):i=et(o)):i=et(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function nt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function rt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-qe(n),i=1<<r;t|=e[r],n&=~i}return t}function it(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function at(){var e=$e;return $e<<=1,!($e&62914560)&&($e=4194304),e}function ot(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function st(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ct(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-qe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&<(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function lt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-qe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ut(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-qe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function dt(e,t){var n=t&-t;return n=n&42?1:ft(n),(n&(e.suspendedLanes|t))===0?n:0}function ft(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function pt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function mt(){var e=B.p;return e===0?(e=window.event,e===void 0?32:wh(e.type)):e}function ht(e,t){var n=B.p;try{return B.p=e,t()}finally{B.p=n}}var gt=Math.random().toString(36).slice(2),_t=`__reactFiber$`+gt,vt=`__reactProps$`+gt,yt=`__reactContainer$`+gt,bt=`__reactEvents$`+gt,xt=`__reactListeners$`+gt,St=`__reactHandles$`+gt,Ct=`__reactResources$`+gt,wt=`__reactMarker$`+gt,Tt=`__reactLoad$`+gt;function Et(e){delete e[_t],delete e[vt],delete e[xt],delete e[St]}function Dt(e){var t;if(t=e[_t])return t;for(var n=e.parentNode;n;){if(t=n[yt]||n[_t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pm(e);e!==null;){if(n=e[_t])return n;e=pm(e)}return t}e=n,n=e.parentNode}return null}function Ot(e){if(e=e[_t]||e[yt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function kt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(s(33))}function At(e){var t=e[Ct];return t||=e[Ct]={hoistableStyles:new Map,hoistableScripts:new Map},t}function jt(e){e[wt]=!0}function Mt(e){e[Tt]=void 0}var Nt=new Set,Pt={};function Ft(e,t){It(e,t),It(e+`Capture`,t)}function It(e,t){for(Pt[e]=t,e=0;e<t.length;e++)Nt.add(t[e])}var Lt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Rt={},zt={};function Bt(e){return Ae.call(zt,e)?!0:Ae.call(Rt,e)?!1:Lt.test(e)?zt[e]=!0:(Rt[e]=!0,!1)}var Vt=!1;function Ht(){var e=Vt;return Vt=!1,e}function Ut(e,t,n){if(Bt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function W(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Wt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Gt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Kt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function qt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Jt(e){if(!e._valueTracker){var t=Kt(e)?`checked`:`value`;e._valueTracker=qt(e,t,``+e[t])}}function Yt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Kt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var Xt=/[\n"\\]/g;function Zt(e){return e.replace(Xt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Qt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Gt(t)):e.value!==``+Gt(t)&&(e.value=``+Gt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):en(e,Gt(n)):o===`number`&&e.value==t?en(e,Gt(e.value)):en(e,Gt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Gt(s):e.removeAttribute(`name`)}function $t(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Jt(e);return}n=n==null?``:``+Gt(n),t=t==null?n:``+Gt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Jt(e)}function en(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function tn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Gt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function nn(e,t,n){if(t!=null&&(t=``+Gt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Gt(n)}function rn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(s(92));if(R(r)){if(1<r.length)throw Error(s(93));r=r[0]}n=r}n??=``,t=n}n=Gt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Jt(e)}function an(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var on=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function sn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||on.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function cn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(s(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Vt=!0);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&(sn(e,i,r),Vt=!0)}else for(var a in t)t.hasOwnProperty(a)&&sn(e,a,t[a])}function ln(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var un=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),dn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function fn(e){return dn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function pn(){}var mn=null;function hn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gn=null,_n=null;function vn(e){var t=Ot(e);if(t&&(e=t.stateNode)){var n=e[vt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Qt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Zt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[vt]||null;if(!i)throw Error(s(90));Qt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Yt(r)}break a;case`textarea`:nn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&tn(e,!!n.multiple,t,!1)}}}var yn=!1;function bn(e,t,n){if(yn)return e(t,n);yn=!0;try{return e(t)}finally{if(yn=!1,(gn!==null||_n!==null)&&(Bd(),gn&&(t=gn,e=_n,_n=gn=null,vn(t),e)))for(t=0;t<e.length;t++)vn(e[t])}}function xn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[vt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(s(231,t,typeof n));return n}var Sn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Cn=!1;if(Sn)try{var wn={};Object.defineProperty(wn,"passive",{get:function(){Cn=!0}}),window.addEventListener(`test`,wn,wn),window.removeEventListener(`test`,wn,wn)}catch{Cn=!1}var Tn=null,En=null,Dn=null;function On(){if(Dn)return Dn;var e,t=En,n=t.length,r,i=`value`in Tn?Tn.value:Tn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Dn=i.slice(e,1<r?1-r:void 0)}function kn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function An(){return!0}function jn(){return!1}function G(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?An:jn,this.isPropagationStopped=jn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=An)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=An)},persist:function(){},isPersistent:An}),t}var Mn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nn=G(Mn),Pn=D({},Mn,{view:0,detail:0}),Fn=G(Pn),In,Ln,Rn,zn=D({},Pn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Rn&&(Rn&&e.type===`mousemove`?(In=e.screenX-Rn.screenX,Ln=e.screenY-Rn.screenY):Ln=In=0,Rn=e),In)},movementY:function(e){return`movementY`in e?e.movementY:Ln}}),Bn=G(zn),Vn=G(D({},zn,{dataTransfer:0})),Hn=G(D({},Pn,{relatedTarget:0})),Un=G(D({},Mn,{animationName:0,elapsedTime:0,pseudoElement:0})),Wn=G(D({},Mn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Gn=G(D({},Mn,{data:0})),Kn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},qn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Jn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Yn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Jn[e])?!!t[e]:!1}function Xn(){return Yn}var Zn=G(D({},Pn,{key:function(e){if(e.key){var t=Kn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=kn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?qn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xn,charCode:function(e){return e.type===`keypress`?kn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?kn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Qn=G(D({},zn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),$n=G(D({},Mn,{submitter:0})),er=G(D({},Pn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xn})),tr=G(D({},Mn,{propertyName:0,elapsedTime:0,pseudoElement:0})),nr=G(D({},zn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),rr=G(D({},Mn,{newState:0,oldState:0,source:0})),ir=[9,13,27,32],ar=Sn&&`CompositionEvent`in window,or=null;Sn&&`documentMode`in document&&(or=document.documentMode);var sr=Sn&&`TextEvent`in window&&!or,cr=Sn&&(!ar||or&&8<or&&11>=or),lr=` `,ur=!1;function dr(e,t){switch(e){case`keyup`:return ir.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function fr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var pr=!1;function mr(e,t){switch(e){case`compositionend`:return fr(t);case`keypress`:return t.which===32?(ur=!0,lr):null;case`textInput`:return e=t.data,e===lr&&ur?null:e;default:return null}}function hr(e,t){if(pr)return e===`compositionend`||!ar&&dr(e,t)?(e=On(),Dn=En=Tn=null,pr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return cr&&t.locale!==`ko`?null:t.data;default:return null}}var gr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function _r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!gr[e.type]:t===`textarea`}function vr(e,t,n,r){gn?_n?_n.push(r):_n=[r]:gn=r,t=Zf(t,`onChange`),0<t.length&&(n=new Nn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var yr=null,br=null;function xr(e){Uf(e,0)}function Sr(e){if(Yt(kt(e)))return e}function Cr(e,t){if(e===`change`)return t}var wr=!1;if(Sn){var Tr;if(Sn){var Er=`oninput`in document;if(!Er){var Dr=document.createElement(`div`);Dr.setAttribute(`oninput`,`return;`),Er=typeof Dr.oninput==`function`}Tr=Er}else Tr=!1;wr=Tr&&(!document.documentMode||9<document.documentMode)}function Or(){yr&&(yr.detachEvent(`onpropertychange`,kr),br=yr=null)}function kr(e){if(e.propertyName===`value`&&Sr(br)){var t=[];vr(t,br,e,hn(e)),bn(xr,t)}}function Ar(e,t,n){e===`focusin`?(Or(),yr=t,br=n,yr.attachEvent(`onpropertychange`,kr)):e===`focusout`&&Or()}function jr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Sr(br)}function Mr(e,t){if(e===`click`)return Sr(t)}function Nr(e,t){if(e===`input`||e===`change`)return Sr(t)}function Pr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Fr=typeof Object.is==`function`?Object.is:Pr;function Ir(e,t){if(Fr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ae.call(t,i)||!Fr(e[i],t[i]))return!1}return!0}function Lr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Rr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function zr(e,t){var n=Rr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Rr(n)}}function Br(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Br(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Lr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lr(e.document)}return t}function Hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ur=Sn&&`documentMode`in document&&11>=document.documentMode,Wr=null,Gr=null,Kr=null,qr=!1;function Jr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qr||Wr==null||Wr!==Lr(r)||(r=Wr,`selectionStart`in r&&Hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Kr&&Ir(Kr,r)||(Kr=r,r=Zf(Gr,`onSelect`),0<r.length&&(t=new Nn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Wr)))}function Yr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Xr={animationend:Yr(`Animation`,`AnimationEnd`),animationiteration:Yr(`Animation`,`AnimationIteration`),animationstart:Yr(`Animation`,`AnimationStart`),transitionrun:Yr(`Transition`,`TransitionRun`),transitionstart:Yr(`Transition`,`TransitionStart`),transitioncancel:Yr(`Transition`,`TransitionCancel`),transitionend:Yr(`Transition`,`TransitionEnd`)},Zr={},Qr={};Sn&&(Qr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Xr.animationend.animation,delete Xr.animationiteration.animation,delete Xr.animationstart.animation),`TransitionEvent`in window||delete Xr.transitionend.transition);function $r(e){if(Zr[e])return Zr[e];if(!Xr[e])return e;var t=Xr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Qr)return Zr[e]=t[n];return e}var ei=$r(`animationend`),ti=$r(`animationiteration`),ni=$r(`animationstart`),ri=$r(`transitionrun`),ii=$r(`transitionstart`),ai=$r(`transitioncancel`),oi=$r(`transitionend`),si=new Map,ci=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);ci.push(`scrollEnd`);function li(e,t){si.set(e,t),Ft(t,[e])}var ui=0;function di(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=xd.identifierPrefix;var n=ui++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function fi(e){if(e==null||typeof e==`string`)return e;var t=null,n=kd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function pi(e,t){return e=fi(e),t=fi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var mi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},hi=[],gi=0,_i=0;function vi(){for(var e=gi,t=_i=gi=0;t<e;){var n=hi[t];hi[t++]=null;var r=hi[t];hi[t++]=null;var i=hi[t];hi[t++]=null;var a=hi[t];if(hi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Si(n,i,a)}}function yi(e,t,n,r){hi[gi++]=e,hi[gi++]=t,hi[gi++]=n,hi[gi++]=r,_i|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function bi(e,t,n,r){return yi(e,t,n,r),Ci(e)}function xi(e,t){return yi(e,null,null,t),Ci(e)}function Si(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-qe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Ci(e){if(50<Ad)throw Ad=0,jd=null,Error(s(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var wi={};function Ti(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(e,t,n,r){return new Ti(e,t,n,r)}function Di(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Oi(e,t){var n=e.alternate;return n===null?(n=Ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ki(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ai(e,t,n,r,i,a){var o=0;if(r=e,typeof r==`function`)Di(r)&&(o=1);else if(typeof r==`string`)o=Jm(e,n,_e.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case re:return e=Ei(31,n,t,i),e.elementType=re,e.lanes=a,e;case j:return ji(n.children,i,a,t);case ee:o=8,i|=24;break;case M:return e=Ei(12,n,t,i|2),e.elementType=M,e.lanes=a,e;case te:return e=Ei(13,n,t,i),e.elementType=te,e.lanes=a,e;case I:return e=Ei(19,n,t,i),e.elementType=I,e.lanes=a,e;case ie:case oe:return e=i|32,e=Ei(30,n,t,e),e.elementType=oe,e.lanes=a,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case P:o=10;break a;case N:o=9;break a;case F:o=11;break a;case ne:o=14;break a;case L:o=16,r=null;break a}o=29,n=Error(s(130,e===null?`null`:typeof e,``)),r=null}return t=Ei(o,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function ji(e,t,n,r){return e=Ei(7,e,r,t),e.lanes=n,e}function Mi(e,t,n){return e=Ei(6,e,null,t),e.lanes=n,e}function Ni(e){var t=Ei(18,null,null,0);return t.stateNode=e,t}function Pi(e,t,n){return t=Ei(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Fi=new WeakMap;function Ii(e,t){if(typeof e==`object`&&e){var n=Fi.get(e);return n===void 0?(t={value:e,source:t,stack:ke(t)},Fi.set(e,t),t):n}return{value:e,source:t,stack:ke(t)}}var Li=[],Ri=0,zi=null,Bi=0,Vi=[],Hi=0,Ui=null,Wi=1,Gi=``;function Ki(e,t){Li[Ri++]=Bi,Li[Ri++]=zi,zi=e,Bi=t}function qi(e,t,n){Vi[Hi++]=Wi,Vi[Hi++]=Gi,Vi[Hi++]=Ui,Ui=e;var r=Wi;e=Gi;var i=32-qe(r)-1;r&=~(1<<i),n+=1;var a=32-qe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Wi=1<<32-qe(t)+i|n<<i|r,Gi=a+e}else Wi=1<<a|n<<i|r,Gi=e}function Ji(e){e.return!==null&&(Ki(e,1),qi(e,1,0))}function Yi(e){for(;e===zi;)zi=Li[--Ri],Li[Ri]=null,Bi=Li[--Ri],Li[Ri]=null;for(;e===Ui;)Ui=Vi[--Hi],Vi[Hi]=null,Gi=Vi[--Hi],Vi[Hi]=null,Wi=Vi[--Hi],Vi[Hi]=null}function Xi(e,t){Vi[Hi++]=Wi,Vi[Hi++]=Gi,Vi[Hi++]=Ui,Wi=t.id,Gi=t.overflow,Ui=e}var Zi=null,Qi=null,$i=!1,ea=null,ta=!1,na=Error(s(519));function ra(e){throw la(Ii(Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),na}function ia(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[_t]=e,t[vt]=r,n){case`dialog`:Wf(`cancel`,t),Wf(`close`,t);break;case`iframe`:case`object`:case`embed`:Wf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Vf.length;n++)Wf(Vf[n],t);break;case`source`:Wf(`error`,t);break;case`img`:case`image`:case`link`:Wf(`error`,t),Wf(`load`,t);break;case`details`:Wf(`toggle`,t);break;case`input`:Wf(`invalid`,t),$t(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Wf(`invalid`,t);break;case`textarea`:Wf(`invalid`,t),rn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||rp(t.textContent,n)?(r.popover!=null&&(Wf(`beforetoggle`,t),Wf(`toggle`,t)),r.onScroll!=null&&Wf(`scroll`,t),r.onScrollEnd!=null&&Wf(`scrollend`,t),r.onClick!=null&&(t.onclick=pn),t=!0):t=!1,t||ra(e,!0)}function aa(e){for(Zi=e.return;Zi;)switch(Zi.tag){case 5:case 31:case 13:ta=!1;return;case 27:case 3:ta=!0;return;default:Zi=Zi.return}}function oa(e){if(e!==Zi)return!1;if(!$i)return aa(e),$i=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||_p(e.type,e.memoizedProps)),n=!n),n&&Qi&&ra(e),aa(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(317));Qi=fm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(317));Qi=fm(e)}else t===27?(t=Qi,Ep(e.type)?(e=dm,dm=null,Qi=e):Qi=t):Qi=Zi?um(e.stateNode.nextSibling):null;return!0}function sa(){Qi=Zi=null,$i=!1}function ca(){var e=ea;return e!==null&&(pd===null?pd=e:pd.push.apply(pd,e),ea=null),e}function la(e){ea===null?ea=[e]:ea.push(e)}var ua=he(null),da=null,fa=null;function pa(e,t,n){V(ua,t._currentValue),t._currentValue=n}function ma(e){e._currentValue=ua.current,ge(ua)}function ha(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function ga(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var o=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),ha(a.return,n,e),r||(o=null);break a}a=c.next}}else if(i.tag===18){if(o=i.return,o===null)throw Error(s(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),ha(o,n,e),o=null}else i.tag===13&&i.memoizedState!==null&&i.memoizedState.dehydrated===null?(i.lanes|=n,o=i.alternate,o!==null&&(o.lanes|=n),ha(i.return,n,e),o=i.child,o=o===null?null:o.sibling):o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}}function _a(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var o=i.alternate;if(o===null)throw Error(s(387));if(o=o.memoizedProps,o!==null){var c=i.type;Fr(i.pendingProps.value,o.value)||(e===null?e=[c]:e.push(c))}}else if(i===H.current){if(o=i.alternate,o===null)throw Error(s(387));o.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[ch]:e.push(ch))}i=i.return}return e!==null&&ga(t,e,n,r),t.flags|=262144,e!==null}function va(e){for(e=e.firstContext;e!==null;){if(!Fr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ya(e){da=e,fa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ba(e){return Sa(da,e)}function xa(e,t){return da===null&&ya(e),Sa(e,t)}function Sa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},fa===null){if(e===null)throw Error(s(308));fa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else fa=fa.next=t;return n}var Ca=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},wa=t.unstable_scheduleCallback,Ta=t.unstable_NormalPriority,Ea={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Da(){return{controller:new Ca,data:new Map,refCount:0}}function Oa(e){e.refCount--,e.refCount===0&&wa(Ta,function(){e.controller.abort()})}function ka(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Aa=null;function ja(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ma=null,Na=0,Pa=0,Fa=null;function Ia(e,t){if(Ma===null){var n=Ma=[];Na=0,Pa=If(),Fa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Na++,t.then(La,La),t}function La(){if(--Na===0&&(Aa=null,Ma!==null)){Fa!==null&&(Fa.status=`fulfilled`);var e=Ma;Ma=null,Pa=0,Fa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ra(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var za=z.S;z.S=function(e,t){if(gd=Fe(),typeof t==`object`&&t&&typeof t.then==`function`&&Ia(e,t),Aa!==null)for(var n=Sf;n!==null;)ka(n,Aa),n=n.next;if(n=e.types,n!==null){for(var r=Sf;r!==null;)ka(r,n),r=r.next;if(Pa!==0){r=Aa,r===null&&(r=Aa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}za!==null&&za(e,t)};var Ba=he(null);function Va(){var e=Ba.current;return e===null?Zu.pooledCache:e}function Ha(e,t){t===null?V(Ba,Ba.current):V(Ba,t.pool)}function Ua(){var e=Va();return e===null?null:{parent:Ea._currentValue,pool:e}}var Wa=Error(s(460)),Ga=Error(s(474)),Ka=Error(s(542)),qa={then:function(){}};function Ja(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ya(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(pn,pn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,$a(e),e===void 0&&!(`reason`in t)?Error(s(600)):e;default:if(typeof t.status==`string`)t.then(pn,pn);else{if(e=Zu,e!==null&&100<e.shellSuspendCounter)throw Error(s(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,$a(e),e}throw Za=t,Wa}}function Xa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Za=e,Wa):e}}var Za=null;function Qa(){if(Za===null)throw Error(s(459));var e=Za;return Za=null,e}function $a(e){if(e===Wa||e===Ka)throw Error(s(483))}var eo=null,to=0;function no(e){var t=to;return to+=1,eo===null&&(eo=[]),Ya(eo,e,t)}function ro(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function io(e,t){throw t.$$typeof===O?Error(s(525)):(e=Object.prototype.toString.call(t),Error(s(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function ao(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=Oi(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function o(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Mi(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===j?(e=d(e,t,n.props.children,r,n.key),ro(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===L&&Xa(a)===t.type)?(t=i(t,n.props),ro(t,n),t.return=e,t):(t=Ai(n.type,n.key,n.props,null,e.mode,r),ro(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Pi(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=ji(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Mi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Ai(t.type,t.key,t.props,null,e.mode,n),ro(n,t),n.return=e,n;case A:return t=Pi(t,e.mode,n),t.return=e,t;case L:return t=Xa(t),f(e,t,n)}if(R(t)||le(t))return t=ji(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,no(t),n);if(t.$$typeof===P)return f(e,xa(e,t),n);io(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case L:return n=Xa(n),p(e,t,n,r)}if(R(n)||le(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,no(n),r);if(n.$$typeof===P)return p(e,t,xa(e,n),r);io(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case L:return r=Xa(r),m(e,t,n,r,i)}if(R(r)||le(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,no(r),i);if(r.$$typeof===P)return m(e,t,n,xa(t,r),i);io(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),$i&&Ki(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return $i&&Ki(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),$i&&Ki(i,h),l}function g(i,o,c,l){if(c==null)throw Error(s(151));for(var u=null,d=null,h=o,g=o=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),o=a(y,o,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),$i&&Ki(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return $i&&Ki(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),$i&&Ki(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===j&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case k:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),ro(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===L&&Xa(l)===r.type){n(e,r.sibling),c=i(r,a.props),ro(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===j?(c=ji(a.props.children,e.mode,c,a.key),ro(c,a),c.return=e,e=c):(c=Ai(a.type,a.key,a.props,null,e.mode,c),ro(c,a),c.return=e,e=c)}return o(e);case A:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Pi(a,e.mode,c),c.return=e,e=c}return o(e);case L:return a=Xa(a),_(e,r,a,c)}if(R(a))return h(e,r,a,c);if(le(a)){if(l=le(a),typeof l!=`function`)throw Error(s(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,no(a),c);if(a.$$typeof===P)return _(e,r,xa(e,a),c);io(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Mi(a,e.mode,c),c.return=e,e=c),o(e)):n(e,r)}return function(e,t,n,r){try{to=0;var i=_(e,t,n,r);return eo=null,i}catch(t){if(t===Wa||t===Ka)throw t;var a=Ei(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var oo=ao(!0),so=ao(!1),co=!1;function lo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function uo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function fo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function po(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Xu&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ci(e),Si(e,null,n),t}return yi(e,r,t,n),Ci(e)}function mo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}function ho(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var go=!1;function _o(){if(go){var e=Fa;if(e!==null)throw e}}function vo(e,t,n,r){go=!1;var i=e.updateQueue;co=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?($u&f)===f:(r&f)===f){f!==0&&f===Pa&&(go=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:co=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function yo(e,t){if(typeof e!=`function`)throw Error(s(191,e));e.call(t)}function bo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)yo(n[e],t)}var xo=he(null),So=he(0);function Co(e,t){e=ad,V(So,e),V(xo,t),ad=e|t.baseLanes}function wo(){V(So,ad),V(xo,xo.current)}function To(){ad=So.current,ge(xo),ge(So)}var Eo=he(null),Do=null;function Oo(e){var t=e.alternate;V(No,No.current&1),V(Eo,e),Do===null&&(t===null||xo.current!==null||t.memoizedState!==null)&&(Do=e)}function ko(e){V(No,No.current),V(Eo,e),Do===null&&(Do=e)}function Ao(e){e.tag===22?(V(No,No.current),V(Eo,e),Do===null&&(Do=e)):jo()}function jo(){V(No,No.current),V(Eo,Eo.current)}function Mo(e){ge(Eo),Do===e&&(Do=null),ge(No)}var No=he(0);function Po(e,t){V(Eo,Eo.current),V(No,t)}function Fo(e){ge(No),ge(Eo),Do===e&&(Do=null)}function Io(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||sm(n)||cm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Lo=0,Ro=null,zo=null,Bo=null,Vo=!1,Ho=!1,Uo=!1,Wo=0,Go=0,Ko=null,qo=0;function Jo(){throw Error(s(321))}function Yo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Fr(e[n],t[n]))return!1;return!0}function Xo(e,t,n,r,i,a){return Lo=a,Ro=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=e===null||e.memoizedState===null?pc:mc,Uo=!1,a=n(r,i),Uo=!1,Ho&&(a=Qo(t,n,r,i)),Zo(e),a}function Zo(e){z.H=fc;var t=zo!==null&&zo.next!==null;if(Lo=0,Bo=zo=Ro=null,Vo=!1,Go=0,Ko=null,t)throw Error(s(300));e===null||jc||(e=e.dependencies,e!==null&&va(e)&&(jc=!0))}function Qo(e,t,n,r){Ro=e;var i=0;do{if(Ho&&(Ko=null),Go=0,Ho=!1,25<=i)throw Error(s(301));if(i+=1,Bo=zo=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}z.H=hc,a=t(n,r)}while(Ho);return a}function $o(){var e=z.H,t=e.useState()[0];return t=typeof t.then==`function`?os(t):t,e=e.useState()[0],(zo===null?null:zo.memoizedState)!==e&&(Ro.flags|=1024),t}function es(){var e=Wo!==0;return Wo=0,e}function ts(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function ns(e){if(Vo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Vo=!1}Lo=0,Bo=zo=Ro=null,Ho=!1,Go=Wo=0,Ko=null}function rs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bo===null?Ro.memoizedState=Bo=e:Bo=Bo.next=e,Bo}function is(){if(zo===null){var e=Ro.alternate;e=e===null?null:e.memoizedState}else e=zo.next;var t=Bo===null?Ro.memoizedState:Bo.next;if(t!==null)Bo=t,zo=e;else{if(e===null)throw Ro.alternate===null?Error(s(467)):Error(s(310));zo=e,e={memoizedState:zo.memoizedState,baseState:zo.baseState,baseQueue:zo.baseQueue,queue:zo.queue,next:null},Bo===null?Ro.memoizedState=Bo=e:Bo=Bo.next=e}return Bo}function as(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function os(e){var t=Go;return Go+=1,Ko===null&&(Ko=[]),e=Ya(Ko,e,t),t=Ro,(Bo===null?t.memoizedState:Bo.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?pc:mc),e}function ss(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return os(e);if(e.$$typeof===se)return;if(e.$$typeof===P)return ba(e)}throw Error(s(438,String(e)))}function cs(e){var t=null,n=Ro.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Ro.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=as(),Ro.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ae;return t.index++,n}function ls(e,t){return typeof t==`function`?t(e):t}function us(e){return ds(is(),zo,e)}function ds(e,t,n){var r=e.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var o=i.next;i.next=a.next,a.next=o}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=o=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Lo&f)===f:($u&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Pa&&(d=!0);else if((Lo&p)===p){u=u.next,p===Pa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,o=a):l=l.next=f,Ro.lanes|=p,sd|=p;f=u.action,Uo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,o=a):l=l.next=p,Ro.lanes|=f,sd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?o=a:l.next=c,!Fr(a,e.memoizedState)&&(jc=!0,d&&(n=Fa,n!==null)))throw n;e.memoizedState=a,e.baseState=o,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function fs(e){var t=is(),n=t.queue;if(n===null)throw Error(s(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var o=i=i.next;do a=e(a,o.action),o=o.next;while(o!==i);Fr(a,t.memoizedState)||(jc=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function ps(e,t,n){var r=Ro,i=is(),a=$i;if(a){if(n===void 0)throw Error(s(407));n=n()}else n=t();var o=!Fr((zo||i).memoizedState,n);if(o&&(i.memoizedState=n,jc=!0),i=i.queue,Rs(gs.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||o||Bo!==null&&!!(Bo.memoizedState.tag&1),Ns(e?9:8,{destroy:void 0},hs.bind(null,r,i,n,t),null),e){if(r.flags|=2048,Zu===null)throw Error(s(349));a||Lo&127||ms(r,t,n)}return n}function ms(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ro.updateQueue,t===null?(t=as(),Ro.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function hs(e,t,n,r){t.value=n,t.getSnapshot=r,_s(t)&&vs(e)}function gs(e,t,n){return n(function(){_s(t)&&vs(e)})}function _s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Fr(e,n)}catch{return!0}}function vs(e){var t=xi(e,2);t!==null&&Fd(t,e,2)}function ys(e){var t=rs();if(typeof e==`function`){var n=e;if(e=n(),Uo){Ke(!0);try{n()}finally{Ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:e},t}function bs(e,t,n,r){return e.baseState=n,ds(e,zo,typeof r==`function`?r:ls)}function xs(e,t,n,r,i){if(lc(e))throw Error(s(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};z.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,Ss(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Ss(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=z.T,o={};o.types=a===null?null:a.types,z.T=o;try{var s=n(i,r),c=z.S;c!==null&&c(o,s),Cs(e,t,s)}catch(n){Ts(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),z.T=a}}else try{a=n(i,r),Cs(e,t,a)}catch(n){Ts(e,t,n)}}function Cs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ws(e,t,n)},function(n){return Ts(e,t,n)}):ws(e,t,n)}function ws(e,t,n){t.status=`fulfilled`,t.value=n,Es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Es(t),t=t.next;while(t!==r)}e.action=null}function Es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ds(e,t){return t}function Os(e,t){if($i){var n=Zu.formState;if(n!==null){a:{var r=Ro;if($i){if(Qi){b:{for(var i=Qi,a=ta;i.nodeType!==8;){if(!a){i=null;break b}if(i=um(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Qi=um(i.nextSibling),r=i.data===`F!`;break a}}ra(r)}r=!1}r&&(t=n[0])}}return n=rs(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ds,lastRenderedState:t},n.queue=r,n=oc.bind(null,Ro,r),r.dispatch=n,r=ys(!1),a=cc.bind(null,Ro,!1,r.queue),r=rs(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=xs.bind(null,Ro,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ks(e){return As(is(),zo,e)}function As(e,t,n){if(t=ds(e,t,Ds)[0],e=us(ls)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=os(t)}catch(e){throw e===Wa?Ka:e}else r=t;t=is();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Ro.flags|=2048,Ns(9,{destroy:void 0},js.bind(null,i,n),null)),[r,a,e]}function js(e,t){e.action=t}function Ms(e){var t=is(),n=zo;if(n!==null)return As(t,n,e);is(),t=t.memoizedState,n=is();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Ns(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Ro.updateQueue,t===null&&(t=as(),Ro.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ps(){return is().memoizedState}function Fs(e,t,n,r){var i=rs();Ro.flags|=e,i.memoizedState=Ns(1|t,{destroy:void 0},n,r===void 0?null:r)}function Is(e,t,n,r){var i=is();r=r===void 0?null:r;var a=i.memoizedState.inst;zo!==null&&r!==null&&Yo(r,zo.memoizedState.deps)?i.memoizedState=Ns(t,a,n,r):(Ro.flags|=e,i.memoizedState=Ns(1|t,a,n,r))}function Ls(e,t){Fs(8390656,8,e,t)}function Rs(e,t){Is(2048,8,e,t)}function zs(e){Ro.flags|=4;var t=Ro.updateQueue;if(t===null)t=as(),Ro.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Bs(e){var t=is().memoizedState;return zs({ref:t,nextImpl:e}),function(){if(Xu&2)throw Error(s(440));return t.impl.apply(void 0,arguments)}}function Vs(e,t){return Is(4,2,e,t)}function Hs(e,t){return Is(4,4,e,t)}function Us(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ws(e,t,n){n=n==null?null:n.concat([e]),Is(4,4,Us.bind(null,t,e),n)}function Gs(){}function Ks(e,t){var n=is();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Yo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function qs(e,t){var n=is();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Yo(t,r[1]))return r[0];if(r=e(),Uo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r}function Js(e,t,n){return n===void 0||Lo&1073741824&&!($u&261930)?e.memoizedState=t:(e.memoizedState=n,e=Nd(),Ro.lanes|=e,sd|=e,n)}function Ys(e,t,n,r){return Fr(n,t)?n:xo.current===null?!(Lo&106)||Lo&1073741824&&!($u&261930)?(jc=!0,e.memoizedState=n):(e=Nd(),Ro.lanes|=e,sd|=e,t):(e=Js(e,n,r),Fr(e,t)||(jc=!0),e)}function Xs(e,t,n,r,i){var a=B.p;B.p=a!==0&&8>a?a:8;var o=z.T,s={};s.types=o===null?null:o.types,z.T=s,cc(e,!1,t,n);try{var c=i(),l=z.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?sc(e,t,Ra(c,r),Md(e)):sc(e,t,r,Md(e))}catch(n){sc(e,t,{then:function(){},status:`rejected`,reason:n},Md())}finally{B.p=a,o!==null&&s.types!==null&&(o.types=s.types),z.T=o}}function Zs(){}function Qs(e,t,n,r){if(e.tag!==5)throw Error(s(476));var i=$s(e).queue;Xs(e,i,t,fe,n===null?Zs:function(){return ec(e),n(r)})}function $s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:fe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ec(e){var t=$s(e);t.next===null&&(t=e.alternate.memoizedState),sc(e,t.next.queue,{},Md())}function tc(){return ba(ch)}function nc(){return is().memoizedState}function rc(){return is().memoizedState}function ic(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Md();e=fo(n);var r=po(t,e,n);r!==null&&(Fd(r,t,n),mo(r,t,n)),t={cache:Da()},e.payload=t;return}t=t.return}}function ac(e,t,n){var r=Md();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},lc(e)?uc(t,n):(n=bi(e,t,n,r),n!==null&&(Fd(n,e,r),dc(n,t,r)))}function oc(e,t,n){sc(e,t,n,Md())}function sc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(lc(e))uc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Fr(s,o))return yi(e,t,i,0),Zu===null&&vi(),!1}catch{}if(n=bi(e,t,i,r),n!==null)return Fd(n,e,r),dc(n,t,r),!0}return!1}function cc(e,t,n,r){if(r={lane:2,revertLane:If(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},lc(e)){if(t)throw Error(s(479))}else t=bi(e,n,r,2),t!==null&&Fd(t,e,2)}function lc(e){var t=e.alternate;return e===Ro||t!==null&&t===Ro}function uc(e,t){Ho=Vo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function dc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}var fc={readContext:ba,use:ss,useCallback:Jo,useContext:Jo,useEffect:Jo,useImperativeHandle:Jo,useLayoutEffect:Jo,useInsertionEffect:Jo,useMemo:Jo,useReducer:Jo,useRef:Jo,useState:Jo,useDebugValue:Jo,useDeferredValue:Jo,useTransition:Jo,useSyncExternalStore:Jo,useId:Jo,useHostTransitionStatus:Jo,useFormState:Jo,useActionState:Jo,useOptimistic:Jo,useMemoCache:Jo,useCacheRefresh:Jo,useEffectEvent:Jo},pc={readContext:ba,use:ss,useCallback:function(e,t){return rs().memoizedState=[e,t===void 0?null:t],e},useContext:ba,useEffect:Ls,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Fs(4194308,4,Us.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fs(4194308,4,e,t)},useInsertionEffect:function(e,t){Fs(4,2,e,t)},useMemo:function(e,t){var n=rs();t=t===void 0?null:t;var r=e();if(Uo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=rs();if(n!==void 0){var i=n(t);if(Uo){Ke(!0);try{n(t)}finally{Ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ac.bind(null,Ro,e),[r.memoizedState,e]},useRef:function(e){var t=rs();return e={current:e},t.memoizedState=e},useState:function(e){e=ys(e);var t=e.queue,n=oc.bind(null,Ro,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Gs,useDeferredValue:function(e,t){return Js(rs(),e,t)},useTransition:function(){var e=ys(!1);return e=Xs.bind(null,Ro,e.queue,!0,!1),rs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ro,i=rs();if($i){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),Zu===null)throw Error(s(349));$u&127||ms(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ls(gs.bind(null,r,a,e),[e]),r.flags|=2048,Ns(9,{destroy:void 0},hs.bind(null,r,a,n,t),null),n},useId:function(){var e=rs(),t=Zu.identifierPrefix;if($i){var n=Gi,r=Wi;n=(r&~(1<<32-qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Wo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=qo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:tc,useFormState:Os,useActionState:Os,useOptimistic:function(e){var t=rs();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=cc.bind(null,Ro,!0,n),n.dispatch=t,[e,t]},useMemoCache:cs,useCacheRefresh:function(){return rs().memoizedState=ic.bind(null,Ro)},useEffectEvent:function(e){var t=rs(),n={impl:e};return t.memoizedState=n,function(){if(Xu&2)throw Error(s(440));return n.impl.apply(void 0,arguments)}}},mc={readContext:ba,use:ss,useCallback:Ks,useContext:ba,useEffect:Rs,useImperativeHandle:Ws,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:us,useRef:Ps,useState:function(){return us(ls)},useDebugValue:Gs,useDeferredValue:function(e,t){return Ys(is(),zo.memoizedState,e,t)},useTransition:function(){var e=us(ls)[0],t=is().memoizedState;return[typeof e==`boolean`?e:os(e),t]},useSyncExternalStore:ps,useId:nc,useHostTransitionStatus:tc,useFormState:ks,useActionState:ks,useOptimistic:function(e,t){return bs(is(),zo,e,t)},useMemoCache:cs,useCacheRefresh:rc,useEffectEvent:Bs},hc={readContext:ba,use:ss,useCallback:Ks,useContext:ba,useEffect:Rs,useImperativeHandle:Ws,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:fs,useRef:Ps,useState:function(){return fs(ls)},useDebugValue:Gs,useDeferredValue:function(e,t){var n=is();return zo===null?Js(n,e,t):Ys(n,zo.memoizedState,e,t)},useTransition:function(){var e=fs(ls)[0],t=is().memoizedState;return[typeof e==`boolean`?e:os(e),t]},useSyncExternalStore:ps,useId:nc,useHostTransitionStatus:tc,useFormState:Ms,useActionState:Ms,useOptimistic:function(e,t){var n=is();return zo===null?(n.baseState=e,[e,n.queue.dispatch]):bs(n,zo,e,t)},useMemoCache:cs,useCacheRefresh:rc,useEffectEvent:Bs};function gc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var _c={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Md(),i=fo(r);i.payload=t,n!=null&&(i.callback=n),t=po(e,i,r),t!==null&&(Fd(t,e,r),mo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Md(),i=fo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=po(e,i,r),t!==null&&(Fd(t,e,r),mo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Md(),r=fo(n);r.tag=2,t!=null&&(r.callback=t),t=po(e,r,n),t!==null&&(Fd(t,e,n),mo(t,e,n))}};function vc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Ir(n,r)||!Ir(i,a):!0}function yc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&_c.enqueueReplaceState(t,t.state,null)}function bc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function xc(e){mi(e)}function Sc(e){console.error(e)}function Cc(e){mi(e)}function wc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Tc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ec(e,t,n){return n=fo(n),n.tag=3,n.payload={element:null},n.callback=function(){wc(e,t)},n}function Dc(e){return e=fo(e),e.tag=3,e}function Oc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Tc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Tc(t,n,r),typeof i!=`function`&&(yd===null?yd=new Set([this]):yd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function kc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&_a(t,n,i,!0),n=Eo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Do===null?qd():n.alternate===null&&od===0&&(od=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===qa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),gf(e,r,i)),!1;case 22:return n.flags|=65536,r===qa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),gf(e,r,i)),!1}throw Error(s(435,n.tag))}return gf(e,r,i),qd(),!1}if($i)return t=Eo.current,t===null?(r!==na&&(t=Error(s(423),{cause:r}),la(Ii(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Ii(r,n),i=Ec(e.stateNode,r,i),ho(e,i),od!==4&&(od=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==na&&(e=Error(s(422),{cause:r}),la(Ii(e,n)))),!1;var a=Error(s(520),{cause:r});if(a=Ii(a,n),fd===null?fd=[a]:fd.push(a),od!==4&&(od=2),t===null)return!0;r=Ii(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Ec(n.stateNode,r,e),ho(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(yd===null||!yd.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Dc(i),Oc(i,e,n,r),ho(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Ac=Error(s(461)),jc=!1;function Mc(e,t,n,r){t.child=e===null?so(t,null,n,r):oo(t,e.child,n,r)}function Nc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ya(t),r=Xo(e,t,n,o,a,i),s=es(),e!==null&&!jc?(ts(e,t,i),ol(e,t,i)):($i&&s&&Ji(t),t.flags|=1,Mc(e,t,r,i),t.child)}function Pc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Di(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Fc(e,t,a,r,i)):(e=Ai(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!sl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Ir:n,n(o,r)&&e.ref===t.ref)return ol(e,t,i)}return t.flags|=1,e=Oi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Fc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Ir(a,r)&&e.ref===t.ref){if(jc=!1,t.pendingProps=r=a,sl(e,i))e.flags&131072&&(jc=!0);else return t.lanes=e.lanes,ol(e,t,i)}}return Hc(e,t,n,r,i)}function Ic(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return K(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ha(t,a===null?null:a.cachePool),a===null?wo():Co(t,a),Ao(t);else return r=t.lanes=536870912,K(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ha(t,null),wo(),jo()):(Ha(t,a.cachePool),Co(t,a),jo(),t.memoizedState=null);return Mc(e,t,i,n),t.child}function Lc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function K(e,t,n,r,i){var a=Va();return a=a===null?null:{parent:Ea._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ha(t,null),wo(),Ao(t),e!==null&&_a(e,t,r,!0),t.childLanes=i,null}function Rc(e,t){return t=Zc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function zc(e,t,n){return oo(t,e.child,null,n),e=Rc(t,t.pendingProps),e.flags|=2,Mo(t),t.memoizedState=null,e}function Bc(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if($i){if(r.mode===`hidden`)return e=Rc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Lc(null,e);if(ko(t),(e=Qi)?(e=om(e,ta),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ui===null?null:{id:Wi,overflow:Gi},retryLane:536870912,hydrationErrors:null},n=Ni(e),n.return=t,t.child=n,Zi=t,Qi=null)):e=null,e===null)throw ra(t);return t.lanes=536870912,null}return Rc(t,r)}var a=e.memoizedState;if(a!==null){var o=a.dehydrated;if(ko(t),i){if(t.flags&256)t.flags&=-257,t=zc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(s(558))}else if(jc||_a(e,t,n,!1),i=(n&e.childLanes)!==0,jc||i){if(xo.current===null){if(r=Zu,r!==null&&(o=dt(r,n),o!==0&&o!==a.retryLane))throw a.retryLane=o,xi(e,o),Fd(r,e,o),Ac;qd()}t=zc(e,t,n)}else e=a.treeContext,Qi=um(o.nextSibling),Zi=t,$i=!0,ea=null,ta=!1,e!==null&&Xi(t,e),t=Rc(t,r),t.flags|=134221824;return t}return e=Oi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Vc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(s(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Hc(e,t,n,r,i){return ya(t),n=Xo(e,t,n,r,void 0,i),r=es(),e!==null&&!jc?(ts(e,t,i),ol(e,t,i)):($i&&r&&Ji(t),t.flags|=1,Mc(e,t,n,i),t.child)}function Uc(e,t,n,r,i,a){return ya(t),t.updateQueue=null,n=Qo(t,r,n,i),Zo(e),r=es(),e!==null&&!jc?(ts(e,t,a),ol(e,t,a)):($i&&r&&Ji(t),t.flags|=1,Mc(e,t,n,a),t.child)}function Wc(e,t,n,r,i){if(ya(t),t.stateNode===null){var a=wi,o=n.contextType;typeof o==`object`&&o&&(a=ba(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=_c,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},lo(t),o=n.contextType,a.context=typeof o==`object`&&o?ba(o):wi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(gc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&_c.enqueueReplaceState(a,a.state,null),vo(t,r,a,i),_o(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=bc(n,s);a.props=c;var l=a.context,u=n.contextType;o=wi,typeof u==`object`&&u&&(o=ba(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&yc(t,a,r,o),co=!1;var f=t.memoizedState;a.state=f,vo(t,r,a,i),_o(),l=t.memoizedState,s||f!==l||co?(typeof d==`function`&&(gc(t,n,d,r),l=t.memoizedState),(c=co||vc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,uo(e,t),o=t.memoizedProps,u=bc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=wi,typeof l==`object`&&l&&(c=ba(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&yc(t,a,r,c),co=!1,f=t.memoizedState,a.state=f,vo(t,r,a,i),_o();var p=t.memoizedState;o!==d||f!==p||co||e!==null&&e.dependencies!==null&&va(e.dependencies)?(typeof s==`function`&&(gc(t,n,s,r),p=t.memoizedState),(u=co||vc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&va(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Vc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=oo(t,e.child,null,i),t.child=oo(t,null,n,i)):Mc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=ol(e,t,i),e}function Gc(e,t,n,r){return sa(),t.flags|=256,Mc(e,t,n,r),t.child}var Kc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qc(e){return{baseLanes:e,cachePool:Ua()}}function Jc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ud),e}function Yc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(No.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if($i){if(i?Oo(t):jo(),(e=Qi)?(e=om(e,ta),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ui===null?null:{id:Wi,overflow:Gi},retryLane:536870912,hydrationErrors:null},n=Ni(e),n.return=t,t.child=n,Zi=t,Qi=null)):e=null,e===null)throw ra(t);return t.lanes=cm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(jo(),i=t.mode,a=Zc({mode:`hidden`,children:a},i),r=ji(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=qc(n),r.childLanes=Jc(e,o,n),t.memoizedState=Kc,Lc(null,r)):(Oo(t),Xc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return $c(e,t,a,o,r,c,s,n)}return i?(jo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Oi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=ji(i,a,n,null),i.flags|=2):i=Oi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Lc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=qc(n):(a=i.cachePool,a===null?a=Ua():(s=Ea._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Jc(e,o,n),t.memoizedState=Kc,Lc(e.child,r)):(Oo(t),n=e.child,e=n.sibling,n=Oi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Xc(e,t){return t=Zc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Zc(e,t){return e=Ei(22,e,null,t),e.lanes=0,e}function Qc(e,t,n){return oo(t,e.child,null,n),e=Xc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function $c(e,t,n,r,i,a,o,c){if(n)return t.flags&256?(Oo(t),t.flags&=-257,Qc(e,t,c)):t.memoizedState===null?(jo(),a=i.fallback,o=t.mode,i=Zc({mode:`visible`,children:i.children},o),a=ji(a,o,c,null),a.flags|=2,i.return=t,a.return=t,i.sibling=a,t.child=i,oo(t,e.child,null,c),i=t.child,i.memoizedState=qc(c),i.childLanes=Jc(e,r,c),t.memoizedState=Kc,Lc(null,i)):(jo(),t.child=e.child,t.flags|=128,null);if(Oo(t),cm(a)){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(i=Error(s(419)),i.stack=``,i.digest=r,la({value:i,source:null,stack:null})),Qc(e,t,c)}if(jc||_a(e,t,c,!1),r=(c&e.childLanes)!==0,jc||r){if(xo.current!==null)return Qc(e,t,c);if(r=Zu,r!==null&&(i=dt(r,c),i!==0&&i!==o.retryLane))throw o.retryLane=i,xi(e,i),Fd(r,e,i),Ac;return sm(a)||qd(),Qc(e,t,c)}return sm(a)?(t.flags|=192,t.child=e.child,null):(e=o.treeContext,Qi=um(a.nextSibling),Zi=t,$i=!0,ea=null,ta=!1,e!==null&&Xi(t,e),t=Xc(t,i.children),t.flags|=134221824,t)}function el(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ha(e.return,t,n)}function tl(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Io(n)===null&&(t=e),e=e.sibling}return t}function nl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function rl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function il(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=No.current;if(t.flags&128)return Po(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Po(t,o),i===`backwards`&&e!==null?(rl(e),Mc(e,t,r,n),rl(e)):Mc(e,t,r,n),r=$i?Bi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&el(e,n,t);else if(e.tag===19)el(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=tl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,rl(t)),nl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Io(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}nl(t,!0,n,null,a,r);break;case`together`:nl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=tl(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),nl(t,!1,i,n,a,r)}return t.child}function al(e,t,n){var r=t.pendingProps;return pa(t,t.type,r.value),Mc(e,t,r.children,n),t.child}function ol(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),sd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(_a(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(s(153));if(t.child!==null){for(e=t.child,n=Oi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Oi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function sl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&va(e)))}function cl(e,t,n){switch(t.tag){case 3:be(t,t.stateNode.containerInfo),pa(t,Ea,e.memoizedState.cache),sa();break;case 27:case 5:xe(t);break;case 4:be(t,t.stateNode.containerInfo);break;case 10:pa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ko(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Oo(t),t.flags|=128,null;r=_a(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Yc(e,t,n):(Oo(t),e=ol(e,t,n),e===null?null:e.sibling)}Oo(t);break;case 19:if(t.flags&128)return il(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(_a(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return il(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Po(t,No.current),r)break;return null;case 22:return t.lanes=0,Ic(e,t,n,t.pendingProps);case 24:pa(t,Ea,e.memoizedState.cache)}return ol(e,t,n)}function ll(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)jc=!0;else{if(!sl(e,n)&&!(t.flags&128))return jc=!1,cl(e,t,n);jc=!!(e.flags&131072)}}else jc=!1,$i&&t.flags&1048576&&qi(t,Bi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Xa(t.elementType),t.type=e,typeof e==`function`)Di(e)?(r=bc(e,r),t.tag=1,t=Wc(null,t,e,r,n)):(t.tag=0,t=Hc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===F){t.tag=11,t=Nc(null,t,e,r,n);break a}if(i===ne){t.tag=14,t=Pc(null,t,e,r,n);break a}if(i===P){t.tag=10,t.type=e,t=al(null,t,n);break a}}throw t=de(e)||e,Error(s(306,t,``))}}return t;case 0:return Hc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=bc(r,t.pendingProps),Wc(e,t,r,i,n);case 3:a:{if(be(t,t.stateNode.containerInfo),e===null)throw Error(s(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,uo(e,t),vo(t,r,null,n);var o=t.memoizedState;if(r=o.cache,pa(t,Ea,r),r!==a.cache&&ga(t,[Ea],n,!0),_o(),r=o.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=Gc(e,t,r,n);break a}if(r!==i){i=Ii(Error(s(424)),t),la(i),t=Gc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Qi=um(e.firstChild),Zi=t,$i=!0,ea=null,ta=!0,n=so(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(sa(),r===i){t=ol(e,t,n);break a}Mc(e,t,r,n)}t=t.child}return t;case 26:return Vc(e,t),e===null?(n=Pm(t.type,null,t.pendingProps,null))?t.memoizedState=n:$i||(t.stateNode=gp(t.type,t.pendingProps,ye.current,t)):t.memoizedState=Pm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&$i&&(r=t.stateNode=gm(t.type,t.pendingProps,ye.current),Zi=t,ta=!0,i=Qi,Ep(t.type)?(dm=i,Qi=um(r.firstChild)):Qi=i),Mc(e,t,t.pendingProps.children,n),Vc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&$i&&((i=r=Qi)&&(r=im(r,t.type,t.pendingProps,ta),r===null?i=!1:(t.stateNode=r,Zi=t,Qi=um(r.firstChild),ta=!1,i=!0)),i||ra(t)),xe(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,r=a.children,_p(i,a)?r=null:o!==null&&_p(i,o)&&(t.flags|=32),t.memoizedState!==null&&(i=Xo(e,t,$o,null,null,n),ch._currentValue=i),Vc(e,t),Mc(e,t,r,n),t.child;case 6:return e===null&&$i&&((e=n=Qi)&&(n=am(n,t.pendingProps,ta),n===null?e=!1:(t.stateNode=n,Zi=t,Qi=null,e=!0)),e||ra(t)),null;case 13:return Yc(e,t,n);case 4:return be(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=oo(t,null,r,n):Mc(e,t,r,n),t.child;case 11:return Nc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Vc(e,t),Mc(e,t,r,n),t.child;case 8:return Mc(e,t,t.pendingProps.children,n),t.child;case 12:return Mc(e,t,t.pendingProps.children,n),t.child;case 10:return al(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,ya(t),i=ba(i),r=r(i),t.flags|=1,Mc(e,t,r,n),t.child;case 14:return Pc(e,t,t.type,t.pendingProps,n);case 15:return Fc(e,t,t.type,t.pendingProps,n);case 19:return il(e,t,n);case 31:return Bc(e,t,n);case 22:return Ic(e,t,n,t.pendingProps);case 24:return ya(t),r=ba(Ea),e===null?(i=Va(),i===null&&(i=Zu,a=Da(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},lo(t),pa(t,Ea,i)):((e.lanes&n)!==0&&(uo(e,t),vo(t,null,null,n),_o()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,pa(t,Ea,r),r!==i.cache&&ga(t,[Ea],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),pa(t,Ea,r))),Mc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:$i&&Ji(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Vc(e,t),Mc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(s(156,t.tag))}function ul(e){e.flags|=4}function dl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Ym(t,r):Ym(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Wd())e.flags|=8192;else throw Za=qa,Ga}}else e.flags&=-16777217}function fl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Xm(t)){if(Wd())e.flags|=8192;else throw Za=qa,Ga}}function pl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:at(),e.lanes|=t,dd|=t)}function ml(e,t){if(!$i)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function hl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function gl(e,t,n){var r=t.pendingProps;switch(Yi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hl(t),null;case 1:return hl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ma(Ea),U(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(oa(t)?ul(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ca())),hl(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(ul(t),a===null?(hl(t),dl(t,i,null,r,n)):(hl(t),fl(t,a))):a?a===e.memoizedState?(hl(t),t.flags&=-16777217):(ul(t),hl(t),fl(t,a)):(e=e.memoizedProps,e!==r&&ul(t),hl(t),dl(t,i,e,r,n)),null;case 27:if(Se(t),n=ye.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ul(t);else{if(!r){if(t.stateNode===null)throw Error(s(166));return hl(t),t.subtreeFlags&=-33554433,null}e=_e.current,oa(t)?ia(t,e):(e=gm(i,r,n),t.stateNode=e,ul(t))}return hl(t),t.subtreeFlags&=-33554433,null;case 5:if(Se(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ul(t);else{if(!r){if(t.stateNode===null)throw Error(s(166));return hl(t),t.subtreeFlags&=-33554433,null}if(a=_e.current,oa(t))ia(t,a);else{var o=pp(ye.current);switch(a){case 1:a=o.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=o.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=o.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=o.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=o.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?o.createElement(`select`,{is:r.is}):o.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?o.createElement(i,{is:r.is}):o.createElement(i)}}a[_t]=t,a[vt]=r;a:for(o=t.child;o!==null;){if(o.tag===5||o.tag===6)a.appendChild(o.stateNode);else if(o.tag!==4&&o.tag!==27&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break a;for(;o.sibling===null;){if(o.return===null||o.return===t)break a;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;a:switch(op(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ul(t)}}return hl(t),t.subtreeFlags&=-33554433,dl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ul(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(s(166));if(e=ye.current,oa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Zi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||rp(e.nodeValue,n)),e||ra(t,!0)}else e=pp(e).createTextNode(r),e[_t]=t,t.stateNode=e}return hl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=oa(t),n!==null){if(e===null){if(!r)throw Error(s(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(557));e[_t]=t}else sa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;hl(t),e=!1}else n=ca(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Mo(t),t):(Mo(t),null);if(t.flags&128)throw Error(s(558))}return hl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=oa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(s(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(s(317));i[_t]=t}else sa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;hl(t),i=!1}else i=ca(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Mo(t),t):(Mo(t),null)}return Mo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),pl(t,t.updateQueue),hl(t),null);case 4:return U(),e===null&&qf(t.stateNode.containerInfo),t.flags|=67108864,hl(t),null;case 10:return ma(t.type),hl(t),null;case 19:if(Fo(t),r=t.memoizedState,r===null)return hl(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)ml(r,!1);else{if(od!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Io(e),a!==null){for(t.flags|=128,ml(r,!1),e=a.updateQueue,t.updateQueue=e,pl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ki(n,e),n=n.sibling;return Po(t,No.current&1|2),$i&&Ki(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Fe()>_d&&(t.flags|=128,i=!0,ml(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Io(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,pl(t,e),ml(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!$i)return hl(t),null}else 2*Fe()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,ml(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Fe(),e.sibling=null,a=No.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||$i?Po(t,a):(n=a,V(Eo,t),V(No,n),Do===null&&(Do=t)),$i&&Ki(t,r.treeForkCount),e}return hl(t),null;case 22:case 23:return Mo(t),To(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(hl(t),t.subtreeFlags&6&&(t.flags|=8192)):hl(t),n=t.updateQueue,n!==null&&pl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ge(Ba),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ma(Ea),hl(t),null;case 25:return null;case 30:return t.flags|=33554432,hl(t),null}throw Error(s(156,t.tag))}function _l(e,t){switch(Yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ma(Ea),U(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Se(t),null;case 31:if(t.memoizedState!==null){if(Mo(t),t.alternate===null)throw Error(s(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Mo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Fo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return U(),null;case 10:return ma(t.type),null;case 22:case 23:return Mo(t),To(),e!==null&&ge(Ba),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ma(Ea),null;case 25:return null;default:return null}}function vl(e,t){switch(Yi(t),t.tag){case 3:ma(Ea),U();break;case 26:case 27:case 5:Se(t);break;case 4:U();break;case 31:t.memoizedState!==null&&Mo(t);break;case 13:Mo(t);break;case 19:Fo(t);break;case 10:ma(t.type);break;case 22:case 23:Mo(t),To(),e!==null&&ge(Ba);break;case 24:ma(Ea)}}function yl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){hf(t,t.return,e)}}function bl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){hf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){hf(t,t.return,e)}}function q(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{bo(t,n)}catch(t){hf(e,e.return,t)}}}function xl(e,t,n){n.props=bc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){hf(e,t,n)}}function Sl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=di(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Rp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new zp(e);h(e.child,!1,em,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){hf(e,t,n)}}function Cl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){hf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){hf(e,t,n)}else n.current=null}}function wl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)nm(e.stateNode,t[n])}function Tl(e){for(var t=e.return;t!==null&&(Ol(t)&&nm(e.stateNode,t.stateNode),!Dl(t));)t=t.return}function El(e){for(var t=e.return;t!==null&&(Ol(t)&&Q(e.stateNode,t.stateNode),!Dl(t));)t=t.return}function Dl(e){return e.tag===5||e.tag===3||e.tag===27}function Ol(e){return e&&e.tag===7&&e.stateNode!==null}function kl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){hf(e,e.return,t)}}function J(e,t,n){try{var r=e.stateNode;cp(r,e.type,n,t),r[vt]=t}catch(t){hf(e,e.return,t)}}function Al(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ep(e.type)||e.tag===4}function Y(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Al(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ep(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function jl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=pn)),wl(e,r),Vt=!0;else if(i!==4&&(i===27&&(wl(e,r),r=null,Ep(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(jl(e,t,n,r),e=e.sibling;e!==null;)jl(e,t,n,r),e=e.sibling}function Ml(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),wl(e,r),Vt=!0;else if(i!==4&&(i===27&&(wl(e,r),r=null,Ep(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Ml(e,t,n,r),e=e.sibling;e!==null;)Ml(e,t,n,r),e=e.sibling}function Nl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);op(t,r,n),t[_t]=e,t[vt]=n}catch(t){hf(e,e.return,t)}}var Pl=!1,Fl=null;function Il(e){(e.tag===30||e.subtreeFlags&33554432)&&(Pl=!0)}var Ll=null;function Rl(){var e=Ll;return Ll=null,e}var zl=0;function Bl(e,t,n,r,i){return zl=0,Vl(e.child,t,n,r,i)}function Vl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Mp(o);r.push(s),s.view&&(a=!0)}else a||Mp(o).view&&(a=!0);Pl=!0,kp(o,zl===0?t:t+`_`+zl,n),zl++}else(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&i||Vl(e.child,t,n,r,i)&&(a=!0));e=e.sibling}return a}function Hl(e,t){for(;e!==null;)e.tag===5?Ap(e.stateNode,e.memoizedProps):(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&t||Hl(e.child,t)),e=e.sibling}function Ul(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Ul(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(s(544));var n=t.name;t=pi(t.default,t.share),t!==`none`&&(Bl(e,n,t,null,!1)||Hl(e.child,!1))}e=e.sibling}}function Wl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=di(r,n),a=pi(r.default,n.paired?r.share:r.enter);a===`none`?Ul(e):Bl(e,i,a,null,!1)?(Ul(e),n.paired||t||Pd(e,r.onEnter)):Hl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e,t),e=e.sibling;else Ul(e)}function Gl(e){if(Fl!==null&&Fl.size!==0){var t=Fl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=pi(n.default,n.share);if(a!==`none`&&(Bl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Pd(e,n.onShare)):Hl(e.child,!1)),t.delete(r),t.size===0)break}}}Gl(e)}e=e.sibling}}}function Kl(e){if(e.tag===30){var t=e.memoizedProps,n=di(t,e.stateNode),r=Fl===null?void 0:Fl.get(n),i=pi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Bl(e,n,i,null,!1)?r===void 0?Pd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Fl.delete(n),Pd(e,t.onShare)):Hl(e.child,!1)),Fl!==null&&Gl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Kl(e),e=e.sibling;else Fl!==null&&Gl(e)}function ql(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=di(t,e.stateNode);t=pi(t.default,t.update),e.flags&=-5,t!==`none`&&Bl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&ql(e);e=e.sibling}}function Jl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Hl(e.child,!1))}Jl(e)}e=e.sibling}}function Yl(e){if(e.tag===30)e.stateNode.paired=null,Hl(e.child,!1),Jl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Yl(e),e=e.sibling;else Jl(e)}function Xl(e){for(e=e.child;e!==null;)e.tag===30?Hl(e.child,!1):e.subtreeFlags&33554432&&Xl(e),e=e.sibling}function Zl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&zl<a.length){var l=a[zl],u=Mp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&kp(c,zl===0?n:n+`_`+zl,i),s&&e.flags&4||(Ll===null&&(Ll=[]),Ll.push(c,zl===0?r:r+`_`+zl,t.memoizedProps)),zl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Zl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Ql(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=di(n,r),a=pi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Np)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;zl=0,i=Zl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Pd(e,n.onUpdate))}else e.subtreeFlags&33554432&&Ql(e,t);e=e.sibling}}var $l=!1,eu=!1,tu=!1,nu=!1,ru=typeof WeakSet==`function`?WeakSet:Set,iu=null,au=!1,ou=!1,su=!1,cu=!1;function lu(e,t,n){if(e=e.containerInfo,dp=_h,e=Vr(e),Hr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(fp={focusedElem:e,selectionRange:r},_h=!1,n=(n&335544064)===n,iu=t,t=n?9270:1024;iu!==null;){if(e=iu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Kl(r[a]);if(e.alternate===null&&e.flags&2)n&&Il(e),uu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Kl(r),uu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Il(e),uu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,iu=r):(n&&ql(e),uu(n))}}Fl=null}function uu(e){for(;iu!==null;){var t=iu,n=e,r=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(i&1024&&r!==null){n=void 0,i=r.memoizedProps,r=r.memoizedState;var a=t.stateNode;try{var o=bc(t.type,i);n=a.getSnapshotBeforeUpdate(o,r),a.__reactInternalSnapshotBeforeUpdate=n}catch(e){hf(t,t.return,e)}}break;case 3:if(i&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)rm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:rm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=di(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=pi(i.default,i.update),i!==`none`&&Bl(r,n,i,r.memoizedState=[],!0));break;default:if(i&1024)throw Error(s(163))}if(r=t.sibling,r!==null){r.return=t.return,iu=r;break}iu=t.return}}function du(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ju(e,n),r&4&&yl(5,n);break;case 1:if(ju(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){hf(n,n.return,e)}else{var i=bc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){hf(n,n.return,e)}}}r&64&&q(n),r&512&&Sl(n,n.return);break;case 3:if(ju(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{bo(e,t)}catch(e){hf(n,n.return,e)}}break;case 27:t===null&&r&4&&Nl(n);case 26:case 5:ju(e,n),t===null&&r&4&&kl(n),r&512&&Sl(n,n.return);break;case 12:ju(e,n);break;case 31:ju(e,n),r&4&&bu(e,n);break;case 13:ju(e,n),r&4&&xu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=yf.bind(null,n),lm(e,n))));break;case 22:if(r=n.memoizedState!==null||$l,!r){var a=t!==null&&t.memoizedState!==null||eu;t=$l,i=eu,$l=r,(eu=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Nu(e,n,r)):ju(e,n),$l=t,eu=i}break;case 30:ju(e,n),r&512&&Sl(n,n.return);break;case 7:r&512&&Sl(n,n.return);default:ju(e,n)}}function fu(e,t){for(e=e.child;e!==null;)pu(e,t),e=e.sibling}function pu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){hf(e,e.return,t)}mu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Vt=!0}catch(t){hf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Op(s,!0):Op(e.stateNode,!1)}catch(t){hf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&fu(e,t);break;default:fu(e,t)}}function mu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:pu(n,r);break a;case 22:n.memoizedState===null&&mu(n,r);break a;default:mu(n,r)}}e=e.sibling}}function hu(e){var t=e.alternate;t!==null&&(e.alternate=null,hu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Et(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var gu=null,_u=!1;function vu(e,t,n){for(n=n.child;n!==null;)yu(e,t,n),n=n.sibling}function yu(e,t,n){if(Ge&&typeof Ge.onCommitFiberUnmount==`function`)try{Ge.onCommitFiberUnmount(We,n)}catch{}switch(n.tag){case 26:eu||Cl(n,t),vu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!eu&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:eu||Cl(n,t),El(n);var r=gu,i=_u;Ep(n.type)&&(gu=n.stateNode,_u=!1),vu(e,t,n),_m(n.stateNode,n.type,n.memoizedProps),gu=r,_u=i;break;case 5:eu||Cl(n,t),El(n);case 6:if(n.tag===6&&El(n),r=gu,i=_u,gu=null,vu(e,t,n),gu=r,_u=i,gu!==null){if(_u)try{(gu.nodeType===9?gu.body:gu.nodeName===`HTML`?gu.ownerDocument.body:gu).removeChild(n.stateNode),Vt=!0}catch(e){hf(n,t,e)}else try{gu.removeChild(n.stateNode),Vt=!0}catch(e){hf(n,t,e)}}break;case 18:gu!==null&&(_u?(e=gu,Dp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Uh(e)):Dp(gu,n.stateNode));break;case 4:r=gu,i=_u,gu=n.stateNode.containerInfo,_u=!0,vu(e,t,n),gu=r,_u=i;break;case 0:case 11:case 14:case 15:bl(2,n,t),eu||bl(4,n,t),vu(e,t,n);break;case 1:eu||(Cl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&xl(n,t,r)),vu(e,t,n);break;case 21:vu(e,t,n);break;case 22:eu=(r=eu)||n.memoizedState!==null,vu(e,t,n),eu=r;break;case 30:Cl(n,t),vu(e,t,n);break;case 7:eu||Cl(n,t),vu(e,t,n);break;default:vu(e,t,n)}}function bu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Uh(e)}catch(e){hf(t,t.return,e)}}}function xu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Uh(e)}catch(e){hf(t,t.return,e)}}function Su(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ru),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ru),t;default:throw Error(s(435,e.tag))}}function Cu(e,t){var n=Su(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=bf.bind(null,e,t);t.then(r,r)}})}function wu(e,t,n){var r=t.deletions;if(r!==null)for(var i=0;i<r.length;i++){var a=r[i],o=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Ep(l.type)){gu=l.stateNode,_u=!1;break a}break;case 5:gu=l.stateNode,_u=!1;break a;case 3:case 4:gu=l.stateNode.containerInfo,_u=!0;break a}l=l.return}if(gu===null)throw Error(s(160));yu(o,c,a),gu=null,_u=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Eu(t,e,n),t=t.sibling}var Tu=null;function Eu(e,t,n){var r=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(i&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var a=0;a<r.length;a++){var o=r[a];o.ref.impl=o.nextImpl}wu(t,e,n),Du(e),i&4&&(bl(3,e,e.return),yl(3,e),bl(5,e,e.return));break;case 1:wu(t,e,n),Du(e),i&512&&(eu||r===null||Cl(r,r.return)),i&64&&$l&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(a=Tu,wu(t,e,n),Du(e),i&512&&(eu||r===null||Cl(r,r.return)),i&4){if(i=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if($l)e.stateNode=gp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,i=a.ownerDocument||a;b:switch(t){case`title`:r=i.getElementsByTagName(`title`)[0],(!r||r[wt]||r[_t]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=i.createElement(t),i.head.insertBefore(r,i.querySelector(`head > title`))),op(r,t,n),r[_t]=e,jt(r),t=r;break a;case`link`:if(a=Km(`link`,`href`,i).get(t+(n.href||``))){for(o=0;o<a.length;o++)if(r=a[o],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){a.splice(o,1);break b}}r=i.createElement(t),op(r,t,n),i.head.appendChild(r);break;case`meta`:if(a=Km(`meta`,`content`,i).get(t+(n.content||``))){for(o=0;o<a.length;o++)if(r=a[o],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){a.splice(o,1);break b}}r=i.createElement(t),op(r,t,n),i.head.appendChild(r);break;default:throw Error(s(468,t))}r[_t]=e,jt(r),t=r}e.stateNode=t}}else $l||qm(a,e.type,e.stateNode)}else e.stateNode=Vm(a,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&J(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||eu||t.parentNode.removeChild(t)):i.count--,n===null?$l||qm(a,e.type,e.stateNode):Vm(a,n,e.memoizedProps))}break;case 27:wu(t,e,n),Du(e),i&512&&(eu||r===null||Cl(r,r.return)),r!==null&&i&4&&J(e,e.memoizedProps,r.memoizedProps);break;case 5:if(a=tu,tu=!1,wu(t,e,n),tu=a,Du(e),i&512&&(eu||r===null||Cl(r,r.return)),e.flags&32){t=e.stateNode;try{an(t,``),Vt=!0}catch(t){hf(e,e.return,t)}}i&4&&e.stateNode!=null&&(t=e.memoizedProps,J(e,t,r===null?t:r.memoizedProps)),i&1024&&(nu=!0);break;case 6:if(wu(t,e,n),Du(e),i&4){if(e.stateNode===null)throw Error(s(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Vt=!0}catch(t){hf(e,e.return,t)}}break;case 3:if(Vt=!1,Gm=null,a=Tu,Tu=xm(t.containerInfo),wu(t,e,n),Tu=a,Du(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Uh(t.containerInfo)}catch(t){hf(e,e.return,t)}nu&&(nu=!1,Ou(e)),Vt=!1;break;case 4:i=tu,tu=$l,r=Ht(),a=Tu,Tu=xm(e.stateNode.containerInfo),wu(t,e,n),Du(e),Tu=a,Vt&&ou&&(su=!0),Vt=r,tu=i;break;case 12:wu(t,e,n),Du(e);break;case 31:wu(t,e,n),Du(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 13:wu(t,e,n),Du(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(hd=Fe()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 22:a=e.memoizedState!==null,o=r!==null&&r.memoizedState!==null;var c=$l,l=eu,u=tu;$l=c||a,tu=u||a,eu=l||o,wu(t,e,n),eu=l,tu=u,$l=c,Du(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,!a||r===null||o||$l||eu||(t=o||eu,n=$l,r=eu,$l=a||$l,eu=t,Mu(e,2),$l=n,eu=r),!a&&tu||fu(e,a)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Cu(e,n))));break;case 19:wu(t,e,n),Du(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 30:i&512&&(eu||r===null||Cl(r,r.return)),i=Ht(),a=ou,o=(n&335544064)===n,c=e.memoizedProps,ou=o&&pi(c.default,c.update)!==`none`,wu(t,e,n),Du(e),o&&r!==null&&Vt&&(e.flags|=4),ou=a,Vt=i;break;case 21:break;case 7:i&512&&(eu||r===null||Cl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:wu(t,e,n),Du(e)}}function Du(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Al(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(Ol(i)){var a=i.stateNode;r===null?r=[a]:r.push(a)}if(Dl(i))break;i=i.return}var o=r;if(n==null)throw Error(s(160));switch(n.tag){case 27:var c=n.stateNode;Ml(e,Y(e),c,o);break;case 5:var l=n.stateNode;n.flags&32&&(an(l,``),n.flags&=-33),Ml(e,Y(e),l,o);break;case 3:case 4:var u=n.stateNode.containerInfo;jl(e,Y(e),u,o);break;default:throw Error(s(161))}}catch(t){hf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ou(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ou(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,_h=!0,t.reset(),_h=!1),e=e.sibling}}function ku(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Au(t,e),t=t.sibling;else Ql(t,!1)}function Au(e,t){var n=e.alternate;if(n===null)Wl(e,!1);else switch(e.tag){case 3:if(cu=au=!1,Rl(),ku(t,e),!au&&!su){if(e=Ll,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Ap(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),cu=!0}Ll=null;break;case 5:ku(t,e);break;case 4:r=au,au=!1,ku(t,e),au&&(su=!0),au=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?ku(t,e):Wl(e,!1));break;case 30:r=au,i=Rl(),au=!1,ku(t,e),au&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=di(a,o),o=di(n.memoizedProps,o);var s=pi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,zl=0,t=Zl(e,n,t,o,s,a,!0),zl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Pd(e,e.memoizedProps.onUpdate),Ll=i):i!==null&&(i.push.apply(i,Ll),Ll=i),au=e.flags&32?!0:r;break;default:ku(t,e)}}function ju(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)du(e,t.alternate,t),t=t.sibling}function Mu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:bl(4,n,n.return),Mu(n,r);break;case 1:Cl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&xl(n,n.return,i),Mu(n,r);break;case 27:r&2&&_m(n.stateNode,n.type,n.memoizedProps);case 5:Cl(n,n.return),n.tag!==5&&n.tag!==27||El(n),Mu(n,r);break;case 6:El(n);break;case 26:Cl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||eu||i.parentNode.removeChild(i),Mu(n,r);break;case 22:n.memoizedState===null&&Mu(n,r);break;case 30:Cl(n,n.return),Mu(n,r);break;case 7:Cl(n,n.return);default:Mu(n,r)}e=e.sibling}}function Nu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Nu(i,a,n),yl(4,a);break;case 1:if(Nu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){hf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)yo(l[i],c)}catch(e){hf(r,r.return,e)}}s&&o&64&&q(a),Sl(a,a.return);break;case 27:n&2&&Nl(a);case 5:a.tag!==5&&a.tag!==27||Tl(a),Nu(i,a,n),s&&r===null&&o&4&&kl(a),Sl(a,a.return);break;case 6:Tl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||$l||qm(xm(c.ownerDocument),a.type,c),Nu(i,a,n),s&&r===null&&o&4&&kl(a),Sl(a,a.return);break;case 12:Nu(i,a,n);break;case 31:Nu(i,a,n),s&&o&4&&bu(i,a);break;case 13:Nu(i,a,n),s&&o&4&&xu(i,a);break;case 22:a.memoizedState===null&&Nu(i,a,n),Sl(a,a.return);break;case 30:Nu(i,a,n),Sl(a,a.return);break;case 7:Sl(a,a.return);default:Nu(i,a,n)}t=t.sibling}}function Pu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Oa(n))}function Fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Oa(e))}function Iu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Lu(e,t,n,r),t=t.sibling;else i&&Xl(t)}function Lu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Yl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Iu(e,t,n,r),a&2048&&yl(9,t);break;case 1:Iu(e,t,n,r);break;case 3:Iu(e,t,n,r),i&&cu&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Oa(a)));break;case 12:if(a&2048){Iu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){hf(t,t.return,e)}}else Iu(e,t,n,r);break;case 31:Iu(e,t,n,r);break;case 13:Iu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Yl(t),o._visibility&2?Iu(e,t,n,r):(o._visibility|=2,Ru(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Yl(s),o._visibility&2?Iu(e,t,n,r):zu(e,t)),a&2048&&Pu(s,t);break;case 24:Iu(e,t,n,r),a&2048&&Fu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Hl(a.child,!0),Hl(t.child,!0))),Iu(e,t,n,r);break;default:Iu(e,t,n,r)}}function Ru(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ru(a,o,s,c,i),yl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ru(a,o,s,c,i)):u._visibility&2?Ru(a,o,s,c,i):zu(a,o),i&&l&2048&&Pu(o.alternate,o);break;case 24:Ru(a,o,s,c,i),i&&l&2048&&Fu(o.alternate,o);break;default:Ru(a,o,s,c,i)}t=t.sibling}}function zu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:zu(n,r),i&2048&&Pu(r.alternate,r);break;case 24:zu(n,r),i&2048&&Fu(r.alternate,r);break;default:zu(n,r)}t=t.sibling}}var Bu=8192;function Vu(e,t,n){if(e.subtreeFlags&Bu)for(e=e.child;e!==null;)Hu(e,t,n),e=e.sibling}function Hu(e,t,n){switch(e.tag){case 26:Vu(e,t,n),e.flags&Bu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Qm(n,e)):$m(n,Tu,e.memoizedState,e.memoizedProps));break;case 5:Vu(e,t,n),e.flags&Bu&&(e=e.stateNode,(t&335544128)===t&&Qm(n,e));break;case 3:case 4:var r=Tu;Tu=xm(e.stateNode.containerInfo),Vu(e,t,n),Tu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Bu,Bu=16777216,Vu(e,t,n),Bu=r):Vu(e,t,n));break;case 30:if((e.flags&Bu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Fl===null&&(Fl=new Map),Fl.set(r,i)}Vu(e,t,n);break;default:Vu(e,t,n)}}function Uu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];iu=r,qu(r,e)}Uu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Gu(e),e=e.sibling}function Gu(e){switch(e.tag){case 0:case 11:case 15:Wu(e),e.flags&2048&&bl(9,e,e.return);break;case 3:Wu(e);break;case 12:Wu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ku(e)):Wu(e);break;default:Wu(e)}}function Ku(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];iu=r,qu(r,e)}Uu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:bl(8,t,t.return),Ku(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ku(t));break;default:Ku(t)}e=e.sibling}}function qu(e,t){for(;iu!==null;){var n=iu;switch(n.tag){case 0:case 11:case 15:bl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Oa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,iu=r;else a:for(n=e;iu!==null;){r=iu;var i=r.sibling,a=r.return;if(hu(r),r===n){iu=null;break a}if(i!==null){i.return=a,iu=i;break a}iu=a}}}var Ju={getCacheForType:function(e){var t=ba(Ea),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ba(Ea).controller.signal}},Yu=typeof WeakMap==`function`?WeakMap:Map,Xu=0,Zu=null,Qu=null,$u=0,ed=0,td=null,nd=!1,rd=!1,id=!1,ad=0,od=0,sd=0,cd=0,ld=0,ud=0,dd=0,fd=null,pd=null,md=!1,hd=0,gd=0,_d=1/0,vd=null,yd=null,bd=0,xd=null,Sd=null,Cd=0,wd=0,Td=null,Ed=null,Dd=null,Od=null,kd=null,Ad=0,jd=null;function Md(){return Xu&2&&$u!==0?$u&-$u:z.T===null?mt():If()}function Nd(){if(ud===0){if(!($u&536870912)||$i){var e=Qe;Qe<<=1,!(Qe&3932160)&&(Qe=262144),ud=e}else ud=536870912}return e=Eo.current,e!==null&&(e.flags|=32),ud}function Pd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Rp(di(e.memoizedProps,n))),Od===null&&(Od=[]),Od.push(t.bind(null,r))}}function Fd(e,t,n){(e===Zu&&(ed===2||ed===9)||e.cancelPendingCommit!==null)&&(Hd(e,0),zd(e,$u,ud,!1)),st(e,n),(!(Xu&2)||e!==Zu)&&(e===Zu&&(!(Xu&2)&&(cd|=n),od===4&&zd(e,$u,ud,!1)),Of(e))}function Id(e,t,n){if(Xu&6)throw Error(s(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||nt(e,t),i=r?Xd(e,t):Jd(e,t,!0),a=r;do{if(i===0){rd&&!r&&zd(e,t,0,!1);break}if(n=e.current.alternate,a&&!Rd(n)){i=Jd(e,t,!1),a=!1;continue}if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var o=0;else o=e.pendingLanes&-536870913,o=o===0?o&536870912?536870912:0:o;if(o!==0){t=o;a:{var c=e;i=fd;var l=c.current.memoizedState.isDehydrated;if(l&&(Hd(c,o).flags|=256),o=Jd(c,o,!1),o!==2&&o!==6){if(id&&!l){c.errorRecoveryDisabledLanes|=a,cd|=a,i=4;break a}a=pd,pd=i,a!==null&&(pd===null?pd=a:pd.push.apply(pd,a))}i=o}if(a=!1,i!==2)continue}}if(i===1){Hd(e,0),zd(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(s(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:zd(r,t,ud,!nd);break a;case 2:pd=null;break;case 3:case 5:break;default:throw Error(s(329))}if((t&62914560)===t&&(i=hd+300-Fe(),10<i)){if(zd(r,t,ud,!nd),tt(r,0,!0)!==0)break a;Cd=t,r.timeoutHandle=bp(Ld.bind(null,r,n,pd,vd,md,t,ud,cd,dd,nd,a,`Throttled`,-0,0),i);break a}Ld(r,n,pd,vd,md,t,ud,cd,dd,nd,a,null,-0,0)}break}while(1);Of(e)}function Ld(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;if(d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pn},Fl=null,Hu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=rh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?hd-Fe():(a&4194048)===a?gd-Fe():0,m=th(d,m),m!==null)){Cd=a,e.cancelPendingCommit=m(rf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),zd(e,a,o,!l);return}rf(e,t,a,n,r,i,o,s,c,l,u,d)}function Rd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Fr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function zd(e,t,n,r){t=rt(e,t),t&=~ld,t&=~cd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-qe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&<(e,n,t)}function Bd(){return Xu&6?!0:(kf(0,!1),!1)}function Vd(){if(Qu!==null){if(ed===0)var e=Qu.return;else e=Qu,fa=da=null,ns(e),eo=null,to=0,e=Qu;for(;e!==null;)vl(e.alternate,e),e=e.return;Qu=null}}function Hd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,xp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Cd=0,Vd(),Zu=e,Qu=n=Oi(e.current,null),$u=t,ed=0,td=null,nd=!1,rd=nt(e,t),id=!1,dd=ud=ld=cd=sd=od=0,pd=fd=null,md=!1,ad=rt(e,t),vi(),n}function Ud(e,t){Ro=null,z.H=fc,t===Wa||t===Ka?(t=Qa(),ed=3):t===Ga?(t=Qa(),ed=4):ed=t===Ac?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,td=t,Qu===null&&(od=1,wc(e,Ii(t,e.current)))}function Wd(){var e=Eo.current;return e===null?!0:($u&4194048)===$u?Do===null:($u&62914560)===$u||$u&536870912?e===Do:!1}function Gd(){var e=z.H;return z.H=fc,e===null?fc:e}function Kd(){var e=z.A;return z.A=Ju,e}function qd(){od=4,nd||($u&4194048)!==$u&&Eo.current!==null||(rd=!0),!(sd&134217727)&&!(cd&134217727)||Zu===null||zd(Zu,$u,ud,!1)}function Jd(e,t,n){var r=Xu;Xu|=2;var i=Gd(),a=Kd();(Zu!==e||$u!==t)&&(vd=null,Hd(e,t)),t=!1;var o=od;a:do try{if(ed!==0&&Qu!==null){var s=Qu,c=td;switch(ed){case 8:Vd(),o=6;break a;case 3:case 2:case 9:case 6:Eo.current===null&&(t=!0);var l=ed;if(ed=0,td=null,ef(e,s,c,l),n&&rd){o=0;break a}break;default:l=ed,ed=0,td=null,ef(e,s,c,l)}}Yd(),o=od;break}catch(t){Ud(e,t)}while(1);return t&&e.shellSuspendCounter++,fa=da=null,Xu=r,z.H=i,z.A=a,Qu===null&&(Zu=null,$u=0,vi()),o}function Yd(){for(;Qu!==null;)Qd(Qu)}function Xd(e,t){var n=Xu;Xu|=2;var r=Gd(),i=Kd();Zu!==e||$u!==t?(vd=null,_d=Fe()+500,Hd(e,t)):rd=nt(e,t);a:do try{if(ed!==0&&Qu!==null){t=Qu;var a=td;b:switch(ed){case 1:ed=0,td=null,ef(e,t,a,1);break;case 2:case 9:if(Ja(a)){ed=0,td=null,$d(t);break}t=function(){ed!==2&&ed!==9||Zu!==e||(ed=7),Of(e)},a.then(t,t);break a;case 3:ed=7;break a;case 4:ed=5;break a;case 7:Ja(a)?(ed=0,td=null,$d(t)):(ed=0,td=null,ef(e,t,a,7));break;case 5:var o=null;switch(Qu.tag){case 26:o=Qu.memoizedState;case 5:case 27:var c=Qu;if(o?Xm(o):c.stateNode.complete){ed=0,td=null;var l=c.sibling;if(l!==null)Qu=l;else{var u=c.return;u===null?Qu=null:(Qu=u,tf(u))}break b}}ed=0,td=null,ef(e,t,a,5);break;case 6:ed=0,td=null,ef(e,t,a,6);break;case 8:Vd(),od=6;break a;default:throw Error(s(462))}}Zd();break}catch(t){Ud(e,t)}while(1);return fa=da=null,z.H=r,z.A=i,Xu=n,Qu===null?(Zu=null,$u=0,vi(),od):0}function Zd(){for(;Qu!==null&&!Ne();)Qd(Qu)}function Qd(e){var t=ll(e.alternate,e,ad);e.memoizedProps=e.pendingProps,t===null?tf(e):Qu=t}function $d(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Uc(n,t,t.pendingProps,t.type,void 0,$u);break;case 11:t=Uc(n,t,t.pendingProps,t.type.render,t.ref,$u);break;case 5:ns(t);var r=t;r===Zi&&($i?(aa(r),r.tag===5&&r.stateNode!=null&&(Qi=r.stateNode)):(aa(r),$i=!0));default:vl(n,t),t=Qu=ki(t,ad),t=ll(n,t,ad)}e.memoizedProps=e.pendingProps,t===null?tf(e):Qu=t}function ef(e,t,n,r){fa=da=null,ns(t),eo=null,to=0;var i=t.return;try{if(kc(e,i,t,n,$u)){od=1,wc(e,Ii(n,e.current)),Qu=null;return}}catch(t){if(i!==null)throw Qu=i,t;od=1,wc(e,Ii(n,e.current)),Qu=null;return}t.flags&32768?($i||r===1?e=!0:rd||$u&536870912?e=!1:(nd=e=!0,(r===2||r===9||r===3||r===6)&&(r=Eo.current,r!==null&&r.tag===13&&(r.flags|=16384))),nf(t,e)):tf(t)}function tf(e){var t=e;do{if(t.flags&32768){nf(t,nd);return}e=t.return;var n=gl(t.alternate,t,ad);if(n!==null){Qu=n;return}if(t=t.sibling,t!==null){Qu=t;return}Qu=t=e}while(t!==null);od===0&&(od=5)}function nf(e,t){do{var n=_l(e.alternate,e);if(n!==null){n.flags&=32767,Qu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Qu=e;return}Qu=e=n}while(e!==null);od=6,Qu=null}function rf(e,t,n,r,i,a,o,c,l,u,d,f){e.cancelPendingCommit=null;do ff();while(bd!==0);if(Xu&6)throw Error(s(327));if(t!==null){if(t===e.current)throw Error(s(177));e===Zu&&(Qu=Zu=null,$u=0),Sd=t,xd=e,Cd=n,Td=i,Ed=r,af(e,t,n,o,c,l,f)}}function af(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(wd=s,s|=_i,ct(e,n,s,r,i,a),Od=null,(n&335544064)===n?(kd=ja(e),r=10262):(kd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,xf(ze,function(){return pf(),null})):(e.callbackNode=null,e.callbackPriority=0),Pl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=z.T,z.T=null,i=B.p,B.p=2,a=Xu,Xu|=4;try{lu(e,t,n)}finally{Xu=a,B.p=i,z.T=r}}bd=1,Pl?Dd=Ip(o,e.containerInfo,kd,cf,lf,sf,uf,pf,of,null,null):(cf(),lf(),uf())}function of(e){if(bd!==0){var t=xd.onRecoverableError;t(e,{componentStack:null})}}function sf(){bd===3&&(bd=0,Au(Sd,xd),bd=4)}function cf(){if(bd===1){bd=0;var e=xd,t=Sd,n=Cd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=z.T,z.T=null;var i=B.p;B.p=2;var a=Xu;Xu|=4;try{ou=su=!1,Eu(t,e,n),n=fp;var o=Vr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Br(s.ownerDocument.documentElement,s)){if(c!==null&&Hr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=zr(s,h),v=zr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}_h=!!dp,fp=dp=null}finally{Xu=a,B.p=i,z.T=r}}e.current=t,bd=2}}function lf(){if(bd===2){bd=0;var e=xd,t=Sd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=z.T,z.T=null;var r=B.p;B.p=2;var i=Xu;Xu|=4;try{du(e,t.alternate,t)}finally{Xu=i,B.p=r,z.T=n}}bd=3}}function uf(){if(bd===4||bd===3){bd=0;var e=Dd;Dd=null,Pe();var t=xd,n=Sd,r=Cd,i=Ed,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?bd=5:(bd=0,Sd=xd=null,df(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(yd=null),pt(r),n=n.stateNode,Ge&&typeof Ge.onCommitFiberRoot==`function`)try{Ge.onCommitFiberRoot(We,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=z.T,a=B.p,B.p=2,z.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{z.T=n,B.p=a}}if(i=Od,o=kd,kd=null,i!==null&&(Od=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);Cd&3&&ff(),Of(t),a=t.pendingLanes,r&261930&&a&42?t===jd?Ad++:(Ad=0,jd=t):(Ad=0,jd=null),kf(0,!1)}}function df(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Oa(t)))}function ff(){return Dd!==null&&(Dd.skipTransition(),Dd=null),cf(),lf(),uf(),pf()}function pf(){if(bd!==5)return!1;var e=xd,t=wd;wd=0;var n=pt(Cd),r=z.T,i=B.p;try{B.p=32>n?32:n,z.T=null,n=Td,Td=null;var a=xd,o=Cd;if(bd=0,Sd=xd=null,Cd=0,Xu&6)throw Error(s(331));var c=Xu;if(Xu|=4,Gu(a.current),Lu(a,a.current,o,n),Xu=c,kf(0,!1),Ge&&typeof Ge.onPostCommitFiberRoot==`function`)try{Ge.onPostCommitFiberRoot(We,a)}catch{}return!0}finally{B.p=i,z.T=r,df(e,t)}}function mf(e,t,n){t=Ii(n,t),t=Ec(e.stateNode,t,2),e=po(e,t,2),e!==null&&(st(e,2),Of(e))}function hf(e,t,n){if(e.tag===3)mf(e,e,n);else for(;t!==null;){if(t.tag===3){mf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=Ii(n,e),n=Dc(2),r=po(t,n,2),r!==null&&(Oc(n,r,t,e),st(r,2),Of(r));break}}t=t.return}}function gf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Yu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(id=!0,i.add(n),e=_f.bind(null,e,t,n),t.then(e,e))}function _f(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Zu===e&&($u&n)===n&&(od===4||od===3&&($u&62914560)===$u&&300>Fe()-hd?Xu&2?ld|=n:Hd(e,0):ld|=n,dd===$u&&(dd=0)),Of(e)}function vf(e,t){t===0&&(t=at()),e=xi(e,t),e!==null&&(st(e,t),Of(e))}function yf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vf(e,n)}function bf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(s(314))}r!==null&&r.delete(t),vf(e,n)}function xf(e,t){return je(e,t)}var Sf=null,Cf=null,wf=!1,Tf=!1,Ef=!1,Df=0;function Of(e){e!==Cf&&e.next===null&&(Cf===null?Sf=Cf=e:Cf=Cf.next=e),Tf=!0,wf||(wf=!0,Ff())}function kf(e,t){if(!Ef&&Tf){Ef=!0;do for(var n=!1,r=Sf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-qe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Pf(r,a))}else a=$u,a=tt(r,r===Zu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||nt(r,a)||(n=!0,Pf(r,a))}r=r.next}while(n);Ef=!1}}function Af(){jf()}function jf(){Tf=wf=!1;var e=0;Df!==0&&yp()&&(e=Df);for(var t=Fe(),n=null,r=Sf;r!==null;){var i=r.next,a=Mf(r,t);a===0?(r.next=null,n===null?Sf=i:n.next=i,i===null&&(Cf=n)):(n=r,(e!==0||a&3)&&(Tf=!0)),r=i}bd!==0&&bd!==5||kf(e,!1),Df!==0&&(Df=0)}function Mf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-qe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=it(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Zu,n=$u,n=tt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(ed===2||ed===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Me(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||nt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Me(r),pt(n)){case 2:case 8:n=Re;break;case 32:n=ze;break;case 268435456:n=Ve;break;default:n=ze}return r=Nf.bind(null,e),n=je(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Me(r),e.callbackPriority=2,e.callbackNode=null,2}function Nf(e,t){if(bd!==0&&bd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(ff()&&e.callbackNode!==n)return null;var r=$u;return r=tt(e,e===Zu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Id(e,r,t),Mf(e,Fe()),e.callbackNode!=null&&e.callbackNode===n?Nf.bind(null,e):null)}function Pf(e,t){if(ff())return null;Id(e,t,!0)}function Ff(){wp(function(){Xu&6?je(Le,Af):jf()})}function If(){if(Df===0){var e=Pa;e===0&&(e=Ze,Ze<<=1,!(Ze&261888)&&(Ze=256)),Df=e}return Df}function Lf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:fn(e)}function Rf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Lf((i[vt]||null).action),o=r.submitter;o&&(t=(t=o[vt]||null)?Lf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Nn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Df!==0){var e=new FormData(i,o);Qs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Qs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var zf=0;zf<ci.length;zf++){var Bf=ci[zf];li(Bf.toLowerCase(),`on`+(Bf[0].toUpperCase()+Bf.slice(1)))}li(ei,`onAnimationEnd`),li(ti,`onAnimationIteration`),li(ni,`onAnimationStart`),li(`dblclick`,`onDoubleClick`),li(`focusin`,`onFocus`),li(`focusout`,`onBlur`),li(ri,`onTransitionRun`),li(ii,`onTransitionStart`),li(ai,`onTransitionCancel`),li(oi,`onTransitionEnd`),It(`onMouseEnter`,[`mouseout`,`mouseover`]),It(`onMouseLeave`,[`mouseout`,`mouseover`]),It(`onPointerEnter`,[`pointerout`,`pointerover`]),It(`onPointerLeave`,[`pointerout`,`pointerover`]),Ft(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ft(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ft(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ft(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ft(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ft(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Vf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Hf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Vf));function Uf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){mi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){mi(e)}i.currentTarget=null,a=c}}}}function Wf(e,t){var n=t[bt];n===void 0&&(n=t[bt]=new Set);var r=e+`__bubble`;n.has(r)||(Jf(t,e,2,!1),n.add(r))}function Gf(e,t,n){var r=0;t&&(r|=4),Jf(n,e,r,t)}var Kf=`_reactListening`+Math.random().toString(36).slice(2);function qf(e){if(!e[Kf]){e[Kf]=!0,Nt.forEach(function(t){t!==`selectionchange`&&(Hf.has(t)||Gf(t,!1,e),Gf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Kf]||(t[Kf]=!0,Gf(`selectionchange`,!1,t))}}function Jf(e,t,n,r){switch(wh(t)){case 2:var i=vh;break;case 8:i=yh;break;default:i=bh}n=i.bind(null,t,n,e),i=void 0,!Cn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Yf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=Dt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}bn(function(){var r=a,i=hn(n),o=[];a:{var s=si.get(e);if(s!==void 0){var c=Nn,u=e;switch(e){case`keypress`:if(kn(n)===0)break a;case`keydown`:case`keyup`:c=Zn;break;case`focusin`:u=`focus`,c=Hn;break;case`focusout`:u=`blur`,c=Hn;break;case`beforeblur`:case`afterblur`:c=Hn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Bn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Vn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=er;break;case ei:case ti:case ni:c=Un;break;case oi:c=tr;break;case`scroll`:case`scrollend`:c=Fn;break;case`wheel`:c=nr;break;case`copy`:case`cut`:case`paste`:c=Wn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=Qn;break;case`submit`:c=$n;break;case`toggle`:case`beforetoggle`:c=rr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=xn(m,p),g!=null&&d.push(Xf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,c&&n!==mn&&(u=n.relatedTarget||n.fromElement)&&(Dt(u)||u[yt]))break a;(s||c)&&(u=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,s?(c=n.relatedTarget||n.toElement,s=r,c=c?Dt(c):null,c!==null&&(f=l(c),d=c.tag,c!==f||d!==5&&d!==27&&d!==6)&&(c=null)):(s=null,c=r),s!==c&&(d=Bn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Qn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:kt(s),h=c==null?u:kt(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Dt(i)===r&&(d=new d(p,m+`enter`,c,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&c?E(s,c,Qf):null,s!==null&&$f(o,u,s,d,!1),c!==null&&f!==null&&$f(o,f,c,d,!0)))}a:{if(s=r?kt(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var _=Cr;else if(_r(s)){if(wr)_=Nr;else{_=jr;var v=Ar}}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&ln(r.elementType)&&(_=Cr):_=Mr;if(_&&=_(e,r)){vr(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?kt(r):window,e){case`focusin`:(_r(v)||v.contentEditable===`true`)&&(Wr=v,Gr=r,Kr=null);break;case`focusout`:Kr=Gr=Wr=null;break;case`mousedown`:qr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:qr=!1,Jr(o,n,i);break;case`selectionchange`:if(Ur)break;case`keydown`:case`keyup`:Jr(o,n,i)}var y;if(ar)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else pr?dr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(cr&&n.locale!==`ko`&&(pr||b!==`onCompositionStart`?b===`onCompositionEnd`&&pr&&(y=On()):(Tn=i,En=`value`in Tn?Tn.value:Tn.textContent,pr=!0)),v=Zf(r,b),0<v.length&&(b=new Gn(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=fr(n),y!==null&&(b.data=y)))),(y=sr?mr(e,n):hr(e,n))&&(b=Zf(r,`onBeforeInput`),0<b.length&&(v=new Gn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),Rf(o,e,r,n,i)}Uf(o,t)})}function Xf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Zf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=xn(e,n),i!=null&&r.unshift(Xf(e,i,a)),i=xn(e,t),i!=null&&r.push(Xf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Qf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function $f(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=xn(n,a),l!=null&&o.unshift(Xf(n,l,c))):i||(l=xn(n,a),l!=null&&o.push(Xf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var ep=/\r\n?/g,tp=/\u0000|\uFFFD/g;function np(e){return(typeof e==`string`?e:``+e).replace(ep,`
|
|
9
9
|
`).replace(tp,``)}function rp(e,t){return t=np(t),np(e)===t}function ip(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||an(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&an(e,``+r);else return;break;case`className`:W(e,`class`,r);break;case`tabIndex`:W(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:W(e,n,r);break;case`style`:cn(e,r,a);return;case`data`:if(t!==`object`){W(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=fn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&ip(e,t,`name`,i.name,i,null),ip(e,t,`formEncType`,i.formEncType,i,null),ip(e,t,`formMethod`,i.formMethod,i,null),ip(e,t,`formTarget`,i.formTarget,i,null)):(ip(e,t,`encType`,i.encType,i,null),ip(e,t,`method`,i.method,i,null),ip(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=fn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=pn);return;case`onScroll`:r!=null&&Wf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Wf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(s(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(s(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=fn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Wf(`beforetoggle`,e),Wf(`toggle`,e),Ut(e,`popover`,r);break;case`xlinkActuate`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ut(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=un.get(n)||n,Ut(e,n,r);else return}Vt=!0}function ap(e,t,n,r,i,a){switch(n){case`style`:cn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(s(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(s(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)an(e,r);else if(typeof r==`number`||typeof r==`bigint`)an(e,``+r);else return;break;case`onScroll`:r!=null&&Wf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Wf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=pn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Pt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[vt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}Vt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Ut(e,n,r)}return}Vt=!0}function op(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Wf(`error`,e),Wf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var o=n[a];if(o!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(s(137,t));default:ip(e,t,a,o,n,null)}}i&&ip(e,t,`srcSet`,n.srcSet,n,null),r&&ip(e,t,`src`,n.src,n,null);return;case`input`:Wf(`invalid`,e);var c=a=o=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:o=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(s(137,t));break;default:ip(e,t,r,d,n,null)}}$t(e,a,c,l,u,o,i,!1);return;case`select`:for(i in Wf(`invalid`,e),r=o=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:o=c;break;case`multiple`:r=c;default:ip(e,t,i,c,n,null)}t=a,n=o,e.multiple=!!r,t==null?n!=null&&tn(e,!!r,n,!0):tn(e,!!r,t,!1);return;case`textarea`:for(o in Wf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(o)&&(c=n[o],c!=null))switch(o){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(s(91));break;default:ip(e,t,o,c,n,null)}rn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ip(e,t,l,r,n,null)}return;case`dialog`:Wf(`beforetoggle`,e),Wf(`toggle`,e),Wf(`cancel`,e),Wf(`close`,e);break;case`iframe`:case`object`:Wf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Vf.length;r++)Wf(Vf[r],e);break;case`image`:Wf(`error`,e),Wf(`load`,e);break;case`details`:Wf(`toggle`,e);break;case`embed`:case`source`:case`link`:Wf(`error`,e),Wf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(s(137,t));default:ip(e,t,u,r,n,null)}return;default:if(ln(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&ap(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ip(e,t,c,r,n,null))}var sp={};function cp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,o=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ip(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Vt=!0),a=m;break;case`name`:m!==f&&(Vt=!0),i=m;break;case`checked`:m!==f&&(Vt=!0),u=m;break;case`defaultChecked`:m!==f&&(Vt=!0),d=m;break;case`value`:m!==f&&(Vt=!0),o=m;break;case`defaultValue`:m!==f&&(Vt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(s(137,t));break;default:m!==f&&ip(e,t,p,m,r,f)}}Qt(e,o,c,l,u,d,a,i);return;case`select`:for(a in m=o=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||ip(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(Vt=!0),p=a;break;case`defaultValue`:a!==l&&(Vt=!0),c=a;break;case`multiple`:a!==l&&(Vt=!0),o=a;default:a!==l&&ip(e,t,i,a,r,l)}t=c,n=o,r=m,p==null?!!r!=!!n&&(t==null?tn(e,!!n,n?[]:``,!1):tn(e,!!n,t,!0)):tn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ip(e,t,c,null,r,i)}for(o in r)if(i=r[o],a=n[o],r.hasOwnProperty(o)&&(i!=null||a!=null))switch(o){case`value`:i!==a&&(Vt=!0),p=i;break;case`defaultValue`:i!==a&&(Vt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(s(91));break;default:i!==a&&ip(e,t,o,i,r,a)}nn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ip(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Vt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ip(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ip(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(s(137,t));break;default:ip(e,t,u,p,r,m)}return;default:if(ln(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&ap(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||ap(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ip(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ip(e,t,f,p,r,m)}function lp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function up(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&lp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&lp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var dp=null,fp=null;function pp(e){return e.nodeType===9?e:e.ownerDocument}function mp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function hp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function gp(e,t,n,r){return n=pp(n).createElement(e),n[_t]=r,n[vt]=t,op(n,e,t),jt(n),n}function _p(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var vp=null;function yp(){var e=window.event;return e&&e.type===`popstate`?e!==vp&&(vp=e,!0):(vp=null,!1)}var bp=typeof setTimeout==`function`?setTimeout:void 0,xp=typeof clearTimeout==`function`?clearTimeout:void 0,Sp=typeof Promise==`function`?Promise:void 0,Cp=typeof requestAnimationFrame==`function`?requestAnimationFrame:bp,wp=typeof queueMicrotask==`function`?queueMicrotask:Sp===void 0?bp:function(e){return Sp.resolve(null).then(e).catch(Tp)};function Tp(e){setTimeout(function(){throw e})}function Ep(e){return e===`head`}function Dp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Uh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)vm(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,vm(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[wt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&vm(e.ownerDocument.body)}n=i}while(n);Uh(t)}function Op(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function kp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ap(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function jp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Mp(e){return jp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Np(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return jp(t,n,e)}function Pp(e){return e.documentElement.clientHeight}function Fp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Ip(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Pp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Zm(f),u>eh){s.length=o;break}f=new Promise(Fp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Lp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Lp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Lp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Lp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Rp(e){return{name:e,group:new Lp(`group`,e),imagePair:new Lp(`image-pair`,e),old:new Lp(`old`,e),new:new Lp(`new`,e)}}function zp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}zp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=X(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Bp,e,s,r)}this._eventListeners=a}};function Bp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}zp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=X(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,Vp,e,n,i),r.splice(t,1),a!==null&&a()}};function Vp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function X(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Z(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Z(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Z(a.optionsOrUseCapture)===r)return i}return-1}zp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,X(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,X(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},zp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),mm(e,t))}zp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}zp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=pp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}zp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag!==6&&(e=b(e),t.observe(e),!1)}zp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag!==6&&(e=b(e),t.unobserve(e),!1)}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,hm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}zp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}zp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},zp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Dt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}zp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(s(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,X(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function Q(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,X(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function rm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:rm(n),Et(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function im(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[wt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=um(e.nextSibling),e===null)break}return null}function am(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=um(e.nextSibling),e===null))return null;return e}function om(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=um(e.nextSibling),e===null))return null;return e}function sm(e){return e.data===`$?`||e.data===`$~`}function cm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function um(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var dm=null;function fm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return um(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function hm(e){Cp(function(){Cp(function(t){return e(t)})})}function gm(e,t,n){switch(t=pp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(s(452));return e;case`head`:if(e=t.head,!e)throw Error(s(453));return e;case`body`:if(e=t.body,!e)throw Error(s(454));return e;default:throw Error(s(451))}}function _m(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ip(e,t,r,null,sp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===pn&&(e.onclick=null),Et(e)}function vm(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Et(e)}var ym=new Map,bm=new Set;function xm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Sm=B.d;B.d={f:Cm,r:wm,D:Dm,C:Om,L:km,m:Am,X:Mm,S:jm,M:Nm};function Cm(){var e=Sm.f(),t=Bd();return e||t}function wm(e){var t=Ot(e);t!==null&&t.tag===5&&t.type===`form`?ec(t):Sm.r(e)}var Tm=typeof document>`u`?null:document;function Em(e,t,n){var r=Tm;if(r&&typeof t==`string`&&t){var i=Zt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),bm.has(i)||(bm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),op(t,`link`,e),jt(t),r.head.appendChild(t)))}}function Dm(e){Sm.D(e),Em(`dns-prefetch`,e,null)}function Om(e,t){Sm.C(e,t),Em(`preconnect`,e,t)}function km(e,t,n){Sm.L(e,t,n);var r=Tm;if(r&&e&&t){var i=`link[rel="preload"][as="`+Zt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Zt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Zt(n.imageSizes)+`"]`)):i+=`[href="`+Zt(e)+`"]`;var a=i;switch(t){case`style`:a=Fm(e);break;case`script`:a=zm(e)}if(!(ym.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),ym.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Im(a))||t===`script`&&r.querySelector(Bm(a))))){var o=r.createElement(`link`);op(o,`link`,e),t===`style`&&(o[Tt]=!0,o.onload=o.onerror=function(){Mt(o)}),jt(o),r.head.appendChild(o)}}}function Am(e,t){Sm.m(e,t);var n=Tm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Zt(r)+`"][href="`+Zt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=zm(e)}if(!ym.has(a)&&(e=D({rel:`modulepreload`,href:e},t),ym.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Bm(a)))return}r=n.createElement(`link`),op(r,`link`,e),jt(r),n.head.appendChild(r)}}}function jm(e,t,n){Sm.S(e,t,n);var r=Tm;if(r&&e){var i=At(r).hoistableStyles,a=Fm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Im(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=ym.get(a))&&Um(e,n);var c=o=r.createElement(`link`);jt(c),op(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Hm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Mm(e,t){Sm.X(e,t);var n=Tm;if(n&&e){var r=At(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),jt(a),op(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t){Sm.M(e,t);var n=Tm;if(n&&e){var r=At(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),jt(a),op(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t,n,r){var i=(i=ye.current)?xm(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Fm(n.href),t=At(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Fm(n.href);var a=At(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(Im(e)))?a._p||(o.instance=a,o.state.loading=5):(a=ym.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},ym.set(e,a)),Rm(i,e,a,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=zm(n),t=At(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Fm(e){return`href="`+Zt(e)+`"`}function Im(e){return`link[rel="stylesheet"][`+e+`]`}function Lm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Rm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Tt]){r.loading=1;return}}else t=e.createElement(`link`),t[Tt]=!0,t.onload=t.onerror=Mt.bind(null,t),op(t,`link`,n),jt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function zm(e){return`[src="`+Zt(e)+`"]`}function Bm(e){return`script[async]`+e}function Vm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Zt(n.href)+`"]`);if(r)return t.instance=r,jt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),jt(r),op(r,`style`,i),Hm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Fm(n.href);var a=e.querySelector(Im(i));if(a)return t.state.loading|=4,t.instance=a,jt(a),a;r=Lm(n),(i=ym.get(i))&&Um(r,i),a=(e.ownerDocument||e).createElement(`link`),jt(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),op(a,`link`,r),t.state.loading|=4,Hm(a,n.precedence,e),t.instance=a;case`script`:return a=zm(n.src),(i=e.querySelector(Bm(a)))?(t.instance=i,jt(i),i):(r=n,(i=ym.get(a))&&(r=D({},n),Wm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),jt(i),op(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Hm(r,n.precedence,e));return t.instance}function Hm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Gm=null;function Km(e,t,n){if(Gm===null){var r=new Map,i=Gm=new Map;i.set(n,r)}else i=Gm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[wt]||a[_t]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function qm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Jm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Ym(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Xm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Zm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Qm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Zm(t),e.suspenseyImages.push(t)),e=ih.bind(e),t.decode().then(e,e))}function $m(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Fm(r.href),a=t.querySelector(Im(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,jt(a);return}a=t.ownerDocument||t,r=Lm(r),(i=ym.get(i))&&Um(r,i),a=a.createElement(`link`),jt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),op(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var eh=0;function th(e,t){return e.stylesheets&&e.count===0&&oh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&eh===0&&(eh=62500*up());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>eh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function nh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)oh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function rh(){this.count--,nh(this)}function ih(){this.imgCount--,nh(this)}var ah=null;function oh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ah=new Map,t.forEach(sh,e),ah=null,rh.call(e))}function sh(e,t){if(!(t.state.loading&4)){var n=ah.get(e);if(n)var r=n.get(null);else{n=new Map,ah.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ch={$$typeof:P,Provider:null,Consumer:null,_currentValue:fe,_currentValue2:fe,_threadCount:0};function lh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ot(0),this.hiddenUpdates=ot(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function uh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new lh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ei(3,null,null,t),e.current=a,a.stateNode=e,t=Da(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},lo(a),e}function dh(e){return e?(e=wi,e):wi}function fh(e,t,n,r,i,a){i=dh(i),r.context===null?r.context=i:r.pendingContext=i,r=fo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=po(e,r,t),n!==null&&(Fd(n,e,t),mo(n,e,t))}function ph(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mh(e,t){ph(e,t),(e=e.alternate)&&ph(e,t)}function hh(e){if(e.tag===13||e.tag===31){var t=xi(e,67108864);t!==null&&Fd(t,e,67108864),mh(e,67108864)}}function gh(e){if(e.tag===13||e.tag===31){var t=Md();t=ft(t);var n=xi(e,t);n!==null&&Fd(n,e,t),mh(e,t)}}var _h=!0;function vh(e,t,n,r){var i=z.T;z.T=null;var a=B.p;try{B.p=2,bh(e,t,n,r)}finally{B.p=a,z.T=i}}function yh(e,t,n,r){var i=z.T;z.T=null;var a=B.p;try{B.p=8,bh(e,t,n,r)}finally{B.p=a,z.T=i}}function bh(e,t,n,r){if(_h){var i=xh(r);if(i===null)Yf(e,t,r,Sh,n),Nh(e,r);else if(Fh(i,e,t,n,r))r.stopPropagation();else if(Nh(e,r),t&4&&-1<Mh.indexOf(e)){for(;i!==null;){var a=Ot(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=et(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-qe(o);s.entanglements[1]|=c,o&=~c}Of(a),!(Xu&6)&&(_d=Fe()+500,kf(0,!1))}}break;case 31:case 13:s=xi(a,2),s!==null&&Fd(s,a,2),Bd(),mh(a,2)}if(a=xh(r),a===null&&Yf(e,t,r,Sh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Yf(e,t,r,null,n)}}function xh(e){return e=hn(e),Ch(e)}var Sh=null;function Ch(e){if(Sh=null,e=Dt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Sh=e,null}function wh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ie()){case Le:return 2;case Re:return 8;case ze:case Be:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var Th=!1,Eh=null,Dh=null,Oh=null,kh=new Map,Ah=new Map,jh=[],Mh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Nh(e,t){switch(e){case`focusin`:case`focusout`:Eh=null;break;case`dragenter`:case`dragleave`:Dh=null;break;case`mouseover`:case`mouseout`:Oh=null;break;case`pointerover`:case`pointerout`:kh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Ah.delete(t.pointerId)}}function Ph(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ot(t),t!==null&&hh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Fh(e,t,n,r,i){switch(t){case`focusin`:return Eh=Ph(Eh,e,t,n,r,i),!0;case`dragenter`:return Dh=Ph(Dh,e,t,n,r,i),!0;case`mouseover`:return Oh=Ph(Oh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return kh.set(a,Ph(kh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Ah.set(a,Ph(Ah.get(a)||null,e,t,n,r,i)),!0}return!1}function Ih(e){var t=Dt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,ht(e.priority,function(){gh(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,ht(e.priority,function(){gh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);mn=r,n.target.dispatchEvent(r),mn=null}else return t=Ot(n),t!==null&&hh(t),e.blockedOn=n,!1;t.shift()}return!0}function Rh(e,t,n){Lh(e)&&n.delete(t)}function zh(){Th=!1,Eh!==null&&Lh(Eh)&&(Eh=null),Dh!==null&&Lh(Dh)&&(Dh=null),Oh!==null&&Lh(Oh)&&(Oh=null),kh.forEach(Rh),Ah.forEach(Rh)}function Bh(e,n){e.blockedOn===n&&(e.blockedOn=null,Th||(Th=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zh)))}var Vh=null;function Hh(e){Vh!==e&&(Vh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Vh===e&&(Vh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Ch(r||n)===null)continue;break}var a=Ot(n);a!==null&&(e.splice(t,3),t-=3,Qs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Uh(e){function t(t){return Bh(t,e)}Eh!==null&&Bh(Eh,e),Dh!==null&&Bh(Dh,e),Oh!==null&&Bh(Oh,e),kh.forEach(t),Ah.forEach(t);for(var n=0;n<jh.length;n++){var r=jh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<jh.length&&(n=jh[0],n.blockedOn===null);)Ih(n),n.blockedOn===null&&jh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[vt]||null;if(typeof a==`function`)o||Hh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[vt]||null)s=o.formAction;else if(Ch(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Hh(n)}}}function Wh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Gh(e){this._internalRoot=e}Kh.prototype.render=Gh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(s(409));var n=t.current;fh(n,Md(),e,t,null,null)},Kh.prototype.unmount=Gh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fh(e.current,2,null,e,null,null),Bd(),t[yt]=null}};function Kh(e){this._internalRoot=e}Kh.prototype.unstable_scheduleHydration=function(e){if(e){var t=mt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jh.length&&t!==0&&t<jh[n].priority;n++);jh.splice(n,0,e),n===0&&Ih(e)}};var qh=r.version;if(qh!==`19.3.0`)throw Error(s(527,qh,`19.3.0`));B.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(s(188)):(e=Object.keys(e).join(`,`),Error(s(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Jh={bundleType:0,version:`19.3.0`,rendererPackageName:`react-dom`,currentDispatcherRef:z,reconcilerVersion:`19.3.0`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Yh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yh.isDisabled&&Yh.supportsFiber)try{We=Yh.inject(Jh),Ge=Yh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(s(299));var n=!1,r=``,i=xc,a=Sc,o=Cc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=uh(e,1,!1,null,null,n,r,null,i,a,o,Wh),e[yt]=t.current,qf(e),new Gh(t)}})),c=e(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n(),u=c(),d={minHeight:44,minWidth:44},f=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),p=e(((e,t)=>{t.exports=f()}))(),m=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`;function h({onLoggedIn:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(0),[u,f]=(0,l.useState)(()=>Date.now()),h=Math.max(0,Math.ceil((s-u)/1e3)),g=h>0;return(0,l.useEffect)(()=>{if(!s)return;let e=setInterval(()=>{let e=Date.now();f(e),e>=s&&(c(0),i(``))},500);return()=>clearInterval(e)},[s]),(0,p.jsxs)(`form`,{className:`auth glass`,onSubmit:async r=>{if(r.preventDefault(),!g){o(!0),i(``);try{let r=await fetch(`/api/login`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:t})});if(r.ok)return n(``),e();let a=await r.json().catch(()=>({}));if(n(``),a.retryAfterSeconds&&a.retryAfterSeconds>0){let e=Date.now();f(e),c(e+a.retryAfterSeconds*1e3),i(r.status===429?`Too many wrong passwords.`:`Wrong password.`)}else r.status===401&&typeof a.triesLeft==`number`?i(`Wrong password. ${a.triesLeft} ${a.triesLeft===1?`try`:`tries`} left before a lock.`):i(a.error??`Could not sign in`)}catch{i(`Could not reach the server`)}finally{o(!1)}}},children:[(0,p.jsx)(`h1`,{children:`Friend`}),(0,p.jsx)(`label`,{htmlFor:`pw`,children:`Password`}),(0,p.jsx)(`input`,{id:`pw`,type:`password`,autoComplete:`current-password`,autoFocus:!0,value:t,disabled:g,onChange:e=>n(e.target.value),style:d}),r&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:r}),g&&(0,p.jsxs)(`p`,{role:`status`,className:`auth-note`,"data-testid":`lock-countdown`,children:[`Sign-in is locked for a short time to stop guessing. Try again in `,m(h),`.`]}),(0,p.jsx)(`button`,{type:`submit`,className:`primary`,style:d,disabled:a||g||!t,children:g?`Locked ${m(h)}`:`Sign in`})]})}function g({onDone:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(!1);return(0,p.jsxs)(`form`,{className:`auth glass`,onSubmit:async n=>{n.preventDefault(),f(!0),c(``);try{let n=await fetch(`/api/setup`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:t,pin:r,assistantName:a})});if(n.ok)return e();let i=await n.json().catch(()=>({}));c(i.error??`Setup failed`)}catch{c(`Could not reach the server`)}finally{f(!1)}},children:[(0,p.jsx)(`h1`,{children:`Welcome`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Create your account. This only works on the PC that runs Friend.`}),(0,p.jsx)(`label`,{htmlFor:`su-pw`,children:`Password (8+ characters)`}),(0,p.jsx)(`input`,{id:`su-pw`,type:`password`,autoComplete:`new-password`,value:t,onChange:e=>n(e.target.value),style:d}),(0,p.jsx)(`label`,{htmlFor:`su-pin`,children:`PIN (6+ digits)`}),(0,p.jsx)(`input`,{id:`su-pin`,type:`password`,inputMode:`numeric`,autoComplete:`off`,value:r,onChange:e=>i(e.target.value),style:d}),(0,p.jsx)(`label`,{htmlFor:`su-name`,children:`Assistant name`}),(0,p.jsx)(`input`,{id:`su-name`,value:a,onChange:e=>o(e.target.value),style:d}),s&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:s}),(0,p.jsx)(`button`,{type:`submit`,className:`primary`,style:d,disabled:u||!t||!r||!a,children:`Create account`})]})}function _(e,t){let n=Math.max(1,Math.ceil(e.length/6)),r=Math.min(t,n-1);return{here:e.slice(r*6,r*6+6),at:r,pages:n}}function v(e,t,n){return t>1?{index:e,total:t,onPrev:()=>n((e+t-1)%t),onNext:()=>n((e+1)%t)}:void 0}function y({tabs:e,active:t,onTab:n,cards:r,empty:i,ready:a=!0}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`holo-tabs`,role:`tablist`,"aria-label":`Sections`,children:e.map(e=>(0,p.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,className:`holo-tab${t===e.id?` on`:``}`,onClick:()=>n(e.id),children:[e.label,` `,(0,p.jsx)(`small`,{children:e.count})]},e.id))}),a&&r.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:i}),(0,p.jsx)(`ul`,{className:`holo-cards`,children:r.map(e=>(0,p.jsxs)(`li`,{className:`holo-card`,...e.integrationId?{"data-integration":e.integrationId}:{},children:[(0,p.jsxs)(`div`,{className:`holo-card-head`,children:[(0,p.jsx)(`strong`,{children:e.name}),e.badge&&(0,p.jsx)(`span`,{className:`holo-badge ${e.badge}`,children:e.badgeText})]}),e.meta&&(0,p.jsx)(`small`,{className:`holo-version`,children:e.meta}),(0,p.jsx)(`div`,{className:`holo-card-note ${e.noteClass}`,children:e.note}),(0,p.jsx)(`div`,{className:`holo-card-actions`,children:e.actions.map(e=>(0,p.jsx)(`button`,{type:`button`,className:`holo-btn sm${e.kind===`primary`?` go`:e.kind===`danger`?` warn`:``}`,disabled:e.disabled,onClick:e.onClick,children:e.label},e.label))})]},e.key))})]})}function b({label:e,title:t,page:n,children:r,help:i,onApply:a,onDone:o,dirty:s=!1,busy:c=!1,onUndo:u,extra:d}){let[f,m]=(0,l.useState)(!1);return(0,p.jsx)(`div`,{className:`holo-layer`,style:{pointerEvents:`none`},children:(0,p.jsxs)(`div`,{className:`holo-panel`,role:`dialog`,"aria-label":e,style:{pointerEvents:`auto`},children:[(0,p.jsxs)(`div`,{className:`holo-head`,children:[(0,p.jsx)(`h2`,{className:`holo-title`,children:t}),n&&(0,p.jsx)(`div`,{className:`holo-dots`,"aria-label":`Page ${n.index+1} of ${n.total}`,children:Array.from({length:n.total},(e,t)=>(0,p.jsx)(`i`,{className:t===n.index?`on`:``},t))})]}),n&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,className:`holo-page holo-prev`,"aria-label":`Previous page`,onClick:n.onPrev,children:(0,p.jsx)(`span`,{children:`Previous`})}),(0,p.jsx)(`button`,{type:`button`,className:`holo-page holo-next`,"aria-label":`Next page`,onClick:n.onNext,children:(0,p.jsx)(`span`,{children:`Next`})}),(0,p.jsx)(`span`,{className:`holo-sr`,style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clip:`rect(0 0 0 0)`},children:`Page ${n.index+1} of ${n.total}`})]}),(0,p.jsx)(`div`,{className:`holo-body`,children:r}),(0,p.jsx)(`div`,{className:`holo-foot`,children:f?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`holo-help`,role:`alert`,children:[(0,p.jsx)(`b`,{children:`Changes not applied.`}),` Closing now throws them away.`]}),(0,p.jsxs)(`div`,{className:`holo-actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`holo-btn`,onClick:()=>m(!1),children:`Keep editing`}),(0,p.jsx)(`button`,{type:`button`,className:`holo-btn warn`,onClick:o,children:`Discard`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`holo-help`,children:i}),(0,p.jsxs)(`div`,{className:`holo-actions`,children:[d,s&&u&&(0,p.jsx)(`button`,{type:`button`,className:`holo-btn quiet`,onClick:u,children:`Undo`}),a&&(0,p.jsx)(`button`,{type:`button`,className:`holo-btn`,disabled:!s||c,onClick:a,children:`Apply`}),(0,p.jsx)(`button`,{type:`button`,className:`holo-btn`,onClick:()=>s?m(!0):o(),children:`Done`})]})]})})]})})}var x=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],S=12,C=6,w=e=>e instanceof HTMLElement&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||e.isContentEditable);function T({pin:e,onChange:t,onSubmit:n}){let r=n=>t((e+n).slice(0,S)),i=(0,l.useRef)({pin:e,onChange:t,onSubmit:n});return i.current={pin:e,onChange:t,onSubmit:n},(0,l.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey||w(e.target))return;let{pin:t,onChange:n,onSubmit:r}=i.current;/^[0-9]$/.test(e.key)?(e.preventDefault(),e.stopPropagation(),n((t+e.key).slice(0,S))):e.key===`Backspace`?(e.preventDefault(),e.stopPropagation(),n(t.slice(0,-1))):e.key===`Enter`&&r&&(e.preventDefault(),e.stopPropagation(),t.length>=C&&r())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,p.jsxs)(`div`,{className:`pinpad`,children:[(0,p.jsx)(`div`,{className:`pin-dots`,"data-testid":`pin-dots`,"aria-label":`PIN entered`,"aria-live":`polite`,children:`•`.repeat(e.length)}),(0,p.jsxs)(`div`,{className:`pin-keys`,children:[x.map(e=>(0,p.jsx)(`button`,{type:`button`,style:d,"aria-label":e,onClick:()=>r(e),children:e},e)),(0,p.jsx)(`span`,{}),(0,p.jsx)(`button`,{type:`button`,style:d,"aria-label":`0`,onClick:()=>r(`0`),children:`0`}),(0,p.jsx)(`button`,{type:`button`,style:d,"aria-label":`Backspace`,onClick:()=>t(e.slice(0,-1)),children:`⌫`})]})]})}async function E(e,t={}){let n;try{n=await fetch(`/api/connectors${e}`,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||(n.status===401?`Please sign in again.`:n.status===429?`Too many attempts. Wait a moment.`:`The request failed (${n.status}).`))}return await n.json()}var D=(e,t)=>({method:e,...t===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(t)}}),O={list:()=>E(``),quickCheck:e=>E(`/quick/${encodeURIComponent(e)}`),quickInstall:(e,t)=>E(`/quick/${encodeURIComponent(e)}/install`,D(`POST`,{pin:t})),quickConnect:(e,t)=>E(`/quick/${encodeURIComponent(e)}/connect`,D(`POST`,{pin:t})),add:(e,t)=>E(``,D(`POST`,{pin:t,connector:e})),setEnabled:(e,t,n)=>E(`/${encodeURIComponent(e)}/enabled`,D(`POST`,{enabled:t,...n?{pin:n}:{}})),reload:e=>E(`/${encodeURIComponent(e)}/reload`,D(`POST`,{})),remove:async e=>{await E(`/${encodeURIComponent(e)}`,D(`DELETE`))}},k=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);function A(e){let t={};for(let n of k(e)){let e=n.indexOf(`=`);if(e<1)throw Error(`"${n.slice(0,30)}" should look like NAME=value`);t[n.slice(0,e).trim()]=n.slice(e+1).trim()}return t}function j(e){let t={};for(let n of k(e)){let e=n.indexOf(`:`);if(e<1)throw Error(`"${n.slice(0,30)}" should look like Name: value`);t[n.slice(0,e).trim()]=n.slice(e+1).trim()}return t}var ee={off:`Off`,connecting:`Connecting…`,ready:`Ready`,error:`Not working`},M=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,16);function N({api:e=O,onClose:t,variant:n=`classic`}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)({name:`list`}),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[g,x]=(0,l.useState)(null),[S,C]=(0,l.useState)(`connected`),[w,E]=(0,l.useState)(0),D=(0,l.useRef)(!0),[N,P]=(0,l.useState)(`stdio`),[F,te]=(0,l.useState)(``),[I,ne]=(0,l.useState)(``),[L,re]=(0,l.useState)(``),[ie,ae]=(0,l.useState)(``),[oe,se]=(0,l.useState)(``),ce=(0,l.useCallback)(async()=>{try{let t=await e.list();D.current&&i(t)}catch(e){D.current&&h(e.message)}},[e]);(0,l.useEffect)(()=>{D.current=!0,ce();let e=setInterval(()=>void ce(),4e3);return()=>{D.current=!1,clearInterval(e)}},[ce]);let le=async e=>{h(null),f(!0);try{let t=await e();if(!D.current)return;t&&x(t),o({name:`list`}),await ce()}catch(e){D.current&&h(e.message)}finally{D.current&&(f(!1),c(``))}},ue=async t=>{h(null),x(null),o({name:`quick-check`,preset:t});try{let n=await e.quickCheck(t.id);if(!D.current)return;o(n.ready?{name:`quick-pin`,preset:t,mode:`connect`,check:n}:{name:`quick-help`,preset:t,check:n})}catch(e){if(!D.current)return;h(e.message),o({name:`list`})}},de=async()=>{if(a.name!==`quick-pin`)return;let{preset:t,mode:n}=a;h(null),f(!0);try{let r=[],i=!0;if(n===`install`){let n=await e.quickInstall(t.id,s);r.push(n.message),n.output&&!n.ok&&r.push(n.output),i=n.ok}if(i){let n=await e.quickConnect(t.id,s);r.push(n.message),i=n.ok}if(!D.current)return;o({name:`quick-done`,preset:t,ok:i,lines:r}),await ce()}catch(e){D.current&&h(e.message)}finally{D.current&&(f(!1),c(``))}},R=e=>{h(null),x(null),P(`stdio`),te(e?.connector.name??``),ne(e?.connector.command??``),re((e?.connector.args??[]).join(`
|
|
10
10
|
`)),ae(``),se(``),o({name:`form`,preset:e})},z=()=>{h(null);try{let e=a.name===`form`&&a.preset?a.preset.connector.id:M(F);if(!e)throw Error(`Give it a name.`);let t=N===`stdio`?{id:e,name:F.trim(),kind:N,command:I.trim(),args:k(L),env:A(ie)}:{id:e,name:F.trim(),kind:N,url:oe.trim(),headers:j(ie)};if(t.kind===`stdio`&&!t.command)throw Error(`Enter the program to start.`);if(t.kind===`http`&&!t.url)throw Error(`Enter the address of the server.`);o({name:`pin`,connector:t,preset:a.name===`form`?a.preset:null})}catch(e){h(e.message)}},B=()=>{a.name===`pin`?le(async()=>{let t=await e.add(a.connector,s);return t.status===`ready`?`${t.name} is connected with ${t.tools} tools.`:`${t.name} was saved but is not working yet: ${t.error??`unknown error`}`}):a.name===`switch-on`&&le(async()=>{let t=await e.setEnabled(a.id,!0,s);return t.status===`ready`?`${t.name} is on with ${t.tools} tools.`:`${t.name} did not start: ${t.error??`unknown error`}`})},fe=(e,r={})=>n===`holo`?(0,p.jsx)(b,{label:`Connectors`,title:r.title??`Connectors`,page:r.page,help:r.help,onDone:t,children:e}):(0,p.jsxs)(`div`,{className:`approval connectors glass`,role:`dialog`,"aria-label":`Connectors`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Connectors`})}),e]}),pe=m&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:m});if(a.name===`quick-check`)return fe((0,p.jsxs)(`p`,{className:`auth-note`,children:[`Checking `,a.preset.name,`…`]}));if(a.name===`quick-help`){let{preset:e,check:t}=a;return fe((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note connector-warning`,children:t.message}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Easiest: let Friend install it for you in the background. You will only need your PIN, and then one step in Chrome.`}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:()=>o({name:`quick-pin`,preset:e,mode:`install`,check:t}),children:`Set it up for me`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>void ue(e),children:`Check again`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>o({name:`list`}),children:`Back`})]}),t.installCommand&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Or do it yourself: open a terminal and run`}),(0,p.jsx)(`pre`,{className:`connector-command`,children:t.installCommand})]}),t.manualStep&&(0,p.jsx)(`p`,{className:`auth-note`,children:t.manualStep})]}))}if(a.name===`quick-pin`){let{preset:e,mode:t}=a,n=[e.connector.command,...e.connector.args].join(` `);return fe((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:t===`connect`?`Friend will add ${e.name} for you and start it. It runs: ${n}`:`Friend will install ${e.name} for you in the background, then connect it. It runs: ${a.check.installCommand??``}, without touching Claude's settings or Chrome's shortcuts. It copies a small helper and the Chrome extension into your home folder. This can take a minute.`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to continue.`}),(0,p.jsx)(T,{pin:s,onChange:c,onSubmit:()=>!u&&void de()}),pe,(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:u||s.length<6,onClick:()=>void de(),children:u?t===`install`?`Installing… this can take a minute`:`Connecting…`:t===`install`?`Install and connect`:`Connect`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:u,onClick:()=>{c(``),h(null),o({name:`list`})},children:`Back`})]})]}))}if(a.name===`quick-done`)return fe((0,p.jsxs)(p.Fragment,{children:[a.lines.map((e,t)=>(0,p.jsx)(`p`,{className:`auth-note${t===0&&!a.ok?` connector-warning`:``}`,children:e},t)),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:()=>o({name:`list`}),children:`Done`}),!a.ok&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>void ue(a.preset),children:`Try again`})]})]}));if(a.name===`pin`||a.name===`switch-on`){let e=a.name===`pin`?a.connector.kind===`stdio`?`Friend will start this program on your PC: ${[a.connector.command,...a.connector.args].join(` `)}`:`Friend will connect to ${a.connector.url.replace(/\?.*$/,`?…`)}`:`Switch on ${a.label}? It starts the program or connects to the service.`;return fe((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:e}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to confirm.`}),(0,p.jsx)(T,{pin:s,onChange:c,onSubmit:()=>!u&&B()}),pe,(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:u||s.length<6,onClick:B,children:u?`Connecting…`:`Confirm`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{o(a.name===`pin`?{name:`form`,preset:a.preset}:{name:`list`}),c(``),h(null)},children:`Back`})]})]}))}if(a.name===`form`){let e=a.preset;return fe((0,p.jsxs)(`div`,{className:`connector-form`,children:[e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:e.description}),(0,p.jsx)(`ol`,{className:`connector-steps`,children:e.setup.map((e,t)=>(0,p.jsx)(`li`,{children:e},t))}),e.warning&&(0,p.jsx)(`p`,{className:`auth-note connector-warning`,children:e.warning})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Name`}),(0,p.jsx)(`input`,{value:F,maxLength:60,onChange:e=>te(e.target.value)})]}),!e&&(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Type`}),(0,p.jsxs)(`select`,{value:N,onChange:e=>P(e.target.value),children:[(0,p.jsx)(`option`,{value:`stdio`,children:`A program on this PC`}),(0,p.jsx)(`option`,{value:`http`,children:`A server by address`})]})]}),N===`stdio`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Program`}),(0,p.jsx)(`input`,{value:I,onChange:e=>ne(e.target.value),placeholder:`npx`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Arguments (one per line)`}),(0,p.jsx)(`textarea`,{rows:3,value:L,onChange:e=>re(e.target.value),placeholder:`-y
|
|
11
|
-
some-mcp-server`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Secret variables (NAME=value, one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:ie,onChange:e=>ae(e.target.value),autoComplete:`off`,placeholder:`Leave empty if it needs none`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Saved privately on this PC and never shown again.`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Address`}),(0,p.jsx)(`input`,{value:oe,onChange:e=>se(e.target.value),placeholder:`https://… or http://127.0.0.1:8766/mcp`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Plain http is only allowed for a server on this PC.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Secret headers (Name: value, one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:ie,onChange:e=>ae(e.target.value),autoComplete:`off`})]})]}),pe,(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:z,children:`Next`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>o({name:`list`}),children:`Back`})]})]}))}if(n===`holo`){let t=r?.connectors??[],n=r?.presets??[],i={off:`off`,connecting:`warn`,ready:`on`,error:`error`},a=t.map(t=>({key:t.id,name:t.name,badge:i[t.status],badgeText:ee[t.status],...t.status===`ready`?{meta:`${t.tools} tools`}:{},note:`${t.error?t.error:t.target}${t.secret?` · secret saved`:``}`,noteClass:t.error?`auth-error`:`auth-note`,actions:[{label:t.enabled?`Turn off`:`Turn on`,disabled:u,onClick:()=>t.enabled?void le(async()=>{await e.setEnabled(t.id,!1)}):o({name:`switch-on`,id:t.id,label:t.name})},...t.enabled?[{label:`Reload`,disabled:u,onClick:()=>void le(async()=>{await e.reload(t.id)})}]:[],{label:`Remove`,kind:`danger`,disabled:u,onClick:()=>void le(async()=>{await e.remove(t.id)})}]})),s=[...n.map(e=>({key:e.id,name:e.name,note:e.description,noteClass:`auth-note`,actions:[{label:e.quick?`Connect`:`Add`,kind:`primary`,disabled:t.some(t=>t.id===e.connector.id),onClick:()=>e.quick?void ue(e):R(e)}]})),{key:`something-else`,name:`Something else`,note:`Any MCP program or server.`,noteClass:`auth-note`,actions:[{label:`Add`,onClick:()=>R(null)}]}],{here:c,at:l,pages:d}=_(S===`connected`?a:s,w);return fe((0,p.jsxs)(p.Fragment,{children:[pe,g&&(0,p.jsx)(`p`,{className:`auth-note`,children:g}),(0,p.jsx)(y,{tabs:[{id:`connected`,label:`Connected`,count:a.length},{id:`add`,label:`Add`,count:s.length}],active:S,onTab:e=>{C(e),E(0)},cards:c,empty:`Nothing connected yet. Add one on the Add tab.`,ready:!!r})]}),{page:v(l,d,E),help:(0,p.jsxs)(p.Fragment,{children:[`Outside programs and services Friend may use. Adding or switching one on needs your `,(0,p.jsx)(`b`,{children:`PIN`}),`.`]})})}return fe((0,p.jsxs)(p.Fragment,{children:[pe,g&&(0,p.jsx)(`p`,{className:`auth-note`,children:g}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Connected`}),r&&r.connectors.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing connected yet. Add one below.`}),(0,p.jsx)(`ul`,{className:`plugin-list`,children:(r?.connectors??[]).map(t=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:t.name}),` `,(0,p.jsxs)(`small`,{className:`conn-status conn-${t.status}`,children:[ee[t.status],t.status===`ready`?` · ${t.tools} tools`:``]}),(0,p.jsxs)(`div`,{className:`auth-note`,children:[t.error?`${t.error}`:t.target,t.secret?` · secret saved`:``]})]}),(0,p.jsxs)(`div`,{className:`plugin-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:u,onClick:()=>t.enabled?void le(async()=>{await e.setEnabled(t.id,!1)}):o({name:`switch-on`,id:t.id,label:t.name}),children:t.enabled?`Turn off`:`Turn on`}),t.enabled&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:u,onClick:()=>void le(async()=>{await e.reload(t.id)}),children:`Reload`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:u,onClick:()=>void le(async()=>{await e.remove(t.id)}),children:`Remove`})]})]},t.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Add`}),(0,p.jsxs)(`ul`,{className:`plugin-list`,children:[(r?.presets??[]).map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:e.name}),(0,p.jsx)(`div`,{className:`auth-note`,children:e.description})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:(r?.connectors??[]).some(t=>t.id===e.connector.id),onClick:()=>e.quick?void ue(e):R(e),children:e.quick?`Connect`:`Add`})})]},e.id)),(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:`Something else`}),(0,p.jsx)(`div`,{className:`auth-note`,children:`Any MCP program or server.`})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>R(null),children:`Add`})})]})]}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})})]}))}function P(e){let t=e.trimStart();if(!t.startsWith(`/`)||t.startsWith(`//`))return null;let n=/^\/(\S*)\s*(.*)$/s.exec(t);return n?{name:n[1].toLowerCase(),args:n[2].trim()}:null}function F(e,t){let n=P(t);if(!n)return[];if(/^\/\S*\s/.test(t.trimStart()))return e.filter(e=>e.name===n.name);let r=e.filter(e=>e.name.startsWith(n.name)),i=e.filter(e=>!e.name.startsWith(n.name)&&e.name.includes(n.name));return[...r,...i]}function te(e,t,n){let r=P(t);if(!r)return;let i=e.find(e=>e.name===r.name);if(!i){n(r.name?`There is no command /${r.name}. Type /help to see them.`:`Type /help to see the commands.`);return}i.run(r.args)}var I=e=>e.trimStart().startsWith(`//`)?e.trimStart().slice(1):e;function ne(e){let t=[{name:`settings`,description:`Open the settings (model, voice, …)`,run:e.openSettings},{name:`plugins`,description:`Add, switch or remove plugins (skills and tools)`,run:e.openPlugins},{name:`look`,description:`Choose how the voice presence looks: theme, colour, size, captions`,run:e.openLook},{name:`connectors`,description:`Connect Gmail, Chrome control or any MCP service; switch or remove them`,run:e.openConnectors},{name:`voice`,description:`Teach Friend your voice`,run:()=>e.openVoice?e.openVoice():e.notify(`Speech is not set up. Run: friend voice setup`)},{name:`camera`,usage:`on|off`,description:`Switch the camera on or off (it only takes a picture when you approve)`,run:t=>{let n=t===`on`||t!==`off`&&!e.cameraOn;if(t&&t!==`on`&&t!==`off`)return e.notify(`Use /camera on or /camera off.`);e.setCamera(n),e.notify(n?`Camera switched on.`:`Camera switched off.`)}},{name:`mute`,description:`Hide everything on the stage (/unmute shows it again)`,run:()=>e.setMuted(!0)},{name:`unmute`,description:`Show the stage again`,run:()=>e.setMuted(!1)},...[`chat`,`tasks`,`music`,`launcher`].map(t=>({name:t,usage:`on|off`,description:{chat:`Show or hide the conversation`,tasks:`Show or hide the schedule and to-dos`,music:`Show or hide the music player`,launcher:`Show or hide the quick-launch buttons`}[t],run:n=>{if(n&&n!==`on`&&n!==`off`)return e.notify(`Use /${t} on or off.`);e.setPanel(t,n?n===`on`:!e.panelOn(t))}})),{name:`view`,usage:`minimal|companion|workspace`,description:`Choose how much is on the screen besides the AI's pictures`,run:t=>{if(t===`minimal`||t===`companion`||t===`workspace`)return e.setView(t);e.notify(t?`Use /view minimal, companion or workspace.`:`The view is ${e.view}. Use /view minimal, companion or workspace.`)}},{name:`layout`,usage:`reset`,description:`Put every panel back where it started`,run:t=>t===`reset`?e.resetLayout():e.notify(`Drag a panel by its title to move it. /layout reset puts them all back.`)},{name:`clear`,description:`Take everything off the screen`,run:e.clearScreen},{name:`status`,description:`What Friend is doing right now`,run:()=>e.notify(e.statusLine())},{name:`logout`,description:`Sign out of Friend on this screen`,run:()=>e.endSession(`logout`)},{name:`lock`,description:`Emergency lock: end every session and stop the agent`,run:()=>e.endSession(`lock`)}];return t.push({name:`help`,description:`List every command with what it does`,run:()=>e.openHelp(t)}),t.sort((e,t)=>e.name.localeCompare(t.name))}function L(e){let t=ne(e);return{commands:t,run:n=>te(t,n,e.notify)}}function re({commands:e,onClose:t}){return(0,p.jsxs)(`div`,{className:`approval help glass`,role:`dialog`,"aria-label":`Commands`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Commands`})}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Type / in the message bar to see these as you type. They run on this screen and never go to the AI. Anything else you type is a message to Friend.`}),(0,p.jsx)(`dl`,{className:`help-list`,children:e.map(e=>(0,p.jsxs)(`div`,{className:`help-row`,children:[(0,p.jsxs)(`dt`,{children:[`/`,e.name,e.usage&&(0,p.jsxs)(`i`,{children:[` `,e.usage]})]}),(0,p.jsx)(`dd`,{children:e.description})]},e.name))}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:t,children:`Close`})})]})}var ie=`(pointer: coarse)`;function ae(){let[e,t]=(0,l.useState)(()=>typeof matchMedia==`function`&&matchMedia(ie).matches);return(0,l.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let e=matchMedia(ie),n=()=>t(e.matches);return e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}var oe=[`chat`,`tasks`,`status`,`clock`,`profile`,`launcher`,`music`],se={minimal:{chat:!1,tasks:!1,status:!1,clock:!1,profile:!1,launcher:!1,music:!1},companion:{chat:!1,tasks:!1,status:!0,clock:!0,profile:!0,launcher:!0,music:!0},workspace:{chat:!0,tasks:!0,status:!0,clock:!0,profile:!0,launcher:!0,music:!0}},ce=`friend.panels`,le=`friend.pos.`;function ue(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function de(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch{}}var R=e=>{let t=ue(le+e);return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:Math.min(Math.max(t.x,0),95),y:Math.min(Math.max(t.y,0),95)}:null},z=(e,t)=>de(le+e,t),B=()=>oe.forEach(e=>z(e,null));function fe(e){let[t,n]=(0,l.useState)(()=>ue(ce)??{}),r=(0,l.useRef)(e);return(0,l.useEffect)(()=>{r.current!==e&&(r.current=e,n({}),de(ce,null))},[e]),{show:{...se[e],...t},toggle:(0,l.useCallback)((t,r)=>n(n=>{let i={...se[e],...n}[t],a={...n,[t]:r??!i};return de(ce,a),a}),[e])}}var pe=(e,t,n)=>Math.min(Math.max(e,t),n),me=2;function he({id:e,label:t,className:n,style:r,wholeBox:i,head:a,testId:o,children:s}){let[c,u]=(0,l.useState)(()=>R(e)),d=(0,l.useRef)(null),f=(0,l.useRef)(null),m=(t,n,r)=>{let i={x:pe(t,0,95),y:pe(n,0,95)};return u(i),r&&z(e,i),i},h={onPointerDown:e=>{let t=d.current;if(!t||e.pointerType===`mouse`&&e.button!==0||e.target.closest(`button, input, textarea, select, a`))return;let n=t.getBoundingClientRect();f.current={dx:e.clientX-n.left,dy:e.clientY-n.top,pointer:e.pointerId};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.stopPropagation()},onPointerMove:e=>{let t=f.current;t&&t.pointer===e.pointerId&&m((e.clientX-t.dx)/window.innerWidth*100,(e.clientY-t.dy)/window.innerHeight*100,!1)},onPointerUp:e=>{let t=f.current;if(!t||t.pointer!==e.pointerId)return;f.current=null;let n=d.current?.getBoundingClientRect();n&&m(n.left/window.innerWidth*100,n.top/window.innerHeight*100,!0)},onPointerCancel:()=>{f.current=null},onDoubleClick:()=>{z(e,null),u(null)},onKeyDown:e=>{let t=d.current?.getBoundingClientRect();if(!t)return;let n=t.left/window.innerWidth*100,r=t.top/window.innerHeight*100,i={ArrowLeft:[-2,0],ArrowRight:[me,0],ArrowUp:[0,-2],ArrowDown:[0,me]}[e.key];i&&(e.preventDefault(),m(n+i[0],r+i[1],!0))},tabIndex:0,role:`group`,"aria-label":`${t}. Drag to move, arrow keys to nudge, double-click to put it back.`},g=c?{left:`${c.x}%`,top:`${c.y}%`,right:`auto`,bottom:`auto`}:{};return(0,p.jsxs)(`div`,{ref:d,"data-panel":e,"data-testid":o,className:`movable ${n??``}`,style:{pointerEvents:`auto`,...r,...g},...i?h:{},children:[a!==void 0&&(0,p.jsx)(`div`,{className:`panel-head`,...i?{}:h,children:a}),s]})}function ge({lines:e,live:t,onSend:n,onClose:r}){let[i,a]=(0,l.useState)(``),o=(0,l.useRef)(null);return(0,l.useEffect)(()=>{o.current?.scrollIntoView?.({block:`end`})},[e,t]),(0,p.jsxs)(he,{id:`chat`,label:`Chat panel`,className:`panel panel-chat glass`,style:{left:`70%`,top:`12%`},head:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`approval-title`,children:`Chat`}),(0,p.jsx)(`button`,{type:`button`,className:`obj-close`,"aria-label":`Close chat`,onClick:r,children:`×`})]}),children:[(0,p.jsxs)(`div`,{className:`chat-lines`,role:`log`,"aria-live":`polite`,children:[e.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing said yet. Talk to me, or type below.`}),e.map((e,t)=>(0,p.jsx)(`p`,{className:`chat-line chat-${e.role}`,children:e.text},t)),(0,p.jsx)(`div`,{ref:o})]}),(0,p.jsxs)(`form`,{className:`chat-form`,onSubmit:e=>{e.preventDefault();let t=i.trim();t&&(n(t),a(``))},children:[(0,p.jsx)(`input`,{"aria-label":`Type to chat`,value:i,placeholder:`Type a message…`,autoComplete:`off`,onChange:e=>a(e.target.value)}),(0,p.jsx)(`button`,{type:`submit`,"aria-label":`Send message`,children:`↵`})]})]})}var V={list:async()=>{let e=await fetch(`/api/tasks`);if(!e.ok)throw Error(e.status===401?`Please sign in again.`:`The request failed (${e.status}).`);return await e.json()}};function _e(e,t){if(e===null)return{text:`to do`,overdue:!1};let n=e-t;if(n<0)return{text:`overdue`,overdue:!0};let r=Math.round(n/6e4);if(r<1)return{text:`now`,overdue:!1};if(r<60)return{text:`in ${r} min`,overdue:!1};let i=new Date(e),a=new Date(t),o=i.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}),s=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),c=Math.round((s(i)-s(a))/864e5);return c===0?{text:`today ${o}`,overdue:!1}:c===1?{text:`tomorrow ${o}`,overdue:!1}:{text:`${i.toLocaleDateString([],{weekday:`short`,day:`numeric`,month:`short`})} ${o}`,overdue:!1}}function ve({source:e=V,busy:t,onClose:n,now:r=Date.now}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),c=(0,l.useRef)(!0),u=(0,l.useCallback)(async()=>{try{let t=await e.list();if(!c.current)return;a(t),s(null)}catch(e){c.current&&s(e.message)}},[e]);(0,l.useEffect)(()=>{c.current=!0,u();let e=setInterval(()=>void u(),15e3);return()=>{c.current=!1,clearInterval(e)}},[u]),(0,l.useEffect)(()=>{t||u()},[t,u]);let d=r();return(0,p.jsx)(he,{id:`tasks`,label:`Schedule panel`,className:`panel panel-tasks glass`,style:{left:`2%`,top:`12%`},head:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`approval-title`,children:`Schedule`}),(0,p.jsx)(`button`,{type:`button`,className:`obj-close`,"aria-label":`Close schedule`,onClick:n,children:`×`})]}),children:(0,p.jsxs)(`div`,{className:`task-body`,children:[o&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:o}),i&&i.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing scheduled. Say "remind me in 30 minutes to…".`}),(0,p.jsx)(`ul`,{className:`task-list`,children:(i??[]).map(e=>{let t=_e(e.dueAt,d);return(0,p.jsxs)(`li`,{className:t.overdue?`overdue`:void 0,children:[(0,p.jsx)(`span`,{className:`task-title`,children:e.title}),(0,p.jsxs)(`span`,{className:`task-due`,children:[t.text,e.repeat?` · ${e.repeat}`:``]})]},e.id)})})]})})}var ye={minimal:`companion`,companion:`workspace`,workspace:`companion`},H=`friend.menuStyle`;function be(){try{return localStorage.getItem(H)===`classic`?`classic`:`orb`}catch{return`orb`}}function U(e){try{localStorage.setItem(H,e)}catch{}}function xe({muted:e,onToggleMute:t,onSignedOut:n,voiceAvailable:r,voiceEnrolled:i,onEnroll:a,onHousehold:o,handsFreeOn:s,onToggleHandsFree:c,assistantName:u,onOrb:f,cameraOn:m,onToggleCamera:h,onPlugins:g,onSettings:_,onConnectors:v,chatOn:y,onToggleChat:b,tasksOn:x,onToggleTasks:S,musicOn:C,onToggleMusic:w,launcherOn:T,onToggleLauncher:E,view:D,onView:O,openRequest:k}){let[A,j]=(0,l.useState)(!1),ee=(0,l.useRef)(null);(0,l.useEffect)(()=>{k&&j(!0)},[k]),(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&j(e=>!e)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let M=async e=>{try{await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`})}catch{}n()},N=()=>{ee.current&&clearTimeout(ee.current),ee.current=null};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{"data-testid":`owner-hotspot`,className:`owner-hotspot`,style:{position:`fixed`,top:0,left:0,width:56,height:56,zIndex:1100},onPointerDown:()=>{N(),ee.current=setTimeout(()=>j(!0),600)},onPointerUp:N,onPointerLeave:N,onPointerCancel:N}),A&&(0,p.jsxs)(`div`,{className:`owner-menu glass`,role:`dialog`,"aria-label":`Owner menu`,style:{position:`fixed`,zIndex:1100},children:[(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:e?`Unmute stage`:`Mute stage`}),r&&c&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!s,onClick:c,title:u?`Say "Hey ${u}" and then your request`:void 0,children:s?`Hands-free: on`:`Hands-free: off`}),h&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!m,onClick:h,children:m?`Camera: on`:`Camera: off`}),b&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!y,onClick:b,children:y?`Chat: on`:`Chat: off`}),S&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!x,onClick:S,children:x?`Schedule: on`:`Schedule: off`}),w&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!C,onClick:w,children:C?`Music: on`:`Music: off`}),E&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!T,onClick:E,children:T?`Quick launch: on`:`Quick launch: off`}),D&&O&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>O(ye[D]),children:`View: ${D}`}),_&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),_()},children:`Settings`}),v&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),v()},children:`Connectors`}),g&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),g()},children:`Plugins`}),r&&a&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),a()},children:i?`Voice settings`:`Enroll my voice`}),r&&i&&o&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),o()},children:`Family voices`}),f&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:f,children:`Orb menu`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>M(`/api/logout`),children:`Log out`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>M(`/api/lock`),children:`Emergency lock`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>j(!1),children:`Close`})]})]})}var Se=[{id:`model`,label:`Model`,note:`Where Friend thinks`},{id:`voice`,label:`Voice`,note:`Speaking and listening`},{id:`look`,label:`Voice presence`,note:`How it looks`},{id:`approvals`,label:`Approvals`,note:`How much it asks`},{id:`trading`,label:`Trading`,note:`What Friend may do with money`},{id:`widgets`,label:`Widgets`,note:`Music, clock, quick launch`},{id:`system`,label:`Startup`,note:`Start with the computer, updates`},{id:`usage`,label:`Usage`,note:`Tokens used, day by day`},{id:`security`,label:`Security`,note:`Password and PIN`}],Ce={model:`brain`,voice:`speaker`,look:`sparkle`,approvals:`shield`,trading:`chart`,widgets:`grid`,system:`launch`,usage:`chart`,security:`lock`};function we(e,t){let n=[],r=e=>e.items.length>0&&n.push(e),i=[];e.voiceAvailable&&e.onToggleHandsFree&&i.push({id:`voice.handsfree`,label:`Hands-free`,icon:`hands`,kind:`toggle`,on:!!e.handsFreeOn,run:e.onToggleHandsFree}),e.voiceAvailable&&e.onEnroll&&i.push({id:`voice.enroll`,label:e.voiceEnrolled?`Voice settings`:`Enroll my voice`,icon:`voiceprint`,kind:`open`,run:e.onEnroll}),e.voiceAvailable&&e.voiceEnrolled&&e.onHousehold&&i.push({id:`voice.family`,label:`Family voices`,icon:`family`,kind:`open`,run:e.onHousehold}),i.push({id:`voice.mute`,label:`Mute stage`,icon:`mute`,kind:`toggle`,on:e.muted,run:e.onToggleMute}),r({id:`voice`,label:`Voice`,icon:`mic`,items:i});let a=[],o=(e,t,n,r,i)=>i&&a.push({id:e,label:t,icon:n,kind:`toggle`,on:!!r,run:i});if(o(`screen.camera`,`Camera`,`camera`,e.cameraOn,e.onToggleCamera),o(`screen.chat`,`Chat`,`chat`,e.chatOn,e.onToggleChat),o(`screen.tasks`,`Schedule`,`calendar`,e.tasksOn,e.onToggleTasks),o(`screen.music`,`Music`,`music`,e.musicOn,e.onToggleMusic),o(`screen.launcher`,`Quick launch`,`launch`,e.launcherOn,e.onToggleLauncher),e.view&&e.onView){let{view:t,onView:n}=e;a.push({id:`screen.view`,label:`View: ${t}`,icon:`eye`,kind:`action`,run:()=>n(ye[t])})}if(r({id:`screen`,label:`Screen`,icon:`screen`,items:a}),e.onSettings){let t=e.onSettings;r({id:`settings`,label:`Settings`,icon:`gear`,items:Se.map(e=>({id:`settings.${e.id}`,label:e.label,icon:Ce[e.id]??`gear`,kind:`open`,run:()=>t(e.id)}))})}let s=[];return e.onPlugins&&s.push({id:`connect.plugins`,label:`Plugins`,icon:`plug`,kind:`open`,run:e.onPlugins}),e.onConnectors&&s.push({id:`connect.connectors`,label:`Connectors`,icon:`link`,kind:`open`,run:e.onConnectors}),r({id:`connect`,label:`Connect`,icon:`plug`,items:s}),r({id:`account`,label:`Account`,icon:`user`,items:[{id:`account.classic`,label:`Classic menu`,icon:`list`,kind:`action`,run:t.classic},{id:`account.logout`,label:`Log out`,icon:`logout`,kind:`action`,run:t.logout},{id:`account.lock`,label:`Emergency lock`,icon:`alert`,kind:`action`,danger:!0,run:t.lock}]}),n}var Te=(e,t,n,r)=>{let i=r*Math.PI/180;return{x:e+n*Math.sin(i),y:t-n*Math.cos(i)}};function Ee(e,t=4){let n=360/e;return Array.from({length:e},(e,r)=>{let i=r*n;return{start:i-n/2+t/2,end:i+n/2-t/2,mid:i}})}function De(e,t,n=3,r=36,i=330){let a=Math.min(r,(i-(t-1)*n)/t),o=e-(t*a+(t-1)*n)/2;return Array.from({length:t},(e,t)=>{let r=o+t*(a+n);return{start:r,end:r+a,mid:r+a/2}})}function Oe(e,t,n,r,i,a){let o=+(a-i>180),s=e=>Number(e.toFixed(2)),c=(n,r)=>{let{x:i,y:a}=Te(e,t,n,r);return`${s(i)} ${s(a)}`};return`M ${c(r,i)} A ${r} ${r} 0 ${o} 1 ${c(r,a)} L ${c(n,a)} A ${n} ${n} 0 ${o} 0 ${c(n,i)} Z`}var ke={open:!1,category:null,hover:null};function Ae(e,t){switch(t.type){case`open`:return{open:!0,category:null,hover:null};case`close`:return ke;case`toggle`:return e.open?ke:{open:!0,category:null,hover:null};case`escape`:return e.open?Ae(e,{type:`back`}):{open:!0,category:null,hover:null};case`back`:return e.category?{...e,category:null,hover:null}:ke;case`category`:return e.open?{...e,category:e.category===t.id?null:t.id,hover:null}:e;case`hover`:return e.open?{...e,hover:t.id}:e}}function je(e,t,n,r){if(e.open){if(!e.hover)return e.category&&t.find(t=>t.id===e.category)?.label.toUpperCase()||`SELECT`;let n=t.find(t=>t.id===e.hover),r=t.flatMap(e=>e.items).find(t=>t.id===e.hover);return(n?.label??r?.label??`SELECT`).toUpperCase()}return n===`listening`?`LISTENING`:r||n===`transcribing`||n===`speaking`?`BUSY`:`MARK II`}var Me=(e,t,n)=>{let r=t=>{let{x:n,y:r}=Te(0,0,e,t);return`${n.toFixed(2)} ${r.toFixed(2)}`};return`M ${r(t)} A ${e} ${e} 0 ${+(n-t>180)} 1 ${r(n)}`};function Ne({name:e,caption:t,state:n,onClick:r}){let i=(e.trim()||`Friend`).toUpperCase(),a=Math.max(9,Math.min(15,90/Math.max(i.length,6)));return(0,p.jsxs)(`g`,{className:`orb-core orb-${n}`,role:`button`,tabIndex:0,"aria-label":n===`menu-open`||n===`hover`?`Close the menu`:`Open the menu`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r())},children:[(0,p.jsx)(`circle`,{className:`orb-halo`,r:62}),(0,p.jsx)(`circle`,{className:`orb-disc`,r:52,fill:`url(#orb-disc)`}),(0,p.jsx)(`circle`,{className:`orb-ticks`,r:55}),(0,p.jsx)(`circle`,{className:`orb-ring`,r:46}),(0,p.jsx)(`path`,{className:`orb-gauge`,d:Me(50,-160,-100)}),(0,p.jsx)(`path`,{className:`orb-segments`,d:Me(50,110,250)}),(0,p.jsx)(`text`,{className:`orb-name`,y:-1,fontSize:a,textAnchor:`middle`,children:i}),(0,p.jsx)(`text`,{className:`orb-caption`,y:14,textAnchor:`middle`,children:t})]})}var Pe={mic:`M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3zM6 11a6 6 0 0 0 12 0M12 17v4M9 21h6`,hands:`M3 12h2M7 8v8M11 4v16M15 8v8M19 10v4`,voiceprint:`M12 4a8 8 0 0 0-8 8M12 8a4 4 0 0 0-4 4v2M12 12v6M16 12a4 4 0 0 0-4-4M20 12a8 8 0 0 0-8-8M16 16v2`,family:`M8 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM2 20c0-3 2.5-5 6-5s6 2 6 5M17 10a2.5 2.5 0 1 0 0-5M16 15c3 0 6 1.5 6 5`,mute:`M4 9v6h4l5 4V5L8 9zM17 9l4 6M21 9l-4 6`,screen:`M3 5h18v11H3zM8 20h8M12 16v4`,camera:`M4 8h4l2-3h4l2 3h4v11H4zM12 17a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z`,chat:`M4 5h16v11H9l-5 4z`,calendar:`M4 6h16v14H4zM4 10h16M8 3v4M16 3v4`,music:`M9 18V6l10-2v12M9 18a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM19 16a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z`,launch:`M12 3c3 2 5 5 5 9l-3 3h-4l-3-3c0-4 2-7 5-9zM9 18l-3 3M15 18l3 3`,eye:`M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,gear:`M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M18.4 5.6l-2.1 2.1M7.7 16.3l-2.1 2.1`,brain:`M7 7h10v10H7zM10 10h4v4h-4zM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4`,speaker:`M4 9v6h4l5 4V5L8 9zM16 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11`,sparkle:`M12 3l2 6 6 2-6 2-2 6-2-6-6-2 6-2z`,shield:`M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z`,chart:`M4 19V5M4 19h16M8 15l4-4 3 3 5-6`,grid:`M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z`,lock:`M6 11h12v9H6zM8 11V8a4 4 0 0 1 8 0v3`,plug:`M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4`,link:`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`,user:`M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21c0-4 3.5-6 8-6s8 2 8 6`,list:`M5 6h14M5 12h14M5 18h14`,logout:`M10 4H4v16h6M15 8l4 4-4 4M19 12H9`,alert:`M12 3l10 18H2zM12 10v5M12 18v.01`};function Fe({name:e,x:t,y:n,size:r=20}){return(0,p.jsx)(`g`,{className:`orb-icon`,transform:`translate(${t-r/2} ${n-r/2}) scale(${r/24})`,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:Pe[e]})})}var Ie=[72,128],Le=[138,176],Re=186,ze=e=>(e[0]+e[1])/2;function Be(e,t){let{x:n,y:r}=Te(0,0,e,t),i=Math.sin(t*Math.PI/180),a=Math.cos(t*Math.PI/180),o=i>.35?`start`:i<-.35?`end`:`middle`;return{x:n+(o===`start`?4:o===`end`?-4:0),y:r,anchor:o,dy:Math.abs(i)>.35?`0.35em`:a>0?`-0.4em`:`1em`}}function Ve(e,t,n){if(e.key===`Enter`||e.key===` `)return e.preventDefault(),e.stopPropagation(),n();let r=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(!r)return;e.preventDefault();let i=[...e.currentTarget.closest(`svg`)?.querySelectorAll(`[data-ring="${t}"]`)??[]];i[(i.indexOf(e.currentTarget)+r+i.length)%i.length]?.focus()}function He({categories:e,state:t,onCategory:n,onHover:r,onPick:i}){let a=Ee(e.length),o=e.findIndex(e=>e.id===t.category),s=o>=0?e[o]:null,c=s?De(a[o].mid,s.items.length):[],l=e=>({onPointerEnter:()=>r(e),onPointerLeave:()=>r(null),onFocus:()=>r(e),onBlur:()=>r(null)});return(0,p.jsxs)(`g`,{className:`orb-rings`,children:[(0,p.jsx)(`g`,{className:`orb-ring1`,children:e.map((e,r)=>{let i=a[r],o=Te(0,0,ze(Ie),i.mid),c=Be(Ie[1]+8,i.mid),u=e.id===t.category;return(0,p.jsxs)(`g`,{className:`orb-arc${u?` is-open`:``}${t.hover===e.id?` is-hover`:``}`,"data-ring":1,"data-id":e.id,role:`button`,tabIndex:0,"aria-label":e.label,"aria-expanded":u,style:{animationDelay:`${r*30}ms`},onClick:()=>n(e.id),onKeyDown:t=>Ve(t,1,()=>n(e.id)),...l(e.id),children:[(0,p.jsx)(`path`,{d:Oe(0,0,Ie[0],Ie[1],i.start,i.end)}),(0,p.jsx)(Fe,{name:e.icon,x:o.x,y:o.y,size:24}),!s&&(0,p.jsx)(`text`,{className:`orb-arc-label`,x:c.x,y:c.y,dy:c.dy,textAnchor:c.anchor,children:e.label})]},e.id)})},`ring1`),s&&(0,p.jsx)(`g`,{className:`orb-ring2`,children:s.items.map((e,n)=>{let r=c[n],a=Te(0,0,ze(Le),r.mid),o=Be(Re,r.mid);return(0,p.jsxs)(`g`,{className:`orb-arc orb-sub${e.on?` is-on`:``}${e.danger?` is-danger`:``}${t.hover===e.id?` is-hover`:``}`,"data-ring":2,"data-id":e.id,role:`button`,tabIndex:0,"aria-label":e.label,...e.kind===`toggle`?{"aria-pressed":!!e.on}:{},style:{animationDelay:`${n*25}ms`},onClick:()=>i(e),onKeyDown:t=>Ve(t,2,()=>i(e)),...l(e.id),children:[(0,p.jsx)(`path`,{d:Oe(0,0,Le[0],Le[1],r.start,r.end)}),(0,p.jsx)(Fe,{name:e.icon,x:a.x,y:a.y,size:17}),(0,p.jsxs)(`text`,{className:`orb-arc-label`,x:o.x,y:o.y,dy:o.dy,textAnchor:o.anchor,children:[e.label,e.kind===`toggle`?e.on?` · ON`:` · OFF`:``]})]},e.id)})},`ring2-${s.id}`)]})}var Ue={open:!1,category:null,hover:null};function We(e){let{onSignedOut:t,onClassic:n,openRequest:r,assistantName:i=``,voiceMode:a=`idle`,busy:o=!1}=e,[s,c]=(0,l.useReducer)(Ae,Ue),u=(0,l.useRef)(null),d=(0,l.useRef)(null);(0,l.useEffect)(()=>{r&&c({type:`open`})},[r]),(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&c({type:`escape`})};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,l.useEffect)(()=>{s.open&&!s.category&&d.current?.querySelector(`.orb-core`)?.focus()},[s.open,s.category]);let f=async e=>{try{await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`})}catch{}t()},m=()=>{u.current&&clearTimeout(u.current),u.current=null},h=we(e,{logout:()=>void f(`/api/logout`),lock:()=>void f(`/api/lock`),classic:n}),g=(0,l.useMemo)(()=>je(s,h,a,o),[s,h,a,o]),_=s.open?s.hover?`hover`:`menu-open`:o?`busy`:`idle`;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{"data-testid":`owner-hotspot`,className:`owner-hotspot`,style:{position:`fixed`,top:0,left:0,width:56,height:56,zIndex:1100},onPointerDown:()=>{m(),u.current=setTimeout(()=>c({type:`open`}),600)},onPointerUp:m,onPointerLeave:m,onPointerCancel:m}),s.open&&(0,p.jsxs)(`div`,{className:`orb-layer`,role:`dialog`,"aria-label":`Menu`,style:{position:`fixed`,zIndex:1100},children:[(0,p.jsx)(`div`,{className:`orb-backdrop`,onPointerDown:()=>c({type:`close`})}),(0,p.jsxs)(`svg`,{ref:d,className:`orb-svg`,viewBox:`-300 -300 600 600`,"aria-label":`Menu`,children:[(0,p.jsx)(`defs`,{children:(0,p.jsxs)(`radialGradient`,{id:`orb-disc`,cx:`50%`,cy:`45%`,r:`60%`,children:[(0,p.jsx)(`stop`,{offset:`0%`,stopColor:`#0d2530`}),(0,p.jsx)(`stop`,{offset:`100%`,stopColor:`#03090d`})]})}),(0,p.jsx)(He,{categories:h,state:s,onCategory:e=>c({type:`category`,id:e}),onHover:e=>c({type:`hover`,id:e}),onPick:e=>{e.run(),e.kind!==`toggle`&&c({type:`close`})}}),(0,p.jsx)(Ne,{name:i,caption:g,state:_,onClick:()=>c({type:`close`})})]})]})]})}var Ge=2e4,Ke=({letter:e,tone:t})=>(0,p.jsxs)(`svg`,{className:`profile-shield hud-emblem-svg ${t}`,width:`64`,height:`64`,viewBox:`0 0 64 64`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{className:`hud-ring-turn`,cx:`32`,cy:`32`,r:`30`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.55`,strokeWidth:`1.4`,strokeDasharray:`2 5`}),(0,p.jsx)(`circle`,{className:`hud-ring-chase`,cx:`32`,cy:`32`,r:`26.500`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.200`,strokeLinecap:`round`,strokeDasharray:`14 150`}),(0,p.jsx)(`circle`,{cx:`32`,cy:`32`,r:`22`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1`}),(0,p.jsx)(`path`,{d:`M32 15 44 19.500v9c0 7.200-4.800 13.300-12 15.500-7.200-2.200-12-8.300-12-15.500v-9z`,fill:`currentColor`,fillOpacity:`0.16`,stroke:`currentColor`,strokeWidth:`1.500`,strokeLinejoin:`round`}),(0,p.jsx)(`text`,{x:`32`,y:`36`,textAnchor:`middle`,fontSize:`13`,fontWeight:`600`,fill:`currentColor`,children:e})]});function qe({ownerName:e,speaker:t,assistantName:n=``,terminalLabel:r=`TERMINAL`,busy:i=!1,listening:a=!1}){let[o,s]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!t)return;s(!0);let e=setTimeout(()=>s(!1),Ge);return()=>clearTimeout(e)},[t?.seq]);let c=e.trim()||`Owner`,u=o&&t&&t.trust===`member`&&t.name?{name:t.name,note:`family`,tone:`member`}:o&&t?.trust===`guest`?{name:`Guest`,note:`voice not recognized`,tone:`guest`}:{name:c,note:`signed in`,tone:`owner`},d=(u.tone===`guest`?`?`:u.name.trim().charAt(0)||`?`).toUpperCase(),f=[n.trim(),r.trim()].filter(Boolean).join(` `);return(0,p.jsxs)(he,{id:`profile`,label:`Profile`,wholeBox:!0,testId:`profile`,className:`hud hud-profile ${u.tone}${o?` speaking`:``}${i?` busy`:``}${a?` listening`:``}`,children:[(0,p.jsx)(`span`,{className:`hud-emblem`,children:(0,p.jsx)(Ke,{letter:d,tone:u.tone})},t?.seq??0),(0,p.jsxs)(`span`,{className:`hud-tag hud-cut`,children:[f&&(0,p.jsx)(`small`,{className:`hud-tag-top`,children:f}),(0,p.jsx)(`b`,{children:u.name}),(0,p.jsx)(`small`,{children:u.note})]})]})}function Je({stream:e}){let t=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let n=t.current;if(n)return n.srcObject=e,Promise.resolve(n.play?.()).catch(()=>{}),()=>{n.srcObject=null}},[e]),(0,p.jsxs)(`div`,{className:`camera-indicator glass`,role:`status`,style:{pointerEvents:`none`},children:[(0,p.jsx)(`video`,{ref:t,muted:!0,playsInline:!0,autoPlay:!0,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Camera on`})]})}function Ye({alert:e,dispatch:t}){return(0,l.useEffect)(()=>{let n=setTimeout(()=>t({type:`alert.dismiss`,id:e.id}),5e3);return()=>clearTimeout(n)},[e.id,t]),(0,p.jsx)(`div`,{className:`toast toast-${e.level}`,role:`status`,style:{pointerEvents:`auto`},children:e.text})}function Xe({alerts:e,dispatch:t}){return e.length===0?null:(0,p.jsx)(`div`,{className:`toasts`,children:e.map(e=>(0,p.jsx)(Ye,{alert:e,dispatch:t},e.id))})}function Ze({approval:e,send:t}){let[n,r]=(0,l.useState)(``),i=i=>{if(i!==`deny`&&e.needsPin){t({type:`approval.respond`,id:e.id,decision:i,pin:n}),r(``);return}t({type:`approval.respond`,id:e.id,decision:i})},a=!e.needsPin||n.length>=6;return(0,p.jsxs)(`div`,{className:`approval glass`,role:`alertdialog`,"aria-label":`Approval needed`,style:{pointerEvents:`auto`},children:[(0,p.jsxs)(`div`,{className:`approval-head`,children:[(0,p.jsx)(`span`,{className:`tier tier-${e.tier}`,children:e.tier}),(0,p.jsx)(`span`,{className:`approval-title`,children:`Approval needed`})]}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`approval-summary`,style:{whiteSpace:`pre-wrap`},children:e.summary}),e.needsPin&&(0,p.jsx)(T,{pin:n,onChange:r,onSubmit:()=>a&&i(`approve`)}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!a,onClick:()=>i(`approve`),children:`Approve`}),e.tier===`T2`&&!e.needsPin&&e.tool!==`camera.snap`&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>i(`approve_always`),children:`Always allow`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>i(`deny`),children:`Deny`})]})]})}function Qe({challenge:e,send:t,dispatch:n}){let[r,i]=(0,l.useState)(``),a=()=>{t({type:`voice.confirm`,id:e.id,pin:r}),i(``)};return(0,p.jsxs)(`div`,{className:`approval challenge glass`,role:`alertdialog`,"aria-label":`Was that you?`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Was that you?`})}),(0,p.jsx)(`p`,{className:`auth-note`,children:`I heard this but I am not sure it was your voice. Enter your PIN to let it run.`}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`challenge-text`,style:{whiteSpace:`pre-wrap`},children:e.text}),(0,p.jsx)(T,{pin:r,onChange:i,onSubmit:a}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:r.length<6,onClick:a,children:`Confirm`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>{t({type:`voice.cancel`,id:e.id}),n({type:`challenge.dismiss`,id:e.id})},children:`Dismiss`})]})]})}var $e={hour12:!0,seconds:!1,locale:``},et=({text:e})=>(0,p.jsx)(p.Fragment,{children:[...e].map((e,t)=>(0,p.jsx)(`span`,{className:`hud-digit`,children:e},`${t}-${e}`))});function tt({now:e=()=>new Date,clock:t=$e}){let[n,r]=(0,l.useState)(e);(0,l.useEffect)(()=>{let n=setInterval(()=>r(e()),t.seconds?1e3:5e3);return()=>clearInterval(n)},[e,t.seconds]);let i=t.locale||void 0,a=new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,...t.seconds?{second:`2-digit`}:{},hour12:t.hour12}).formatToParts(n),o=e=>a.find(t=>t.type===e)?.value??``,s=o(`hour`),c=o(`minute`),u=o(`second`),d=o(`dayPeriod`),f=n.toLocaleDateString(i,{month:`long`}),m=n.toLocaleDateString(i,{weekday:`long`});return(0,p.jsx)(he,{id:`clock`,label:`Clock`,wholeBox:!0,testId:`clock`,className:`hud hud-clock`,children:(0,p.jsxs)(`time`,{dateTime:n.toISOString(),children:[(0,p.jsxs)(`span`,{className:`hud-date`,children:[(0,p.jsx)(`b`,{className:`hud-day`,children:(0,p.jsx)(et,{text:String(n.getDate()).padStart(2,`0`)})}),(0,p.jsx)(`span`,{className:`hud-month`,children:f}),(0,p.jsx)(`small`,{className:`hud-weekday`,children:m})]}),(0,p.jsxs)(`span`,{className:`hud-time-block`,children:[(0,p.jsxs)(`span`,{className:`hud-clock-time`,children:[(0,p.jsx)(et,{text:s}),(0,p.jsx)(`i`,{className:`hud-colon`,children:`:`}),(0,p.jsx)(et,{text:c}),t.seconds&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`i`,{className:`hud-colon`,children:`:`}),(0,p.jsx)(et,{text:u})]}),d&&(0,p.jsx)(`small`,{className:`hud-period`,children:d})]}),(0,p.jsx)(`span`,{className:`hud-line`,children:(0,p.jsx)(`i`,{className:`hud-dot`})})]})]})})}function nt(e){return e.connection===`unauthorized`?{kind:`offline`,text:`Signed out`}:e.connection===`elsewhere`?{kind:`offline`,text:`Open in another window`}:e.connection===`open`?e.approval?{kind:`waiting`,text:`Waiting for your approval`}:e.voiceMode===`listening`?{kind:`listening`,text:`Listening`}:e.voiceMode===`transcribing`?{kind:`working`,text:`Understanding what you said`}:e.busy?{kind:e.activity===`Answering`?`speaking`:`working`,text:`${e.activity??`Thinking`}…`}:e.voiceMode===`speaking`?{kind:`speaking`,text:`Speaking`}:{kind:`idle`,text:e.deviceOnline?`Ready`:`Ready (no device connected)`}:{kind:`offline`,text:`Reconnecting…`}}function rt(e){let{kind:t,text:n}=nt(e);return(0,p.jsxs)(he,{id:`status`,label:`Status line`,wholeBox:!0,testId:`status-badge`,className:`status-badge status-${t}`,children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),(0,p.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:n})]})}function it({mode:e}){return e!==`listening`&&e!==`transcribing`?null:(0,p.jsxs)(`div`,{className:`mic-indicator mic-${e}`,role:`status`,"aria-label":`Microphone`,children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),e===`listening`?`Listening…`:`Transcribing…`]})}function at({approval:e,challenge:t,cameraStream:n,children:r,alerts:i,connection:a,deviceOnline:o,voiceMode:s,busy:c=!1,activity:l=null,showStatus:u=!0,showClock:d=!0,profile:f=null,assistantName:m=``,hud:h=null,send:g,dispatch:_}){return(0,p.jsxs)(`div`,{"data-overlay":!0,"data-hud-anim":h?.animations??`full`,className:`overlay`,style:{position:`fixed`,inset:0,zIndex:1e3,pointerEvents:`none`},children:[u&&(0,p.jsx)(rt,{connection:a,deviceOnline:o,approval:e,voiceMode:s,busy:c,activity:l}),d&&(0,p.jsx)(tt,{...h?{clock:h.clock}:{}}),f&&(0,p.jsx)(qe,{ownerName:f.ownerName,speaker:f.speaker,assistantName:m,terminalLabel:h?.terminalLabel??`TERMINAL`,busy:c,listening:s===`listening`}),(0,p.jsx)(it,{mode:s}),n&&(0,p.jsx)(Je,{stream:n}),(0,p.jsx)(Xe,{alerts:i,dispatch:_}),t&&!e&&(0,p.jsx)(Qe,{challenge:t,send:g,dispatch:_},t.id),e&&(0,p.jsx)(Ze,{approval:e,send:g}),r]})}async function ot(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var st=e=>({method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pin:e})}),ct={status:()=>ot(`/api/channels`),link:e=>ot(`/api/channels/telegram/link`,st(e)),unlink:async e=>void await ot(`/api/channels/telegram/unlink`,st(e))};function lt({view:e,secret:t,setSecret:n,api:r=ct}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(!1),y=(0,l.useRef)(!0),b=(0,l.useCallback)(()=>{r.status().then(e=>y.current&&a(e)).catch(()=>{})},[r]);(0,l.useEffect)(()=>{y.current=!0,b();let e=setInterval(b,4e3);return()=>{y.current=!1,clearInterval(e)}},[b]);let x=i?.telegram,S=!_&&e.linked&&(!x||x.linked),C=async e=>{if(c.length<6)return g(`Type your PIN first.`);m(!0),g(null);try{e===`link`?s(await r.link(c)):(await r.unlink(c),s(null),v(!0)),u(``),b()}catch(e){g(e.message)}finally{m(!1)}};return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Open Telegram, find `,(0,p.jsx)(`b`,{children:`@BotFather`}),`, send `,(0,p.jsx)(`code`,{children:`/newbot`}),`, and paste the token it gives you here.`]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Bot token`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,value:t,placeholder:e.tokenSet?`A token is saved. Type to replace it.`:`123456789:ABC…`,onChange:e=>n(e.target.value),style:d})]}),x&&e.enabled&&(0,p.jsxs)(`p`,{className:x.state===`error`?`auth-error`:`auth-note`,role:x.state===`error`?`alert`:`status`,children:[{off:`Off`,connecting:`Connecting…`,online:`Connected`,error:`Not working`}[x.state],x.bot?` as @${x.bot}`:``,x.detail?`: ${x.detail}`:``]}),e.tokenSet&&e.enabled&&(0,p.jsxs)(`div`,{className:`channels-link`,children:[S?(0,p.jsx)(`p`,{className:`auth-note`,children:`Your Telegram is linked. Messages from it are answered like on your PC, and anything risky is still decided here.`}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Not linked yet. Get a link code, then send it to your bot.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`PIN (to link or unlink)`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:c,onChange:e=>u(e.target.value.replace(/\D/g,``)),style:d})]}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[!S&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f,onClick:()=>void C(`link`),children:`Get a link code`}),S&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f,onClick:()=>void C(`unlink`),children:`Unlink`})]}),o&&!S&&(0,p.jsxs)(`p`,{className:`auth-note`,role:`status`,children:[`In Telegram, open `,o.bot?`@${o.bot}`:`your bot`,` and send: `,(0,p.jsxs)(`code`,{children:[`/link `,o.code]}),` (works for `,Math.round(o.expiresInSeconds/60),` minutes).`]})]}),!e.enabled&&e.tokenSet&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Switch the plugin on (Turn on) to connect, then come back here to link your Telegram.`}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h})]})}function ut({view:e,setView:t,secret:n,setSecret:r,webhook:i}){let a=n=>t({...e,...n});return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Both use one Twilio account. Messages come in through an address Twilio calls, so Friend needs a public address (`,(0,p.jsx)(`code`,{children:`friend config set publicUrl https://…`}),`).`]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Account SID`}),(0,p.jsx)(`input`,{value:e.accountSid,autoComplete:`off`,onChange:e=>a({accountSid:e.target.value}),placeholder:`AC…`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Auth token`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,placeholder:e.tokenSet?`A token is saved. Type to replace it.`:``,onChange:e=>r(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your SMS number (the Twilio number)`}),(0,p.jsx)(`input`,{value:e.smsFrom,inputMode:`tel`,onChange:e=>a({smsFrom:e.target.value}),placeholder:`+14155550100`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your WhatsApp number (the Twilio sender)`}),(0,p.jsx)(`input`,{value:e.whatsappFrom,inputMode:`tel`,onChange:e=>a({whatsappFrom:e.target.value}),placeholder:`+14155550101`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your own phone number`}),(0,p.jsx)(`input`,{value:e.ownerNumber,inputMode:`tel`,onChange:e=>a({ownerNumber:e.target.value}),placeholder:`+919800000000`,style:d})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Only messages from this number are answered as you. Everyone else's go to the inbox as untrusted mail.`}),(0,p.jsx)(`p`,{className:`auth-note`,children:i?(0,p.jsxs)(p.Fragment,{children:[`In Twilio, set the "when a message comes in" address (HTTP POST) to `,(0,p.jsx)(`code`,{children:i})]}):`No public address is set yet, so Twilio cannot reach Friend.`})]})}var dt={style:`sphere`,accent:`#3fd8ff`,intensity:.6,size:1,reactivity:.7,ambient:!0,captions:!0,captionSize:`medium`,aiMayChange:!0},ft=new Set([`view`,`look`,`ownerName`]),pt=e=>Object.keys(e).some(e=>!ft.has(e));async function mt(e={}){let t;try{t=await fetch(`/api/settings`,e)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!t.ok){let e=``;try{e=(await t.json()).error??``}catch{}throw Error(e||(t.status===401?`Please sign in again.`:t.status===429?`Too many attempts. Wait a moment.`:`The request failed (${t.status}).`))}return await t.json()}var ht={get:()=>mt(),save:(e,t)=>mt({method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({...t?{pin:t}:{},settings:e})})};async function gt(e){let t;try{t=await fetch(`/api/voice/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({voice:e})})}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!t.ok){let e=``;try{e=(await t.json()).error??``}catch{}throw Error(e||`The request failed (${t.status}).`)}let n=URL.createObjectURL(await t.blob()),r=new Audio(n);r.addEventListener(`ended`,()=>URL.revokeObjectURL(n),{once:!0});try{await r.play()}catch{throw URL.revokeObjectURL(n),Error(`The browser blocked the sound. Click anywhere on the page, then try again.`)}}function _t(e,t,n,r=``){let i={};t.provider!==e.provider&&(i.provider=t.provider),t.model!==e.model&&(i.model=t.model),t.view!==e.view&&(i.view=t.view),(t.ownerName??``)!==(e.ownerName??``)&&(i.ownerName=t.ownerName??``),(t.approvals??`manual`)!==(e.approvals??`manual`)&&(i.approvals=t.approvals??`manual`),n.trim()&&(i.apiKey=n.trim());for(let n of[`ollama`,`claudeCode`,`voice`,`look`,`updates`]){if(!t[n]||!e[n])continue;let r={};for(let i of Object.keys(t[n])){let a=t[n][i];a!==e[n][i]&&(r[i]=n===`voice`&&i===`language`?a??``:a)}Object.keys(r).length&&(i[n]=r)}if(e.music&&t.music){let n={};for(let r of Object.keys(t.music))JSON.stringify(t.music[r])!==JSON.stringify(e.music[r])&&(n[r]=t.music[r]);Object.keys(n).length&&(i.music=n)}if(e.hud&&t.hud){let n={};t.hud.terminalLabel!==e.hud.terminalLabel&&(n.terminalLabel=t.hud.terminalLabel),t.hud.animations!==e.hud.animations&&(n.animations=t.hud.animations);let r={};for(let n of Object.keys(t.hud.clock))t.hud.clock[n]!==e.hud.clock[n]&&(r[n]=t.hud.clock[n]);Object.keys(r).length&&(n.clock=r),JSON.stringify(t.hud.launcher)!==JSON.stringify(e.hud.launcher)&&(n.launcher=t.hud.launcher),Object.keys(n).length&&(i.hud=n)}if(e.openai&&t.openai){let n={};for(let r of[`url`,`model`,`vision`])t.openai[r]!==e.openai[r]&&(n[r]=t.openai[r]);r.trim()&&(n.apiKey=r.trim()),Object.keys(n).length&&(i.openai=n)}return i}function vt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function yt(e,t=`|`){return e.map(e=>Wt(e)).join(t)}function bt(e,t){return typeof t==`bigint`?t.toString():t}var xt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function St(e){return new xt(e)}function Ct(e){return e==null}function wt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Tt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Et(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Dt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ot(e){return Dt(e._zod.def)??e._zod.def.shape}function kt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Et(this,t,e),e},enumerable:!0,configurable:!0})}function At(e,t,n){t in e?Et(e,t,n):e[t]=n}function jt(e,t,n,r){let i=Ot(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?kt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):At(e,a,r?r(n.value,a):n.value))}}function Mt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?kt(e,n,()=>t[n]):At(e,n,r.value))}}function Nt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Pt(e){return JSON.stringify(e)}function Ft(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var It=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Rt=St(()=>{if(Pn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function zt(e){if(Lt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Lt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Bt(e){return zt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Vt=new Set([`string`,`number`,`symbol`]);function Ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ut(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function W(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Wt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Gt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Kt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},qt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Jt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return jt(i,e,Yt(e,t)),Ut(e,Nt(n,{shape:i,checks:[]}))}function Yt(e,t){let n=Ot(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Yt(e,t)),a={};return jt(a,e,Reflect.ownKeys(Ot(e)).filter(e=>!i.has(e))),Ut(e,Nt(n,{shape:a,checks:[]}))}function Zt(e,t){if(!zt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ot(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ut(e,Nt(e._zod.def,{shape:Qt(e,t)}))}function Qt(e,t){let n={};return jt(n,e,Reflect.ownKeys(Ot(e))),Mt(n,t),n}function $t(e,t){if(!zt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ut(e,Nt(e._zod.def,{shape:Qt(e,t)}))}function en(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return jt(n,e,Reflect.ownKeys(Ot(e))),jt(n,t,Reflect.ownKeys(Ot(t))),Ut(e,Nt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function tn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Yt(t,n)):void 0,o={};return jt(o,t,Reflect.ownKeys(Ot(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Ut(t,Nt(t._zod.def,{shape:o,checks:[]}))}function nn(e,t,n){let r=n?new Set(Yt(t,n)):void 0,i={};return jt(i,t,Reflect.ownKeys(Ot(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Ut(t,Nt(t._zod.def,{shape:i}))}function rn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function an(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function on(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function sn(e){return typeof e==`string`?e:e?.message}function cn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ln(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:sn(e.inst?._zod.def?.error?.(e))??sn(a?.(e))??sn(t?.error?.(e))??sn(n.customError?.(e))??sn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var un=/[\uD800-\uDBFF]/;function dn(e){let t=e.length;if(!un.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function fn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function pn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function mn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function hn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):yn(e,n,r.value)}}function gn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function _n(e,t,n){return gn(e,t,n,!1)}function vn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return gn(this,n,r(this))},set(e){gn(this,n,e)}})}return t}function yn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:gn(this,t,n.bind(this))},set(e){gn(this,t,e)}})}function bn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var xn,Sn=!1,Cn={configurable:!0,get(){Sn=!0}};function wn(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&xn!==e._zod){xn=void 0;return}xn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Cn);let e=Sn;Sn=!1;try{let r=n(this);return Sn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Sn||=e,r}catch(n){throw delete this[t],Sn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Tn(e,t,n,r){let i=bn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var En=`~constantCatch`;function Dn(e){let t=()=>e;return t[En]=!0,t}var On,kn={value:void 0,enumerable:!1},An=`captureStackTrace`in Error?Error:null;function jn(e){let t=An;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return An=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function G(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){kn.value=new a(r);try{Object.defineProperty(n,"_zod",kn)}finally{kn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),hn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?jn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Mn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Nn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(On=globalThis).__zod_globalConfig??(On.__zod_globalConfig={});var Pn=globalThis.__zod_globalConfig;function Fn(e){return e&&Object.assign(Pn,e),Pn}function In(){let e=this._zod;return e.message??=JSON.stringify(e.def,bt,2),e.message}function Ln(e){this._zod.message=e}var Rn={get:In,set:Ln,enumerable:!0,configurable:!0},zn={value:void 0,enumerable:!1},Bn=new WeakSet([Object.prototype,Error.prototype]),Vn=(e,t)=>{e.name=`$ZodError`,zn.value=t,Object.defineProperty(e,"issues",zn),zn.value=void 0,Object.defineProperty(e,"message",Rn);let n=Object.getPrototypeOf(e);Bn.has(n)||(Bn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Hn=G(`$ZodError`,Vn);G(`$ZodError`,Vn,void 0,{Parent:Error});function Un(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Wn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Un(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Gn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Kn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Mn;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ln(e,o,Fn())));throw It(n,a?.callee??t),n}return s.value};return t},Jn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ln(e,o,Fn())));throw It(n,a?.callee??t),n}return s.value};return t},Yn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Mn;return a.issues.length?Xn(e,a.issues,i):{success:!0,data:a.value}};function Xn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ln(e,n,Fn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Zn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Xn(e,a.issues,i):{success:!0,data:a.value}},Qn=Symbol.for(`zod.compile.invalid`),$n=Symbol.for(`zod.compile.fallback`),er=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Qn)return!0;if(r.definite===!0&&n===void 0)return!1}return tr(e,t,n)});function tr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[$n]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Mn;return a.issues.length===0}var nr=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},rr=e=>{let t=qn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Kn(n,a))};return n},ir=e=>{let t=qn(e),n=(e,r,i,a)=>t(e,r,i,Kn(n,a));return n},ar=e=>{let t=Jn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Kn(n,a))};return n},or=e=>{let t=Jn(e),n=async(e,r,i,a)=>await t(e,r,i,Kn(n,a));return n},sr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Yn(e)(t,n,i)},cr=e=>(t,n,r)=>Yn(e)(t,n,r),lr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Zn(e)(t,n,i)},ur=e=>async(t,n,r)=>Zn(e)(t,n,r),dr=/^[cC][0-9a-z]{6,}$/,fr=/^[0-9a-z]+$/,pr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,mr=/^[0-9a-vA-V]{20}$/,hr=/^[A-Za-z0-9]{27}$/,gr=/^[a-zA-Z0-9_-]{21}$/;function _r(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var vr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,br=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Sr=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Cr(){return new RegExp(Sr,`u`)}var wr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Er=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Dr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Or=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ar=/^https?$/,jr=/^\+[1-9]\d{6,14}$/,Mr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Nr(e){return RegExp(`^${e}$`)}var Pr=Nr(Mr);function Fr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ir(e){return RegExp(`^${Fr(e)}$`)}function Lr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Fr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Fr({precision:e.precision})}`:n;return RegExp(`^${Mr}T(?:${r})$`)}var Rr=/^[\s\S]{0,}$/,zr=/^-?\d+$/,Br=/^-?\d+(?:\.\d+)?$/,Vr=/^(?:true|false)$/i,Hr=/^[^A-Z]*$/,Ur=/^[^a-z]*$/,Wr=G(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Gr=e=>{let t=e.value;return!Ct(t)&&t.length!==void 0},Kr={number:`number`,bigint:`bigint`,object:`date`},qr=G(`$ZodCheckLessThan`,(e,t)=>{Wr.init(e,t);let n=Kr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Kr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jr=G(`$ZodCheckGreaterThan`,(e,t)=>{Wr.init(e,t);let n=Kr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Kr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yr=G(`$ZodCheckMultipleOf`,(e,t)=>{Wr.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Tt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Xr=G(`$ZodCheckNumberFormat`,(e,t)=>{Wr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Kt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Zr=G(`$ZodCheckMaxLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?dn(r):i)<=t.maximum)return;let a=fn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qr=G(`$ZodCheckMinLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?dn(r):i)>=t.minimum)return;let a=fn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$r=G(`$ZodCheckLengthEquals`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?dn(r):i;if(a===t.length)return;let o=fn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ei=G(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Wr.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ti=G(`$ZodCheckRegex`,(e,t)=>{ei.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ni=G(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Hr,ei.init(e,t)}),ri=G(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ur,ei.init(e,t)}),ii=G(`$ZodCheckIncludes`,(e,t)=>{Wr.init(e,t);let n=Ht(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ai=G(`$ZodCheckStartsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`^${Ht(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),oi=G(`$ZodCheckEndsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`.*${Ht(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),si=G(`$ZodCheckOverwrite`,(e,t)=>{Wr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ci=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
11
|
+
some-mcp-server`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Secret variables (NAME=value, one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:ie,onChange:e=>ae(e.target.value),autoComplete:`off`,placeholder:`Leave empty if it needs none`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Saved privately on this PC and never shown again.`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Address`}),(0,p.jsx)(`input`,{value:oe,onChange:e=>se(e.target.value),placeholder:`https://… or http://127.0.0.1:8766/mcp`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Plain http is only allowed for a server on this PC.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Secret headers (Name: value, one per line)`}),(0,p.jsx)(`textarea`,{rows:2,value:ie,onChange:e=>ae(e.target.value),autoComplete:`off`})]})]}),pe,(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:z,children:`Next`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>o({name:`list`}),children:`Back`})]})]}))}if(n===`holo`){let t=r?.connectors??[],n=r?.presets??[],i={off:`off`,connecting:`warn`,ready:`on`,error:`error`},a=t.map(t=>({key:t.id,name:t.name,badge:i[t.status],badgeText:ee[t.status],...t.status===`ready`?{meta:`${t.tools} tools`}:{},note:`${t.error?t.error:t.target}${t.secret?` · secret saved`:``}`,noteClass:t.error?`auth-error`:`auth-note`,actions:[{label:t.enabled?`Turn off`:`Turn on`,disabled:u,onClick:()=>t.enabled?void le(async()=>{await e.setEnabled(t.id,!1)}):o({name:`switch-on`,id:t.id,label:t.name})},...t.enabled?[{label:`Reload`,disabled:u,onClick:()=>void le(async()=>{await e.reload(t.id)})}]:[],{label:`Remove`,kind:`danger`,disabled:u,onClick:()=>void le(async()=>{await e.remove(t.id)})}]})),s=[...n.map(e=>({key:e.id,name:e.name,note:e.description,noteClass:`auth-note`,actions:[{label:e.quick?`Connect`:`Add`,kind:`primary`,disabled:t.some(t=>t.id===e.connector.id),onClick:()=>e.quick?void ue(e):R(e)}]})),{key:`something-else`,name:`Something else`,note:`Any MCP program or server.`,noteClass:`auth-note`,actions:[{label:`Add`,onClick:()=>R(null)}]}],{here:c,at:l,pages:d}=_(S===`connected`?a:s,w);return fe((0,p.jsxs)(p.Fragment,{children:[pe,g&&(0,p.jsx)(`p`,{className:`auth-note`,children:g}),(0,p.jsx)(y,{tabs:[{id:`connected`,label:`Connected`,count:a.length},{id:`add`,label:`Add`,count:s.length}],active:S,onTab:e=>{C(e),E(0)},cards:c,empty:`Nothing connected yet. Add one on the Add tab.`,ready:!!r})]}),{page:v(l,d,E),help:(0,p.jsxs)(p.Fragment,{children:[`Outside programs and services Friend may use. Adding or switching one on needs your `,(0,p.jsx)(`b`,{children:`PIN`}),`.`]})})}return fe((0,p.jsxs)(p.Fragment,{children:[pe,g&&(0,p.jsx)(`p`,{className:`auth-note`,children:g}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Connected`}),r&&r.connectors.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing connected yet. Add one below.`}),(0,p.jsx)(`ul`,{className:`plugin-list`,children:(r?.connectors??[]).map(t=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:t.name}),` `,(0,p.jsxs)(`small`,{className:`conn-status conn-${t.status}`,children:[ee[t.status],t.status===`ready`?` · ${t.tools} tools`:``]}),(0,p.jsxs)(`div`,{className:`auth-note`,children:[t.error?`${t.error}`:t.target,t.secret?` · secret saved`:``]})]}),(0,p.jsxs)(`div`,{className:`plugin-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:u,onClick:()=>t.enabled?void le(async()=>{await e.setEnabled(t.id,!1)}):o({name:`switch-on`,id:t.id,label:t.name}),children:t.enabled?`Turn off`:`Turn on`}),t.enabled&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:u,onClick:()=>void le(async()=>{await e.reload(t.id)}),children:`Reload`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:u,onClick:()=>void le(async()=>{await e.remove(t.id)}),children:`Remove`})]})]},t.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Add`}),(0,p.jsxs)(`ul`,{className:`plugin-list`,children:[(r?.presets??[]).map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:e.name}),(0,p.jsx)(`div`,{className:`auth-note`,children:e.description})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:(r?.connectors??[]).some(t=>t.id===e.connector.id),onClick:()=>e.quick?void ue(e):R(e),children:e.quick?`Connect`:`Add`})})]},e.id)),(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`div`,{className:`plugin-info`,children:[(0,p.jsx)(`strong`,{children:`Something else`}),(0,p.jsx)(`div`,{className:`auth-note`,children:`Any MCP program or server.`})]}),(0,p.jsx)(`div`,{className:`plugin-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>R(null),children:`Add`})})]})]}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})})]}))}function P(e){let t=e.trimStart();if(!t.startsWith(`/`)||t.startsWith(`//`))return null;let n=/^\/(\S*)\s*(.*)$/s.exec(t);return n?{name:n[1].toLowerCase(),args:n[2].trim()}:null}function F(e,t){let n=P(t);if(!n)return[];if(/^\/\S*\s/.test(t.trimStart()))return e.filter(e=>e.name===n.name);let r=e.filter(e=>e.name.startsWith(n.name)),i=e.filter(e=>!e.name.startsWith(n.name)&&e.name.includes(n.name));return[...r,...i]}function te(e,t,n){let r=P(t);if(!r)return;let i=e.find(e=>e.name===r.name);if(!i){n(r.name?`There is no command /${r.name}. Type /help to see them.`:`Type /help to see the commands.`);return}i.run(r.args)}var I=e=>e.trimStart().startsWith(`//`)?e.trimStart().slice(1):e;function ne(e){let t=[{name:`settings`,description:`Open the settings (model, voice, …)`,run:e.openSettings},{name:`plugins`,description:`Add, switch or remove plugins (skills and tools)`,run:e.openPlugins},{name:`look`,description:`Choose how the voice presence looks: theme, colour, size, captions`,run:e.openLook},{name:`connectors`,description:`Connect Gmail, Chrome control or any MCP service; switch or remove them`,run:e.openConnectors},{name:`voice`,description:`Teach Friend your voice`,run:()=>e.openVoice?e.openVoice():e.notify(`Speech is not set up. Run: friend voice setup`)},{name:`camera`,usage:`on|off`,description:`Switch the camera on or off (it only takes a picture when you approve)`,run:t=>{let n=t===`on`||t!==`off`&&!e.cameraOn;if(t&&t!==`on`&&t!==`off`)return e.notify(`Use /camera on or /camera off.`);e.setCamera(n),e.notify(n?`Camera switched on.`:`Camera switched off.`)}},{name:`mute`,description:`Hide everything on the stage (/unmute shows it again)`,run:()=>e.setMuted(!0)},{name:`unmute`,description:`Show the stage again`,run:()=>e.setMuted(!1)},...[`chat`,`tasks`,`music`,`launcher`].map(t=>({name:t,usage:`on|off`,description:{chat:`Show or hide the conversation`,tasks:`Show or hide the schedule and to-dos`,music:`Show or hide the music player`,launcher:`Show or hide the quick-launch buttons`}[t],run:n=>{if(n&&n!==`on`&&n!==`off`)return e.notify(`Use /${t} on or off.`);e.setPanel(t,n?n===`on`:!e.panelOn(t))}})),{name:`view`,usage:`minimal|companion|workspace`,description:`Choose how much is on the screen besides the AI's pictures`,run:t=>{if(t===`minimal`||t===`companion`||t===`workspace`)return e.setView(t);e.notify(t?`Use /view minimal, companion or workspace.`:`The view is ${e.view}. Use /view minimal, companion or workspace.`)}},{name:`layout`,usage:`reset`,description:`Put every panel back where it started`,run:t=>t===`reset`?e.resetLayout():e.notify(`Drag a panel by its title to move it. /layout reset puts them all back.`)},{name:`clear`,description:`Take everything off the screen`,run:e.clearScreen},{name:`status`,description:`What Friend is doing right now`,run:()=>e.notify(e.statusLine())},{name:`logout`,description:`Sign out of Friend on this screen`,run:()=>e.endSession(`logout`)},{name:`lock`,description:`Emergency lock: end every session and stop the agent`,run:()=>e.endSession(`lock`)}];return t.push({name:`help`,description:`List every command with what it does`,run:()=>e.openHelp(t)}),t.sort((e,t)=>e.name.localeCompare(t.name))}function L(e){let t=ne(e);return{commands:t,run:n=>te(t,n,e.notify)}}function re({commands:e,onClose:t}){return(0,p.jsxs)(`div`,{className:`approval help glass`,role:`dialog`,"aria-label":`Commands`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Commands`})}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Type / in the message bar to see these as you type. They run on this screen and never go to the AI. Anything else you type is a message to Friend.`}),(0,p.jsx)(`dl`,{className:`help-list`,children:e.map(e=>(0,p.jsxs)(`div`,{className:`help-row`,children:[(0,p.jsxs)(`dt`,{children:[`/`,e.name,e.usage&&(0,p.jsxs)(`i`,{children:[` `,e.usage]})]}),(0,p.jsx)(`dd`,{children:e.description})]},e.name))}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:t,children:`Close`})})]})}var ie=`(pointer: coarse)`;function ae(){let[e,t]=(0,l.useState)(()=>typeof matchMedia==`function`&&matchMedia(ie).matches);return(0,l.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let e=matchMedia(ie),n=()=>t(e.matches);return e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}var oe=[`chat`,`tasks`,`status`,`clock`,`profile`,`launcher`,`music`],se={minimal:{chat:!1,tasks:!1,status:!1,clock:!1,profile:!1,launcher:!1,music:!1},companion:{chat:!1,tasks:!1,status:!0,clock:!0,profile:!0,launcher:!0,music:!0},workspace:{chat:!0,tasks:!0,status:!0,clock:!0,profile:!0,launcher:!0,music:!0}},ce=`friend.panels`,le=`friend.pos.`;function ue(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function de(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch{}}var R=e=>{let t=ue(le+e);return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:Math.min(Math.max(t.x,0),95),y:Math.min(Math.max(t.y,0),95)}:null},z=(e,t)=>de(le+e,t),B=()=>oe.forEach(e=>z(e,null));function fe(e){let[t,n]=(0,l.useState)(()=>ue(ce)??{}),r=(0,l.useRef)(e);return(0,l.useEffect)(()=>{r.current!==e&&(r.current=e,n({}),de(ce,null))},[e]),{show:{...se[e],...t},toggle:(0,l.useCallback)((t,r)=>n(n=>{let i={...se[e],...n}[t],a={...n,[t]:r??!i};return de(ce,a),a}),[e])}}var pe=(e,t,n)=>Math.min(Math.max(e,t),n),me=2;function he({id:e,label:t,className:n,style:r,wholeBox:i,head:a,testId:o,children:s}){let[c,u]=(0,l.useState)(()=>R(e)),d=(0,l.useRef)(null),f=(0,l.useRef)(null),m=(t,n,r)=>{let i={x:pe(t,0,95),y:pe(n,0,95)};return u(i),r&&z(e,i),i},h={onPointerDown:e=>{let t=d.current;if(!t||e.pointerType===`mouse`&&e.button!==0||e.target.closest(`button, input, textarea, select, a`))return;let n=t.getBoundingClientRect();f.current={dx:e.clientX-n.left,dy:e.clientY-n.top,pointer:e.pointerId};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.stopPropagation()},onPointerMove:e=>{let t=f.current;t&&t.pointer===e.pointerId&&m((e.clientX-t.dx)/window.innerWidth*100,(e.clientY-t.dy)/window.innerHeight*100,!1)},onPointerUp:e=>{let t=f.current;if(!t||t.pointer!==e.pointerId)return;f.current=null;let n=d.current?.getBoundingClientRect();n&&m(n.left/window.innerWidth*100,n.top/window.innerHeight*100,!0)},onPointerCancel:()=>{f.current=null},onDoubleClick:()=>{z(e,null),u(null)},onKeyDown:e=>{let t=d.current?.getBoundingClientRect();if(!t)return;let n=t.left/window.innerWidth*100,r=t.top/window.innerHeight*100,i={ArrowLeft:[-2,0],ArrowRight:[me,0],ArrowUp:[0,-2],ArrowDown:[0,me]}[e.key];i&&(e.preventDefault(),m(n+i[0],r+i[1],!0))},tabIndex:0,role:`group`,"aria-label":`${t}. Drag to move, arrow keys to nudge, double-click to put it back.`},g=c?{left:`${c.x}%`,top:`${c.y}%`,right:`auto`,bottom:`auto`}:{};return(0,p.jsxs)(`div`,{ref:d,"data-panel":e,"data-testid":o,className:`movable ${n??``}`,style:{pointerEvents:`auto`,...r,...g},...i?h:{},children:[a!==void 0&&(0,p.jsx)(`div`,{className:`panel-head`,...i?{}:h,children:a}),s]})}function ge({lines:e,live:t,onSend:n,onClose:r}){let[i,a]=(0,l.useState)(``),o=(0,l.useRef)(null);return(0,l.useEffect)(()=>{o.current?.scrollIntoView?.({block:`end`})},[e,t]),(0,p.jsxs)(he,{id:`chat`,label:`Chat panel`,className:`panel panel-chat glass`,style:{left:`70%`,top:`12%`},head:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`approval-title`,children:`Chat`}),(0,p.jsx)(`button`,{type:`button`,className:`obj-close`,"aria-label":`Close chat`,onClick:r,children:`×`})]}),children:[(0,p.jsxs)(`div`,{className:`chat-lines`,role:`log`,"aria-live":`polite`,children:[e.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing said yet. Talk to me, or type below.`}),e.map((e,t)=>(0,p.jsx)(`p`,{className:`chat-line chat-${e.role}`,children:e.text},t)),(0,p.jsx)(`div`,{ref:o})]}),(0,p.jsxs)(`form`,{className:`chat-form`,onSubmit:e=>{e.preventDefault();let t=i.trim();t&&(n(t),a(``))},children:[(0,p.jsx)(`input`,{"aria-label":`Type to chat`,value:i,placeholder:`Type a message…`,autoComplete:`off`,onChange:e=>a(e.target.value)}),(0,p.jsx)(`button`,{type:`submit`,"aria-label":`Send message`,children:`↵`})]})]})}var V={list:async()=>{let e=await fetch(`/api/tasks`);if(!e.ok)throw Error(e.status===401?`Please sign in again.`:`The request failed (${e.status}).`);return await e.json()}};function _e(e,t){if(e===null)return{text:`to do`,overdue:!1};let n=e-t;if(n<0)return{text:`overdue`,overdue:!0};let r=Math.round(n/6e4);if(r<1)return{text:`now`,overdue:!1};if(r<60)return{text:`in ${r} min`,overdue:!1};let i=new Date(e),a=new Date(t),o=i.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}),s=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),c=Math.round((s(i)-s(a))/864e5);return c===0?{text:`today ${o}`,overdue:!1}:c===1?{text:`tomorrow ${o}`,overdue:!1}:{text:`${i.toLocaleDateString([],{weekday:`short`,day:`numeric`,month:`short`})} ${o}`,overdue:!1}}function ve({source:e=V,busy:t,onClose:n,now:r=Date.now}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),c=(0,l.useRef)(!0),u=(0,l.useCallback)(async()=>{try{let t=await e.list();if(!c.current)return;a(t),s(null)}catch(e){c.current&&s(e.message)}},[e]);(0,l.useEffect)(()=>{c.current=!0,u();let e=setInterval(()=>void u(),15e3);return()=>{c.current=!1,clearInterval(e)}},[u]),(0,l.useEffect)(()=>{t||u()},[t,u]);let d=r();return(0,p.jsx)(he,{id:`tasks`,label:`Schedule panel`,className:`panel panel-tasks glass`,style:{left:`2%`,top:`12%`},head:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`approval-title`,children:`Schedule`}),(0,p.jsx)(`button`,{type:`button`,className:`obj-close`,"aria-label":`Close schedule`,onClick:n,children:`×`})]}),children:(0,p.jsxs)(`div`,{className:`task-body`,children:[o&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:o}),i&&i.length===0&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing scheduled. Say "remind me in 30 minutes to…".`}),(0,p.jsx)(`ul`,{className:`task-list`,children:(i??[]).map(e=>{let t=_e(e.dueAt,d);return(0,p.jsxs)(`li`,{className:t.overdue?`overdue`:void 0,children:[(0,p.jsx)(`span`,{className:`task-title`,children:e.title}),(0,p.jsxs)(`span`,{className:`task-due`,children:[t.text,e.repeat?` · ${e.repeat}`:``]})]},e.id)})})]})})}var ye={minimal:`companion`,companion:`workspace`,workspace:`companion`},H=`friend.menuStyle`;function be(){try{return localStorage.getItem(H)===`classic`?`classic`:`orb`}catch{return`orb`}}function U(e){try{localStorage.setItem(H,e)}catch{}}function xe({muted:e,onToggleMute:t,onSignedOut:n,voiceAvailable:r,voiceEnrolled:i,onEnroll:a,onHousehold:o,handsFreeOn:s,onToggleHandsFree:c,assistantName:u,onOrb:f,cameraOn:m,onToggleCamera:h,onPlugins:g,onSettings:_,onConnectors:v,chatOn:y,onToggleChat:b,tasksOn:x,onToggleTasks:S,musicOn:C,onToggleMusic:w,launcherOn:T,onToggleLauncher:E,view:D,onView:O,openRequest:k}){let[A,j]=(0,l.useState)(!1),ee=(0,l.useRef)(null);(0,l.useEffect)(()=>{k&&j(!0)},[k]),(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&j(e=>!e)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let M=async e=>{try{await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`})}catch{}n()},N=()=>{ee.current&&clearTimeout(ee.current),ee.current=null};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{"data-testid":`owner-hotspot`,className:`owner-hotspot`,style:{position:`fixed`,top:0,left:0,width:56,height:56,zIndex:1100},onPointerDown:()=>{N(),ee.current=setTimeout(()=>j(!0),600)},onPointerUp:N,onPointerLeave:N,onPointerCancel:N}),A&&(0,p.jsxs)(`div`,{className:`owner-menu glass`,role:`dialog`,"aria-label":`Owner menu`,style:{position:`fixed`,zIndex:1100},children:[(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:e?`Unmute stage`:`Mute stage`}),r&&c&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!s,onClick:c,title:u?`Say "Hey ${u}" and then your request`:void 0,children:s?`Hands-free: on`:`Hands-free: off`}),h&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!m,onClick:h,children:m?`Camera: on`:`Camera: off`}),b&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!y,onClick:b,children:y?`Chat: on`:`Chat: off`}),S&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!x,onClick:S,children:x?`Schedule: on`:`Schedule: off`}),w&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!C,onClick:w,children:C?`Music: on`:`Music: off`}),E&&(0,p.jsx)(`button`,{type:`button`,style:d,"aria-pressed":!!T,onClick:E,children:T?`Quick launch: on`:`Quick launch: off`}),D&&O&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>O(ye[D]),children:`View: ${D}`}),_&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),_()},children:`Settings`}),v&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),v()},children:`Connectors`}),g&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),g()},children:`Plugins`}),r&&a&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),a()},children:i?`Voice settings`:`Enroll my voice`}),r&&i&&o&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{j(!1),o()},children:`Family voices`}),f&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:f,children:`Orb menu`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>M(`/api/logout`),children:`Log out`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>M(`/api/lock`),children:`Emergency lock`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>j(!1),children:`Close`})]})]})}var Se=[{id:`model`,label:`Model`,note:`Where Friend thinks`},{id:`voice`,label:`Voice`,note:`Speaking and listening`},{id:`look`,label:`Voice presence`,note:`How it looks`},{id:`approvals`,label:`Approvals`,note:`How much it asks`},{id:`trading`,label:`Trading`,note:`What Friend may do with money`},{id:`widgets`,label:`Widgets`,note:`Music, clock, quick launch`},{id:`system`,label:`Startup`,note:`Start with the computer, updates`},{id:`usage`,label:`Usage`,note:`Tokens used, day by day`},{id:`security`,label:`Security`,note:`Password and PIN`}],Ce={model:`brain`,voice:`speaker`,look:`sparkle`,approvals:`shield`,trading:`chart`,widgets:`grid`,system:`launch`,usage:`chart`,security:`lock`};function we(e,t){let n=[],r=e=>e.items.length>0&&n.push(e),i=[];e.voiceAvailable&&e.onToggleHandsFree&&i.push({id:`voice.handsfree`,label:`Hands-free`,icon:`hands`,kind:`toggle`,on:!!e.handsFreeOn,run:e.onToggleHandsFree}),e.voiceAvailable&&e.onEnroll&&i.push({id:`voice.enroll`,label:e.voiceEnrolled?`Voice settings`:`Enroll my voice`,icon:`voiceprint`,kind:`open`,run:e.onEnroll}),e.voiceAvailable&&e.voiceEnrolled&&e.onHousehold&&i.push({id:`voice.family`,label:`Family voices`,icon:`family`,kind:`open`,run:e.onHousehold}),i.push({id:`voice.mute`,label:`Mute stage`,icon:`mute`,kind:`toggle`,on:e.muted,run:e.onToggleMute}),r({id:`voice`,label:`Voice`,icon:`mic`,items:i});let a=[],o=(e,t,n,r,i)=>i&&a.push({id:e,label:t,icon:n,kind:`toggle`,on:!!r,run:i});if(o(`screen.camera`,`Camera`,`camera`,e.cameraOn,e.onToggleCamera),o(`screen.chat`,`Chat`,`chat`,e.chatOn,e.onToggleChat),o(`screen.tasks`,`Schedule`,`calendar`,e.tasksOn,e.onToggleTasks),o(`screen.music`,`Music`,`music`,e.musicOn,e.onToggleMusic),o(`screen.launcher`,`Quick launch`,`launch`,e.launcherOn,e.onToggleLauncher),e.view&&e.onView){let{view:t,onView:n}=e;a.push({id:`screen.view`,label:`View: ${t}`,icon:`eye`,kind:`action`,run:()=>n(ye[t])})}if(r({id:`screen`,label:`Screen`,icon:`screen`,items:a}),e.onSettings){let t=e.onSettings;r({id:`settings`,label:`Settings`,icon:`gear`,items:Se.map(e=>({id:`settings.${e.id}`,label:e.label,icon:Ce[e.id]??`gear`,kind:`open`,run:()=>t(e.id)}))})}let s=[];return e.onPlugins&&s.push({id:`connect.plugins`,label:`Plugins`,icon:`plug`,kind:`open`,run:e.onPlugins}),e.onConnectors&&s.push({id:`connect.connectors`,label:`Connectors`,icon:`link`,kind:`open`,run:e.onConnectors}),r({id:`connect`,label:`Connect`,icon:`plug`,items:s}),r({id:`account`,label:`Account`,icon:`user`,items:[{id:`account.classic`,label:`Classic menu`,icon:`list`,kind:`action`,run:t.classic},{id:`account.logout`,label:`Log out`,icon:`logout`,kind:`action`,run:t.logout},{id:`account.lock`,label:`Emergency lock`,icon:`alert`,kind:`action`,danger:!0,run:t.lock}]}),n}var Te=(e,t,n,r)=>{let i=r*Math.PI/180;return{x:e+n*Math.sin(i),y:t-n*Math.cos(i)}};function Ee(e,t=4){let n=360/e;return Array.from({length:e},(e,r)=>{let i=r*n;return{start:i-n/2+t/2,end:i+n/2-t/2,mid:i}})}function De(e,t,n=3,r=36,i=330){let a=Math.min(r,(i-(t-1)*n)/t),o=e-(t*a+(t-1)*n)/2;return Array.from({length:t},(e,t)=>{let r=o+t*(a+n);return{start:r,end:r+a,mid:r+a/2}})}function Oe(e,t,n,r,i,a){let o=+(a-i>180),s=e=>Number(e.toFixed(2)),c=(n,r)=>{let{x:i,y:a}=Te(e,t,n,r);return`${s(i)} ${s(a)}`};return`M ${c(r,i)} A ${r} ${r} 0 ${o} 1 ${c(r,a)} L ${c(n,a)} A ${n} ${n} 0 ${o} 0 ${c(n,i)} Z`}var ke={open:!1,category:null,hover:null};function Ae(e,t){switch(t.type){case`open`:return{open:!0,category:null,hover:null};case`close`:return ke;case`toggle`:return e.open?ke:{open:!0,category:null,hover:null};case`escape`:return e.open?Ae(e,{type:`back`}):{open:!0,category:null,hover:null};case`back`:return e.category?{...e,category:null,hover:null}:ke;case`category`:return e.open?{...e,category:e.category===t.id?null:t.id,hover:null}:e;case`hover`:return e.open?{...e,hover:t.id}:e}}function je(e,t,n,r){if(e.open){if(!e.hover)return e.category&&t.find(t=>t.id===e.category)?.label.toUpperCase()||`SELECT`;let n=t.find(t=>t.id===e.hover),r=t.flatMap(e=>e.items).find(t=>t.id===e.hover);return(n?.label??r?.label??`SELECT`).toUpperCase()}return n===`listening`?`LISTENING`:r||n===`transcribing`||n===`speaking`?`BUSY`:`MARK II`}var Me=(e,t,n)=>{let r=t=>{let{x:n,y:r}=Te(0,0,e,t);return`${n.toFixed(2)} ${r.toFixed(2)}`};return`M ${r(t)} A ${e} ${e} 0 ${+(n-t>180)} 1 ${r(n)}`};function Ne({name:e,caption:t,state:n,onClick:r}){let i=(e.trim()||`Friend`).toUpperCase(),a=Math.max(9,Math.min(15,90/Math.max(i.length,6)));return(0,p.jsxs)(`g`,{className:`orb-core orb-${n}`,role:`button`,tabIndex:0,"aria-label":n===`menu-open`||n===`hover`?`Close the menu`:`Open the menu`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r())},children:[(0,p.jsx)(`circle`,{className:`orb-halo`,r:62}),(0,p.jsx)(`circle`,{className:`orb-disc`,r:52,fill:`url(#orb-disc)`}),(0,p.jsx)(`circle`,{className:`orb-ticks`,r:55}),(0,p.jsx)(`circle`,{className:`orb-ring`,r:46}),(0,p.jsx)(`path`,{className:`orb-gauge`,d:Me(50,-160,-100)}),(0,p.jsx)(`path`,{className:`orb-segments`,d:Me(50,110,250)}),(0,p.jsx)(`text`,{className:`orb-name`,y:-1,fontSize:a,textAnchor:`middle`,children:i}),(0,p.jsx)(`text`,{className:`orb-caption`,y:14,textAnchor:`middle`,children:t})]})}var Pe={mic:`M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3zM6 11a6 6 0 0 0 12 0M12 17v4M9 21h6`,hands:`M3 12h2M7 8v8M11 4v16M15 8v8M19 10v4`,voiceprint:`M12 4a8 8 0 0 0-8 8M12 8a4 4 0 0 0-4 4v2M12 12v6M16 12a4 4 0 0 0-4-4M20 12a8 8 0 0 0-8-8M16 16v2`,family:`M8 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM2 20c0-3 2.5-5 6-5s6 2 6 5M17 10a2.5 2.5 0 1 0 0-5M16 15c3 0 6 1.5 6 5`,mute:`M4 9v6h4l5 4V5L8 9zM17 9l4 6M21 9l-4 6`,screen:`M3 5h18v11H3zM8 20h8M12 16v4`,camera:`M4 8h4l2-3h4l2 3h4v11H4zM12 17a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z`,chat:`M4 5h16v11H9l-5 4z`,calendar:`M4 6h16v14H4zM4 10h16M8 3v4M16 3v4`,music:`M9 18V6l10-2v12M9 18a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0zM19 16a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z`,launch:`M12 3c3 2 5 5 5 9l-3 3h-4l-3-3c0-4 2-7 5-9zM9 18l-3 3M15 18l3 3`,eye:`M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,gear:`M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M18.4 5.6l-2.1 2.1M7.7 16.3l-2.1 2.1`,brain:`M7 7h10v10H7zM10 10h4v4h-4zM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4`,speaker:`M4 9v6h4l5 4V5L8 9zM16 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11`,sparkle:`M12 3l2 6 6 2-6 2-2 6-2-6-6-2 6-2z`,shield:`M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z`,chart:`M4 19V5M4 19h16M8 15l4-4 3 3 5-6`,grid:`M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z`,lock:`M6 11h12v9H6zM8 11V8a4 4 0 0 1 8 0v3`,plug:`M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4`,link:`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`,user:`M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21c0-4 3.5-6 8-6s8 2 8 6`,list:`M5 6h14M5 12h14M5 18h14`,logout:`M10 4H4v16h6M15 8l4 4-4 4M19 12H9`,alert:`M12 3l10 18H2zM12 10v5M12 18v.01`};function Fe({name:e,x:t,y:n,size:r=20}){return(0,p.jsx)(`g`,{className:`orb-icon`,transform:`translate(${t-r/2} ${n-r/2}) scale(${r/24})`,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:Pe[e]})})}var Ie=[72,128],Le=[138,176],Re=186,ze=e=>(e[0]+e[1])/2;function Be(e,t){let{x:n,y:r}=Te(0,0,e,t),i=Math.sin(t*Math.PI/180),a=Math.cos(t*Math.PI/180),o=i>.35?`start`:i<-.35?`end`:`middle`;return{x:n+(o===`start`?4:o===`end`?-4:0),y:r,anchor:o,dy:Math.abs(i)>.35?`0.35em`:a>0?`-0.4em`:`1em`}}function Ve(e,t,n){if(e.key===`Enter`||e.key===` `)return e.preventDefault(),e.stopPropagation(),n();let r=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(!r)return;e.preventDefault();let i=[...e.currentTarget.closest(`svg`)?.querySelectorAll(`[data-ring="${t}"]`)??[]];i[(i.indexOf(e.currentTarget)+r+i.length)%i.length]?.focus()}function He({categories:e,state:t,onCategory:n,onHover:r,onPick:i}){let a=Ee(e.length),o=e.findIndex(e=>e.id===t.category),s=o>=0?e[o]:null,c=s?De(a[o].mid,s.items.length):[],l=e=>({onPointerEnter:()=>r(e),onPointerLeave:()=>r(null),onFocus:()=>r(e),onBlur:()=>r(null)});return(0,p.jsxs)(`g`,{className:`orb-rings`,children:[(0,p.jsx)(`g`,{className:`orb-ring1`,children:e.map((e,r)=>{let i=a[r],o=Te(0,0,ze(Ie),i.mid),c=Be(Ie[1]+8,i.mid),u=e.id===t.category;return(0,p.jsxs)(`g`,{className:`orb-arc${u?` is-open`:``}${t.hover===e.id?` is-hover`:``}`,"data-ring":1,"data-id":e.id,role:`button`,tabIndex:0,"aria-label":e.label,"aria-expanded":u,style:{animationDelay:`${r*30}ms`},onClick:()=>n(e.id),onKeyDown:t=>Ve(t,1,()=>n(e.id)),...l(e.id),children:[(0,p.jsx)(`path`,{d:Oe(0,0,Ie[0],Ie[1],i.start,i.end)}),(0,p.jsx)(Fe,{name:e.icon,x:o.x,y:o.y,size:24}),!s&&(0,p.jsx)(`text`,{className:`orb-arc-label`,x:c.x,y:c.y,dy:c.dy,textAnchor:c.anchor,children:e.label})]},e.id)})},`ring1`),s&&(0,p.jsx)(`g`,{className:`orb-ring2`,children:s.items.map((e,n)=>{let r=c[n],a=Te(0,0,ze(Le),r.mid),o=Be(Re,r.mid);return(0,p.jsxs)(`g`,{className:`orb-arc orb-sub${e.on?` is-on`:``}${e.danger?` is-danger`:``}${t.hover===e.id?` is-hover`:``}`,"data-ring":2,"data-id":e.id,role:`button`,tabIndex:0,"aria-label":e.label,...e.kind===`toggle`?{"aria-pressed":!!e.on}:{},style:{animationDelay:`${n*25}ms`},onClick:()=>i(e),onKeyDown:t=>Ve(t,2,()=>i(e)),...l(e.id),children:[(0,p.jsx)(`path`,{d:Oe(0,0,Le[0],Le[1],r.start,r.end)}),(0,p.jsx)(Fe,{name:e.icon,x:a.x,y:a.y,size:17}),(0,p.jsxs)(`text`,{className:`orb-arc-label`,x:o.x,y:o.y,dy:o.dy,textAnchor:o.anchor,children:[e.label,e.kind===`toggle`?e.on?` · ON`:` · OFF`:``]})]},e.id)})},`ring2-${s.id}`)]})}var Ue={open:!1,category:null,hover:null};function We(e){let{onSignedOut:t,onClassic:n,openRequest:r,assistantName:i=``,voiceMode:a=`idle`,busy:o=!1}=e,[s,c]=(0,l.useReducer)(Ae,Ue),u=(0,l.useRef)(null),d=(0,l.useRef)(null);(0,l.useEffect)(()=>{r&&c({type:`open`})},[r]),(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&c({type:`escape`})};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,l.useEffect)(()=>{s.open&&!s.category&&d.current?.querySelector(`.orb-core`)?.focus()},[s.open,s.category]);let f=async e=>{try{await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`})}catch{}t()},m=()=>{u.current&&clearTimeout(u.current),u.current=null},h=we(e,{logout:()=>void f(`/api/logout`),lock:()=>void f(`/api/lock`),classic:n}),g=(0,l.useMemo)(()=>je(s,h,a,o),[s,h,a,o]),_=s.open?s.hover?`hover`:`menu-open`:o?`busy`:`idle`;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{"data-testid":`owner-hotspot`,className:`owner-hotspot`,style:{position:`fixed`,top:0,left:0,width:56,height:56,zIndex:1100},onPointerDown:()=>{m(),u.current=setTimeout(()=>c({type:`open`}),600)},onPointerUp:m,onPointerLeave:m,onPointerCancel:m}),s.open&&(0,p.jsxs)(`div`,{className:`orb-layer`,role:`dialog`,"aria-label":`Menu`,style:{position:`fixed`,zIndex:1100},children:[(0,p.jsx)(`div`,{className:`orb-backdrop`,onPointerDown:()=>c({type:`close`})}),(0,p.jsxs)(`svg`,{ref:d,className:`orb-svg`,viewBox:`-300 -300 600 600`,"aria-label":`Menu`,children:[(0,p.jsx)(`defs`,{children:(0,p.jsxs)(`radialGradient`,{id:`orb-disc`,cx:`50%`,cy:`45%`,r:`60%`,children:[(0,p.jsx)(`stop`,{offset:`0%`,stopColor:`#0d2530`}),(0,p.jsx)(`stop`,{offset:`100%`,stopColor:`#03090d`})]})}),(0,p.jsx)(He,{categories:h,state:s,onCategory:e=>c({type:`category`,id:e}),onHover:e=>c({type:`hover`,id:e}),onPick:e=>{e.run(),e.kind!==`toggle`&&c({type:`close`})}}),(0,p.jsx)(Ne,{name:i,caption:g,state:_,onClick:()=>c({type:`close`})})]})]})]})}var Ge=2e4,Ke=({letter:e,tone:t})=>(0,p.jsxs)(`svg`,{className:`profile-shield hud-emblem-svg ${t}`,width:`64`,height:`64`,viewBox:`0 0 64 64`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{className:`hud-ring-turn`,cx:`32`,cy:`32`,r:`30`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.55`,strokeWidth:`1.4`,strokeDasharray:`2 5`}),(0,p.jsx)(`circle`,{className:`hud-ring-chase`,cx:`32`,cy:`32`,r:`26.500`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.200`,strokeLinecap:`round`,strokeDasharray:`14 150`}),(0,p.jsx)(`circle`,{cx:`32`,cy:`32`,r:`22`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1`}),(0,p.jsx)(`path`,{d:`M32 15 44 19.500v9c0 7.200-4.800 13.300-12 15.500-7.200-2.200-12-8.300-12-15.500v-9z`,fill:`currentColor`,fillOpacity:`0.16`,stroke:`currentColor`,strokeWidth:`1.500`,strokeLinejoin:`round`}),(0,p.jsx)(`text`,{x:`32`,y:`36`,textAnchor:`middle`,fontSize:`13`,fontWeight:`600`,fill:`currentColor`,children:e})]});function qe({ownerName:e,speaker:t,assistantName:n=``,terminalLabel:r=`TERMINAL`,busy:i=!1,listening:a=!1}){let[o,s]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!t)return;s(!0);let e=setTimeout(()=>s(!1),Ge);return()=>clearTimeout(e)},[t?.seq]);let c=e.trim()||`Owner`,u=o&&t&&t.trust===`member`&&t.name?{name:t.name,note:`family`,tone:`member`}:o&&t?.trust===`guest`?{name:`Guest`,note:`voice not recognized`,tone:`guest`}:{name:c,note:`signed in`,tone:`owner`},d=(u.tone===`guest`?`?`:u.name.trim().charAt(0)||`?`).toUpperCase(),f=[n.trim(),r.trim()].filter(Boolean).join(` `);return(0,p.jsxs)(he,{id:`profile`,label:`Profile`,wholeBox:!0,testId:`profile`,className:`hud hud-profile ${u.tone}${o?` speaking`:``}${i?` busy`:``}${a?` listening`:``}`,children:[(0,p.jsx)(`span`,{className:`hud-emblem`,children:(0,p.jsx)(Ke,{letter:d,tone:u.tone})},t?.seq??0),(0,p.jsxs)(`span`,{className:`hud-tag hud-cut`,children:[f&&(0,p.jsx)(`small`,{className:`hud-tag-top`,children:f}),(0,p.jsx)(`b`,{children:u.name}),(0,p.jsx)(`small`,{children:u.note})]})]})}function Je({stream:e}){let t=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let n=t.current;if(n)return n.srcObject=e,Promise.resolve(n.play?.()).catch(()=>{}),()=>{n.srcObject=null}},[e]),(0,p.jsxs)(`div`,{className:`camera-indicator glass`,role:`status`,style:{pointerEvents:`none`},children:[(0,p.jsx)(`video`,{ref:t,muted:!0,playsInline:!0,autoPlay:!0,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Camera on`})]})}function Ye({alert:e,dispatch:t}){return(0,l.useEffect)(()=>{let n=setTimeout(()=>t({type:`alert.dismiss`,id:e.id}),5e3);return()=>clearTimeout(n)},[e.id,t]),(0,p.jsx)(`div`,{className:`toast toast-${e.level}`,role:`status`,style:{pointerEvents:`auto`},children:e.text})}function Xe({alerts:e,dispatch:t}){return e.length===0?null:(0,p.jsx)(`div`,{className:`toasts`,children:e.map(e=>(0,p.jsx)(Ye,{alert:e,dispatch:t},e.id))})}function Ze({approval:e,send:t}){let[n,r]=(0,l.useState)(``),i=i=>{if(i!==`deny`&&e.needsPin){t({type:`approval.respond`,id:e.id,decision:i,pin:n}),r(``);return}t({type:`approval.respond`,id:e.id,decision:i})},a=!e.needsPin||n.length>=6;return(0,p.jsxs)(`div`,{className:`approval glass`,role:`alertdialog`,"aria-label":`Approval needed`,style:{pointerEvents:`auto`},children:[(0,p.jsxs)(`div`,{className:`approval-head`,children:[(0,p.jsx)(`span`,{className:`tier tier-${e.tier}`,children:e.tier}),(0,p.jsx)(`span`,{className:`approval-title`,children:`Approval needed`})]}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`approval-summary`,style:{whiteSpace:`pre-wrap`},children:e.summary}),e.needsPin&&(0,p.jsx)(T,{pin:n,onChange:r,onSubmit:()=>a&&i(`approve`)}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!a,onClick:()=>i(`approve`),children:`Approve`}),e.tier===`T2`&&!e.needsPin&&e.tool!==`camera.snap`&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>i(`approve_always`),children:`Always allow`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>i(`deny`),children:`Deny`})]})]})}function Qe({challenge:e,send:t,dispatch:n}){let[r,i]=(0,l.useState)(``),a=()=>{t({type:`voice.confirm`,id:e.id,pin:r}),i(``)};return(0,p.jsxs)(`div`,{className:`approval challenge glass`,role:`alertdialog`,"aria-label":`Was that you?`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Was that you?`})}),(0,p.jsx)(`p`,{className:`auth-note`,children:`I heard this but I am not sure it was your voice. Enter your PIN to let it run.`}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`challenge-text`,style:{whiteSpace:`pre-wrap`},children:e.text}),(0,p.jsx)(T,{pin:r,onChange:i,onSubmit:a}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:r.length<6,onClick:a,children:`Confirm`}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>{t({type:`voice.cancel`,id:e.id}),n({type:`challenge.dismiss`,id:e.id})},children:`Dismiss`})]})]})}var $e={hour12:!0,seconds:!1,locale:``},et=({text:e})=>(0,p.jsx)(p.Fragment,{children:[...e].map((e,t)=>(0,p.jsx)(`span`,{className:`hud-digit`,children:e},`${t}-${e}`))});function tt({now:e=()=>new Date,clock:t=$e}){let[n,r]=(0,l.useState)(e);(0,l.useEffect)(()=>{let n=setInterval(()=>r(e()),t.seconds?1e3:5e3);return()=>clearInterval(n)},[e,t.seconds]);let i=t.locale||void 0,a=new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,...t.seconds?{second:`2-digit`}:{},hour12:t.hour12}).formatToParts(n),o=e=>a.find(t=>t.type===e)?.value??``,s=o(`hour`),c=o(`minute`),u=o(`second`),d=o(`dayPeriod`),f=n.toLocaleDateString(i,{month:`long`}),m=n.toLocaleDateString(i,{weekday:`long`});return(0,p.jsx)(he,{id:`clock`,label:`Clock`,wholeBox:!0,testId:`clock`,className:`hud hud-clock`,children:(0,p.jsxs)(`time`,{dateTime:n.toISOString(),children:[(0,p.jsxs)(`span`,{className:`hud-date`,children:[(0,p.jsx)(`b`,{className:`hud-day`,children:(0,p.jsx)(et,{text:String(n.getDate()).padStart(2,`0`)})}),(0,p.jsx)(`span`,{className:`hud-month`,children:f}),(0,p.jsx)(`small`,{className:`hud-weekday`,children:m})]}),(0,p.jsxs)(`span`,{className:`hud-time-block`,children:[(0,p.jsxs)(`span`,{className:`hud-clock-time`,children:[(0,p.jsx)(et,{text:s}),(0,p.jsx)(`i`,{className:`hud-colon`,children:`:`}),(0,p.jsx)(et,{text:c}),t.seconds&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`i`,{className:`hud-colon`,children:`:`}),(0,p.jsx)(et,{text:u})]}),d&&(0,p.jsx)(`small`,{className:`hud-period`,children:d})]}),(0,p.jsx)(`span`,{className:`hud-line`,children:(0,p.jsx)(`i`,{className:`hud-dot`})})]})]})})}function nt(e){return e.connection===`unauthorized`?{kind:`offline`,text:`Signed out`}:e.connection===`elsewhere`?{kind:`offline`,text:`Open in another window`}:e.connection===`open`?e.approval?{kind:`waiting`,text:`Waiting for your approval`}:e.voiceMode===`listening`?{kind:`listening`,text:`Listening`}:e.voiceMode===`transcribing`?{kind:`working`,text:`Understanding what you said`}:e.busy?{kind:e.activity===`Answering`?`speaking`:`working`,text:`${e.activity??`Thinking`}…`}:e.voiceMode===`speaking`?{kind:`speaking`,text:`Speaking`}:{kind:`idle`,text:e.deviceOnline?`Ready`:`Ready (no device connected)`}:{kind:`offline`,text:`Reconnecting…`}}function rt(e){let{kind:t,text:n}=nt(e);return(0,p.jsxs)(he,{id:`status`,label:`Status line`,wholeBox:!0,testId:`status-badge`,className:`status-badge status-${t}`,children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),(0,p.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:n})]})}function it({mode:e}){return e!==`listening`&&e!==`transcribing`?null:(0,p.jsxs)(`div`,{className:`mic-indicator mic-${e}`,role:`status`,"aria-label":`Microphone`,children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),e===`listening`?`Listening…`:`Transcribing…`]})}function at({approval:e,challenge:t,cameraStream:n,children:r,alerts:i,connection:a,deviceOnline:o,voiceMode:s,busy:c=!1,activity:l=null,showStatus:u=!0,showClock:d=!0,profile:f=null,assistantName:m=``,hud:h=null,send:g,dispatch:_}){return(0,p.jsxs)(`div`,{"data-overlay":!0,"data-hud-anim":h?.animations??`full`,className:`overlay`,style:{position:`fixed`,inset:0,zIndex:1e3,pointerEvents:`none`},children:[u&&(0,p.jsx)(rt,{connection:a,deviceOnline:o,approval:e,voiceMode:s,busy:c,activity:l}),d&&(0,p.jsx)(tt,{...h?{clock:h.clock}:{}}),f&&(0,p.jsx)(qe,{ownerName:f.ownerName,speaker:f.speaker,assistantName:m,terminalLabel:h?.terminalLabel??`TERMINAL`,busy:c,listening:s===`listening`}),(0,p.jsx)(it,{mode:s}),n&&(0,p.jsx)(Je,{stream:n}),(0,p.jsx)(Xe,{alerts:i,dispatch:_}),t&&!e&&(0,p.jsx)(Qe,{challenge:t,send:g,dispatch:_},t.id),e&&(0,p.jsx)(Ze,{approval:e,send:g}),r]})}async function ot(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var st=e=>({method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pin:e})}),ct={status:()=>ot(`/api/channels`),link:e=>ot(`/api/channels/telegram/link`,st(e)),unlink:async e=>void await ot(`/api/channels/telegram/unlink`,st(e))};function lt({view:e,secret:t,setSecret:n,api:r=ct}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(!1),y=(0,l.useRef)(!0),b=(0,l.useCallback)(()=>{r.status().then(e=>y.current&&a(e)).catch(()=>{})},[r]);(0,l.useEffect)(()=>{y.current=!0,b();let e=setInterval(b,4e3);return()=>{y.current=!1,clearInterval(e)}},[b]);let x=i?.telegram,S=!_&&e.linked&&(!x||x.linked),C=async e=>{if(c.length<6)return g(`Type your PIN first.`);m(!0),g(null);try{e===`link`?s(await r.link(c)):(await r.unlink(c),s(null),v(!0)),u(``),b()}catch(e){g(e.message)}finally{m(!1)}};return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Open Telegram, find `,(0,p.jsx)(`b`,{children:`@BotFather`}),`, send `,(0,p.jsx)(`code`,{children:`/newbot`}),`, and paste the token it gives you here.`]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Bot token`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,value:t,placeholder:e.tokenSet?`A token is saved. Type to replace it.`:`123456789:ABC…`,onChange:e=>n(e.target.value),style:d})]}),x&&e.enabled&&(0,p.jsxs)(`p`,{className:x.state===`error`?`auth-error`:`auth-note`,role:x.state===`error`?`alert`:`status`,children:[{off:`Off`,connecting:`Connecting…`,online:`Connected`,error:`Not working`}[x.state],x.bot?` as @${x.bot}`:``,x.detail?`: ${x.detail}`:``]}),e.tokenSet&&e.enabled&&(0,p.jsxs)(`div`,{className:`channels-link`,children:[S?(0,p.jsx)(`p`,{className:`auth-note`,children:`Your Telegram is linked. Messages from it are answered like on your PC, and anything risky is still decided here.`}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Not linked yet. Get a link code, then send it to your bot.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`PIN (to link or unlink)`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:c,onChange:e=>u(e.target.value.replace(/\D/g,``)),style:d})]}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[!S&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f,onClick:()=>void C(`link`),children:`Get a link code`}),S&&(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f,onClick:()=>void C(`unlink`),children:`Unlink`})]}),o&&!S&&(0,p.jsxs)(`p`,{className:`auth-note`,role:`status`,children:[`In Telegram, open `,o.bot?`@${o.bot}`:`your bot`,` and send: `,(0,p.jsxs)(`code`,{children:[`/link `,o.code]}),` (works for `,Math.round(o.expiresInSeconds/60),` minutes).`]})]}),!e.enabled&&e.tokenSet&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Switch the plugin on (Turn on) to connect, then come back here to link your Telegram.`}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h})]})}function ut({view:e,setView:t,secret:n,setSecret:r,webhook:i}){let a=n=>t({...e,...n});return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Both use one Twilio account. Messages come in through an address Twilio calls, so Friend needs a public address (`,(0,p.jsx)(`code`,{children:`friend config set publicUrl https://…`}),`).`]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Account SID`}),(0,p.jsx)(`input`,{value:e.accountSid,autoComplete:`off`,onChange:e=>a({accountSid:e.target.value}),placeholder:`AC…`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Auth token`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,placeholder:e.tokenSet?`A token is saved. Type to replace it.`:``,onChange:e=>r(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your SMS number (the Twilio number)`}),(0,p.jsx)(`input`,{value:e.smsFrom,inputMode:`tel`,onChange:e=>a({smsFrom:e.target.value}),placeholder:`+14155550100`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your WhatsApp number (the Twilio sender)`}),(0,p.jsx)(`input`,{value:e.whatsappFrom,inputMode:`tel`,onChange:e=>a({whatsappFrom:e.target.value}),placeholder:`+14155550101`,style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Your own phone number`}),(0,p.jsx)(`input`,{value:e.ownerNumber,inputMode:`tel`,onChange:e=>a({ownerNumber:e.target.value}),placeholder:`+919800000000`,style:d})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Only messages from this number are answered as you. Everyone else's go to the inbox as untrusted mail.`}),(0,p.jsx)(`p`,{className:`auth-note`,children:i?(0,p.jsxs)(p.Fragment,{children:[`In Twilio, set the "when a message comes in" address (HTTP POST) to `,(0,p.jsx)(`code`,{children:i})]}):`No public address is set yet, so Twilio cannot reach Friend.`})]})}var dt={style:`sphere`,accent:`#3fd8ff`,intensity:.6,size:1,reactivity:.7,ambient:!0,captions:!0,captionSize:`medium`,aiMayChange:!0},ft=new Set([`view`,`look`,`ownerName`]),pt=e=>Object.keys(e).some(e=>!ft.has(e));async function mt(e={}){let t;try{t=await fetch(`/api/settings`,e)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!t.ok){let e=``;try{e=(await t.json()).error??``}catch{}throw Error(e||(t.status===401?`Please sign in again.`:t.status===429?`Too many attempts. Wait a moment.`:`The request failed (${t.status}).`))}return await t.json()}var ht={get:()=>mt(),save:(e,t)=>mt({method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({...t?{pin:t}:{},settings:e})})};async function gt(e){let t;try{t=await fetch(`/api/voice/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({voice:e})})}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!t.ok){let e=``;try{e=(await t.json()).error??``}catch{}throw Error(e||`The request failed (${t.status}).`)}let n=URL.createObjectURL(await t.blob()),r=new Audio(n);r.addEventListener(`ended`,()=>URL.revokeObjectURL(n),{once:!0});try{await r.play()}catch{throw URL.revokeObjectURL(n),Error(`The browser blocked the sound. Click anywhere on the page, then try again.`)}}function _t(e,t,n,r=``){let i={};t.provider!==e.provider&&(i.provider=t.provider),t.model!==e.model&&(i.model=t.model),t.view!==e.view&&(i.view=t.view),(t.ownerName??``)!==(e.ownerName??``)&&(i.ownerName=t.ownerName??``),(t.approvals??`manual`)!==(e.approvals??`manual`)&&(i.approvals=t.approvals??`manual`),n.trim()&&(i.apiKey=n.trim());for(let n of[`ollama`,`claudeCode`,`voice`,`look`,`updates`,`session`]){if(!t[n]||!e[n])continue;let r={};for(let i of Object.keys(t[n])){let a=t[n][i];a!==e[n][i]&&(r[i]=n===`voice`&&i===`language`?a??``:a)}Object.keys(r).length&&(i[n]=r)}if(e.music&&t.music){let n={};for(let r of Object.keys(t.music))JSON.stringify(t.music[r])!==JSON.stringify(e.music[r])&&(n[r]=t.music[r]);Object.keys(n).length&&(i.music=n)}if(e.hud&&t.hud){let n={};t.hud.terminalLabel!==e.hud.terminalLabel&&(n.terminalLabel=t.hud.terminalLabel),t.hud.animations!==e.hud.animations&&(n.animations=t.hud.animations);let r={};for(let n of Object.keys(t.hud.clock))t.hud.clock[n]!==e.hud.clock[n]&&(r[n]=t.hud.clock[n]);Object.keys(r).length&&(n.clock=r),JSON.stringify(t.hud.launcher)!==JSON.stringify(e.hud.launcher)&&(n.launcher=t.hud.launcher),Object.keys(n).length&&(i.hud=n)}if(e.openai&&t.openai){let n={};for(let r of[`url`,`model`,`vision`])t.openai[r]!==e.openai[r]&&(n[r]=t.openai[r]);r.trim()&&(n.apiKey=r.trim()),Object.keys(n).length&&(i.openai=n)}return i}function vt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function yt(e,t=`|`){return e.map(e=>Wt(e)).join(t)}function bt(e,t){return typeof t==`bigint`?t.toString():t}var xt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function St(e){return new xt(e)}function Ct(e){return e==null}function wt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Tt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Et(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Dt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ot(e){return Dt(e._zod.def)??e._zod.def.shape}function kt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Et(this,t,e),e},enumerable:!0,configurable:!0})}function At(e,t,n){t in e?Et(e,t,n):e[t]=n}function jt(e,t,n,r){let i=Ot(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?kt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):At(e,a,r?r(n.value,a):n.value))}}function Mt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?kt(e,n,()=>t[n]):At(e,n,r.value))}}function Nt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Pt(e){return JSON.stringify(e)}function Ft(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var It=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Rt=St(()=>{if(Pn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function zt(e){if(Lt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Lt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Bt(e){return zt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Vt=new Set([`string`,`number`,`symbol`]);function Ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ut(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function W(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Wt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Gt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Kt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},qt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Jt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return jt(i,e,Yt(e,t)),Ut(e,Nt(n,{shape:i,checks:[]}))}function Yt(e,t){let n=Ot(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Yt(e,t)),a={};return jt(a,e,Reflect.ownKeys(Ot(e)).filter(e=>!i.has(e))),Ut(e,Nt(n,{shape:a,checks:[]}))}function Zt(e,t){if(!zt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ot(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ut(e,Nt(e._zod.def,{shape:Qt(e,t)}))}function Qt(e,t){let n={};return jt(n,e,Reflect.ownKeys(Ot(e))),Mt(n,t),n}function $t(e,t){if(!zt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ut(e,Nt(e._zod.def,{shape:Qt(e,t)}))}function en(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return jt(n,e,Reflect.ownKeys(Ot(e))),jt(n,t,Reflect.ownKeys(Ot(t))),Ut(e,Nt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function tn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Yt(t,n)):void 0,o={};return jt(o,t,Reflect.ownKeys(Ot(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Ut(t,Nt(t._zod.def,{shape:o,checks:[]}))}function nn(e,t,n){let r=n?new Set(Yt(t,n)):void 0,i={};return jt(i,t,Reflect.ownKeys(Ot(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Ut(t,Nt(t._zod.def,{shape:i}))}function rn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function an(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function on(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function sn(e){return typeof e==`string`?e:e?.message}function cn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ln(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:sn(e.inst?._zod.def?.error?.(e))??sn(a?.(e))??sn(t?.error?.(e))??sn(n.customError?.(e))??sn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var un=/[\uD800-\uDBFF]/;function dn(e){let t=e.length;if(!un.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function fn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function pn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function mn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function hn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):yn(e,n,r.value)}}function gn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function _n(e,t,n){return gn(e,t,n,!1)}function vn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return gn(this,n,r(this))},set(e){gn(this,n,e)}})}return t}function yn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:gn(this,t,n.bind(this))},set(e){gn(this,t,e)}})}function bn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var xn,Sn=!1,Cn={configurable:!0,get(){Sn=!0}};function wn(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&xn!==e._zod){xn=void 0;return}xn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Cn);let e=Sn;Sn=!1;try{let r=n(this);return Sn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Sn||=e,r}catch(n){throw delete this[t],Sn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Tn(e,t,n,r){let i=bn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var En=`~constantCatch`;function Dn(e){let t=()=>e;return t[En]=!0,t}var On,kn={value:void 0,enumerable:!1},An=`captureStackTrace`in Error?Error:null;function jn(e){let t=An;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return An=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function G(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){kn.value=new a(r);try{Object.defineProperty(n,"_zod",kn)}finally{kn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),hn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?jn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Mn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Nn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(On=globalThis).__zod_globalConfig??(On.__zod_globalConfig={});var Pn=globalThis.__zod_globalConfig;function Fn(e){return e&&Object.assign(Pn,e),Pn}function In(){let e=this._zod;return e.message??=JSON.stringify(e.def,bt,2),e.message}function Ln(e){this._zod.message=e}var Rn={get:In,set:Ln,enumerable:!0,configurable:!0},zn={value:void 0,enumerable:!1},Bn=new WeakSet([Object.prototype,Error.prototype]),Vn=(e,t)=>{e.name=`$ZodError`,zn.value=t,Object.defineProperty(e,"issues",zn),zn.value=void 0,Object.defineProperty(e,"message",Rn);let n=Object.getPrototypeOf(e);Bn.has(n)||(Bn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Hn=G(`$ZodError`,Vn);G(`$ZodError`,Vn,void 0,{Parent:Error});function Un(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Wn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Un(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Gn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Kn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Mn;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ln(e,o,Fn())));throw It(n,a?.callee??t),n}return s.value};return t},Jn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ln(e,o,Fn())));throw It(n,a?.callee??t),n}return s.value};return t},Yn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Mn;return a.issues.length?Xn(e,a.issues,i):{success:!0,data:a.value}};function Xn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ln(e,n,Fn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Zn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Xn(e,a.issues,i):{success:!0,data:a.value}},Qn=Symbol.for(`zod.compile.invalid`),$n=Symbol.for(`zod.compile.fallback`),er=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Qn)return!0;if(r.definite===!0&&n===void 0)return!1}return tr(e,t,n)});function tr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[$n]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Mn;return a.issues.length===0}var nr=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},rr=e=>{let t=qn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Kn(n,a))};return n},ir=e=>{let t=qn(e),n=(e,r,i,a)=>t(e,r,i,Kn(n,a));return n},ar=e=>{let t=Jn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Kn(n,a))};return n},or=e=>{let t=Jn(e),n=async(e,r,i,a)=>await t(e,r,i,Kn(n,a));return n},sr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Yn(e)(t,n,i)},cr=e=>(t,n,r)=>Yn(e)(t,n,r),lr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Zn(e)(t,n,i)},ur=e=>async(t,n,r)=>Zn(e)(t,n,r),dr=/^[cC][0-9a-z]{6,}$/,fr=/^[0-9a-z]+$/,pr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,mr=/^[0-9a-vA-V]{20}$/,hr=/^[A-Za-z0-9]{27}$/,gr=/^[a-zA-Z0-9_-]{21}$/;function _r(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var vr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,br=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Sr=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Cr(){return new RegExp(Sr,`u`)}var wr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Er=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Dr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Or=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ar=/^https?$/,jr=/^\+[1-9]\d{6,14}$/,Mr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Nr(e){return RegExp(`^${e}$`)}var Pr=Nr(Mr);function Fr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ir(e){return RegExp(`^${Fr(e)}$`)}function Lr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Fr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Fr({precision:e.precision})}`:n;return RegExp(`^${Mr}T(?:${r})$`)}var Rr=/^[\s\S]{0,}$/,zr=/^-?\d+$/,Br=/^-?\d+(?:\.\d+)?$/,Vr=/^(?:true|false)$/i,Hr=/^[^A-Z]*$/,Ur=/^[^a-z]*$/,Wr=G(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Gr=e=>{let t=e.value;return!Ct(t)&&t.length!==void 0},Kr={number:`number`,bigint:`bigint`,object:`date`},qr=G(`$ZodCheckLessThan`,(e,t)=>{Wr.init(e,t);let n=Kr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Kr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jr=G(`$ZodCheckGreaterThan`,(e,t)=>{Wr.init(e,t);let n=Kr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Kr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yr=G(`$ZodCheckMultipleOf`,(e,t)=>{Wr.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Tt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Xr=G(`$ZodCheckNumberFormat`,(e,t)=>{Wr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Kt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Zr=G(`$ZodCheckMaxLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?dn(r):i)<=t.maximum)return;let a=fn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qr=G(`$ZodCheckMinLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?dn(r):i)>=t.minimum)return;let a=fn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$r=G(`$ZodCheckLengthEquals`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=Gr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?dn(r):i;if(a===t.length)return;let o=fn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ei=G(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Wr.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ti=G(`$ZodCheckRegex`,(e,t)=>{ei.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ni=G(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Hr,ei.init(e,t)}),ri=G(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ur,ei.init(e,t)}),ii=G(`$ZodCheckIncludes`,(e,t)=>{Wr.init(e,t);let n=Ht(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ai=G(`$ZodCheckStartsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`^${Ht(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),oi=G(`$ZodCheckEndsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`.*${Ht(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),si=G(`$ZodCheckOverwrite`,(e,t)=>{Wr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ci=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
12
12
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
13
13
|
`)}\n};`)(...Object.values(this.closed))}},li={major:4,minor:6,patch:5},ui=G(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=li;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=rn(t),a;for(let o of n){if(o._zod.def.when){if(an(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Mn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(cn(t.issues,n,e),i||=rn(t,n))});else{if(t.issues.length===n)continue;cn(t.issues,n,e),i||=rn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(rn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Mn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Mn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return _n(this,`~standard`,pi(this))},set"~standard"(e){gn(this,`~standard`,e)}}),di=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ln(e,t,Fn()))}:{value:e.value};async function fi(e,t){let n={async:!0};return di(await e._zod.run({value:t,issues:[]},n),n)}function pi(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return di(r,n)}catch{}return fi(e,t)},vendor:`zod`,version:1}}var mi=G(`$ZodString`,(e,t)=>{ui.init(e,t),e._zod.pattern=t.pattern??Rr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),hi=G(`$ZodStringFormat`,(e,t)=>{ei.init(e,t),mi.init(e,t)}),gi=G(`$ZodGUID`,(e,t)=>{t.pattern??=yr,hi.init(e,t)}),_i=G(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=br(e)}else t.pattern??=br();hi.init(e,t)}),vi=G(`$ZodEmail`,(e,t)=>{t.pattern??=xr,hi.init(e,t)});function yi(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function bi(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?yi(e)||2:xi(e,t)}function xi(e,t){if(!t.normalize&&t.protocol?.source===Ar.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Si=/[\t\n\r]/g;function Ci(e){return e.replace(Si,``)}function wi(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ti(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Ei=G(`$ZodURL`,(e,t)=>{hi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=bi(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Ci(r);return}t.hostname&&!wi(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Ti(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Ci(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Di=G(`$ZodEmoji`,(e,t)=>{t.pattern??=Cr(),hi.init(e,t)}),Oi=G(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?gr:_r(t.length),hi.init(e,t)}),ki=G(`$ZodCUID`,(e,t)=>{t.pattern??=dr,hi.init(e,t)}),Ai=G(`$ZodCUID2`,(e,t)=>{t.pattern??=fr,hi.init(e,t)}),ji=G(`$ZodULID`,(e,t)=>{t.pattern??=pr,hi.init(e,t)}),Mi=G(`$ZodXID`,(e,t)=>{t.pattern??=mr,hi.init(e,t)}),Ni=G(`$ZodKSUID`,(e,t)=>{t.pattern??=hr,hi.init(e,t)}),Pi=G(`$ZodISODateTime`,(e,t)=>{t.pattern??=Lr(t),hi.init(e,t)}),Fi=G(`$ZodISODate`,(e,t)=>{t.pattern??=Pr,hi.init(e,t)}),Ii=G(`$ZodISOTime`,(e,t)=>{t.pattern??=Ir(t),hi.init(e,t)}),Li=G(`$ZodISODuration`,(e,t)=>{t.pattern??=vr,hi.init(e,t)}),Ri=G(`$ZodIPv4`,(e,t)=>{t.pattern??=wr,hi.init(e,t)}),zi=/^[0-9a-fA-F:.]+$/;function Bi(e){return zi.test(e)?yi(`http://[${e}]`):!1}var Vi=G(`$ZodIPv6`,(e,t)=>{t.pattern??=Tr,hi.init(e,t),e._zod.check=n=>{Bi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Hi=G(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Er,hi.init(e,t)});function Ui(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Bi(n)}var Wi=G(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Dr,hi.init(e,t),e._zod.check=n=>{Ui(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Gi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ki=/^[0-9a-zA-Z+/]*={0,2}$/,qi=G(`$ZodBase64`,(e,t)=>{t.pattern??=Ki,hi.init(e,t),e._zod.check=n=>{Gi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ji=/^[A-Za-z0-9_-]*$/;function Yi(e){if(!Ji.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Gi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Xi=G(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ji,hi.init(e,t),e._zod.check=n=>{Yi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Zi=G(`$ZodE164`,(e,t)=>{t.pattern??=jr,hi.init(e,t)});function Qi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var $i=G(`$ZodJWT`,(e,t)=>{hi.init(e,t),e._zod.check=n=>{Qi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ea=G(`$ZodNumber`,(e,t)=>{ui.init(e,t),e._zod.pattern=Br,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ta=G(`$ZodNumberFormat`,(e,t)=>{Xr.init(e,t),ea.init(e,t)}),na=G(`$ZodBoolean`,(e,t)=>{ui.init(e,t),e._zod.pattern=Vr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ra=G(`$ZodUnknown`,(e,t)=>{ui.init(e,t),e._zod.parse=e=>e}),ia=G(`$ZodNever`,(e,t)=>{ui.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function aa(e,t,n){e.issues.length&&t.issues.push(...on(n,e.issues)),t.value[n]=e.value}var oa=G(`$ZodArray`,(e,t)=>{ui.init(e,t);let n=Pn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>aa(t,r,e)));else if(aa(c,r,e),s&&c.issues.length!==0&&rn(c))break}return o.length?Promise.all(o).then(()=>r):r}});function sa(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...on(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var ca=[];function la(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ca,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Gt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ua(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(rn(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>sa(e,n,i,t,d,f))):sa(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var da=G(`$ZodObject`,(e,t)=>{ui.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=St(()=>la(t));wn(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Et(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Lt,o=t.catchall,s,c=Pn.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(rn(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>sa(n,t,e,r,a,o))):sa(s,t,e,r,a,o)}return o?ua(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),fa=G(`$ZodObjectJIT`,(e,t)=>{da.init(e,t);let n=e._zod.parse,r=St(()=>la(t)),i=Pn.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ci([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
14
14
|
let ${e}_ab = false;
|
|
@@ -4384,16 +4384,16 @@ void main() {
|
|
|
4384
4384
|
float v = body * 0.35 + plasma * 0.7 + rim * 1.1 + halo + ripple;
|
|
4385
4385
|
gl_FragColor = vec4(uColor * v * uBright, clamp(v * uBright, 0.0, 1.0));
|
|
4386
4386
|
}
|
|
4387
|
-
`,wx=class{host;core;renderer;scene=new lh;camera=new N_(-1,1,1,-1,0,1);material;geometry=new qg(2,2);raf=0;last=0;ro;disposed=!1;constructor(e,t,n){this.host=e,this.core=new af({reducedMotion:n}),this.renderer=new hx({alpha:!0,antialias:!1}),this.renderer.setClearColor(0,0),this.renderer.domElement.style.cssText=`width:100%;height:100%;display:block`,e.appendChild(this.renderer.domElement),this.material=new n_({vertexShader:Sx,fragmentShader:Cx,transparent:!0,depthWrite:!1,blending:2,uniforms:{uPhase:{value:0},uAmp:{value:0},uBright:{value:.85},uNoise:{value:.05},uTighten:{value:0},uAspect:{value:1},uColor:{value:new sh(t)}}}),this.scene.add(new Dg(this.geometry,this.material)),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(e),this.resize(),this.raf=requestAnimationFrame(this.frame)}resize(){let e=Math.max(1,this.host.clientWidth),t=Math.max(1,this.host.clientHeight);this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setSize(e,t,!1),this.material.uniforms.uAspect.value=e/t}frame=e=>{if(this.disposed)return;if(this.raf=requestAnimationFrame(this.frame),document.hidden){this.last=e;return}let t=this.last?Math.min((e-this.last)/1e3,.1):.016;this.last=e,this.core.tick(t);let n=this.core.uniforms(),r=this.material.uniforms;r.uPhase.value=n.phase,r.uAmp.value=n.amplitude,r.uBright.value=n.brightness,r.uNoise.value=n.noise,r.uTighten.value=n.tighten,this.renderer.render(this.scene,this.camera)};setState(e){this.core.setState(e)}setAmplitude(e){this.core.setAmplitude(e)}setMode(e){this.resize()}setAccent(e){this.material.uniforms.uColor.value.set(e)}setIntensity(e){this.core.setIntensity(e)}dispose(){this.disposed=!0,cancelAnimationFrame(this.raf),this.ro.disconnect(),this.geometry.dispose(),this.material.dispose(),this.renderer.dispose(),this.renderer.domElement.remove()}},Tx=e=>Number.isFinite(e)?e:0;function Ex(e,t,n,r){let i=Tx(t),a=Math.min(1,Math.max(0,Tx(n))),o=Math.min(1,Math.max(0,Tx(r)));return Array.from({length:Math.max(0,Math.floor(e))},(e,t)=>{let n=.12+.18*(.5+.5*Math.sin(t*.31+i*2.2))+o*(.5+.5*Math.sin(t*.9+i*4)),r=a*(.35+.65*(.5+.5*Math.sin(t*2.1+i*9)));return Math.min(1,Math.max(0,n+r))})}var Dx=96,Ox=class{host;core;canvas=document.createElement(`canvas`);ctx;raf=0;last=0;ro=null;disposed=!1;accent;constructor(e,t,n){this.host=e,this.core=new af({reducedMotion:n}),this.accent=t,this.canvas.style.cssText=`width:100%;height:100%;display:block`,this.ctx=this.canvas.getContext(`2d`),e.appendChild(this.canvas),this.ctx&&(typeof ResizeObserver<`u`&&(this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(e)),this.resize(),this.raf=requestAnimationFrame(this.frame))}resize(){let e=Math.min(window.devicePixelRatio||1,2);this.canvas.width=Math.max(1,this.host.clientWidth)*e,this.canvas.height=Math.max(1,this.host.clientHeight)*e}frame=e=>{if(this.disposed||!this.ctx)return;if(this.raf=requestAnimationFrame(this.frame),document.hidden){this.last=e;return}let t=this.last?Math.min((e-this.last)/1e3,.1):.016;this.last=e,this.core.tick(t);let n=this.core.uniforms(),r=this.ctx,{width:i,height:a}=this.canvas,o=Math.min(i,a);r.clearRect(0,0,i,a);let s=o*.27*(1-n.tighten),c=o*.2,l=Ex(Dx,n.phase,n.amplitude,n.noise);r.save(),r.translate(i/2,a/2),r.rotate(n.angle),r.lineCap=`round`,r.strokeStyle=this.accent,r.shadowColor=this.accent,r.shadowBlur=o*.02*n.brightness,r.lineWidth=Math.max(2,o*.008);let u=this.core.state===`thinking`;for(let e=0;e<Dx;e++){let t=e/Dx*Math.PI*2,i=u?.25+.75*Math.abs(Math.sin((t-n.phase*2)/2)):1;r.globalAlpha=Math.min(1,(.35+l[e]*.65)*n.brightness*i);let a=o*.012+l[e]*c;r.beginPath(),r.moveTo(Math.cos(t)*s,Math.sin(t)*s),r.lineTo(Math.cos(t)*(s+a),Math.sin(t)*(s+a)),r.stroke()}r.globalAlpha=.28*n.brightness,r.shadowBlur=0,r.lineWidth=Math.max(1,o*.003),r.beginPath(),r.arc(0,0,s*.9,0,Math.PI*2),r.stroke(),r.restore()};setState(e){this.core.setState(e)}setAmplitude(e){this.core.setAmplitude(e)}setMode(e){this.resize()}setAccent(e){this.accent=e}setIntensity(e){this.core.setIntensity(e)}dispose(){this.disposed=!0,cancelAnimationFrame(this.raf),this.ro?.disconnect(),this.canvas.remove()}};function kx(e,t,n){let r=ef({...n.env??tf(),reducedMotion:n.reducedMotion}),i=()=>new xx(t,r||8e3,n.accent,n.reducedMotion);if(e===`ring`)return new Ox(t,n.accent,n.reducedMotion);if(r===0)return i();try{return e===`orb`?new wx(t,n.accent,n.reducedMotion):new bx(t,r,n.accent,n.reducedMotion)}catch{return i()}}function Ax({state:e,amplitude:t,pulse:n=0,mode:r,accent:i=`#3fd8ff`,style:a=`sphere`,intensity:o=.6,scale:s=1}){let c=(0,l.useRef)(null),u=(0,l.useRef)(null),d=(0,l.useRef)({state:e,amplitude:t,mode:r,accent:i,intensity:o});return d.current={state:e,amplitude:t,mode:r,accent:i,intensity:o},(0,l.useEffect)(()=>{let e=d.current,t=kx(a,c.current,{accent:e.accent,reducedMotion:tf().reducedMotion});return t.setState(e.state),t.setAmplitude(e.amplitude),t.setIntensity(e.intensity),t.setMode(e.mode),u.current=t,()=>{t.dispose(),u.current=null}},[a]),(0,l.useEffect)(()=>u.current?.setState(e),[e]),(0,l.useEffect)(()=>u.current?.setAmplitude(t),[t,n]),(0,l.useEffect)(()=>u.current?.setMode(r),[r]),(0,l.useEffect)(()=>u.current?.setAccent(i),[i]),(0,l.useEffect)(()=>u.current?.setIntensity(o),[o]),(0,p.jsx)(`div`,{ref:c,"data-presence":!0,"data-mode":r,"data-style":a,"data-state":e,"data-amplitude":t.toFixed(2),className:`presence presence-${r}`,style:r===`full`&&s!==1?{transform:`scale(${s})`}:void 0,"aria-hidden":`true`})}var jx=e=>.25+Math.min(1,Math.max(0,e))/.7*.75;function Mx({look:e}){let[t,n]=(0,l.useState)(.4),[r,i]=(0,l.useState)(0);(0,l.useEffect)(()=>{let e=setInterval(()=>{n(.3+Math.random()*.5),i(e=>e+1)},600);return()=>clearInterval(e)},[]);let a=jx(e.reactivity);return(0,p.jsxs)(`div`,{className:`look-preview`,"data-testid":`look-preview`,role:`img`,"aria-label":`Preview of the voice presence`,children:[e.ambient&&(0,p.jsx)(`div`,{className:`look-preview-glow`,style:{opacity:.35+.65*e.intensity,"--accent":e.accent}}),(0,p.jsx)(`div`,{className:`look-preview-stage`,style:{"--accent":e.accent},children:(0,p.jsx)(Ax,{state:`speaking`,amplitude:Math.min(1,t*a),pulse:r,mode:`full`,accent:e.accent,style:e.style,intensity:e.intensity,scale:e.size})}),e.captions&&(0,p.jsx)(`p`,{className:`look-preview-caption captions-${e.captionSize}`,children:`This is how my words will look.`})]})}var Nx=async e=>{let t;try{t=await fetch(`/api/account/secret`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}catch{throw Error(`Could not reach Friend. Check the connection.`)}let n={};try{n=await t.json()}catch{}if(!t.ok){let e=typeof n.triesLeft==`number`&&n.triesLeft>0?` ${n.triesLeft} ${n.triesLeft===1?`try`:`tries`} left.`:``;throw Error((n.error??(t.status===401?`Please sign in again.`:`The request failed (${t.status}).`))+e)}return{signedOutOthers:!!n.signedOutOthers}};function Px({change:e=Nx}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(``),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=r!==``||a!==``,x=s!==``||u!==``,S=async()=>{if(_(null),y(null),!t)return _(`Type your current password.`);if(!b&&!x)return _(`Type a new password or a new PIN.`);if(b&&r.length<8)return _(`The new password must be at least 8 characters.`);if(b&&r!==a)return _(`The two new passwords are not the same.`);if(x&&!/^\d{6,}$/.test(s))return _(`The new PIN must be at least 6 digits.`);if(x&&s!==u)return _(`The two new PINs are not the same.`);h(!0);try{let a=await e({current:t,...b?{newPassword:r}:{},...x?{newPin:s}:{}});y([b&&`Password changed.`,x&&`PIN changed.`,b&&a.signedOutOthers&&`Other browsers and phones were signed out.`].filter(Boolean).join(` `)),n(``),i(``),o(``),c(``),f(``)}catch(e){_(e.message),n(``)}finally{h(!1)}};return(0,p.jsxs)(`form`,{className:`settings-section`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,p.jsx)(`h3`,{children:`Password and PIN`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Change either one or both. Your current password is always needed. Forgot it? On this PC run: friend password`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Current password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`current-password`,value:t,disabled:m,onChange:e=>n(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:r,disabled:m,onChange:e=>i(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New password again`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:a,disabled:m,onChange:e=>o(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New PIN`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:s,disabled:m,onChange:e=>c(e.target.value.replace(/\D/g,``)),style:d})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The PIN is at least 6 digits. It is asked before risky actions.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New PIN again`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:u,disabled:m,onChange:e=>f(e.target.value.replace(/\D/g,``)),style:d})]}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),v&&(0,p.jsx)(`p`,{role:`status`,className:`auth-note`,children:v}),(0,p.jsx)(`button`,{type:`submit`,className:`primary`,style:d,disabled:m,children:m?`Saving…`:`Change`})]})}var Fx=[{id:`read`,label:`Read only`,note:`Friend can look at your portfolio, funds, positions and orders, and send you reports. It cannot place, change or cancel any order. This is the only level in this version.`,locked:!1},{id:`orders`,label:`Orders with my confirmation (later version)`,note:`Friend would prepare an order and wait for you to confirm it with your PIN.`,locked:!0},{id:`limits`,label:`Orders within limits (later version)`,note:`Friend would place small orders on its own, inside limits you set.`,locked:!0}];function Ix({level:e=`read`}){return(0,p.jsxs)(`div`,{className:`settings-section`,role:`radiogroup`,"aria-label":`What Friend may do with money`,children:[(0,p.jsx)(`h3`,{children:`What may Friend do with your trading account?`}),Fx.map(t=>(0,p.jsxs)(`label`,{className:`settings-check`,style:{alignItems:`flex-start`,opacity:t.locked?.55:1},children:[(0,p.jsx)(`input`,{type:`radio`,name:`trading`,value:t.id,checked:!t.locked&&e===t.id,disabled:t.locked,readOnly:!0,onChange:()=>{}}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{children:t.label}),(0,p.jsx)(`br`,{}),(0,p.jsx)(`small`,{className:`auth-note`,children:t.note})]})]},t.id)),(0,p.jsx)(`small`,{className:`auth-note`,children:`The assistant can never change this, even with your PIN. Orders will only arrive in a later version, with their own safeguards.`})]})}var Lx=async()=>{let e=await fetch(`/api/music/host/check`,{cache:`no-store`});if(!e.ok)throw Error(e.status===401?`Please sign in again.`:`The request failed (${e.status}).`);return await e.json()},Rx={url:`Open an address`,prompt:`Ask the assistant`,panel:`Open a panel`,music:`Control the music`},zx=e=>e===`panel`?zu[0]:e===`music`?Bu[0]:``;function Bx({music:e,hud:t,onMusic:n,onHud:r,checkHost:i=Lx}){let[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(!1),u=()=>{c(!0),o(null),i().then(e=>o(e.found?`mpv ${e.version} found (${e.path}).`:e.install)).catch(e=>o(e.message)).finally(()=>c(!1))},d=t.launcher,f=(e,t)=>r({launcher:d.map((n,r)=>r===e?{...n,...t}:n)}),m=(e,t)=>{let n=e+t;if(n<0||n>=d.length)return;let i=[...d];[i[e],i[n]]=[i[n],i[e]],r({launcher:i})};return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsx)(`h3`,{children:`Music player`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Music folder`}),(0,p.jsx)(`input`,{type:`text`,value:e.folder,placeholder:`C:\\Users\\you\\Music`,onChange:e=>n({folder:e.target.value})}),(0,p.jsx)(`small`,{className:`auth-note`,children:`A folder on the PC that runs Friend. Its sub-folders are searched too. Saving checks that it exists.`})]}),(0,p.jsxs)(`fieldset`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`File types to look for`}),Lu.map(t=>(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.extensions.includes(t),onChange:r=>{let i=r.target.checked?[...e.extensions,t]:e.extensions.filter(e=>e!==t);i.length&&n({extensions:Lu.filter(e=>i.includes(e))})}}),(0,p.jsx)(`span`,{children:t})]},t))]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsxs)(`span`,{children:[`Start volume (`,e.volume,`%)`]}),(0,p.jsx)(`input`,{type:`range`,min:Ru.volume.min,max:Ru.volume.max,value:e.volume,onChange:e=>n({volume:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Repeat`}),(0,p.jsxs)(`select`,{value:e.repeat,onChange:e=>n({repeat:e.target.value}),children:[(0,p.jsx)(`option`,{value:`off`,children:`Off`}),(0,p.jsx)(`option`,{value:`all`,children:`The whole list`}),(0,p.jsx)(`option`,{value:`one`,children:`One track`})]})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Starts as`}),(0,p.jsxs)(`select`,{value:e.startView,onChange:e=>n({startView:e.target.value}),children:[(0,p.jsx)(`option`,{value:`mini`,children:`Small player`}),(0,p.jsx)(`option`,{value:`full`,children:`Big player with the playlist`})]})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.shuffle,onChange:e=>n({shuffle:e.target.checked})}),(0,p.jsx)(`span`,{children:`Shuffle`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.visualizer,onChange:e=>n({visualizer:e.target.checked})}),(0,p.jsx)(`span`,{children:`Moving bars around the dial`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Where music comes from, when the assistant is not told`}),(0,p.jsxs)(`select`,{value:e.defaultSource,onChange:e=>n({defaultSource:e.target.value}),children:[(0,p.jsx)(`option`,{value:`local`,children:`The music folder`}),(0,p.jsx)(`option`,{value:`spotify`,children:`Spotify`}),(0,p.jsx)(`option`,{value:`soundcloud`,children:`SoundCloud`}),(0,p.jsx)(`option`,{value:`audius`,children:`Audius`}),(0,p.jsx)(`option`,{value:`any`,children:`All`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Spotify, SoundCloud and Audius are added from Plugins. Playing from Spotify needs Spotify Premium on your account.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Most results from a service such as Spotify`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.searchLimit.min,max:Ru.searchLimit.max,value:e.searchLimit,onChange:e=>n({searchLimit:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Where the sound comes out`}),(0,p.jsxs)(`select`,{value:e.output,onChange:e=>n({output:e.target.value}),children:[(0,p.jsx)(`option`,{value:`screen`,children:`The screen (the browser plays it)`}),(0,p.jsx)(`option`,{value:`host`,children:`This PC's speakers (no browser needed)`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The PC's speakers play your folder's music through mpv, a free player you install once. Spotify plays on a Spotify device you name below.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Program that plays the folder's music on the PC (empty: find mpv automatically)`}),(0,p.jsx)(`input`,{type:`text`,value:e.hostPlayer,maxLength:260,placeholder:`mpv`,onChange:e=>n({hostPlayer:e.target.value})}),Uu(e.hostPlayer.trim())&&(0,p.jsx)(`small`,{role:`alert`,className:`auth-error`,children:Uu(e.hostPlayer.trim())})]}),(0,p.jsxs)(`div`,{className:`settings-field`,children:[(0,p.jsx)(`button`,{type:`button`,disabled:s,onClick:u,children:`Check mpv`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Looks for mpv with the saved program setting, or automatically when it is empty.`}),a&&(0,p.jsx)(`small`,{role:`status`,className:`auth-note`,children:a})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Spotify device on the PC to play on`}),(0,p.jsx)(`input`,{type:`text`,value:e.spotifyDevice,maxLength:100,placeholder:`the name Spotify shows for that device`,onChange:e=>n({spotifyDevice:e.target.value})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Most tracks to list`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.maxTracks.min,max:Ru.maxTracks.max,value:e.maxTracks,onChange:e=>n({maxTracks:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`How many folders deep to search`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.scanDepth.min,max:Ru.scanDepth.max,value:e.scanDepth,onChange:e=>n({scanDepth:Number(e.target.value)})})]}),(0,p.jsx)(`h3`,{children:`Screen widgets`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Name on the profile tag`}),(0,p.jsx)(`input`,{type:`text`,maxLength:24,value:t.terminalLabel,onChange:e=>r({terminalLabel:e.target.value})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Animations`}),(0,p.jsxs)(`select`,{value:t.animations,onChange:e=>r({animations:e.target.value}),children:[(0,p.jsx)(`option`,{value:`full`,children:`Full`}),(0,p.jsx)(`option`,{value:`reduced`,children:`Reduced (only answers to hover and press)`}),(0,p.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`If the device is set to reduce motion, the screen stays still whatever this says.`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t.clock.hour12,onChange:e=>r({clock:{...t.clock,hour12:e.target.checked}})}),(0,p.jsx)(`span`,{children:`12-hour clock`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t.clock.seconds,onChange:e=>r({clock:{...t.clock,seconds:e.target.checked}})}),(0,p.jsx)(`span`,{children:`Show seconds`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Date language (empty: the device's own)`}),(0,p.jsx)(`input`,{type:`text`,value:t.clock.locale,maxLength:35,placeholder:`en-GB`,onChange:e=>r({clock:{...t.clock,locale:e.target.value}})})]}),(0,p.jsx)(`h3`,{children:`Quick-launch buttons`}),d.length===0&&(0,p.jsx)(`small`,{className:`auth-note`,children:`No buttons yet.`}),d.map((e,t)=>{let n=Hu(e);return(0,p.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-label":`Button ${t+1}`,children:[(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:[(0,p.jsx)(`input`,{type:`text`,"aria-label":`Icon`,style:{width:56},value:e.icon,onChange:e=>f(t,{icon:e.target.value})}),(0,p.jsx)(`input`,{type:`text`,"aria-label":`Label`,maxLength:24,style:{flex:1,minWidth:100},value:e.label,onChange:e=>f(t,{label:e.target.value})}),(0,p.jsx)(`select`,{"aria-label":`What it does`,value:e.action.type,onChange:e=>{let n=e.target.value;f(t,{action:{type:n,value:zx(n)}})},children:Object.keys(Rx).map(e=>(0,p.jsx)(`option`,{value:e,children:Rx[e]},e))})]}),(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:[e.action.type===`panel`||e.action.type===`music`?(0,p.jsx)(`select`,{"aria-label":`Which`,style:{flex:1},value:e.action.value,onChange:n=>f(t,{action:{...e.action,value:n.target.value}}),children:(e.action.type===`panel`?zu:Bu).map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))}):(0,p.jsx)(`input`,{type:`text`,"aria-label":e.action.type===`url`?`Address`:`Question`,style:{flex:1},value:e.action.value,placeholder:e.action.type===`url`?`https://…`:`What should it ask?`,onChange:n=>f(t,{action:{...e.action,value:n.target.value}})}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Move up`,disabled:t===0,onClick:()=>m(t,-1),children:`↑`}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Move down`,disabled:t===d.length-1,onClick:()=>m(t,1),children:`↓`}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Remove button`,onClick:()=>r({launcher:d.filter((e,n)=>n!==t)}),children:`Remove`})]}),n&&(0,p.jsx)(`small`,{role:`alert`,className:`auth-error`,children:n})]},e.id??t)}),(0,p.jsxs)(`button`,{type:`button`,disabled:d.length>=12,onClick:()=>r({launcher:[...d,{label:`New`,icon:`+`,action:{type:`panel`,value:`chat`}}]}),children:[`Add a button (`,d.length,`/`,12,`)`]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The assistant can never change the music folder, these buttons or the animations, even with your PIN.`})]})}var Vx=[`#3fd8ff`,`#2b7bff`,`#a066ff`,`#ff6fae`,`#ff5a5a`,`#ff9b3d`,`#ffd23d`,`#3dff8c`,`#e8f4ff`],Hx=[{id:`sphere`,name:`Sphere`,note:`A cloud of particles`},{id:`orb`,name:`Orb`,note:`A glowing plasma ball`},{id:`ring`,name:`Ring`,note:`Radial bars, like a voice meter`}],Ux=(e,t)=>e.style===t.style&&e.accent.toLowerCase()===t.accent&&Math.abs(e.intensity-t.intensity)<.005;async function Wx(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:n.status===403?`Incorrect PIN`:`The request failed (${n.status}).`));return r}var Gx=e=>({method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),Kx={info:()=>Wx(`/api/system`),check:()=>Wx(`/api/system/update/check`,Gx({})),update:e=>Wx(`/api/system/update/apply`,Gx({pin:e})),setAutostart:(e,t)=>Wx(`/api/system/autostart`,Gx({enabled:e,pin:t}))},qx=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Jx({api:e=Kx,auto:t,onAuto:n,pollMs:r=0}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(null),y=(0,l.useRef)(!0),b=(0,l.useCallback)(async()=>{try{let t=await e.info();y.current&&a(t)}catch(e){y.current&&g(e.message)}},[e]);(0,l.useEffect)(()=>{y.current=!0,b();let e=r>0?setInterval(()=>void b(),r):null;return()=>{y.current=!1,e&&clearInterval(e)}},[b,r]);let x=async()=>{if(o){m(!0),g(null);try{let t=o.kind===`autostart`?await e.setAutostart(o.enabled,c):await e.update(c);if(!y.current)return;v(t.message),s(null),await b()}catch(e){y.current&&g(e.message)}finally{y.current&&(m(!1),u(``))}}},S=async()=>{m(!0),g(null),v(null);try{let t=await e.check();y.current&&a(e=>e&&{...e,update:t})}catch(e){y.current&&g(e.message)}finally{y.current&&m(!1)}};if(o)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:o.kind===`update`?`Enter your PIN to update Friend now. It restarts in a moment.`:o.enabled?`Enter your PIN to start Friend by itself when this computer starts.`:`Enter your PIN to stop starting Friend with this computer.`}),(0,p.jsx)(T,{pin:c,onChange:u,onSubmit:()=>!f&&c.length>=6&&void x()}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f||c.length<6,onClick:()=>void x(),children:`Continue`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{s(null),u(``),g(null)},children:`Back`})]})]});let C=i?.update;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Start with the computer`}),i&&(i.autostart.supported?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:i.autostart.enabled?`Friend starts by itself when you sign in to this computer, so you never have to start it after a restart.`:`Friend does not start by itself yet: after a restart you start it yourself.`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:i.autostart.enabled?void 0:`primary`,disabled:f,onClick:()=>s({kind:`autostart`,enabled:!i.autostart.enabled}),children:i.autostart.enabled?`Stop starting Friend with this computer`:`Start Friend when this computer starts`})})]}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Starting Friend by itself is not supported on this computer.`})),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Updates`}),i&&C&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Friend `,i.version,`.`,` `,C.applying?`Updating Friend to ${C.latest??`the newest version`}…`:C.available?`Friend ${C.latest} is available.`:C.latest?`Up to date.`:`Not checked yet.`,C.checkedAt?` (looked at ${qx(C.checkedAt)})`:``]}),C.error&&(0,p.jsx)(`p`,{className:`auth-error`,children:C.error}),C.available&&!C.canApply&&!C.applying&&(0,p.jsx)(`p`,{className:`auth-note`,children:`This Friend is running in a terminal, so it cannot restart itself. Close it and run: friend upgrade`}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f||C.applying,onClick:()=>void S(),children:`Check for updates`}),C.available&&C.canApply&&!C.applying&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f,onClick:()=>s({kind:`update`}),children:`Update now`})]})]}),(0,p.jsxs)(`label`,{className:`settings-check`,style:{marginTop:10},children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),` Update Friend by itself`]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Looks for a newer Friend when it starts, then every few hours, and installs it while Friend is not busy. Switch it off to update only when you press Update now (or run friend upgrade).`}),_&&(0,p.jsx)(`p`,{className:`auth-note`,children:_}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h})]})}async function Yx(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Xx={summary:e=>Yx(`/api/usage?days=${e}`),clear:()=>Yx(`/api/usage`,{method:`DELETE`})},Zx=[7,30,90],Qx=e=>e.toLocaleString(`en-US`);function $x(e){return e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${+(e/1e3).toFixed(1)}K`:String(e)}var eS={voice:`Voice`,chat:`Chat`,task:`Scheduled tasks`,channel:`Messages (WhatsApp, Telegram…)`,other:`Other`};function tS({api:e=Xx}){let[t,n]=(0,l.useState)(7),[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(null),[u,f]=(0,l.useState)(!1),m=(0,l.useRef)(!0),h=(0,l.useCallback)(async t=>{try{let n=await e.summary(t);m.current&&(i(n),o(null))}catch(e){m.current&&o(e.message)}},[e]);(0,l.useEffect)(()=>(m.current=!0,h(t),()=>{m.current=!1}),[h,t]);let g=async()=>{try{let n=await e.clear();if(!m.current)return;c(`Removed ${n.removed} saved counts.`),f(!1),await h(t)}catch(e){m.current&&o(e.message)}},_=r?Math.max(1,...r.days.map(e=>e.input+e.output)):1,v=!!r&&r.total.turns===0;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`approval-actions`,role:`group`,"aria-label":`How far back`,children:Zx.map(e=>(0,p.jsxs)(`button`,{type:`button`,style:d,className:t===e?`primary`:void 0,"aria-pressed":t===e,onClick:()=>n(e),children:[e,` days`]},e))}),a&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:a}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`usage-totals`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:$x(r.total.input)}),(0,p.jsx)(`span`,{children:`Sent to the model`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:$x(r.total.output)}),(0,p.jsx)(`span`,{children:`Written back`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:r.total.turns}),(0,p.jsx)(`span`,{children:`Answers`})]})]}),v?(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing counted yet. Once Friend has answered, the tokens it used show up here.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`usage-bars`,"aria-hidden":!1,children:r.days.map(e=>{let t=e.input+e.output;return(0,p.jsxs)(`div`,{className:`usage-bar-col`,children:[(0,p.jsx)(`div`,{role:`img`,"aria-label":`${e.day}: ${Qx(t)} tokens on ${e.turns} answers`,className:`usage-bar`,style:{height:`${Math.max(t>0?4:1,Math.round(t/_*100))}%`},title:`${e.day}: ${Qx(t)} tokens`}),r.days.length<=31&&(0,p.jsx)(`span`,{className:`usage-bar-day`,children:e.day.slice(8)})]},e.day)})}),(0,p.jsxs)(`table`,{className:`usage-table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Day`}),(0,p.jsx)(`th`,{scope:`col`,children:`Sent`}),(0,p.jsx)(`th`,{scope:`col`,children:`Written`}),(0,p.jsx)(`th`,{scope:`col`,children:`Answers`})]})}),(0,p.jsx)(`tbody`,{children:[...r.days].reverse().map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`row`,children:e.day}),(0,p.jsx)(`td`,{children:Qx(e.input)}),(0,p.jsx)(`td`,{children:Qx(e.output)}),(0,p.jsx)(`td`,{children:e.turns})]},e.day))})]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`By model`}),(0,p.jsx)(`ul`,{className:`usage-list`,children:r.byModel.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`span`,{children:[e.provider,` / `,e.model]}),(0,p.jsxs)(`span`,{children:[$x(e.input+e.output),` tokens · `,e.turns,` answers`]})]},`${e.provider}/${e.model}`))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`By where it came from`}),(0,p.jsx)(`ul`,{className:`usage-list`,children:r.bySource.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`span`,{children:eS[e.source]??e.source}),(0,p.jsxs)(`span`,{children:[$x(e.input+e.output),` tokens · `,e.turns,` answers`]})]},e.source))})]})]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend keeps counts only: the day, the model, and how many tokens. Never what was said. Counts older than a year are removed by themselves.`}),s&&(0,p.jsx)(`p`,{className:`auth-note`,children:s}),(0,p.jsx)(`div`,{className:`approval-actions`,children:u?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:()=>void g(),children:`Yes, clear them`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>f(!1),children:`Keep them`})]}):(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>f(!0),children:`Clear saved counts`})})]})}var nS=[{id:`manual`,label:`Ask me (manual)`,note:`Friend asks before anything that changes your PC or leaves the safe zone. The most careful.`},{id:`edits`,label:`Auto-approve file work (edits)`,note:`Reading and writing files, and the sandboxed code runner, go ahead without asking. Commands still ask.`},{id:`auto`,label:`Auto-approve everything safe (auto)`,note:`Commands, files and tools go ahead without asking. The most convenient, and the most trust: Friend acts on its own.`}],rS=[{id:`claude-code`,label:`Claude subscription (Claude Code)`,note:`Uses the Claude Code app you are signed in to. No API key.`},{id:`claude`,label:`Claude API key`,note:`Pay per use with an Anthropic API key.`},{id:`ollama`,label:`Local model (Ollama)`,note:`Runs on this PC. Free and private, but slower.`},{id:`openai`,label:`OpenAI-compatible server (OmniRoute, LM Studio…)`,note:`Any server that speaks the OpenAI chat API. OmniRoute is one address that routes to many models, many of them free.`}],iS={"voice.enabled":`Speech on/off`};function aS({label:e,children:t,hint:n}){return(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:e}),t,n&&(0,p.jsx)(`small`,{className:`auth-note`,children:n})]})}function oS({api:e=ht,onClose:t,initialTab:n=`model`,preview:r=gt,variant:i=`classic`}){let[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(null),[u,f]=(0,l.useState)(n),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(``),[v,y]=(0,l.useState)(!1),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(!1),[E,D]=(0,l.useState)(null),[O,k]=(0,l.useState)(null),[A,j]=(0,l.useState)(null),[ee,M]=(0,l.useState)(null),N=(0,l.useRef)(!0);(0,l.useEffect)(()=>(N.current=!0,e.get().then(e=>{N.current&&(o(e),c(structuredClone(e)))}).catch(e=>N.current&&D(e.message)),()=>{N.current=!1}),[e]);let P=(e,n=!1,r={})=>i===`holo`?(0,p.jsx)(b,{label:`Settings`,title:r.title??Se.find(e=>e.id===u)?.label??`Settings`,page:r.page,help:r.help,onApply:r.onApply,onUndo:r.onUndo,dirty:r.dirty,busy:C,onDone:t,children:e}):(0,p.jsxs)(`div`,{className:`approval settings glass${n?` settings-wide`:``}`,role:`dialog`,"aria-label":`Settings`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Settings`})}),e]});if(!s||!a)return P((0,p.jsxs)(p.Fragment,{children:[E?(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Loading…`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})})]}));let F=_t(a,s,m,g),te=Object.keys(F).length>0,I=(e,t,n)=>c({...s,[e]:{...s[e],[t]:n}}),ne=s.look,L=(e,t)=>{t&&(j(e),M(e===`main`?null:`The first time, the voice downloads (about 64 MB). Please wait…`),r(t).then(()=>N.current&&M(`Playing…`)).catch(e=>N.current&&M(e.message)).finally(()=>N.current&&j(null)))},re=async t=>{D(null),w(!0);try{let n=await e.save(F,t);if(!N.current)return;o(n.settings),c(structuredClone(n.settings)),h(``),_(``),y(!1);let r=F.voice&&F.voice.ttsVoice!==void 0,i=F.voice&&F.voice.sttModel!==void 0;k(n.restart.length?`Saved. Restart Friend for: ${n.restart.map(e=>iS[e]??e).join(`, `)}.`:i?`Saved. The listening model is being downloaded in the background (the first time only); Friend keeps listening with the old one and tells you when the new one is ready.`:r?`Saved. The new voice is loading; you will get a message when it is ready (the first time it downloads about 60 MB).`:pt(F)?`Saved. It is in use now.`:`Saved. Every open screen has changed.`)}catch(e){N.current&&D(e.message)}finally{N.current&&(w(!1),S(``))}};if(v)return P((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to save these changes.`}),(0,p.jsx)(T,{pin:x,onChange:S,onSubmit:()=>!C&&void re(x)}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:C||x.length<6,onClick:()=>void re(x),children:`Save`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{y(!1),S(``),D(null)},children:`Back`})]})]}));let ie=rS.find(e=>e.id===s.provider),ae=e=>{let t=Se.findIndex(e=>e.id===u),n=e.key===`ArrowDown`||e.key===`ArrowRight`?(t+1)%Se.length:e.key===`ArrowUp`||e.key===`ArrowLeft`?(t+Se.length-1)%Se.length:e.key===`Home`?0:e.key===`End`?Se.length-1:-1;n<0||(e.preventDefault(),f(Se[n].id),document.getElementById(`settings-tab-${Se[n].id}`)?.focus())},oe=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Where Friend thinks`}),(0,p.jsx)(aS,{label:`Model provider`,hint:ie.note,children:(0,p.jsx)(`select`,{value:s.provider,onChange:e=>c({...s,provider:e.target.value}),children:rS.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),s.provider===`claude-code`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(aS,{label:`Claude model`,hint:`sonnet, haiku, opus, or a full model name`,children:[(0,p.jsx)(`input`,{list:`cc-models`,value:s.claudeCode.model,onChange:e=>I(`claudeCode`,`model`,e.target.value)}),(0,p.jsxs)(`datalist`,{id:`cc-models`,children:[(0,p.jsx)(`option`,{value:`sonnet`}),(0,p.jsx)(`option`,{value:`haiku`}),(0,p.jsx)(`option`,{value:`opus`})]})]}),(0,p.jsx)(aS,{label:`If Claude is unavailable`,hint:`For example when the plan's usage limit is reached.`,children:(0,p.jsxs)(`select`,{value:s.claudeCode.fallback,onChange:e=>I(`claudeCode`,`fallback`,e.target.value),children:[(0,p.jsx)(`option`,{value:`ollama`,children:`Answer with the local model (Ollama)`}),(0,p.jsx)(`option`,{value:`none`,children:`Show an error`})]})}),(0,p.jsx)(aS,{label:`Claude Code command`,hint:`Leave as it is unless the program is somewhere else.`,children:(0,p.jsx)(`input`,{value:s.claudeCode.command,onChange:e=>I(`claudeCode`,`command`,e.target.value)})})]}),s.provider===`claude`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(aS,{label:`Claude model`,children:(0,p.jsx)(`input`,{value:s.model,onChange:e=>c({...s,model:e.target.value})})}),(0,p.jsx)(aS,{label:`API key`,hint:a.apiKeySet?`A key is saved. Type a new one only to replace it.`:`No key saved yet.`,children:(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,placeholder:a.apiKeySet?`saved`:`sk-ant-…`,value:m,onChange:e=>h(e.target.value)})})]}),s.provider===`openai`&&s.openai&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(aS,{label:`Server address`,hint:`Ends in /v1. OmniRoute: http://localhost:20128/v1 (install it with npm install -g omniroute, then run omniroute).`,children:(0,p.jsx)(`input`,{value:s.openai.url,onChange:e=>c({...s,openai:{...s.openai,url:e.target.value}})})}),(0,p.jsx)(aS,{label:`Model`,hint:`The name that server knows. OmniRoute answers to auto.`,children:(0,p.jsx)(`input`,{value:s.openai.model,onChange:e=>c({...s,openai:{...s.openai,model:e.target.value}})})}),(0,p.jsx)(aS,{label:`API key`,hint:a.openai?.apiKeySet?`A key is saved. Type a new one only to replace it.`:`Leave empty if the server asks for none.`,children:(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,placeholder:a.openai?.apiKeySet?`saved`:``,value:g,onChange:e=>_(e.target.value)})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.openai.vision,onChange:e=>c({...s,openai:{...s.openai,vision:e.target.checked}})}),` This model can look at pictures`]})]}),(s.provider===`ollama`||s.provider===`claude-code`&&s.claudeCode.fallback===`ollama`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Local model (Ollama)`}),(0,p.jsx)(aS,{label:`Address`,children:(0,p.jsx)(`input`,{value:s.ollama.url,onChange:e=>I(`ollama`,`url`,e.target.value)})}),(0,p.jsx)(aS,{label:`Model`,children:(0,p.jsx)(`input`,{value:s.ollama.model,onChange:e=>I(`ollama`,`model`,e.target.value)})}),(0,p.jsx)(aS,{label:`Memory window (tokens)`,children:(0,p.jsx)(`input`,{type:`number`,min:1024,max:131072,step:1024,value:s.ollama.contextTokens,onChange:e=>I(`ollama`,`contextTokens`,Number(e.target.value))})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.ollama.vision,onChange:e=>I(`ollama`,`vision`,e.target.checked)}),` This model can look at pictures`]})]})]}),se=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Speaking and listening`}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.voice.speakTyped,onChange:e=>I(`voice`,`speakTyped`,e.target.checked)}),` Also speak the replies to typed messages`]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.voice.duck??!0,onChange:e=>I(`voice`,`duck`,e.target.checked)}),` Turn music and video down while I talk and while Friend speaks`]}),(0,p.jsx)(aS,{label:`Volume while talking: ${s.voice.duckPercent??25}%`,hint:`How loud music and video are then, compared with how loud you have them. They come back as they were when nothing is happening.`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:s.voice.duckPercent??25,disabled:s.voice.duck===!1,onChange:e=>I(`voice`,`duckPercent`,Number(e.target.value))})}),(0,p.jsx)(aS,{label:`Spoken language`,hint:`Leave empty to detect it by itself: best when you mix English, Hindi and Marathi. Or force one: en, hi, mr.`,children:(0,p.jsx)(`input`,{value:s.voice.language??``,maxLength:10,onChange:e=>I(`voice`,`language`,e.target.value.trim()===``?null:e.target.value.trim())})}),(0,p.jsx)(aS,{label:`Speaking voice`,hint:`Female or male. The first time a voice is used it downloads about 60 MB, then it works without internet.`,children:(0,p.jsxs)(`select`,{value:s.voice.ttsVoice,onChange:e=>I(`voice`,`ttsVoice`,e.target.value),children:[(0,p.jsx)(`optgroup`,{label:`Female`,children:uu.filter(e=>e.gender===`female`).map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.accent,e.note?` · ${e.note}`:``]},e.id))}),(0,p.jsx)(`optgroup`,{label:`Male`,children:uu.filter(e=>e.gender===`male`).map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.accent,e.note?` · ${e.note}`:``]},e.id))}),(0,p.jsx)(`optgroup`,{label:`Original`,children:(0,p.jsxs)(`option`,{value:pu.id,children:[pu.name,` · `,pu.accent,` · `,pu.note]})}),!mu(s.voice.ttsVoice)&&(0,p.jsx)(`optgroup`,{label:`Other`,children:(0,p.jsx)(`option`,{value:s.voice.ttsVoice,children:s.voice.ttsVoice})})]})}),(0,p.jsx)(aS,{label:`Hindi voice`,hint:`Reads Hindi (Devanagari) text; English words in the same sentence still use the voice above. The first time it downloads about 64 MB.`,children:(0,p.jsxs)(`select`,{value:s.voice.hindiVoice??``,onChange:e=>I(`voice`,`hindiVoice`,e.target.value),children:[(0,p.jsx)(`option`,{value:``,children:`Same as the voice above`}),du.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.gender,e.note?` · ${e.note}`:``]},e.id))]})}),(0,p.jsx)(aS,{label:`Marathi voice`,hint:`Reads Marathi text. Friend tells Marathi from Hindi by the words used.`,children:(0,p.jsxs)(`select`,{value:s.voice.marathiVoice??``,onChange:e=>I(`voice`,`marathiVoice`,e.target.value),children:[(0,p.jsx)(`option`,{value:``,children:`Same as the voice above`}),fu.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,p.jsxs)(`div`,{className:`voice-hear`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null,onClick:()=>L(`main`,s.voice.ttsVoice),children:A===`main`?`Loading the voice…`:`Hear it`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null||!s.voice.hindiVoice,onClick:()=>L(`hindi`,s.voice.hindiVoice??``),children:A===`hindi`?`Loading the voice…`:`Hear the Hindi voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null||!s.voice.marathiVoice,onClick:()=>L(`marathi`,s.voice.marathiVoice??``),children:A===`marathi`?`Loading the voice…`:`Hear the Marathi voice`}),ee&&(0,p.jsx)(`small`,{className:`auth-note`,role:`status`,children:ee})]}),(0,p.jsx)(aS,{label:`Listening model`,hint:`Bigger hears more accurately, from further away and in Hindi and Marathi, but is slower. It downloads once, in the background, and Friend keeps listening meanwhile. No restart.`,children:(0,p.jsxs)(`select`,{value:s.voice.sttModel,onChange:e=>I(`voice`,`sttModel`,e.target.value),children:[!hu.some(e=>e.id===s.voice.sttModel)&&(0,p.jsx)(`option`,{value:s.voice.sttModel,children:s.voice.sttModel}),hu.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,gu(e.mb).replace(`about `,``),` · `,e.note]},e.id))]})}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Who is speaking`}),(0,p.jsx)(aS,{label:`"It is me" match level: ${s.voice.accept.toFixed(2)}`,hint:`Higher is stricter. Only matters after you enrolled your voice.`,children:(0,p.jsx)(`input`,{type:`range`,min:.3,max:.95,step:.01,value:s.voice.accept,onChange:e=>I(`voice`,`accept`,Number(e.target.value))})}),(0,p.jsx)(aS,{label:`"Ask for my PIN" level: ${s.voice.challenge.toFixed(2)}`,hint:`Voices between this and the level above must be confirmed with the PIN.`,children:(0,p.jsx)(`input`,{type:`range`,min:.2,max:.9,step:.01,value:s.voice.challenge,onChange:e=>I(`voice`,`challenge`,Number(e.target.value))})})]}),ce=(0,p.jsxs)(`div`,{className:`look-tab`,children:[(0,p.jsxs)(`div`,{className:`look-side`,children:[(0,p.jsx)(Mx,{look:ne}),(0,p.jsx)(`p`,{className:`auth-note`,children:`This is a live preview. Nothing changes on the screen until you save.`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>c({...s,look:{...dt}}),children:`Back to the default look`})]}),(0,p.jsxs)(`div`,{className:`look-controls`,children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Themes`}),(0,p.jsx)(`div`,{className:`theme-grid`,role:`group`,"aria-label":`Themes`,children:_u.map(e=>(0,p.jsxs)(`button`,{type:`button`,className:`theme-card${Ux(ne,e)?` on`:``}`,"aria-pressed":Ux(ne,e),style:{"--swatch":e.accent},onClick:()=>c({...s,look:{...ne,style:e.style,accent:e.accent,intensity:e.intensity}}),children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),(0,p.jsx)(`b`,{children:e.name}),(0,p.jsx)(`small`,{children:e.style})]},e.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Shape`}),(0,p.jsx)(`div`,{className:`style-row`,role:`radiogroup`,"aria-label":`Style`,children:Hx.map(e=>(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":ne.style===e.id,className:`style-choice${ne.style===e.id?` on`:``}`,onClick:()=>I(`look`,`style`,e.id),children:[(0,p.jsx)(`b`,{children:e.name}),(0,p.jsx)(`small`,{children:e.note})]},e.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Colour and light`}),(0,p.jsxs)(`div`,{className:`swatch-row`,role:`group`,"aria-label":`Colour`,children:[Vx.map(e=>(0,p.jsx)(`button`,{type:`button`,"aria-label":`Colour ${e}`,"aria-pressed":ne.accent.toLowerCase()===e,className:`swatch${ne.accent.toLowerCase()===e?` on`:``}`,style:{background:e},onClick:()=>I(`look`,`accent`,e)},e)),(0,p.jsxs)(`label`,{className:`swatch-custom`,children:[(0,p.jsx)(`span`,{children:`Other`}),(0,p.jsx)(`input`,{type:`color`,"aria-label":`Pick another colour`,value:ne.accent,onChange:e=>I(`look`,`accent`,e.target.value.toLowerCase())})]})]}),(0,p.jsx)(aS,{label:`Brightness: ${Math.round(ne.intensity*100)}%`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:ne.intensity,onChange:e=>I(`look`,`intensity`,Number(e.target.value))})}),(0,p.jsx)(aS,{label:`Size: ${Math.round(ne.size*100)}%`,hint:`How big it is in the middle of the screen.`,children:(0,p.jsx)(`input`,{type:`range`,min:.5,max:1.5,step:.05,value:ne.size,onChange:e=>I(`look`,`size`,Number(e.target.value))})}),(0,p.jsx)(aS,{label:`Reaction to my voice: ${Math.round(ne.reactivity*100)}%`,hint:`Low is calm, high moves a lot when anyone speaks.`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:ne.reactivity,onChange:e=>I(`look`,`reactivity`,Number(e.target.value))})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.ambient,onChange:e=>I(`look`,`ambient`,e.target.checked)}),` Soft glow behind everything`]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Words on the screen`}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.captions,onChange:e=>I(`look`,`captions`,e.target.checked)}),` Show the live words while Friend speaks`]}),(0,p.jsx)(aS,{label:`Caption size`,children:(0,p.jsxs)(`select`,{value:ne.captionSize,disabled:!ne.captions,onChange:e=>I(`look`,`captionSize`,e.target.value),children:[(0,p.jsx)(`option`,{value:`small`,children:`Small`}),(0,p.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,p.jsx)(`option`,{value:`large`,children:`Large`})]})}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`What is on the screen`}),(0,p.jsx)(aS,{label:`Your name`,hint:`Shown on the badge in the corner, next to the shield, while you are signed in. Empty shows Owner.`,children:(0,p.jsx)(`input`,{value:s.ownerName??``,maxLength:40,placeholder:`Owner`,onChange:e=>c({...s,ownerName:e.target.value})})}),(0,p.jsx)(aS,{label:`View`,hint:`Minimal: only the voice presence. Companion: plus a status line and a clock. Workspace: also the chat and the schedule. Drag any panel to move it.`,children:(0,p.jsxs)(`select`,{value:s.view,onChange:e=>c({...s,view:e.target.value}),children:[(0,p.jsx)(`option`,{value:`minimal`,children:`Minimal`}),(0,p.jsx)(`option`,{value:`companion`,children:`Companion`}),(0,p.jsx)(`option`,{value:`workspace`,children:`Workspace`})]})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.aiMayChange,onChange:e=>I(`look`,`aiMayChange`,e.target.checked)}),` Let the AI change the shape, colour and brightness to suit a topic`]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Off keeps exactly the look you chose. You can still ask it to change the look yourself.`})]})]}),le=s.approvals??`manual`,ue=(0,p.jsxs)(`div`,{className:`settings-section`,role:`radiogroup`,"aria-label":`How much Friend asks before acting`,children:[(0,p.jsx)(`h3`,{children:`How much should Friend ask?`}),nS.map(e=>(0,p.jsxs)(`label`,{className:`settings-check`,style:{alignItems:`flex-start`},children:[(0,p.jsx)(`input`,{type:`radio`,name:`approvals`,value:e.id,checked:le===e.id,onChange:()=>c({...s,approvals:e.id})}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{children:e.label}),(0,p.jsx)(`br`,{}),(0,p.jsx)(`small`,{className:`auth-note`,children:e.note})]})]},e.id)),(0,p.jsx)(`small`,{className:`auth-note`,children:`Whatever you pick, these still ask: risky commands (they need your PIN), the camera, adding connectors or plugins, and anything in Friend's own data folder. Changing this needs your PIN.`})]}),de=(0,p.jsxs)(p.Fragment,{children:[u===`model`&&oe,u===`voice`&&se,u===`look`&&ce,u===`approvals`&&ue,u===`trading`&&(0,p.jsx)(Ix,{level:s.trading?.level??`read`}),u===`widgets`&&s.music&&s.hud&&(0,p.jsx)(Bx,{music:s.music,hud:s.hud,onMusic:e=>c({...s,music:{...s.music,...e}}),onHud:e=>c({...s,hud:{...s.hud,...e}})}),u===`system`&&(0,p.jsx)(Jx,{auto:s.updates?.auto??!0,onAuto:e=>c({...s,updates:{auto:e}})}),u===`usage`&&(0,p.jsx)(tS,{}),u===`security`&&(0,p.jsx)(Px,{})]}),R=()=>{k(null),D(null),pt(F)?y(!0):re()},z=()=>{c(structuredClone(a)),h(``),_(``)},B=(0,p.jsxs)(p.Fragment,{children:[O&&!te&&(0,p.jsx)(`p`,{className:`auth-note`,children:O}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E})]});if(i===`holo`){let e=Se.findIndex(e=>e.id===u),t=e=>f(Se[(e+Se.length)%Se.length].id);return P((0,p.jsxs)(p.Fragment,{children:[de,B]}),!0,{title:Se[e].label,page:{index:e,total:Se.length,onPrev:()=>t(e-1),onNext:()=>t(e+1)},dirty:te,onApply:R,onUndo:z,help:(0,p.jsxs)(p.Fragment,{children:[`Fill in the settings and press `,(0,p.jsx)(`b`,{children:`Apply`}),` to save them. Network, folders and safety rules are not here on purpose: change those in the terminal with friend config set.`]})})}return P((0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`settings-layout`,children:[(0,p.jsx)(`div`,{className:`settings-tabs`,role:`tablist`,"aria-label":`Settings sections`,"aria-orientation":`vertical`,onKeyDown:ae,children:Se.map(e=>(0,p.jsxs)(`button`,{id:`settings-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":u===e.id,"aria-controls":`settings-panel-${e.id}`,tabIndex:u===e.id?0:-1,className:`settings-tab${u===e.id?` on`:``}`,onClick:()=>f(e.id),children:[(0,p.jsx)(`b`,{children:e.label}),(0,p.jsx)(`small`,{children:e.note})]},e.id))}),(0,p.jsx)(`div`,{className:`settings-body`,role:`tabpanel`,id:`settings-panel-${u}`,"aria-labelledby":`settings-tab-${u}`,children:de})]}),O&&!te&&(0,p.jsx)(`p`,{className:`auth-note`,children:O}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!te||C,onClick:R,children:te&&!pt(F)?`Save`:`Save…`}),te&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:z,children:`Undo changes`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Network, folders and safety rules are not here on purpose. Change those in the terminal: friend config set.`})]}),!0)}var sS=e=>e instanceof HTMLElement&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable);function cS({onSend:e,requestOpen:t,slash:n,onOpenChange:r}){let[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(r);o.current=r,(0,l.useEffect)(()=>o.current?.(i),[i]);let[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(0),f=(0,l.useRef)(null);if((0,l.useEffect)(()=>{t>0&&a(!0)},[t]),(0,l.useEffect)(()=>{let e=e=>{i||sS(e.target)||e.ctrlKey||e.metaKey||e.altKey||e.key.length===1&&(e.preventDefault(),c(e.key),d(0),a(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,l.useEffect)(()=>{i&&f.current?.focus()},[i]),!i)return null;let m=n?F(n.commands,s):[],h=m[Math.min(u,Math.max(m.length-1,0))],g=()=>{c(``),d(0),a(!1)},_=()=>{let t=s.trim();if(n&&P(t)){let e=/^\/\S*\s/.test(t);n.run(!e&&h?`/${h.name}`:t)}else t&&e(I(t));g()};return(0,p.jsxs)(`form`,{className:`command-bar`,onSubmit:e=>{e.preventDefault(),_()},children:[m.length>0&&(0,p.jsx)(`ul`,{className:`slash-list`,role:`listbox`,"aria-label":`Commands`,children:m.map((e,t)=>(0,p.jsxs)(`li`,{role:`option`,"aria-selected":e===h,className:e===h?`on`:void 0,onMouseDown:n=>{n.preventDefault(),c(`/${e.name} `),f.current?.focus(),d(t)},children:[(0,p.jsxs)(`b`,{children:[`/`,e.name]}),e.usage&&(0,p.jsx)(`i`,{children:e.usage}),(0,p.jsx)(`span`,{children:e.description})]},e.name))}),(0,p.jsx)(`input`,{ref:f,"aria-label":`Message`,value:s,placeholder:`Talk to me… or type / for commands`,autoComplete:`off`,onChange:e=>{c(e.target.value),d(0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),g()):m.length>0&&(e.key===`ArrowDown`||e.key===`ArrowUp`)?(e.preventDefault(),d(t=>(t+(e.key===`ArrowDown`?1:m.length-1))%m.length)):e.key===`Tab`&&h&&(e.preventDefault(),c(`/${h.name} `))}}),(0,p.jsx)(`button`,{type:`submit`,"aria-label":`Send`,children:`↵`})]})}var lS={width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0},uS=(e,t)=>e===`listening`?t?`Listening… tap to send`:`Listening… let go to send`:e===`transcribing`?`Understanding…`:e===`speaking`?`Tap to talk over me`:`Hold to talk, or tap once`;function dS({voice:e,mode:t,onType:n,onMenu:r}){let i=(0,l.useRef)(null),a=(0,l.useRef)(!1),[o,s]=(0,l.useState)(!1),c=e=>{a.current=e,s(e)},u=(0,l.useRef)(t);u.current=t,(0,l.useEffect)(()=>{t!==`listening`&&!i.current&&c(!1)},[t]);let d=t=>{if((t.pointerType!==`mouse`||t.button===0)&&!i.current){if(a.current&&u.current===`listening`){c(!1),e.pressEnd();return}c(!1),i.current={at:Date.now(),id:t.pointerId};try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}e.pressStart()}},f=t=>{let n=i.current;n&&n.id===t.pointerId&&(i.current=null,Date.now()-n.at>=450?e.pressEnd():c(!0))},m=t=>{let n=i.current;n&&n.id===t.pointerId&&(i.current=null,c(!1),e.blur?.())},h=t===`listening`;return(0,p.jsxs)(`div`,{className:`touch-controls`,"data-testid":`touch-controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`touch-side`,"aria-label":`Open the menu`,onClick:r,children:(0,p.jsx)(`svg`,{...lS,children:(0,p.jsx)(`path`,{d:`M4 7h16M4 12h16M4 17h16`})})}),(0,p.jsxs)(`div`,{className:`touch-talk`,children:[(0,p.jsx)(`button`,{type:`button`,className:`touch-mic${h?` on`:``}`,"aria-label":`Talk to Friend`,"aria-pressed":h,onPointerDown:d,onPointerUp:f,onPointerCancel:m,onContextMenu:e=>e.preventDefault(),children:(0,p.jsxs)(`svg`,{...lS,width:30,height:30,children:[(0,p.jsx)(`rect`,{x:`9`,y:`3`,width:`6`,height:`11`,rx:`3`}),(0,p.jsx)(`path`,{d:`M5 11a7 7 0 0 0 14 0M12 18v3`})]})}),(0,p.jsx)(`span`,{className:`touch-hint`,"aria-live":`polite`,children:uS(t,o)})]}),(0,p.jsx)(`button`,{type:`button`,className:`touch-side`,"aria-label":`Type a message`,onClick:n,children:(0,p.jsxs)(`svg`,{...lS,children:[(0,p.jsx)(`rect`,{x:`3`,y:`6`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M7 10h.01M11 10h.01M15 10h.01M7 14h10`})]})})]})}function fS(e,t){this.v=e,this.k=t}function pS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mS(e){if(Array.isArray(e))return e}function hS(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function gS(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4388
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _S(e,t){return mS(e)||hS(e,t)||vS(e,t)||gS()}function vS(e,t){if(e){if(typeof e==`string`)return pS(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pS(e,t):void 0}}function yS(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof fS;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}yS.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},yS.prototype.next=function(e){return this._invoke(`next`,e)},yS.prototype.throw=function(e){return this._invoke(`throw`,e)},yS.prototype.return=function(e){return this._invoke(`return`,e)};var bS=Object.entries,xS=Object.setPrototypeOf,SS=Object.isFrozen,CS=Object.getPrototypeOf,wS=Object.getOwnPropertyDescriptor,TS=Object.freeze,ES=Object.seal,DS=Object.create,OS=typeof Reflect<`u`&&Reflect,kS=OS.apply,AS=OS.construct;TS||=function(e){return e},ES||=function(e){return e},kS||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},AS||=function(e){return new e(...[...arguments].slice(1))};var jS=ZS(Array.prototype.forEach);Array.prototype.indexOf;var MS=ZS(Array.prototype.lastIndexOf),NS=ZS(Array.prototype.pop),PS=ZS(Array.prototype.push);Array.prototype.slice;var FS=ZS(Array.prototype.splice),IS=Array.isArray,LS=ZS(String.prototype.toLowerCase),RS=ZS(String.prototype.toString),zS=ZS(String.prototype.match),BS=ZS(String.prototype.replace),VS=ZS(String.prototype.indexOf),HS=ZS(String.prototype.trim),US=ZS(Number.prototype.toString),WS=ZS(Boolean.prototype.toString),GS=typeof BigInt>`u`?null:ZS(BigInt.prototype.toString),KS=typeof Symbol>`u`?null:ZS(Symbol.prototype.toString),qS=ZS(Object.prototype.hasOwnProperty),JS=ZS(Object.prototype.toString),YS=ZS(RegExp.prototype.test),XS=QS(TypeError);function ZS(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return kS(e,t,n)}}function QS(e){return function(){return AS(e,[...arguments])}}function $S(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:LS;if(xS&&xS(e,null),!IS(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(SS(t)||(t[r]=e),i=e)}e[i]=!0}return e}function eC(e){for(let t=0;t<e.length;t++)qS(e,t)||(e[t]=null);return e}function tC(e){let t=DS(null);for(let r of bS(e)){var n=_S(r,2);let i=n[0],a=n[1];qS(e,i)&&(t[i]=IS(a)?eC(a):a&&typeof a==`object`&&a.constructor===Object?tC(a):a)}return t}function nC(e){switch(typeof e){case`string`:return e;case`number`:return US(e);case`boolean`:return WS(e);case`bigint`:return GS?GS(e):`0`;case`symbol`:return KS?KS(e):`Symbol()`;case`undefined`:return JS(e);case`function`:case`object`:{if(e===null)return JS(e);let t=e,n=rC(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:JS(e)}return JS(e)}default:return JS(e)}}function rC(e,t){for(;e!==null;){let n=wS(e,t);if(n){if(n.get)return ZS(n.get);if(typeof n.value==`function`)return ZS(n.value)}e=CS(e)}function n(){return null}return n}function iC(e){try{return YS(e,``),!0}catch{return!1}}var aC=TS(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),oC=TS(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),sC=TS([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),cC=TS([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),lC=TS(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),uC=TS([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),dC=TS([`#text`]),fC=TS(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),pC=TS(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),mC=TS(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),hC=TS([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),gC=ES(/{{[\w\W]*|^[\w\W]*}}/g),_C=ES(/<%[\w\W]*|^[\w\W]*%>/g),vC=ES(/\${[\w\W]*/g),yC=ES(/^data-[\-\w.\u00B7-\uFFFF]+$/),bC=ES(/^aria-[\-\w]+$/),xC=ES(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),SC=ES(/^(?:\w+script|data):/i),CC=ES(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),wC=ES(/^html$/i),TC=ES(/^[a-z][.\w]*(-[.\w]+)+$/i),EC=ES(/<[/\w!]/g),DC=ES(/<[/\w]/g),OC=ES(/<\/no(script|embed|frames)/i),kC=ES(/\/>/i),AC={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},jC=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],MC=TS($S({},jC)),NC=function(){let e={};return jS(jC,t=>{e[t]=ES(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),TS(e)}(),PC=function(){return typeof window>`u`?null:window},FC=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},IC=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},LC=function(e,t,n,r){return qS(e,t)&&IS(e[t])?$S(r.base?tC(r.base):{},e[t],r.transform):n},RC=function(e,t,n){let r=qS(e,t)?e[t]:void 0;return r&&typeof r==`object`?tC(r):n()};function zC(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:PC(),t=e=>zC(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==AC.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=rC(d,`cloneNode`),p=rC(d,`remove`),m=rC(d,`removeAttributeNode`),h=rC(d,`nextSibling`),g=rC(d,`childNodes`),_=rC(d,`parentNode`),v=rC(d,`shadowRoot`),y=rC(d,`attributes`),b=o&&o.prototype?rC(o.prototype,`nodeType`):null,x=o&&o.prototype?rC(o.prototype,`nodeName`):null,S=o&&o.prototype?rC(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,O=!1,k=0,A=function(){if(k>0)throw XS(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},j=function(e){A(),k++;try{return T.createHTML(e)}finally{k--}},ee=function(e){A(),k++;try{return T.createScriptURL(e)}finally{k--}},M=function(){return O||=(D=FC(u,i),!0),D},N=n,P=N.implementation,F=N.createNodeIterator,te=N.createDocumentFragment,I=N.getElementsByTagName,ne=r.importNode,L=IC();t.isSupported=typeof bS==`function`&&typeof _==`function`&&P&&P.createHTMLDocument!==void 0;let re=gC,ie=_C,ae=vC,oe=yC,se=bC,ce=SC,le=CC,ue=TC,de=xC,R=null,z=$S({},[...aC,...oC,...sC,...lC,...dC]),B=null,fe=$S({},[...fC,...pC,...mC,...hC]),pe=Object.seal(DS(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),me=null,he=null,ge=Object.seal(DS(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),V=!0,_e=!0,ve=!1,ye=!0,H=!1,be=!0,U=!1,xe=!1,Se=null,Ce=null,we=!1,Te=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},Pe=null,Fe=$S({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ie=null,Le=$S({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Re=null,ze=$S({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Be=`http://www.w3.org/1998/Math/MathML`,Ve=`http://www.w3.org/2000/svg`,He=`http://www.w3.org/1999/xhtml`,Ue=He,We=!1,Ge=null,Ke=$S({},[Be,Ve,He],RS),qe=TS([`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=$S({},qe),Ye=TS([`annotation-xml`]),Xe=$S({},Ye),Ze=$S({},[`title`,`style`,`font`,`a`,`script`]),Qe=null,$e=[`application/xhtml+xml`,`text/html`],et=null,tt=null,nt=n.createElement(`form`),rt=function(e){return e instanceof RegExp||e instanceof Function},it=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tt&&tt===e)return;(!e||typeof e!=`object`)&&(e={}),e=tC(e),Qe=$e.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,et=Qe===`application/xhtml+xml`?RS:LS,R=LC(e,`ALLOWED_TAGS`,z,{transform:et}),B=LC(e,`ALLOWED_ATTR`,fe,{transform:et}),Ge=LC(e,`ALLOWED_NAMESPACES`,Ke,{transform:RS}),Re=LC(e,`ADD_URI_SAFE_ATTR`,ze,{transform:et,base:ze}),Ie=LC(e,`ADD_DATA_URI_TAGS`,Le,{transform:et,base:Le}),Pe=LC(e,`FORBID_CONTENTS`,Fe,{transform:et}),me=LC(e,`FORBID_TAGS`,tC({}),{transform:et}),he=LC(e,`FORBID_ATTR`,tC({}),{transform:et}),Ne=qS(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?tC(e.USE_PROFILES):e.USE_PROFILES:!1,V=e.ALLOW_ARIA_ATTR!==!1,_e=e.ALLOW_DATA_ATTR!==!1,ve=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ye=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=e.SAFE_FOR_TEMPLATES||!1,be=e.SAFE_FOR_XML!==!1,U=e.WHOLE_DOCUMENT||!1,Te=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,de=iC(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:xC,Ue=typeof e.NAMESPACE==`string`?e.NAMESPACE:He,Je=RC(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>$S({},qe)),Xe=RC(e,`HTML_INTEGRATION_POINTS`,()=>$S({},Ye));let t=RC(e,`CUSTOM_ELEMENT_HANDLING`,()=>DS(null));if(pe=DS(null),qS(t,`tagNameCheck`)&&rt(t.tagNameCheck)&&(pe.tagNameCheck=t.tagNameCheck),qS(t,`attributeNameCheck`)&&rt(t.attributeNameCheck)&&(pe.attributeNameCheck=t.attributeNameCheck),qS(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(pe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ES(pe),H&&(_e=!1),Ee&&(Te=!0),Ne&&(R=$S({},dC),B=DS(null),Ne.html===!0&&($S(R,aC),$S(B,fC)),Ne.svg===!0&&($S(R,oC),$S(B,pC),$S(B,hC)),Ne.svgFilters===!0&&($S(R,sC),$S(B,pC),$S(B,hC)),Ne.mathMl===!0&&($S(R,lC),$S(B,mC),$S(B,hC))),ge.tagCheck=null,ge.attributeCheck=null,qS(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?ge.tagCheck=e.ADD_TAGS:IS(e.ADD_TAGS)&&(R===z&&(R=tC(R)),$S(R,e.ADD_TAGS,et))),qS(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?ge.attributeCheck=e.ADD_ATTR:IS(e.ADD_ATTR)&&(B===fe&&(B=tC(B)),$S(B,e.ADD_ATTR,et))),qS(e,`ADD_FORBID_CONTENTS`)&&IS(e.ADD_FORBID_CONTENTS)&&(Pe===Fe&&(Pe=tC(Pe)),$S(Pe,e.ADD_FORBID_CONTENTS,et)),je&&(R[`#text`]=!0),U&&$S(R,[`html`,`head`,`body`]),R.table&&($S(R,[`tbody`]),delete me.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw XS(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw XS(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=j(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=M()),T&&typeof E==`string`&&(E=j(``)));TS&&TS(e),tt=e},at=$S({},[...oC,...sC,...cC]),ot=$S({},[...lC,...uC]),st=function(e,t,n){return t.namespaceURI===He?e===`svg`:t.namespaceURI===Be?e===`svg`&&(n===`annotation-xml`||Je[n]):!!at[e]},ct=function(e,t,n){return t.namespaceURI===He?e===`math`:t.namespaceURI===Ve?e===`math`&&Xe[n]:!!ot[e]},lt=function(e,t,n){return t.namespaceURI===Ve&&!Xe[n]||t.namespaceURI===Be&&!Je[n]?!1:!ot[e]&&(Ze[e]||!at[e])},ut=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=LS(e.tagName),r=LS(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===Ve?st(n,t,r):e.namespaceURI===Be?ct(n,t,r):e.namespaceURI===He?lt(n,t,r):!!(Qe===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},dt=function(e){PS(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw XS(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ft=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},pt=function(e){gt(e);let t=g(e);if(t){let e=[];jS(t,t=>{PS(e,t)}),jS(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&ft(e,r,i)}},mt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}PS(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Te||Ee)try{dt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},ht=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||B[et(i)]||ft(e,r,i)}},gt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===AC.element&&ht(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},_t=function(e,t){return be?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},vt=function(e){if(!be)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===AC.processingInstruction||n===AC.comment&&YS(DC,e.data)){try{p(e)}catch{}continue}if(n===AC.element){let t=e,n=et(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&_t(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},yt=function(e){let t=null,r=null;if(we)e=`<remove></remove>`+e;else{let t=zS(e,/^[\r\n\t ]+/);r=t&&t[0]}Qe===`application/xhtml+xml`&&Ue===He&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?j(e):e;if(Ue===He)try{t=new l().parseFromString(i,Qe)}catch{}if(!t||!t.documentElement){t=P.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===He?I.call(t,U?`html`:`body`)[0]:U?t.documentElement:a},bt=function(e){let t=S?S(e):e.ownerDocument;return F.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},xt=function(e){return e=BS(e,re,` `),e=BS(e,ie,` `),e=BS(e,ae,` `),e},St=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=F.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=xt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&jS(i,e=>{wt(e.content)&&St(e.content)})},Ct=function(e){let t=x?x(e):null;return typeof t!=`string`||et(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},wt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===AC.documentFragment}catch{return!1}},Tt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Et(e,n,r){e.length!==0&&jS(e,e=>{e.call(t,n,r,tt)})}let Dt=function(e,t){return!!(be&&e.hasChildNodes()&&!Tt(e.firstElementChild)&&YS(EC,e.textContent)&&YS(EC,e.innerHTML)||be&&e.namespaceURI===He&&MC[t]&&(Tt(e.firstElementChild)||typeof e.textContent==`string`&&YS(NC[t],e.textContent))||e.nodeType===AC.processingInstruction||be&&e.nodeType===AC.comment&&YS(DC,e.data))},Ot=function(e,t){return e instanceof RegExp?YS(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},kt=function(e,t,n){if(!me[t]&&Ft(t)&&Ot(pe.tagNameCheck,t))return!1;if(je&&!Pe[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return dt(e),!0},At=function(e,t,n,r){return e.length===0?t:t===n||t===r?tC(t):t},jt=function(e,t){return e===t||_(e)!==null?!1:(Me&>(e),!0)},Mt=function(e,n){if(Et(L.beforeSanitizeElements,e,null),jt(e,n))return!0;if(Ct(e))return dt(e),!0;let r=et(w(e));if(R=At(L.uponSanitizeElement,R,z,Se),Et(L.uponSanitizeElement,e,{tagName:r,allowedTags:R}),jt(e,n))return!0;if(Dt(e,r))return dt(e),!0;if(me[r]||!(ge.tagCheck instanceof Function&&ge.tagCheck(r))&&!R[r]){let t=kt(e,r,n);return t===!1&&(Et(L.afterSanitizeElements,e,null),jt(e,n))?!0:t}if(C(e)===AC.element&&!ut(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&YS(OC,e.innerHTML))return dt(e),!0;if(H&&e.nodeType===AC.text){let n=xt(e.textContent);e.textContent!==n&&(PS(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Et(L.afterSanitizeElements,e,null),jt(e,n)},Nt=function(e,t,r){if(he[t]||_t(t,e)||Oe&&(t===`id`||t===`name`)&&(r in n||r in nt))return!1;let i=B[t]||ge.attributeCheck instanceof Function&&ge.attributeCheck(t,e);return _e&&YS(oe,t)||V&&YS(se,t)?!0:i?Re[t]||YS(de,BS(r,le,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&VS(r,`data:`)===0&&Ie[e]||ve&&!YS(ce,BS(r,le,``))?!0:!r:Ft(e)&&Ot(pe.tagNameCheck,e)&&Ot(pe.attributeNameCheck,t,e)||t===`is`&&pe.allowCustomizedBuiltInElements&&Ot(pe.tagNameCheck,r)},Pt=$S({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ft=function(e){return!Pt[LS(e)]&&YS(ue,e)},It=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return j(r);case`TrustedScriptURL`:return ee(r)}return r},Lt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Ct(e)||(dt(e),!1)}catch{return mt(t,e),!1}},Rt=function(e,n){if(Et(L.beforeSanitizeAttributes,e,null),jt(e,n))return;let r=e.attributes;if(!r||Ct(e))return;B=At(L.uponSanitizeAttribute,B,fe,Ce);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0},a=r.length,o=et(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=et(s),d=l,f=s===`value`?d:HS(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Et(L.uponSanitizeAttribute,e,i),f=i.attrValue,ke&&(u===`id`||u===`name`)&&VS(f,Ae)!==0&&(mt(s,e,n),f=Ae+f,p=!0),be&&YS(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){mt(s,e,n);continue}if(u===`attributename`&&zS(f,`href`)){mt(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){mt(s,e,n);continue}if(!ye&&YS(kC,f)){mt(s,e,n);continue}if(H&&(f=xt(f)),!Nt(o,u,f)){mt(s,e,n);continue}f=It(o,u,c,f),f!==d&&Lt(e,s,c,f)&&p&&NS(t.removed)}}Et(L.afterSanitizeAttributes,e,null),jt(e,n)},zt=function(e){let t=null,n=bt(e);for(Et(L.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Et(L.uponSanitizeShadowNode,t,null),Mt(t,e),Rt(t,e),wt(t.content)&&zt(t.content),C(t)===AC.element){let e=v(t);wt(e)&&(Bt(e),zt(e))}Et(L.afterSanitizeShadowDOM,e,null)},Bt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){zt(e.shadow);continue}let n=e.node,r=C(n)===AC.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&et(e)===`template`){let e=n.content;wt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);wt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!Tt(e)&&(e=nC(e),typeof e!=`string`))throw XS(`dirty is not a string, aborting`);if(!t.isSupported)return e;xe?(R=Se,B=Ce):it(n),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(R=tC(R)),L.uponSanitizeAttribute.length>0&&(B=tC(B)),t.removed=[];let c=Me&&typeof e!=`string`&&Tt(e);if(c){vt(e);let t=w(e);if(typeof t==`string`){let n=et(t);if(!R[n]||me[n])throw pt(e),XS(`root node is forbidden and cannot be sanitized in-place`)}if(Ct(e))throw pt(e),XS(`root node is clobbered and cannot be sanitized in-place`);try{Bt(e)}catch(t){throw pt(e),t}}else if(Tt(e))i=yt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===AC.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Bt(i);else{if(!Te&&!H&&!U&&e.indexOf(`<`)===-1)return T&&De?j(e):e;if(i=yt(e),!i)return Te?null:De?E:``}i&&we&&dt(i.firstChild);let l=c?e:i;try{let e=bt(l);for(;o=e.nextNode();)Mt(o,l),Rt(o,l),wt(o.content)&&zt(o.content)}catch(n){throw c&&(pt(e),jS(t.removed,e=>{e.element&>(e.element)})),n}if(c){let n=!1;if(jS(t.removed,t=>{t.element&&(t.element===e&&(n=!0),gt(t.element))}),n)throw XS(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return H&&St(e),e}if(Te){if(H&&St(i),Ee)for(s=te.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(B.shadowroot||B.shadowrootmode)&&(s=ne.call(r,s,!0)),s}let u=U?i.outerHTML:i.innerHTML;return U&&R[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&YS(wC,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
4389
|
-
`+u),H&&(u=xt(u)),T&&De?j(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};it(e),xe=!0,Se=R,Ce=B},t.clearConfig=function(){tt=null,xe=!1,Se=null,Ce=null,T=D,E=``},t.isValidAttribute=function(e,t,n){tt||it({});let r=et(e),i=et(t);return Nt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&
|
|
4390
|
-
]`).replace(`lheading`,
|
|
4391
|
-
`),n=t.length-1;for(;n>=0
|
|
4392
|
-
`)}function
|
|
4387
|
+
`,wx=class{host;core;renderer;scene=new lh;camera=new N_(-1,1,1,-1,0,1);material;geometry=new qg(2,2);raf=0;last=0;ro;disposed=!1;constructor(e,t,n){this.host=e,this.core=new af({reducedMotion:n}),this.renderer=new hx({alpha:!0,antialias:!1}),this.renderer.setClearColor(0,0),this.renderer.domElement.style.cssText=`width:100%;height:100%;display:block`,e.appendChild(this.renderer.domElement),this.material=new n_({vertexShader:Sx,fragmentShader:Cx,transparent:!0,depthWrite:!1,blending:2,uniforms:{uPhase:{value:0},uAmp:{value:0},uBright:{value:.85},uNoise:{value:.05},uTighten:{value:0},uAspect:{value:1},uColor:{value:new sh(t)}}}),this.scene.add(new Dg(this.geometry,this.material)),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(e),this.resize(),this.raf=requestAnimationFrame(this.frame)}resize(){let e=Math.max(1,this.host.clientWidth),t=Math.max(1,this.host.clientHeight);this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setSize(e,t,!1),this.material.uniforms.uAspect.value=e/t}frame=e=>{if(this.disposed)return;if(this.raf=requestAnimationFrame(this.frame),document.hidden){this.last=e;return}let t=this.last?Math.min((e-this.last)/1e3,.1):.016;this.last=e,this.core.tick(t);let n=this.core.uniforms(),r=this.material.uniforms;r.uPhase.value=n.phase,r.uAmp.value=n.amplitude,r.uBright.value=n.brightness,r.uNoise.value=n.noise,r.uTighten.value=n.tighten,this.renderer.render(this.scene,this.camera)};setState(e){this.core.setState(e)}setAmplitude(e){this.core.setAmplitude(e)}setMode(e){this.resize()}setAccent(e){this.material.uniforms.uColor.value.set(e)}setIntensity(e){this.core.setIntensity(e)}dispose(){this.disposed=!0,cancelAnimationFrame(this.raf),this.ro.disconnect(),this.geometry.dispose(),this.material.dispose(),this.renderer.dispose(),this.renderer.domElement.remove()}},Tx=e=>Number.isFinite(e)?e:0;function Ex(e,t,n,r){let i=Tx(t),a=Math.min(1,Math.max(0,Tx(n))),o=Math.min(1,Math.max(0,Tx(r)));return Array.from({length:Math.max(0,Math.floor(e))},(e,t)=>{let n=.12+.18*(.5+.5*Math.sin(t*.31+i*2.2))+o*(.5+.5*Math.sin(t*.9+i*4)),r=a*(.35+.65*(.5+.5*Math.sin(t*2.1+i*9)));return Math.min(1,Math.max(0,n+r))})}var Dx=96,Ox=class{host;core;canvas=document.createElement(`canvas`);ctx;raf=0;last=0;ro=null;disposed=!1;accent;constructor(e,t,n){this.host=e,this.core=new af({reducedMotion:n}),this.accent=t,this.canvas.style.cssText=`width:100%;height:100%;display:block`,this.ctx=this.canvas.getContext(`2d`),e.appendChild(this.canvas),this.ctx&&(typeof ResizeObserver<`u`&&(this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(e)),this.resize(),this.raf=requestAnimationFrame(this.frame))}resize(){let e=Math.min(window.devicePixelRatio||1,2);this.canvas.width=Math.max(1,this.host.clientWidth)*e,this.canvas.height=Math.max(1,this.host.clientHeight)*e}frame=e=>{if(this.disposed||!this.ctx)return;if(this.raf=requestAnimationFrame(this.frame),document.hidden){this.last=e;return}let t=this.last?Math.min((e-this.last)/1e3,.1):.016;this.last=e,this.core.tick(t);let n=this.core.uniforms(),r=this.ctx,{width:i,height:a}=this.canvas,o=Math.min(i,a);r.clearRect(0,0,i,a);let s=o*.27*(1-n.tighten),c=o*.2,l=Ex(Dx,n.phase,n.amplitude,n.noise);r.save(),r.translate(i/2,a/2),r.rotate(n.angle),r.lineCap=`round`,r.strokeStyle=this.accent,r.shadowColor=this.accent,r.shadowBlur=o*.02*n.brightness,r.lineWidth=Math.max(2,o*.008);let u=this.core.state===`thinking`;for(let e=0;e<Dx;e++){let t=e/Dx*Math.PI*2,i=u?.25+.75*Math.abs(Math.sin((t-n.phase*2)/2)):1;r.globalAlpha=Math.min(1,(.35+l[e]*.65)*n.brightness*i);let a=o*.012+l[e]*c;r.beginPath(),r.moveTo(Math.cos(t)*s,Math.sin(t)*s),r.lineTo(Math.cos(t)*(s+a),Math.sin(t)*(s+a)),r.stroke()}r.globalAlpha=.28*n.brightness,r.shadowBlur=0,r.lineWidth=Math.max(1,o*.003),r.beginPath(),r.arc(0,0,s*.9,0,Math.PI*2),r.stroke(),r.restore()};setState(e){this.core.setState(e)}setAmplitude(e){this.core.setAmplitude(e)}setMode(e){this.resize()}setAccent(e){this.accent=e}setIntensity(e){this.core.setIntensity(e)}dispose(){this.disposed=!0,cancelAnimationFrame(this.raf),this.ro?.disconnect(),this.canvas.remove()}};function kx(e,t,n){let r=ef({...n.env??tf(),reducedMotion:n.reducedMotion}),i=()=>new xx(t,r||8e3,n.accent,n.reducedMotion);if(e===`ring`)return new Ox(t,n.accent,n.reducedMotion);if(r===0)return i();try{return e===`orb`?new wx(t,n.accent,n.reducedMotion):new bx(t,r,n.accent,n.reducedMotion)}catch{return i()}}function Ax({state:e,amplitude:t,pulse:n=0,mode:r,accent:i=`#3fd8ff`,style:a=`sphere`,intensity:o=.6,scale:s=1}){let c=(0,l.useRef)(null),u=(0,l.useRef)(null),d=(0,l.useRef)({state:e,amplitude:t,mode:r,accent:i,intensity:o});return d.current={state:e,amplitude:t,mode:r,accent:i,intensity:o},(0,l.useEffect)(()=>{let e=d.current,t=kx(a,c.current,{accent:e.accent,reducedMotion:tf().reducedMotion});return t.setState(e.state),t.setAmplitude(e.amplitude),t.setIntensity(e.intensity),t.setMode(e.mode),u.current=t,()=>{t.dispose(),u.current=null}},[a]),(0,l.useEffect)(()=>u.current?.setState(e),[e]),(0,l.useEffect)(()=>u.current?.setAmplitude(t),[t,n]),(0,l.useEffect)(()=>u.current?.setMode(r),[r]),(0,l.useEffect)(()=>u.current?.setAccent(i),[i]),(0,l.useEffect)(()=>u.current?.setIntensity(o),[o]),(0,p.jsx)(`div`,{ref:c,"data-presence":!0,"data-mode":r,"data-style":a,"data-state":e,"data-amplitude":t.toFixed(2),className:`presence presence-${r}`,style:r===`full`&&s!==1?{transform:`scale(${s})`}:void 0,"aria-hidden":`true`})}var jx=e=>.25+Math.min(1,Math.max(0,e))/.7*.75;function Mx({look:e}){let[t,n]=(0,l.useState)(.4),[r,i]=(0,l.useState)(0);(0,l.useEffect)(()=>{let e=setInterval(()=>{n(.3+Math.random()*.5),i(e=>e+1)},600);return()=>clearInterval(e)},[]);let a=jx(e.reactivity);return(0,p.jsxs)(`div`,{className:`look-preview`,"data-testid":`look-preview`,role:`img`,"aria-label":`Preview of the voice presence`,children:[e.ambient&&(0,p.jsx)(`div`,{className:`look-preview-glow`,style:{opacity:.35+.65*e.intensity,"--accent":e.accent}}),(0,p.jsx)(`div`,{className:`look-preview-stage`,style:{"--accent":e.accent},children:(0,p.jsx)(Ax,{state:`speaking`,amplitude:Math.min(1,t*a),pulse:r,mode:`full`,accent:e.accent,style:e.style,intensity:e.intensity,scale:e.size})}),e.captions&&(0,p.jsx)(`p`,{className:`look-preview-caption captions-${e.captionSize}`,children:`This is how my words will look.`})]})}var Nx=async e=>{let t;try{t=await fetch(`/api/account/secret`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}catch{throw Error(`Could not reach Friend. Check the connection.`)}let n={};try{n=await t.json()}catch{}if(!t.ok){let e=typeof n.triesLeft==`number`&&n.triesLeft>0?` ${n.triesLeft} ${n.triesLeft===1?`try`:`tries`} left.`:``;throw Error((n.error??(t.status===401?`Please sign in again.`:`The request failed (${t.status}).`))+e)}return{signedOutOthers:!!n.signedOutOthers}};function Px({change:e=Nx}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(``),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=r!==``||a!==``,x=s!==``||u!==``,S=async()=>{if(_(null),y(null),!t)return _(`Type your current password.`);if(!b&&!x)return _(`Type a new password or a new PIN.`);if(b&&r.length<8)return _(`The new password must be at least 8 characters.`);if(b&&r!==a)return _(`The two new passwords are not the same.`);if(x&&!/^\d{6,}$/.test(s))return _(`The new PIN must be at least 6 digits.`);if(x&&s!==u)return _(`The two new PINs are not the same.`);h(!0);try{let a=await e({current:t,...b?{newPassword:r}:{},...x?{newPin:s}:{}});y([b&&`Password changed.`,x&&`PIN changed.`,b&&a.signedOutOthers&&`Other browsers and phones were signed out.`].filter(Boolean).join(` `)),n(``),i(``),o(``),c(``),f(``)}catch(e){_(e.message),n(``)}finally{h(!1)}};return(0,p.jsxs)(`form`,{className:`settings-section`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,p.jsx)(`h3`,{children:`Password and PIN`}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Change either one or both. Your current password is always needed. Forgot it? On this PC run: friend password`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Current password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`current-password`,value:t,disabled:m,onChange:e=>n(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New password`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:r,disabled:m,onChange:e=>i(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New password again`}),(0,p.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:a,disabled:m,onChange:e=>o(e.target.value),style:d})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New PIN`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:s,disabled:m,onChange:e=>c(e.target.value.replace(/\D/g,``)),style:d})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The PIN is at least 6 digits. It is asked before risky actions.`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`New PIN again`}),(0,p.jsx)(`input`,{type:`password`,inputMode:`numeric`,autoComplete:`off`,value:u,disabled:m,onChange:e=>f(e.target.value.replace(/\D/g,``)),style:d})]}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),v&&(0,p.jsx)(`p`,{role:`status`,className:`auth-note`,children:v}),(0,p.jsx)(`button`,{type:`submit`,className:`primary`,style:d,disabled:m,children:m?`Saving…`:`Change`})]})}var Fx=[{id:`read`,label:`Read only`,note:`Friend can look at your portfolio, funds, positions and orders, and send you reports. It cannot place, change or cancel any order. This is the only level in this version.`,locked:!1},{id:`orders`,label:`Orders with my confirmation (later version)`,note:`Friend would prepare an order and wait for you to confirm it with your PIN.`,locked:!0},{id:`limits`,label:`Orders within limits (later version)`,note:`Friend would place small orders on its own, inside limits you set.`,locked:!0}];function Ix({level:e=`read`}){return(0,p.jsxs)(`div`,{className:`settings-section`,role:`radiogroup`,"aria-label":`What Friend may do with money`,children:[(0,p.jsx)(`h3`,{children:`What may Friend do with your trading account?`}),Fx.map(t=>(0,p.jsxs)(`label`,{className:`settings-check`,style:{alignItems:`flex-start`,opacity:t.locked?.55:1},children:[(0,p.jsx)(`input`,{type:`radio`,name:`trading`,value:t.id,checked:!t.locked&&e===t.id,disabled:t.locked,readOnly:!0,onChange:()=>{}}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{children:t.label}),(0,p.jsx)(`br`,{}),(0,p.jsx)(`small`,{className:`auth-note`,children:t.note})]})]},t.id)),(0,p.jsx)(`small`,{className:`auth-note`,children:`The assistant can never change this, even with your PIN. Orders will only arrive in a later version, with their own safeguards.`})]})}var Lx=async()=>{let e=await fetch(`/api/music/host/check`,{cache:`no-store`});if(!e.ok)throw Error(e.status===401?`Please sign in again.`:`The request failed (${e.status}).`);return await e.json()},Rx={url:`Open an address`,prompt:`Ask the assistant`,panel:`Open a panel`,music:`Control the music`},zx=e=>e===`panel`?zu[0]:e===`music`?Bu[0]:``;function Bx({music:e,hud:t,onMusic:n,onHud:r,checkHost:i=Lx}){let[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(!1),u=()=>{c(!0),o(null),i().then(e=>o(e.found?`mpv ${e.version} found (${e.path}).`:e.install)).catch(e=>o(e.message)).finally(()=>c(!1))},d=t.launcher,f=(e,t)=>r({launcher:d.map((n,r)=>r===e?{...n,...t}:n)}),m=(e,t)=>{let n=e+t;if(n<0||n>=d.length)return;let i=[...d];[i[e],i[n]]=[i[n],i[e]],r({launcher:i})};return(0,p.jsxs)(`div`,{className:`settings-section`,children:[(0,p.jsx)(`h3`,{children:`Music player`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Music folder`}),(0,p.jsx)(`input`,{type:`text`,value:e.folder,placeholder:`C:\\Users\\you\\Music`,onChange:e=>n({folder:e.target.value})}),(0,p.jsx)(`small`,{className:`auth-note`,children:`A folder on the PC that runs Friend. Its sub-folders are searched too. Saving checks that it exists.`})]}),(0,p.jsxs)(`fieldset`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`File types to look for`}),Lu.map(t=>(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.extensions.includes(t),onChange:r=>{let i=r.target.checked?[...e.extensions,t]:e.extensions.filter(e=>e!==t);i.length&&n({extensions:Lu.filter(e=>i.includes(e))})}}),(0,p.jsx)(`span`,{children:t})]},t))]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsxs)(`span`,{children:[`Start volume (`,e.volume,`%)`]}),(0,p.jsx)(`input`,{type:`range`,min:Ru.volume.min,max:Ru.volume.max,value:e.volume,onChange:e=>n({volume:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Repeat`}),(0,p.jsxs)(`select`,{value:e.repeat,onChange:e=>n({repeat:e.target.value}),children:[(0,p.jsx)(`option`,{value:`off`,children:`Off`}),(0,p.jsx)(`option`,{value:`all`,children:`The whole list`}),(0,p.jsx)(`option`,{value:`one`,children:`One track`})]})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Starts as`}),(0,p.jsxs)(`select`,{value:e.startView,onChange:e=>n({startView:e.target.value}),children:[(0,p.jsx)(`option`,{value:`mini`,children:`Small player`}),(0,p.jsx)(`option`,{value:`full`,children:`Big player with the playlist`})]})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.shuffle,onChange:e=>n({shuffle:e.target.checked})}),(0,p.jsx)(`span`,{children:`Shuffle`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:e.visualizer,onChange:e=>n({visualizer:e.target.checked})}),(0,p.jsx)(`span`,{children:`Moving bars around the dial`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Where music comes from, when the assistant is not told`}),(0,p.jsxs)(`select`,{value:e.defaultSource,onChange:e=>n({defaultSource:e.target.value}),children:[(0,p.jsx)(`option`,{value:`local`,children:`The music folder`}),(0,p.jsx)(`option`,{value:`spotify`,children:`Spotify`}),(0,p.jsx)(`option`,{value:`soundcloud`,children:`SoundCloud`}),(0,p.jsx)(`option`,{value:`audius`,children:`Audius`}),(0,p.jsx)(`option`,{value:`any`,children:`All`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Spotify, SoundCloud and Audius are added from Plugins. Playing from Spotify needs Spotify Premium on your account.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Most results from a service such as Spotify`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.searchLimit.min,max:Ru.searchLimit.max,value:e.searchLimit,onChange:e=>n({searchLimit:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Where the sound comes out`}),(0,p.jsxs)(`select`,{value:e.output,onChange:e=>n({output:e.target.value}),children:[(0,p.jsx)(`option`,{value:`screen`,children:`The screen (the browser plays it)`}),(0,p.jsx)(`option`,{value:`host`,children:`This PC's speakers (no browser needed)`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The PC's speakers play your folder's music through mpv, a free player you install once. Spotify plays on a Spotify device you name below.`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Program that plays the folder's music on the PC (empty: find mpv automatically)`}),(0,p.jsx)(`input`,{type:`text`,value:e.hostPlayer,maxLength:260,placeholder:`mpv`,onChange:e=>n({hostPlayer:e.target.value})}),Uu(e.hostPlayer.trim())&&(0,p.jsx)(`small`,{role:`alert`,className:`auth-error`,children:Uu(e.hostPlayer.trim())})]}),(0,p.jsxs)(`div`,{className:`settings-field`,children:[(0,p.jsx)(`button`,{type:`button`,disabled:s,onClick:u,children:`Check mpv`}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Looks for mpv with the saved program setting, or automatically when it is empty.`}),a&&(0,p.jsx)(`small`,{role:`status`,className:`auth-note`,children:a})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Spotify device on the PC to play on`}),(0,p.jsx)(`input`,{type:`text`,value:e.spotifyDevice,maxLength:100,placeholder:`the name Spotify shows for that device`,onChange:e=>n({spotifyDevice:e.target.value})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Most tracks to list`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.maxTracks.min,max:Ru.maxTracks.max,value:e.maxTracks,onChange:e=>n({maxTracks:Number(e.target.value)})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`How many folders deep to search`}),(0,p.jsx)(`input`,{type:`number`,min:Ru.scanDepth.min,max:Ru.scanDepth.max,value:e.scanDepth,onChange:e=>n({scanDepth:Number(e.target.value)})})]}),(0,p.jsx)(`h3`,{children:`Screen widgets`}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Name on the profile tag`}),(0,p.jsx)(`input`,{type:`text`,maxLength:24,value:t.terminalLabel,onChange:e=>r({terminalLabel:e.target.value})})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Animations`}),(0,p.jsxs)(`select`,{value:t.animations,onChange:e=>r({animations:e.target.value}),children:[(0,p.jsx)(`option`,{value:`full`,children:`Full`}),(0,p.jsx)(`option`,{value:`reduced`,children:`Reduced (only answers to hover and press)`}),(0,p.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`If the device is set to reduce motion, the screen stays still whatever this says.`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t.clock.hour12,onChange:e=>r({clock:{...t.clock,hour12:e.target.checked}})}),(0,p.jsx)(`span`,{children:`12-hour clock`})]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t.clock.seconds,onChange:e=>r({clock:{...t.clock,seconds:e.target.checked}})}),(0,p.jsx)(`span`,{children:`Show seconds`})]}),(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Date language (empty: the device's own)`}),(0,p.jsx)(`input`,{type:`text`,value:t.clock.locale,maxLength:35,placeholder:`en-GB`,onChange:e=>r({clock:{...t.clock,locale:e.target.value}})})]}),(0,p.jsx)(`h3`,{children:`Quick-launch buttons`}),d.length===0&&(0,p.jsx)(`small`,{className:`auth-note`,children:`No buttons yet.`}),d.map((e,t)=>{let n=Hu(e);return(0,p.jsxs)(`div`,{className:`settings-field`,role:`group`,"aria-label":`Button ${t+1}`,children:[(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:[(0,p.jsx)(`input`,{type:`text`,"aria-label":`Icon`,style:{width:56},value:e.icon,onChange:e=>f(t,{icon:e.target.value})}),(0,p.jsx)(`input`,{type:`text`,"aria-label":`Label`,maxLength:24,style:{flex:1,minWidth:100},value:e.label,onChange:e=>f(t,{label:e.target.value})}),(0,p.jsx)(`select`,{"aria-label":`What it does`,value:e.action.type,onChange:e=>{let n=e.target.value;f(t,{action:{type:n,value:zx(n)}})},children:Object.keys(Rx).map(e=>(0,p.jsx)(`option`,{value:e,children:Rx[e]},e))})]}),(0,p.jsxs)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:[e.action.type===`panel`||e.action.type===`music`?(0,p.jsx)(`select`,{"aria-label":`Which`,style:{flex:1},value:e.action.value,onChange:n=>f(t,{action:{...e.action,value:n.target.value}}),children:(e.action.type===`panel`?zu:Bu).map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))}):(0,p.jsx)(`input`,{type:`text`,"aria-label":e.action.type===`url`?`Address`:`Question`,style:{flex:1},value:e.action.value,placeholder:e.action.type===`url`?`https://…`:`What should it ask?`,onChange:n=>f(t,{action:{...e.action,value:n.target.value}})}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Move up`,disabled:t===0,onClick:()=>m(t,-1),children:`↑`}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Move down`,disabled:t===d.length-1,onClick:()=>m(t,1),children:`↓`}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Remove button`,onClick:()=>r({launcher:d.filter((e,n)=>n!==t)}),children:`Remove`})]}),n&&(0,p.jsx)(`small`,{role:`alert`,className:`auth-error`,children:n})]},e.id??t)}),(0,p.jsxs)(`button`,{type:`button`,disabled:d.length>=12,onClick:()=>r({launcher:[...d,{label:`New`,icon:`+`,action:{type:`panel`,value:`chat`}}]}),children:[`Add a button (`,d.length,`/`,12,`)`]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`The assistant can never change the music folder, these buttons or the animations, even with your PIN.`})]})}var Vx=[`#3fd8ff`,`#2b7bff`,`#a066ff`,`#ff6fae`,`#ff5a5a`,`#ff9b3d`,`#ffd23d`,`#3dff8c`,`#e8f4ff`],Hx=[{id:`sphere`,name:`Sphere`,note:`A cloud of particles`},{id:`orb`,name:`Orb`,note:`A glowing plasma ball`},{id:`ring`,name:`Ring`,note:`Radial bars, like a voice meter`}],Ux=(e,t)=>e.style===t.style&&e.accent.toLowerCase()===t.accent&&Math.abs(e.intensity-t.intensity)<.005;async function Wx(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:`The request failed (${n.status}).`));return r}var Gx={summary:e=>Wx(`/api/usage?days=${e}`),clear:()=>Wx(`/api/usage`,{method:`DELETE`})},Kx=[7,30,90],qx=e=>e.toLocaleString(`en-US`);function Jx(e){return e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${+(e/1e3).toFixed(1)}K`:String(e)}var Yx={voice:`Voice`,chat:`Chat`,task:`Scheduled tasks`,channel:`Messages (WhatsApp, Telegram…)`,other:`Other`};function Xx({api:e=Gx}){let[t,n]=(0,l.useState)(7),[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(null),[u,f]=(0,l.useState)(!1),m=(0,l.useRef)(!0),h=(0,l.useCallback)(async t=>{try{let n=await e.summary(t);m.current&&(i(n),o(null))}catch(e){m.current&&o(e.message)}},[e]);(0,l.useEffect)(()=>(m.current=!0,h(t),()=>{m.current=!1}),[h,t]);let g=async()=>{try{let n=await e.clear();if(!m.current)return;c(`Removed ${n.removed} saved counts.`),f(!1),await h(t)}catch(e){m.current&&o(e.message)}},_=r?Math.max(1,...r.days.map(e=>e.input+e.output)):1,v=!!r&&r.total.turns===0;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`approval-actions`,role:`group`,"aria-label":`How far back`,children:Kx.map(e=>(0,p.jsxs)(`button`,{type:`button`,style:d,className:t===e?`primary`:void 0,"aria-pressed":t===e,onClick:()=>n(e),children:[e,` days`]},e))}),a&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:a}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`usage-totals`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:Jx(r.total.input)}),(0,p.jsx)(`span`,{children:`Sent to the model`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:Jx(r.total.output)}),(0,p.jsx)(`span`,{children:`Written back`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`strong`,{children:r.total.turns}),(0,p.jsx)(`span`,{children:`Answers`})]})]}),v?(0,p.jsx)(`p`,{className:`auth-note`,children:`Nothing counted yet. Once Friend has answered, the tokens it used show up here.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`usage-bars`,"aria-hidden":!1,children:r.days.map(e=>{let t=e.input+e.output;return(0,p.jsxs)(`div`,{className:`usage-bar-col`,children:[(0,p.jsx)(`div`,{role:`img`,"aria-label":`${e.day}: ${qx(t)} tokens on ${e.turns} answers`,className:`usage-bar`,style:{height:`${Math.max(t>0?4:1,Math.round(t/_*100))}%`},title:`${e.day}: ${qx(t)} tokens`}),r.days.length<=31&&(0,p.jsx)(`span`,{className:`usage-bar-day`,children:e.day.slice(8)})]},e.day)})}),(0,p.jsxs)(`table`,{className:`usage-table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Day`}),(0,p.jsx)(`th`,{scope:`col`,children:`Sent`}),(0,p.jsx)(`th`,{scope:`col`,children:`Written`}),(0,p.jsx)(`th`,{scope:`col`,children:`Answers`})]})}),(0,p.jsx)(`tbody`,{children:[...r.days].reverse().map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`row`,children:e.day}),(0,p.jsx)(`td`,{children:qx(e.input)}),(0,p.jsx)(`td`,{children:qx(e.output)}),(0,p.jsx)(`td`,{children:e.turns})]},e.day))})]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`By model`}),(0,p.jsx)(`ul`,{className:`usage-list`,children:r.byModel.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(`span`,{children:[e.provider,` / `,e.model]}),(0,p.jsxs)(`span`,{children:[Jx(e.input+e.output),` tokens · `,e.turns,` answers`]})]},`${e.provider}/${e.model}`))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`By where it came from`}),(0,p.jsx)(`ul`,{className:`usage-list`,children:r.bySource.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`span`,{children:Yx[e.source]??e.source}),(0,p.jsxs)(`span`,{children:[Jx(e.input+e.output),` tokens · `,e.turns,` answers`]})]},e.source))})]})]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend keeps counts only: the day, the model, and how many tokens. Never what was said. Counts older than a year are removed by themselves.`}),s&&(0,p.jsx)(`p`,{className:`auth-note`,children:s}),(0,p.jsx)(`div`,{className:`approval-actions`,children:u?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:()=>void g(),children:`Yes, clear them`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>f(!1),children:`Keep them`})]}):(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>f(!0),children:`Clear saved counts`})})]})}async function Zx(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:n.status===403?`Incorrect PIN`:`The request failed (${n.status}).`));return r}var Qx=e=>({method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),$x={info:()=>Zx(`/api/conversation`),compact:()=>Zx(`/api/conversation/compact`,Qx({})),clear:e=>Zx(`/api/conversation/clear`,Qx({pin:e}))},eS=[5e4,1e5,2e5,4e5,8e5];function tS({api:e=$x,autoCompact:t,limit:n,onChange:r}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(null),y=(0,l.useRef)(!0),b=(0,l.useCallback)(async()=>{try{let t=await e.info();y.current&&a(t)}catch(e){y.current&&g(e.message)}},[e]);(0,l.useEffect)(()=>(y.current=!0,b(),()=>{y.current=!1}),[b]);let x=async e=>{m(!0),g(null),v(null);try{let t=await e();if(!y.current)return;t.ok?v(t.message):g(t.message),s(!1),await b()}catch(e){y.current&&g(e.message)}finally{y.current&&(m(!1),u(``))}};if(o)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to start fresh. Friend keeps its notes and memory, but forgets the earlier conversation.`}),(0,p.jsx)(T,{pin:c,onChange:u,onSubmit:()=>!f&&c.length>=6&&void x(()=>e.clear(c))}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f||c.length<6,onClick:()=>void x(()=>e.clear(c)),children:`Continue`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{s(!1),u(``),g(null)},children:`Back`})]})]});let S=eS.includes(n)?eS:[...eS,n].sort((e,t)=>e-t);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Conversation memory`}),i&&!i.supported?(0,p.jsx)(`p`,{className:`auth-note`,children:`This model does not keep a conversation of its own: Friend sends it the recent messages each time, so there is nothing to tidy.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:i?`Claude is holding about ${Jx(i.contextTokens)} tokens of conversation${i.contextTokens===0?` (it counts again after the next answer)`:``}. It reads all of it for every answer, so a long one uses a lot of your plan.`:`Checking…`}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>r({autoCompact:e.target.checked})}),` Tidy up by itself`]}),(0,p.jsxs)(`label`,{className:`settings-check`,style:{marginTop:6},children:[`When it grows past`,` `,(0,p.jsx)(`select`,{value:n,onChange:e=>r({compactAtTokens:Number(e.target.value)}),disabled:!t,children:S.map(e=>(0,p.jsxs)(`option`,{value:e,children:[Jx(e),` tokens`]},e))})]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Tidying up writes short notes on what you were doing and starts a fresh conversation from them, before the next answer. Friend keeps its saved notes either way.`}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f||!i,onClick:()=>void x(()=>e.compact()),children:`Tidy up now`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f||!i,onClick:()=>s(!0),children:`Start fresh`})]})]}),_&&(0,p.jsx)(`p`,{className:`auth-note`,children:_}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h})]})}async function nS(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}let r={};try{r=await n.json()}catch{}if(!n.ok)throw Error(r.error??(n.status===401?`Please sign in again.`:n.status===403?`Incorrect PIN`:`The request failed (${n.status}).`));return r}var rS=e=>({method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),iS={info:()=>nS(`/api/system`),check:()=>nS(`/api/system/update/check`,rS({})),update:e=>nS(`/api/system/update/apply`,rS({pin:e})),setAutostart:(e,t)=>nS(`/api/system/autostart`,rS({enabled:e,pin:t}))},aS=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function oS({api:e=iS,auto:t,onAuto:n,pollMs:r=0}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(``),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)(null),y=(0,l.useRef)(!0),b=(0,l.useCallback)(async()=>{try{let t=await e.info();y.current&&a(t)}catch(e){y.current&&g(e.message)}},[e]);(0,l.useEffect)(()=>{y.current=!0,b();let e=r>0?setInterval(()=>void b(),r):null;return()=>{y.current=!1,e&&clearInterval(e)}},[b,r]);let x=async()=>{if(o){m(!0),g(null);try{let t=o.kind===`autostart`?await e.setAutostart(o.enabled,c):await e.update(c);if(!y.current)return;v(t.message),s(null),await b()}catch(e){y.current&&g(e.message)}finally{y.current&&(m(!1),u(``))}}},S=async()=>{m(!0),g(null),v(null);try{let t=await e.check();y.current&&a(e=>e&&{...e,update:t})}catch(e){y.current&&g(e.message)}finally{y.current&&m(!1)}};if(o)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:o.kind===`update`?`Enter your PIN to update Friend now. It restarts in a moment.`:o.enabled?`Enter your PIN to start Friend by itself when this computer starts.`:`Enter your PIN to stop starting Friend with this computer.`}),(0,p.jsx)(T,{pin:c,onChange:u,onSubmit:()=>!f&&c.length>=6&&void x()}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f||c.length<6,onClick:()=>void x(),children:`Continue`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{s(null),u(``),g(null)},children:`Back`})]})]});let C=i?.update;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Start with the computer`}),i&&(i.autostart.supported?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:i.autostart.enabled?`Friend starts by itself when you sign in to this computer, so you never have to start it after a restart.`:`Friend does not start by itself yet: after a restart you start it yourself.`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:i.autostart.enabled?void 0:`primary`,disabled:f,onClick:()=>s({kind:`autostart`,enabled:!i.autostart.enabled}),children:i.autostart.enabled?`Stop starting Friend with this computer`:`Start Friend when this computer starts`})})]}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Starting Friend by itself is not supported on this computer.`})),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Updates`}),i&&C&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Friend `,i.version,`.`,` `,C.applying?`Updating Friend to ${C.latest??`the newest version`}…`:C.available?`Friend ${C.latest} is available.`:C.latest?`Up to date.`:`Not checked yet.`,C.checkedAt?` (looked at ${aS(C.checkedAt)})`:``]}),C.error&&(0,p.jsx)(`p`,{className:`auth-error`,children:C.error}),C.available&&!C.canApply&&!C.applying&&(0,p.jsx)(`p`,{className:`auth-note`,children:`This Friend is running in a terminal, so it cannot restart itself. Close it and run: friend upgrade`}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:f||C.applying,onClick:()=>void S(),children:`Check for updates`}),C.available&&C.canApply&&!C.applying&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:f,onClick:()=>s({kind:`update`}),children:`Update now`})]})]}),(0,p.jsxs)(`label`,{className:`settings-check`,style:{marginTop:10},children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),` Update Friend by itself`]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Looks for a newer Friend when it starts, then every few hours, and installs it while Friend is not busy. Switch it off to update only when you press Update now (or run friend upgrade).`}),_&&(0,p.jsx)(`p`,{className:`auth-note`,children:_}),h&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:h})]})}var sS=[{id:`manual`,label:`Ask me (manual)`,note:`Friend asks before anything that changes your PC or leaves the safe zone. The most careful.`},{id:`edits`,label:`Auto-approve file work (edits)`,note:`Reading and writing files, and the sandboxed code runner, go ahead without asking. Commands still ask.`},{id:`auto`,label:`Auto-approve everything safe (auto)`,note:`Commands, files and tools go ahead without asking. The most convenient, and the most trust: Friend acts on its own.`}],cS=[{id:`claude-code`,label:`Claude subscription (Claude Code)`,note:`Uses the Claude Code app you are signed in to. No API key.`},{id:`claude`,label:`Claude API key`,note:`Pay per use with an Anthropic API key.`},{id:`ollama`,label:`Local model (Ollama)`,note:`Runs on this PC. Free and private, but slower.`},{id:`openai`,label:`OpenAI-compatible server (OmniRoute, LM Studio…)`,note:`Any server that speaks the OpenAI chat API. OmniRoute is one address that routes to many models, many of them free.`}],lS={"voice.enabled":`Speech on/off`};function uS({label:e,children:t,hint:n}){return(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:e}),t,n&&(0,p.jsx)(`small`,{className:`auth-note`,children:n})]})}function dS({api:e=ht,onClose:t,initialTab:n=`model`,preview:r=gt,variant:i=`classic`}){let[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(null),[u,f]=(0,l.useState)(n),[m,h]=(0,l.useState)(``),[g,_]=(0,l.useState)(``),[v,y]=(0,l.useState)(!1),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(!1),[E,D]=(0,l.useState)(null),[O,k]=(0,l.useState)(null),[A,j]=(0,l.useState)(null),[ee,M]=(0,l.useState)(null),N=(0,l.useRef)(!0);(0,l.useEffect)(()=>(N.current=!0,e.get().then(e=>{N.current&&(o(e),c(structuredClone(e)))}).catch(e=>N.current&&D(e.message)),()=>{N.current=!1}),[e]);let P=(e,n=!1,r={})=>i===`holo`?(0,p.jsx)(b,{label:`Settings`,title:r.title??Se.find(e=>e.id===u)?.label??`Settings`,page:r.page,help:r.help,onApply:r.onApply,onUndo:r.onUndo,dirty:r.dirty,busy:C,onDone:t,children:e}):(0,p.jsxs)(`div`,{className:`approval settings glass${n?` settings-wide`:``}`,role:`dialog`,"aria-label":`Settings`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Settings`})}),e]});if(!s||!a)return P((0,p.jsxs)(p.Fragment,{children:[E?(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}):(0,p.jsx)(`p`,{className:`auth-note`,children:`Loading…`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})})]}));let F=_t(a,s,m,g),te=Object.keys(F).length>0,I=(e,t,n)=>c({...s,[e]:{...s[e],[t]:n}}),ne=s.look,L=(e,t)=>{t&&(j(e),M(e===`main`?null:`The first time, the voice downloads (about 64 MB). Please wait…`),r(t).then(()=>N.current&&M(`Playing…`)).catch(e=>N.current&&M(e.message)).finally(()=>N.current&&j(null)))},re=async t=>{D(null),w(!0);try{let n=await e.save(F,t);if(!N.current)return;o(n.settings),c(structuredClone(n.settings)),h(``),_(``),y(!1);let r=F.voice&&F.voice.ttsVoice!==void 0,i=F.voice&&F.voice.sttModel!==void 0;k(n.restart.length?`Saved. Restart Friend for: ${n.restart.map(e=>lS[e]??e).join(`, `)}.`:i?`Saved. The listening model is being downloaded in the background (the first time only); Friend keeps listening with the old one and tells you when the new one is ready.`:r?`Saved. The new voice is loading; you will get a message when it is ready (the first time it downloads about 60 MB).`:pt(F)?`Saved. It is in use now.`:`Saved. Every open screen has changed.`)}catch(e){N.current&&D(e.message)}finally{N.current&&(w(!1),S(``))}};if(v)return P((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Enter your PIN to save these changes.`}),(0,p.jsx)(T,{pin:x,onChange:S,onSubmit:()=>!C&&void re(x)}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:C||x.length<6,onClick:()=>void re(x),children:`Save`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{y(!1),S(``),D(null)},children:`Back`})]})]}));let ie=cS.find(e=>e.id===s.provider),ae=e=>{let t=Se.findIndex(e=>e.id===u),n=e.key===`ArrowDown`||e.key===`ArrowRight`?(t+1)%Se.length:e.key===`ArrowUp`||e.key===`ArrowLeft`?(t+Se.length-1)%Se.length:e.key===`Home`?0:e.key===`End`?Se.length-1:-1;n<0||(e.preventDefault(),f(Se[n].id),document.getElementById(`settings-tab-${Se[n].id}`)?.focus())},oe=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Where Friend thinks`}),(0,p.jsx)(uS,{label:`Model provider`,hint:ie.note,children:(0,p.jsx)(`select`,{value:s.provider,onChange:e=>c({...s,provider:e.target.value}),children:cS.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),s.provider===`claude-code`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(uS,{label:`Claude model`,hint:`sonnet, haiku, opus, or a full model name`,children:[(0,p.jsx)(`input`,{list:`cc-models`,value:s.claudeCode.model,onChange:e=>I(`claudeCode`,`model`,e.target.value)}),(0,p.jsxs)(`datalist`,{id:`cc-models`,children:[(0,p.jsx)(`option`,{value:`sonnet`}),(0,p.jsx)(`option`,{value:`haiku`}),(0,p.jsx)(`option`,{value:`opus`})]})]}),(0,p.jsx)(uS,{label:`If Claude is unavailable`,hint:`For example when the plan's usage limit is reached.`,children:(0,p.jsxs)(`select`,{value:s.claudeCode.fallback,onChange:e=>I(`claudeCode`,`fallback`,e.target.value),children:[(0,p.jsx)(`option`,{value:`ollama`,children:`Answer with the local model (Ollama)`}),(0,p.jsx)(`option`,{value:`none`,children:`Show an error`})]})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.claudeCode.webSearch??!0,onChange:e=>I(`claudeCode`,`webSearch`,e.target.checked)}),` Let Claude search the web`]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`For prices, news and anything else that changes: Claude looks it up instead of answering from memory. Only searching, never opening pages on this PC.`}),(0,p.jsx)(uS,{label:`Claude Code command`,hint:`Leave as it is unless the program is somewhere else.`,children:(0,p.jsx)(`input`,{value:s.claudeCode.command,onChange:e=>I(`claudeCode`,`command`,e.target.value)})}),(0,p.jsx)(tS,{autoCompact:s.session?.autoCompact??!0,limit:s.session?.compactAtTokens??1e5,onChange:e=>c({...s,session:{autoCompact:!0,compactAtTokens:1e5,...s.session,...e}})})]}),s.provider===`claude`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(uS,{label:`Claude model`,children:(0,p.jsx)(`input`,{value:s.model,onChange:e=>c({...s,model:e.target.value})})}),(0,p.jsx)(uS,{label:`API key`,hint:a.apiKeySet?`A key is saved. Type a new one only to replace it.`:`No key saved yet.`,children:(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,placeholder:a.apiKeySet?`saved`:`sk-ant-…`,value:m,onChange:e=>h(e.target.value)})})]}),s.provider===`openai`&&s.openai&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(uS,{label:`Server address`,hint:`Ends in /v1. OmniRoute: http://localhost:20128/v1 (install it with npm install -g omniroute, then run omniroute).`,children:(0,p.jsx)(`input`,{value:s.openai.url,onChange:e=>c({...s,openai:{...s.openai,url:e.target.value}})})}),(0,p.jsx)(uS,{label:`Model`,hint:`The name that server knows. OmniRoute answers to auto.`,children:(0,p.jsx)(`input`,{value:s.openai.model,onChange:e=>c({...s,openai:{...s.openai,model:e.target.value}})})}),(0,p.jsx)(uS,{label:`API key`,hint:a.openai?.apiKeySet?`A key is saved. Type a new one only to replace it.`:`Leave empty if the server asks for none.`,children:(0,p.jsx)(`input`,{type:`password`,autoComplete:`off`,placeholder:a.openai?.apiKeySet?`saved`:``,value:g,onChange:e=>_(e.target.value)})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.openai.vision,onChange:e=>c({...s,openai:{...s.openai,vision:e.target.checked}})}),` This model can look at pictures`]})]}),(s.provider===`ollama`||s.provider===`claude-code`&&s.claudeCode.fallback===`ollama`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Local model (Ollama)`}),(0,p.jsx)(uS,{label:`Address`,children:(0,p.jsx)(`input`,{value:s.ollama.url,onChange:e=>I(`ollama`,`url`,e.target.value)})}),(0,p.jsx)(uS,{label:`Model`,children:(0,p.jsx)(`input`,{value:s.ollama.model,onChange:e=>I(`ollama`,`model`,e.target.value)})}),(0,p.jsx)(uS,{label:`Memory window (tokens)`,children:(0,p.jsx)(`input`,{type:`number`,min:1024,max:131072,step:1024,value:s.ollama.contextTokens,onChange:e=>I(`ollama`,`contextTokens`,Number(e.target.value))})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.ollama.vision,onChange:e=>I(`ollama`,`vision`,e.target.checked)}),` This model can look at pictures`]})]})]}),se=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Speaking and listening`}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.voice.speakTyped,onChange:e=>I(`voice`,`speakTyped`,e.target.checked)}),` Also speak the replies to typed messages`]}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:s.voice.duck??!0,onChange:e=>I(`voice`,`duck`,e.target.checked)}),` Turn music and video down while I talk and while Friend speaks`]}),(0,p.jsx)(uS,{label:`Volume while talking: ${s.voice.duckPercent??25}%`,hint:`How loud music and video are then, compared with how loud you have them. They come back as they were when nothing is happening.`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:s.voice.duckPercent??25,disabled:s.voice.duck===!1,onChange:e=>I(`voice`,`duckPercent`,Number(e.target.value))})}),(0,p.jsx)(uS,{label:`Spoken language`,hint:`Leave empty to detect it by itself: best when you mix English, Hindi and Marathi. Or force one: en, hi, mr.`,children:(0,p.jsx)(`input`,{value:s.voice.language??``,maxLength:10,onChange:e=>I(`voice`,`language`,e.target.value.trim()===``?null:e.target.value.trim())})}),(0,p.jsx)(uS,{label:`Speaking voice`,hint:`Female or male. The first time a voice is used it downloads about 60 MB, then it works without internet.`,children:(0,p.jsxs)(`select`,{value:s.voice.ttsVoice,onChange:e=>I(`voice`,`ttsVoice`,e.target.value),children:[(0,p.jsx)(`optgroup`,{label:`Female`,children:uu.filter(e=>e.gender===`female`).map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.accent,e.note?` · ${e.note}`:``]},e.id))}),(0,p.jsx)(`optgroup`,{label:`Male`,children:uu.filter(e=>e.gender===`male`).map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.accent,e.note?` · ${e.note}`:``]},e.id))}),(0,p.jsx)(`optgroup`,{label:`Original`,children:(0,p.jsxs)(`option`,{value:pu.id,children:[pu.name,` · `,pu.accent,` · `,pu.note]})}),!mu(s.voice.ttsVoice)&&(0,p.jsx)(`optgroup`,{label:`Other`,children:(0,p.jsx)(`option`,{value:s.voice.ttsVoice,children:s.voice.ttsVoice})})]})}),(0,p.jsx)(uS,{label:`Hindi voice`,hint:`Reads Hindi (Devanagari) text; English words in the same sentence still use the voice above. The first time it downloads about 64 MB.`,children:(0,p.jsxs)(`select`,{value:s.voice.hindiVoice??``,onChange:e=>I(`voice`,`hindiVoice`,e.target.value),children:[(0,p.jsx)(`option`,{value:``,children:`Same as the voice above`}),du.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.gender,e.note?` · ${e.note}`:``]},e.id))]})}),(0,p.jsx)(uS,{label:`Marathi voice`,hint:`Reads Marathi text. Friend tells Marathi from Hindi by the words used.`,children:(0,p.jsxs)(`select`,{value:s.voice.marathiVoice??``,onChange:e=>I(`voice`,`marathiVoice`,e.target.value),children:[(0,p.jsx)(`option`,{value:``,children:`Same as the voice above`}),fu.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,p.jsxs)(`div`,{className:`voice-hear`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null,onClick:()=>L(`main`,s.voice.ttsVoice),children:A===`main`?`Loading the voice…`:`Hear it`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null||!s.voice.hindiVoice,onClick:()=>L(`hindi`,s.voice.hindiVoice??``),children:A===`hindi`?`Loading the voice…`:`Hear the Hindi voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:A!==null||!s.voice.marathiVoice,onClick:()=>L(`marathi`,s.voice.marathiVoice??``),children:A===`marathi`?`Loading the voice…`:`Hear the Marathi voice`}),ee&&(0,p.jsx)(`small`,{className:`auth-note`,role:`status`,children:ee})]}),(0,p.jsx)(uS,{label:`Listening model`,hint:`Bigger hears more accurately, from further away and in Hindi and Marathi, but is slower. It downloads once, in the background, and Friend keeps listening meanwhile. No restart.`,children:(0,p.jsxs)(`select`,{value:s.voice.sttModel,onChange:e=>I(`voice`,`sttModel`,e.target.value),children:[!hu.some(e=>e.id===s.voice.sttModel)&&(0,p.jsx)(`option`,{value:s.voice.sttModel,children:s.voice.sttModel}),hu.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.name,` · `,gu(e.mb).replace(`about `,``),` · `,e.note]},e.id))]})}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Who is speaking`}),(0,p.jsx)(uS,{label:`"It is me" match level: ${s.voice.accept.toFixed(2)}`,hint:`Higher is stricter. Only matters after you enrolled your voice.`,children:(0,p.jsx)(`input`,{type:`range`,min:.3,max:.95,step:.01,value:s.voice.accept,onChange:e=>I(`voice`,`accept`,Number(e.target.value))})}),(0,p.jsx)(uS,{label:`"Ask for my PIN" level: ${s.voice.challenge.toFixed(2)}`,hint:`Voices between this and the level above must be confirmed with the PIN.`,children:(0,p.jsx)(`input`,{type:`range`,min:.2,max:.9,step:.01,value:s.voice.challenge,onChange:e=>I(`voice`,`challenge`,Number(e.target.value))})})]}),ce=(0,p.jsxs)(`div`,{className:`look-tab`,children:[(0,p.jsxs)(`div`,{className:`look-side`,children:[(0,p.jsx)(Mx,{look:ne}),(0,p.jsx)(`p`,{className:`auth-note`,children:`This is a live preview. Nothing changes on the screen until you save.`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>c({...s,look:{...dt}}),children:`Back to the default look`})]}),(0,p.jsxs)(`div`,{className:`look-controls`,children:[(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Themes`}),(0,p.jsx)(`div`,{className:`theme-grid`,role:`group`,"aria-label":`Themes`,children:_u.map(e=>(0,p.jsxs)(`button`,{type:`button`,className:`theme-card${Ux(ne,e)?` on`:``}`,"aria-pressed":Ux(ne,e),style:{"--swatch":e.accent},onClick:()=>c({...s,look:{...ne,style:e.style,accent:e.accent,intensity:e.intensity}}),children:[(0,p.jsx)(`i`,{"aria-hidden":`true`}),(0,p.jsx)(`b`,{children:e.name}),(0,p.jsx)(`small`,{children:e.style})]},e.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Shape`}),(0,p.jsx)(`div`,{className:`style-row`,role:`radiogroup`,"aria-label":`Style`,children:Hx.map(e=>(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":ne.style===e.id,className:`style-choice${ne.style===e.id?` on`:``}`,onClick:()=>I(`look`,`style`,e.id),children:[(0,p.jsx)(`b`,{children:e.name}),(0,p.jsx)(`small`,{children:e.note})]},e.id))}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Colour and light`}),(0,p.jsxs)(`div`,{className:`swatch-row`,role:`group`,"aria-label":`Colour`,children:[Vx.map(e=>(0,p.jsx)(`button`,{type:`button`,"aria-label":`Colour ${e}`,"aria-pressed":ne.accent.toLowerCase()===e,className:`swatch${ne.accent.toLowerCase()===e?` on`:``}`,style:{background:e},onClick:()=>I(`look`,`accent`,e)},e)),(0,p.jsxs)(`label`,{className:`swatch-custom`,children:[(0,p.jsx)(`span`,{children:`Other`}),(0,p.jsx)(`input`,{type:`color`,"aria-label":`Pick another colour`,value:ne.accent,onChange:e=>I(`look`,`accent`,e.target.value.toLowerCase())})]})]}),(0,p.jsx)(uS,{label:`Brightness: ${Math.round(ne.intensity*100)}%`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:ne.intensity,onChange:e=>I(`look`,`intensity`,Number(e.target.value))})}),(0,p.jsx)(uS,{label:`Size: ${Math.round(ne.size*100)}%`,hint:`How big it is in the middle of the screen.`,children:(0,p.jsx)(`input`,{type:`range`,min:.5,max:1.5,step:.05,value:ne.size,onChange:e=>I(`look`,`size`,Number(e.target.value))})}),(0,p.jsx)(uS,{label:`Reaction to my voice: ${Math.round(ne.reactivity*100)}%`,hint:`Low is calm, high moves a lot when anyone speaks.`,children:(0,p.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:ne.reactivity,onChange:e=>I(`look`,`reactivity`,Number(e.target.value))})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.ambient,onChange:e=>I(`look`,`ambient`,e.target.checked)}),` Soft glow behind everything`]}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`Words on the screen`}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.captions,onChange:e=>I(`look`,`captions`,e.target.checked)}),` Show the live words while Friend speaks`]}),(0,p.jsx)(uS,{label:`Caption size`,children:(0,p.jsxs)(`select`,{value:ne.captionSize,disabled:!ne.captions,onChange:e=>I(`look`,`captionSize`,e.target.value),children:[(0,p.jsx)(`option`,{value:`small`,children:`Small`}),(0,p.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,p.jsx)(`option`,{value:`large`,children:`Large`})]})}),(0,p.jsx)(`h4`,{className:`plugins-heading`,children:`What is on the screen`}),(0,p.jsx)(uS,{label:`Your name`,hint:`Shown on the badge in the corner, next to the shield, while you are signed in. Empty shows Owner.`,children:(0,p.jsx)(`input`,{value:s.ownerName??``,maxLength:40,placeholder:`Owner`,onChange:e=>c({...s,ownerName:e.target.value})})}),(0,p.jsx)(uS,{label:`View`,hint:`Minimal: only the voice presence. Companion: plus a status line and a clock. Workspace: also the chat and the schedule. Drag any panel to move it.`,children:(0,p.jsxs)(`select`,{value:s.view,onChange:e=>c({...s,view:e.target.value}),children:[(0,p.jsx)(`option`,{value:`minimal`,children:`Minimal`}),(0,p.jsx)(`option`,{value:`companion`,children:`Companion`}),(0,p.jsx)(`option`,{value:`workspace`,children:`Workspace`})]})}),(0,p.jsxs)(`label`,{className:`settings-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:ne.aiMayChange,onChange:e=>I(`look`,`aiMayChange`,e.target.checked)}),` Let the AI change the shape, colour and brightness to suit a topic`]}),(0,p.jsx)(`small`,{className:`auth-note`,children:`Off keeps exactly the look you chose. You can still ask it to change the look yourself.`})]})]}),le=s.approvals??`manual`,ue=(0,p.jsxs)(`div`,{className:`settings-section`,role:`radiogroup`,"aria-label":`How much Friend asks before acting`,children:[(0,p.jsx)(`h3`,{children:`How much should Friend ask?`}),sS.map(e=>(0,p.jsxs)(`label`,{className:`settings-check`,style:{alignItems:`flex-start`},children:[(0,p.jsx)(`input`,{type:`radio`,name:`approvals`,value:e.id,checked:le===e.id,onChange:()=>c({...s,approvals:e.id})}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{children:e.label}),(0,p.jsx)(`br`,{}),(0,p.jsx)(`small`,{className:`auth-note`,children:e.note})]})]},e.id)),(0,p.jsx)(`small`,{className:`auth-note`,children:`Whatever you pick, these still ask: risky commands (they need your PIN), the camera, adding connectors or plugins, and anything in Friend's own data folder. Changing this needs your PIN.`})]}),de=(0,p.jsxs)(p.Fragment,{children:[u===`model`&&oe,u===`voice`&&se,u===`look`&&ce,u===`approvals`&&ue,u===`trading`&&(0,p.jsx)(Ix,{level:s.trading?.level??`read`}),u===`widgets`&&s.music&&s.hud&&(0,p.jsx)(Bx,{music:s.music,hud:s.hud,onMusic:e=>c({...s,music:{...s.music,...e}}),onHud:e=>c({...s,hud:{...s.hud,...e}})}),u===`system`&&(0,p.jsx)(oS,{auto:s.updates?.auto??!0,onAuto:e=>c({...s,updates:{auto:e}})}),u===`usage`&&(0,p.jsx)(Xx,{}),u===`security`&&(0,p.jsx)(Px,{})]}),R=()=>{k(null),D(null),pt(F)?y(!0):re()},z=()=>{c(structuredClone(a)),h(``),_(``)},B=(0,p.jsxs)(p.Fragment,{children:[O&&!te&&(0,p.jsx)(`p`,{className:`auth-note`,children:O}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E})]});if(i===`holo`){let e=Se.findIndex(e=>e.id===u),t=e=>f(Se[(e+Se.length)%Se.length].id);return P((0,p.jsxs)(p.Fragment,{children:[de,B]}),!0,{title:Se[e].label,page:{index:e,total:Se.length,onPrev:()=>t(e-1),onNext:()=>t(e+1)},dirty:te,onApply:R,onUndo:z,help:(0,p.jsxs)(p.Fragment,{children:[`Fill in the settings and press `,(0,p.jsx)(`b`,{children:`Apply`}),` to save them. Network, folders and safety rules are not here on purpose: change those in the terminal with friend config set.`]})})}return P((0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`settings-layout`,children:[(0,p.jsx)(`div`,{className:`settings-tabs`,role:`tablist`,"aria-label":`Settings sections`,"aria-orientation":`vertical`,onKeyDown:ae,children:Se.map(e=>(0,p.jsxs)(`button`,{id:`settings-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":u===e.id,"aria-controls":`settings-panel-${e.id}`,tabIndex:u===e.id?0:-1,className:`settings-tab${u===e.id?` on`:``}`,onClick:()=>f(e.id),children:[(0,p.jsx)(`b`,{children:e.label}),(0,p.jsx)(`small`,{children:e.note})]},e.id))}),(0,p.jsx)(`div`,{className:`settings-body`,role:`tabpanel`,id:`settings-panel-${u}`,"aria-labelledby":`settings-tab-${u}`,children:de})]}),O&&!te&&(0,p.jsx)(`p`,{className:`auth-note`,children:O}),E&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:E}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:!te||C,onClick:R,children:te&&!pt(F)?`Save`:`Save…`}),te&&(0,p.jsx)(`button`,{type:`button`,style:d,onClick:z,children:`Undo changes`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:t,children:`Close`})]}),(0,p.jsx)(`p`,{className:`auth-note`,children:`Network, folders and safety rules are not here on purpose. Change those in the terminal: friend config set.`})]}),!0)}var fS=e=>e instanceof HTMLElement&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable);function pS({onSend:e,requestOpen:t,slash:n,onOpenChange:r}){let[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(r);o.current=r,(0,l.useEffect)(()=>o.current?.(i),[i]);let[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(0),f=(0,l.useRef)(null);if((0,l.useEffect)(()=>{t>0&&a(!0)},[t]),(0,l.useEffect)(()=>{let e=e=>{i||fS(e.target)||e.ctrlKey||e.metaKey||e.altKey||e.key.length===1&&(e.preventDefault(),c(e.key),d(0),a(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,l.useEffect)(()=>{i&&f.current?.focus()},[i]),!i)return null;let m=n?F(n.commands,s):[],h=m[Math.min(u,Math.max(m.length-1,0))],g=()=>{c(``),d(0),a(!1)},_=()=>{let t=s.trim();if(n&&P(t)){let e=/^\/\S*\s/.test(t);n.run(!e&&h?`/${h.name}`:t)}else t&&e(I(t));g()};return(0,p.jsxs)(`form`,{className:`command-bar`,onSubmit:e=>{e.preventDefault(),_()},children:[m.length>0&&(0,p.jsx)(`ul`,{className:`slash-list`,role:`listbox`,"aria-label":`Commands`,children:m.map((e,t)=>(0,p.jsxs)(`li`,{role:`option`,"aria-selected":e===h,className:e===h?`on`:void 0,onMouseDown:n=>{n.preventDefault(),c(`/${e.name} `),f.current?.focus(),d(t)},children:[(0,p.jsxs)(`b`,{children:[`/`,e.name]}),e.usage&&(0,p.jsx)(`i`,{children:e.usage}),(0,p.jsx)(`span`,{children:e.description})]},e.name))}),(0,p.jsx)(`input`,{ref:f,"aria-label":`Message`,value:s,placeholder:`Talk to me… or type / for commands`,autoComplete:`off`,onChange:e=>{c(e.target.value),d(0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),g()):m.length>0&&(e.key===`ArrowDown`||e.key===`ArrowUp`)?(e.preventDefault(),d(t=>(t+(e.key===`ArrowDown`?1:m.length-1))%m.length)):e.key===`Tab`&&h&&(e.preventDefault(),c(`/${h.name} `))}}),(0,p.jsx)(`button`,{type:`submit`,"aria-label":`Send`,children:`↵`})]})}var mS={width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0},hS=(e,t)=>e===`listening`?t?`Listening… tap to send`:`Listening… let go to send`:e===`transcribing`?`Understanding…`:e===`speaking`?`Tap to talk over me`:`Hold to talk, or tap once`;function gS({voice:e,mode:t,onType:n,onMenu:r}){let i=(0,l.useRef)(null),a=(0,l.useRef)(!1),[o,s]=(0,l.useState)(!1),c=e=>{a.current=e,s(e)},u=(0,l.useRef)(t);u.current=t,(0,l.useEffect)(()=>{t!==`listening`&&!i.current&&c(!1)},[t]);let d=t=>{if((t.pointerType!==`mouse`||t.button===0)&&!i.current){if(a.current&&u.current===`listening`){c(!1),e.pressEnd();return}c(!1),i.current={at:Date.now(),id:t.pointerId};try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}e.pressStart()}},f=t=>{let n=i.current;n&&n.id===t.pointerId&&(i.current=null,Date.now()-n.at>=450?e.pressEnd():c(!0))},m=t=>{let n=i.current;n&&n.id===t.pointerId&&(i.current=null,c(!1),e.blur?.())},h=t===`listening`;return(0,p.jsxs)(`div`,{className:`touch-controls`,"data-testid":`touch-controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`touch-side`,"aria-label":`Open the menu`,onClick:r,children:(0,p.jsx)(`svg`,{...mS,children:(0,p.jsx)(`path`,{d:`M4 7h16M4 12h16M4 17h16`})})}),(0,p.jsxs)(`div`,{className:`touch-talk`,children:[(0,p.jsx)(`button`,{type:`button`,className:`touch-mic${h?` on`:``}`,"aria-label":`Talk to Friend`,"aria-pressed":h,onPointerDown:d,onPointerUp:f,onPointerCancel:m,onContextMenu:e=>e.preventDefault(),children:(0,p.jsxs)(`svg`,{...mS,width:30,height:30,children:[(0,p.jsx)(`rect`,{x:`9`,y:`3`,width:`6`,height:`11`,rx:`3`}),(0,p.jsx)(`path`,{d:`M5 11a7 7 0 0 0 14 0M12 18v3`})]})}),(0,p.jsx)(`span`,{className:`touch-hint`,"aria-live":`polite`,children:hS(t,o)})]}),(0,p.jsx)(`button`,{type:`button`,className:`touch-side`,"aria-label":`Type a message`,onClick:n,children:(0,p.jsxs)(`svg`,{...mS,children:[(0,p.jsx)(`rect`,{x:`3`,y:`6`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M7 10h.01M11 10h.01M15 10h.01M7 14h10`})]})})]})}function _S(e,t){this.v=e,this.k=t}function vS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function yS(e){if(Array.isArray(e))return e}function bS(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function xS(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4388
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function SS(e,t){return yS(e)||bS(e,t)||CS(e,t)||xS()}function CS(e,t){if(e){if(typeof e==`string`)return vS(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?vS(e,t):void 0}}function wS(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof _S;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}wS.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},wS.prototype.next=function(e){return this._invoke(`next`,e)},wS.prototype.throw=function(e){return this._invoke(`throw`,e)},wS.prototype.return=function(e){return this._invoke(`return`,e)};var TS=Object.entries,ES=Object.setPrototypeOf,DS=Object.isFrozen,OS=Object.getPrototypeOf,kS=Object.getOwnPropertyDescriptor,AS=Object.freeze,jS=Object.seal,MS=Object.create,NS=typeof Reflect<`u`&&Reflect,PS=NS.apply,FS=NS.construct;AS||=function(e){return e},jS||=function(e){return e},PS||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},FS||=function(e){return new e(...[...arguments].slice(1))};var IS=nC(Array.prototype.forEach);Array.prototype.indexOf;var LS=nC(Array.prototype.lastIndexOf),RS=nC(Array.prototype.pop),zS=nC(Array.prototype.push);Array.prototype.slice;var BS=nC(Array.prototype.splice),VS=Array.isArray,HS=nC(String.prototype.toLowerCase),US=nC(String.prototype.toString),WS=nC(String.prototype.match),GS=nC(String.prototype.replace),KS=nC(String.prototype.indexOf),qS=nC(String.prototype.trim),JS=nC(Number.prototype.toString),YS=nC(Boolean.prototype.toString),XS=typeof BigInt>`u`?null:nC(BigInt.prototype.toString),ZS=typeof Symbol>`u`?null:nC(Symbol.prototype.toString),QS=nC(Object.prototype.hasOwnProperty),$S=nC(Object.prototype.toString),eC=nC(RegExp.prototype.test),tC=rC(TypeError);function nC(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return PS(e,t,n)}}function rC(e){return function(){return FS(e,[...arguments])}}function iC(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:HS;if(ES&&ES(e,null),!VS(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(DS(t)||(t[r]=e),i=e)}e[i]=!0}return e}function aC(e){for(let t=0;t<e.length;t++)QS(e,t)||(e[t]=null);return e}function oC(e){let t=MS(null);for(let r of TS(e)){var n=SS(r,2);let i=n[0],a=n[1];QS(e,i)&&(t[i]=VS(a)?aC(a):a&&typeof a==`object`&&a.constructor===Object?oC(a):a)}return t}function sC(e){switch(typeof e){case`string`:return e;case`number`:return JS(e);case`boolean`:return YS(e);case`bigint`:return XS?XS(e):`0`;case`symbol`:return ZS?ZS(e):`Symbol()`;case`undefined`:return $S(e);case`function`:case`object`:{if(e===null)return $S(e);let t=e,n=cC(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:$S(e)}return $S(e)}default:return $S(e)}}function cC(e,t){for(;e!==null;){let n=kS(e,t);if(n){if(n.get)return nC(n.get);if(typeof n.value==`function`)return nC(n.value)}e=OS(e)}function n(){return null}return n}function lC(e){try{return eC(e,``),!0}catch{return!1}}var uC=AS(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),dC=AS(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),fC=AS([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),pC=AS([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),mC=AS(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),hC=AS([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),gC=AS([`#text`]),_C=AS(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),vC=AS(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),yC=AS(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),bC=AS([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),xC=jS(/{{[\w\W]*|^[\w\W]*}}/g),SC=jS(/<%[\w\W]*|^[\w\W]*%>/g),CC=jS(/\${[\w\W]*/g),wC=jS(/^data-[\-\w.\u00B7-\uFFFF]+$/),TC=jS(/^aria-[\-\w]+$/),EC=jS(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),DC=jS(/^(?:\w+script|data):/i),OC=jS(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kC=jS(/^html$/i),AC=jS(/^[a-z][.\w]*(-[.\w]+)+$/i),jC=jS(/<[/\w!]/g),MC=jS(/<[/\w]/g),NC=jS(/<\/no(script|embed|frames)/i),PC=jS(/\/>/i),FC={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},IC=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],LC=AS(iC({},IC)),RC=function(){let e={};return IS(IC,t=>{e[t]=jS(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),AS(e)}(),zC=function(){return typeof window>`u`?null:window},BC=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},VC=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},HC=function(e,t,n,r){return QS(e,t)&&VS(e[t])?iC(r.base?oC(r.base):{},e[t],r.transform):n},UC=function(e,t,n){let r=QS(e,t)?e[t]:void 0;return r&&typeof r==`object`?oC(r):n()};function WC(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:zC(),t=e=>WC(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==FC.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=cC(d,`cloneNode`),p=cC(d,`remove`),m=cC(d,`removeAttributeNode`),h=cC(d,`nextSibling`),g=cC(d,`childNodes`),_=cC(d,`parentNode`),v=cC(d,`shadowRoot`),y=cC(d,`attributes`),b=o&&o.prototype?cC(o.prototype,`nodeType`):null,x=o&&o.prototype?cC(o.prototype,`nodeName`):null,S=o&&o.prototype?cC(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,O=!1,k=0,A=function(){if(k>0)throw tC(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},j=function(e){A(),k++;try{return T.createHTML(e)}finally{k--}},ee=function(e){A(),k++;try{return T.createScriptURL(e)}finally{k--}},M=function(){return O||=(D=BC(u,i),!0),D},N=n,P=N.implementation,F=N.createNodeIterator,te=N.createDocumentFragment,I=N.getElementsByTagName,ne=r.importNode,L=VC();t.isSupported=typeof TS==`function`&&typeof _==`function`&&P&&P.createHTMLDocument!==void 0;let re=xC,ie=SC,ae=CC,oe=wC,se=TC,ce=DC,le=OC,ue=AC,de=EC,R=null,z=iC({},[...uC,...dC,...fC,...mC,...gC]),B=null,fe=iC({},[..._C,...vC,...yC,...bC]),pe=Object.seal(MS(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),me=null,he=null,ge=Object.seal(MS(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),V=!0,_e=!0,ve=!1,ye=!0,H=!1,be=!0,U=!1,xe=!1,Se=null,Ce=null,we=!1,Te=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},Pe=null,Fe=iC({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ie=null,Le=iC({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Re=null,ze=iC({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Be=`http://www.w3.org/1998/Math/MathML`,Ve=`http://www.w3.org/2000/svg`,He=`http://www.w3.org/1999/xhtml`,Ue=He,We=!1,Ge=null,Ke=iC({},[Be,Ve,He],US),qe=AS([`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=iC({},qe),Ye=AS([`annotation-xml`]),Xe=iC({},Ye),Ze=iC({},[`title`,`style`,`font`,`a`,`script`]),Qe=null,$e=[`application/xhtml+xml`,`text/html`],et=null,tt=null,nt=n.createElement(`form`),rt=function(e){return e instanceof RegExp||e instanceof Function},it=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tt&&tt===e)return;(!e||typeof e!=`object`)&&(e={}),e=oC(e),Qe=$e.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,et=Qe===`application/xhtml+xml`?US:HS,R=HC(e,`ALLOWED_TAGS`,z,{transform:et}),B=HC(e,`ALLOWED_ATTR`,fe,{transform:et}),Ge=HC(e,`ALLOWED_NAMESPACES`,Ke,{transform:US}),Re=HC(e,`ADD_URI_SAFE_ATTR`,ze,{transform:et,base:ze}),Ie=HC(e,`ADD_DATA_URI_TAGS`,Le,{transform:et,base:Le}),Pe=HC(e,`FORBID_CONTENTS`,Fe,{transform:et}),me=HC(e,`FORBID_TAGS`,oC({}),{transform:et}),he=HC(e,`FORBID_ATTR`,oC({}),{transform:et}),Ne=QS(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?oC(e.USE_PROFILES):e.USE_PROFILES:!1,V=e.ALLOW_ARIA_ATTR!==!1,_e=e.ALLOW_DATA_ATTR!==!1,ve=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ye=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=e.SAFE_FOR_TEMPLATES||!1,be=e.SAFE_FOR_XML!==!1,U=e.WHOLE_DOCUMENT||!1,Te=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,de=lC(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:EC,Ue=typeof e.NAMESPACE==`string`?e.NAMESPACE:He,Je=UC(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>iC({},qe)),Xe=UC(e,`HTML_INTEGRATION_POINTS`,()=>iC({},Ye));let t=UC(e,`CUSTOM_ELEMENT_HANDLING`,()=>MS(null));if(pe=MS(null),QS(t,`tagNameCheck`)&&rt(t.tagNameCheck)&&(pe.tagNameCheck=t.tagNameCheck),QS(t,`attributeNameCheck`)&&rt(t.attributeNameCheck)&&(pe.attributeNameCheck=t.attributeNameCheck),QS(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(pe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),jS(pe),H&&(_e=!1),Ee&&(Te=!0),Ne&&(R=iC({},gC),B=MS(null),Ne.html===!0&&(iC(R,uC),iC(B,_C)),Ne.svg===!0&&(iC(R,dC),iC(B,vC),iC(B,bC)),Ne.svgFilters===!0&&(iC(R,fC),iC(B,vC),iC(B,bC)),Ne.mathMl===!0&&(iC(R,mC),iC(B,yC),iC(B,bC))),ge.tagCheck=null,ge.attributeCheck=null,QS(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?ge.tagCheck=e.ADD_TAGS:VS(e.ADD_TAGS)&&(R===z&&(R=oC(R)),iC(R,e.ADD_TAGS,et))),QS(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?ge.attributeCheck=e.ADD_ATTR:VS(e.ADD_ATTR)&&(B===fe&&(B=oC(B)),iC(B,e.ADD_ATTR,et))),QS(e,`ADD_FORBID_CONTENTS`)&&VS(e.ADD_FORBID_CONTENTS)&&(Pe===Fe&&(Pe=oC(Pe)),iC(Pe,e.ADD_FORBID_CONTENTS,et)),je&&(R[`#text`]=!0),U&&iC(R,[`html`,`head`,`body`]),R.table&&(iC(R,[`tbody`]),delete me.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw tC(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw tC(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=j(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=M()),T&&typeof E==`string`&&(E=j(``)));AS&&AS(e),tt=e},at=iC({},[...dC,...fC,...pC]),ot=iC({},[...mC,...hC]),st=function(e,t,n){return t.namespaceURI===He?e===`svg`:t.namespaceURI===Be?e===`svg`&&(n===`annotation-xml`||Je[n]):!!at[e]},ct=function(e,t,n){return t.namespaceURI===He?e===`math`:t.namespaceURI===Ve?e===`math`&&Xe[n]:!!ot[e]},lt=function(e,t,n){return t.namespaceURI===Ve&&!Xe[n]||t.namespaceURI===Be&&!Je[n]?!1:!ot[e]&&(Ze[e]||!at[e])},ut=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=HS(e.tagName),r=HS(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===Ve?st(n,t,r):e.namespaceURI===Be?ct(n,t,r):e.namespaceURI===He?lt(n,t,r):!!(Qe===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},dt=function(e){zS(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw tC(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ft=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},pt=function(e){gt(e);let t=g(e);if(t){let e=[];IS(t,t=>{zS(e,t)}),IS(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&ft(e,r,i)}},mt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}zS(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Te||Ee)try{dt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},ht=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||B[et(i)]||ft(e,r,i)}},gt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===FC.element&&ht(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},_t=function(e,t){return be?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},vt=function(e){if(!be)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===FC.processingInstruction||n===FC.comment&&eC(MC,e.data)){try{p(e)}catch{}continue}if(n===FC.element){let t=e,n=et(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&_t(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},yt=function(e){let t=null,r=null;if(we)e=`<remove></remove>`+e;else{let t=WS(e,/^[\r\n\t ]+/);r=t&&t[0]}Qe===`application/xhtml+xml`&&Ue===He&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?j(e):e;if(Ue===He)try{t=new l().parseFromString(i,Qe)}catch{}if(!t||!t.documentElement){t=P.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===He?I.call(t,U?`html`:`body`)[0]:U?t.documentElement:a},bt=function(e){let t=S?S(e):e.ownerDocument;return F.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},xt=function(e){return e=GS(e,re,` `),e=GS(e,ie,` `),e=GS(e,ae,` `),e},St=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=F.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=xt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&IS(i,e=>{wt(e.content)&&St(e.content)})},Ct=function(e){let t=x?x(e):null;return typeof t!=`string`||et(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},wt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===FC.documentFragment}catch{return!1}},Tt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Et(e,n,r){e.length!==0&&IS(e,e=>{e.call(t,n,r,tt)})}let Dt=function(e,t){return!!(be&&e.hasChildNodes()&&!Tt(e.firstElementChild)&&eC(jC,e.textContent)&&eC(jC,e.innerHTML)||be&&e.namespaceURI===He&&LC[t]&&(Tt(e.firstElementChild)||typeof e.textContent==`string`&&eC(RC[t],e.textContent))||e.nodeType===FC.processingInstruction||be&&e.nodeType===FC.comment&&eC(MC,e.data))},Ot=function(e,t){return e instanceof RegExp?eC(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},kt=function(e,t,n){if(!me[t]&&Ft(t)&&Ot(pe.tagNameCheck,t))return!1;if(je&&!Pe[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return dt(e),!0},At=function(e,t,n,r){return e.length===0?t:t===n||t===r?oC(t):t},jt=function(e,t){return e===t||_(e)!==null?!1:(Me&>(e),!0)},Mt=function(e,n){if(Et(L.beforeSanitizeElements,e,null),jt(e,n))return!0;if(Ct(e))return dt(e),!0;let r=et(w(e));if(R=At(L.uponSanitizeElement,R,z,Se),Et(L.uponSanitizeElement,e,{tagName:r,allowedTags:R}),jt(e,n))return!0;if(Dt(e,r))return dt(e),!0;if(me[r]||!(ge.tagCheck instanceof Function&&ge.tagCheck(r))&&!R[r]){let t=kt(e,r,n);return t===!1&&(Et(L.afterSanitizeElements,e,null),jt(e,n))?!0:t}if(C(e)===FC.element&&!ut(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&eC(NC,e.innerHTML))return dt(e),!0;if(H&&e.nodeType===FC.text){let n=xt(e.textContent);e.textContent!==n&&(zS(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Et(L.afterSanitizeElements,e,null),jt(e,n)},Nt=function(e,t,r){if(he[t]||_t(t,e)||Oe&&(t===`id`||t===`name`)&&(r in n||r in nt))return!1;let i=B[t]||ge.attributeCheck instanceof Function&&ge.attributeCheck(t,e);return _e&&eC(oe,t)||V&&eC(se,t)?!0:i?Re[t]||eC(de,GS(r,le,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&KS(r,`data:`)===0&&Ie[e]||ve&&!eC(ce,GS(r,le,``))?!0:!r:Ft(e)&&Ot(pe.tagNameCheck,e)&&Ot(pe.attributeNameCheck,t,e)||t===`is`&&pe.allowCustomizedBuiltInElements&&Ot(pe.tagNameCheck,r)},Pt=iC({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ft=function(e){return!Pt[HS(e)]&&eC(ue,e)},It=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return j(r);case`TrustedScriptURL`:return ee(r)}return r},Lt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Ct(e)||(dt(e),!1)}catch{return mt(t,e),!1}},Rt=function(e,n){if(Et(L.beforeSanitizeAttributes,e,null),jt(e,n))return;let r=e.attributes;if(!r||Ct(e))return;B=At(L.uponSanitizeAttribute,B,fe,Ce);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0},a=r.length,o=et(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=et(s),d=l,f=s===`value`?d:qS(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Et(L.uponSanitizeAttribute,e,i),f=i.attrValue,ke&&(u===`id`||u===`name`)&&KS(f,Ae)!==0&&(mt(s,e,n),f=Ae+f,p=!0),be&&eC(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){mt(s,e,n);continue}if(u===`attributename`&&WS(f,`href`)){mt(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){mt(s,e,n);continue}if(!ye&&eC(PC,f)){mt(s,e,n);continue}if(H&&(f=xt(f)),!Nt(o,u,f)){mt(s,e,n);continue}f=It(o,u,c,f),f!==d&&Lt(e,s,c,f)&&p&&RS(t.removed)}}Et(L.afterSanitizeAttributes,e,null),jt(e,n)},zt=function(e){let t=null,n=bt(e);for(Et(L.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Et(L.uponSanitizeShadowNode,t,null),Mt(t,e),Rt(t,e),wt(t.content)&&zt(t.content),C(t)===FC.element){let e=v(t);wt(e)&&(Bt(e),zt(e))}Et(L.afterSanitizeShadowDOM,e,null)},Bt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){zt(e.shadow);continue}let n=e.node,r=C(n)===FC.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&et(e)===`template`){let e=n.content;wt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);wt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!Tt(e)&&(e=sC(e),typeof e!=`string`))throw tC(`dirty is not a string, aborting`);if(!t.isSupported)return e;xe?(R=Se,B=Ce):it(n),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(R=oC(R)),L.uponSanitizeAttribute.length>0&&(B=oC(B)),t.removed=[];let c=Me&&typeof e!=`string`&&Tt(e);if(c){vt(e);let t=w(e);if(typeof t==`string`){let n=et(t);if(!R[n]||me[n])throw pt(e),tC(`root node is forbidden and cannot be sanitized in-place`)}if(Ct(e))throw pt(e),tC(`root node is clobbered and cannot be sanitized in-place`);try{Bt(e)}catch(t){throw pt(e),t}}else if(Tt(e))i=yt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===FC.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Bt(i);else{if(!Te&&!H&&!U&&e.indexOf(`<`)===-1)return T&&De?j(e):e;if(i=yt(e),!i)return Te?null:De?E:``}i&&we&&dt(i.firstChild);let l=c?e:i;try{let e=bt(l);for(;o=e.nextNode();)Mt(o,l),Rt(o,l),wt(o.content)&&zt(o.content)}catch(n){throw c&&(pt(e),IS(t.removed,e=>{e.element&>(e.element)})),n}if(c){let n=!1;if(IS(t.removed,t=>{t.element&&(t.element===e&&(n=!0),gt(t.element))}),n)throw tC(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return H&&St(e),e}if(Te){if(H&&St(i),Ee)for(s=te.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(B.shadowroot||B.shadowrootmode)&&(s=ne.call(r,s,!0)),s}let u=U?i.outerHTML:i.innerHTML;return U&&R[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&eC(kC,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
4389
|
+
`+u),H&&(u=xt(u)),T&&De?j(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};it(e),xe=!0,Se=R,Ce=B},t.clearConfig=function(){tt=null,xe=!1,Se=null,Ce=null,T=D,E=``},t.isValidAttribute=function(e,t,n){tt||it({});let r=et(e),i=et(t);return Nt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&QS(L,e)&&zS(L[e],t)},t.removeHook=function(e,t){if(QS(L,e)){if(t!==void 0){let n=LS(L[e],t);return n===-1?void 0:BS(L[e],n,1)[0]}return RS(L[e])}},t.removeHooks=function(e){QS(L,e)&&(L[e]=[])},t.removeAllHooks=function(){L=VC()},t}var GC=WC();function KC(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var qC=KC();function JC(e){qC=e}var YC={exec:()=>null};function XC(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function ZC(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace($C.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var QC=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),$C={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:XC(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:XC(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:XC(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:XC(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:XC(e=>RegExp(`^ {0,${e}}(?:</?(?:${mw})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:XC(e=>RegExp(`^ {0,${e}}>`))},ew=/^(?:[ \t]*(?:\n|$))+/,tw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,nw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,rw=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,iw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,aw=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ow=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,sw=ZC(ow).replace(/bull/g,aw).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),cw=ZC(ow).replace(/bull/g,aw).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),lw=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,uw=/^[^\n]+/,dw=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,fw=ZC(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,dw).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),pw=ZC(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,aw).getRegex(),mw=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,hw=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,gw=ZC(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,hw).replace(`tag`,mw).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_w=e=>ZC(lw).replace(`hr`,rw).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,mw).getRegex(),vw=_w(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),yw=_w(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),bw={blockquote:ZC(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,yw).getRegex(),code:tw,def:fw,fences:nw,heading:iw,hr:rw,html:gw,lheading:sw,list:pw,newline:ew,paragraph:vw,table:YC,text:uw},xw=ZC(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,rw).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,mw).getRegex(),Sw={...bw,lheading:cw,table:xw,paragraph:ZC(lw).replace(`hr`,rw).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,xw).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,mw).getRegex()},Cw={...bw,html:ZC(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,hw).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:YC,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ZC(lw).replace(`hr`,rw).replace(`heading`,` *#{1,6} *[^
|
|
4390
|
+
]`).replace(`lheading`,sw).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},ww=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tw=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ew=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Dw=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ow=/[\p{P}\p{S}]/u,kw=/[\s\p{P}\p{S}]/u,Aw=/[^\s\p{P}\p{S}]/u,jw=ZC(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,kw).getRegex(),Mw=/[\p{Pi}\p{Ps}"']/u,Nw=/(?!~)[\p{P}\p{S}]/u,Pw=/(?!~)[\s\p{P}\p{S}]/u,Fw=/(?:[^\s\p{P}\p{S}]|~)/u,Iw=ZC(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,QC?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Lw=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Rw=ZC(Lw,`u`).replace(/punct/g,Ow).getRegex(),zw=ZC(Lw,`u`).replace(/punct/g,Nw).getRegex(),Bw=ZC(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Mw).replace(/punct/g,Ow).getRegex(),Vw=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Hw=ZC(Vw,`gu`).replace(/notPunctSpace/g,Aw).replace(/punctSpace/g,kw).replace(/punct/g,Ow).getRegex(),Uw=ZC(Vw,`gu`).replace(/notPunctSpace/g,Fw).replace(/punctSpace/g,Pw).replace(/punct/g,Nw).getRegex(),Ww=ZC(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Aw).replace(/punctSpace/g,kw).replace(/punct/g,Ow).getRegex(),Gw=ZC(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Aw).replace(/punctSpace/g,kw).replace(/punct/g,Ow).getRegex(),Kw=ZC(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Aw).replace(/punctSpace/g,kw).replace(/punct/g,Ow).getRegex(),qw=ZC(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Ow).getRegex(),Jw=ZC(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Aw).replace(/punctSpace/g,kw).replace(/punct/g,Ow).getRegex(),Yw=ZC(/\\(punct)/,`gu`).replace(/punct/g,Ow).getRegex(),Xw=ZC(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Zw=ZC(hw).replace(`(?:-->|$)`,`-->`).getRegex(),Qw=ZC(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Zw).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),$w=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,eT=ZC(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,$w).getRegex(),tT=ZC(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,eT).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),nT=ZC(/^!?\[(label)\]\[(ref)\]/).replace(`label`,eT).replace(`ref`,dw).getRegex(),rT=ZC(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,dw).getRegex(),iT=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,aT=ZC(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,$w).getRegex(),oT=ZC(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,ZC(/^!?\[(label)\]\[(ref)\]/).replace(`label`,aT).replace(`ref`,iT).getRegex()).replace(`nolink`,ZC(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,iT).getRegex()).getRegex(),sT=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,cT=ZC(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),lT={_backpedal:YC,anyPunctuation:Yw,autolink:Xw,blockSkip:Iw,br:Ew,code:Tw,del:YC,delLDelim:YC,delRDelim:YC,emStrongLDelim:Rw,emStrongRDelimAst:Hw,emStrongRDelimUnd:Gw,escape:ww,link:tT,nolink:rT,punctuation:jw,reflink:nT,reflinkSearch:oT,tag:Qw,text:Dw,url:YC},uT={...lT,emStrongLDelim:Bw,emStrongRDelimAst:Ww,emStrongRDelimUnd:Kw,link:ZC(/^!?\[(label)\]\((.*?)\)/).replace(`label`,eT).getRegex(),reflink:ZC(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,eT).getRegex()},dT={...lT,emStrongRDelimAst:Uw,emStrongLDelim:zw,delLDelim:qw,delRDelim:Jw,url:ZC(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,cT).replace(`protocol`,sT).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ZC(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,sT).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},fT={...dT,br:ZC(Ew).replace(`{2,}`,`*`).getRegex(),text:ZC(dT.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},pT={normal:bw,gfm:Sw,pedantic:Cw},mT={normal:lT,gfm:dT,breaks:fT,pedantic:uT},hT={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},gT=e=>hT[e];function _T(e,t){if(t){if($C.escapeTest.test(e))return e.replace($C.escapeReplace,gT)}else if($C.escapeTestNoEncode.test(e))return e.replace($C.escapeReplaceNoEncode,gT);return e}function vT(e){return e.replace($C.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function yT(e){try{e=encodeURI(e).replace($C.percentDecode,`%`)}catch{return null}return e}function bT(e,t){let n=e.replace($C.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split($C.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace($C.slashPipe,`|`);return n}function xT(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function ST(e){let t=e.split(`
|
|
4391
|
+
`),n=t.length-1;for(;n>=0&&$C.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
4392
|
+
`)}function CT(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function wT(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function TT(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function ET(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function DT(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
4393
4393
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
4394
|
-
`)}function
|
|
4395
|
-
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:
|
|
4396
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
4394
|
+
`)}function OT(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var kT=class{options;rules;lexer;constructor(e){this.options=e||qC}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:ST(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=DT(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=xT(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:xT(t[0],`
|
|
4395
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:xT(t[0],`
|
|
4396
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=xT(t[0],`
|
|
4397
4397
|
`).split(`
|
|
4398
4398
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
4399
4399
|
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -4408,19 +4408,19 @@ ${d.join(`
|
|
|
4408
4408
|
`+e.join(`
|
|
4409
4409
|
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
4410
4410
|
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
|
|
4411
|
-
`,1)[0],l=t[1].length,u=this.options.pedantic?
|
|
4411
|
+
`,1)[0],l=t[1].length,u=this.options.pedantic?TT(c,l):c.replace(this.rules.other.leadingSpaceTab,e=>TT(e,l)),d=e.split(`
|
|
4412
4412
|
`,1)[0],f=!u.trim(),p=0;if(this.options.pedantic?(p=2,s=u.trimStart()):f?p=l+1:(p=u.search(this.rules.other.nonSpaceChar),p=p>4?1:p,s=u.slice(p),p+=l),f&&this.rules.other.blankLine.test(d)&&(r+=d+`
|
|
4413
4413
|
`,e=e.substring(d.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),i=this.rules.other.fencesBeginRegex(p),a=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),c=this.rules.other.blockquoteBeginRegex(p);for(;e;){let l=e.split(`
|
|
4414
4414
|
`,1)[0],m;if(d=l,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting,` `),m=d):m=d.replace(this.rules.other.leadingSpaceTab,e=>e.replace(this.rules.other.tabCharGlobal,` `)),i.test(d)||a.test(d)||o.test(d)||c.test(d)||t.test(d)||n.test(d))break;if(m.search(this.rules.other.nonSpaceChar)>=p||!d.trim())s+=`
|
|
4415
4415
|
`+m.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(u)||a.test(u)||n.test(u))break;s+=`
|
|
4416
4416
|
`+d}f=!d.trim(),r+=l+`
|
|
4417
|
-
`,e=e.substring(l.length+1),u=m.slice(p)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=
|
|
4418
|
-
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=
|
|
4419
|
-
`):[],a={type:`table`,raw:
|
|
4420
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
4417
|
+
`,e=e.substring(l.length+1),u=m.slice(p)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=ST(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&wT(t[2],`()`)!==-1)return;let e=CT(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:xT(t[0],`
|
|
4418
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=bT(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
4419
|
+
`):[],a={type:`table`,raw:xT(t[0],`
|
|
4420
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(bT(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:xT(t[0],`
|
|
4421
4421
|
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
4422
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&
|
|
4423
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(
|
|
4422
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&OT(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=xT(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=wT(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),ET(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&OT(e,n[1],r,this.rules))return;let i=t[CT((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return ET(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:vT(t[0]),escaped:e}}}},AT=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||qC,this.options.tokenizer=this.options.tokenizer||new kT,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:$C,block:pT.normal,inline:mT.normal};this.options.pedantic?(t.block=pT.pedantic,t.inline=mT.pedantic):this.options.gfm&&(t.block=pT.gfm,t.inline=this.options.breaks?mT.breaks:mT.gfm),this.tokenizer.rules=t}static get rules(){return{block:pT,inline:mT}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace($C.carriageReturn,`
|
|
4423
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace($C.tabCharGlobal,` `).replace($C.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
4424
4424
|
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
4425
4425
|
`)?``:`
|
|
4426
4426
|
`)+i.raw,n.text+=`
|
|
@@ -4433,9 +4433,9 @@ ${d.join(`
|
|
|
4433
4433
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
4434
4434
|
`)?``:`
|
|
4435
4435
|
`)+i.raw,n.text+=`
|
|
4436
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,
|
|
4437
|
-
`:``;return r?`<pre><code class="language-`+
|
|
4438
|
-
`:`<pre><code>`+(n?i:
|
|
4436
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,CT(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,CT(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},jT=class{options;parser;constructor(e){this.options=e||qC}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match($C.notSpaceStart)?.[0],i=e?e.replace($C.endingNewline,``)+`
|
|
4437
|
+
`:``;return r?`<pre><code class="language-`+_T(r)+`">`+(n?i:_T(i,!0))+`</code></pre>
|
|
4438
|
+
`:`<pre><code>`+(n?i:_T(i,!0))+`</code></pre>
|
|
4439
4439
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
4440
4440
|
${this.parser.parse(e)}</blockquote>
|
|
4441
4441
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -4451,6 +4451,6 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
4451
4451
|
`}tablerow({text:e}){return`<tr>
|
|
4452
4452
|
${e}</tr>
|
|
4453
4453
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
4454
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${
|
|
4455
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+fT(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function jT(e,t){return AT.parse(e,t)}jT.options=jT.setOptions=function(e){return AT.setOptions(e),jT.defaults=AT.defaults,UC(jT.defaults),jT},jT.getDefaults=VC,jT.defaults=HC;function MT(...e){return AT.use(...e),jT.defaults=AT.defaults,UC(jT.defaults),jT}jT.use=MT,jT.walkTokens=function(e,t){return AT.walkTokens(e,t)},jT.parseInline=AT.parseInline,jT.Parser=OT,jT.parser=OT.parse,jT.Renderer=ET,jT.TextRenderer=DT,jT.Lexer=TT,jT.lexer=TT.lex,jT.Tokenizer=wT,jT.Hooks=kT,jT.parse=jT,jT.options,jT.setOptions,jT.walkTokens,jT.parseInline,OT.parse,TT.lex;var NT=!1;function PT(){NT||(NT=!0,BC.addHook(`afterSanitizeAttributes`,e=>{e instanceof Element&&e.tagName===`A`&&(e.setAttribute(`rel`,`noopener noreferrer`),e.setAttribute(`target`,`_blank`))}))}function FT(e){PT();let t=jT.parse(e,{async:!1,breaks:!0});return BC.sanitize(t,{ALLOWED_TAGS:[`p`,`br`,`strong`,`em`,`code`,`pre`,`ul`,`ol`,`li`,`a`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`blockquote`,`hr`,`del`,`table`,`thead`,`tbody`,`tr`,`th`,`td`],ALLOWED_ATTR:[`href`,`rel`,`target`],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:)/i})}var IT=e=>Number.isFinite(e);function LT(e){let t=Math.floor(Math.log10(e)),n=e/10**t;return(n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10)*10**t}function RT(e,t,n=5){let r=IT(e)?e:0,i=IT(t)?t:r+1;r>i&&([r,i]=[i,r]),r===i&&(i=r+(Math.abs(r)||1));let a=LT((i-r)/Math.max(1,n-1)),o=Math.floor(r/a)*a,s=Math.ceil(i/a)*a,c=[];for(let e=o;e<=s+a/2;e+=a)c.push(Math.round(e*1e9)/1e9);return{min:o,max:s,ticks:c}}function zT(e,t){let[n,r]=e,[i,a]=t;return r===n?()=>i:e=>i+(e-n)/(r-n)*(a-i)}function BT(e){return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e.toFixed(2)} ${t.toFixed(2)}`).join(` `)}function VT(e,t,n,r,i){let a=r=>{let i=r*Math.PI/180;return`${(e+n*Math.cos(i)).toFixed(2)} ${(t+n*Math.sin(i)).toFixed(2)}`},o=+(Math.abs(i-r)>180);return`M ${a(r)} A ${n} ${n} 0 ${o} 1 ${a(i)}`}function HT(e,t,n){return!IT(e)||!IT(t)||!IT(n)||n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))*240}function UT(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a);if(o===0||o<=n+r)return{from:{...e},to:{...t}};let s=i/o,c=a/o;return{from:{x:e.x+s*n,y:e.y+c*n},to:{x:t.x-s*r,y:t.y-c*r}}}function WT(e,t,n){if(e<=0)return[];if(e===1)return[{x:t/2,y:n/2}];let r=Math.min(t,n)*.36;return Array.from({length:e},(i,a)=>{let o=-Math.PI/2+a*2*Math.PI/e;return{x:t/2+r*Math.cos(o),y:n/2+r*Math.sin(o)}})}var GT=e=>typeof e==`object`&&!!e&&!Array.isArray(e),KT=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,qT=e=>Array.isArray(e)?e:[],JT=e=>typeof e==`number`?Number.isFinite(e)?e:null:typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):null,YT=(e,t)=>e.length>t?e.slice(0,t)+`…`:e,XT=[`var(--accent)`,`#ffb454`,`#7b8cff`,`#5ef0b0`,`#ff6b7a`,`#c792ea`],ZT=({text:e})=>e?(0,p.jsx)(`h3`,{className:`obj-title`,children:e}):null,QT=({text:e=`No data`})=>(0,p.jsx)(`p`,{className:`obj-empty`,children:e}),$T=400,eE=220,tE={l:44,r:12,t:10,b:28};function nE({props:e}){let t=e.kind===`bar`||e.kind===`area`?e.kind:`line`,n=qT(e.labels).slice(0,120).map(KT),r=qT(e.series).slice(0,6).map((e,t)=>{let n=GT(e)?e:{},r=qT(n.values).slice(0,120).map((e,t)=>({idx:t,v:JT(e)})).filter(e=>e.v!==null);return{name:KT(n.name)||`series ${t+1}`,points:r}}).filter(e=>e.points.length>0);if(r.length===0)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsx)(QT,{})]});let i=r.flatMap(e=>e.points.map(e=>e.v)),a=Math.min(...i),o=Math.max(...i),s=RT(t===`line`?a:Math.min(0,a),t===`line`?o:Math.max(0,o),5),c=Math.max(n.length,...r.map(e=>e.points[e.points.length-1].idx+1),2),l=zT([s.min,s.max],[eE-tE.b,tE.t]),u=zT([0,c-1],[tE.l,$T-tE.r]),d=($T-tE.l-tE.r)/c,f=Math.max(1,d*.7/r.length),m=(e,t)=>tE.l+e*d+d*.15+t*f,h=Math.max(1,Math.ceil(c/6)),g=KT(e.unit);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsxs)(`svg`,{className:`obj-chart`,viewBox:`0 0 ${$T} ${eE}`,role:`img`,"aria-label":KT(e.title)||`chart`,children:[s.ticks.map(e=>(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`line`,{className:`grid`,x1:tE.l,x2:$T-tE.r,y1:l(e),y2:l(e)}),(0,p.jsxs)(`text`,{className:`tick`,x:tE.l-6,y:l(e)+3,textAnchor:`end`,children:[e,g&&e===s.max?g:``]})]},e)),Array.from({length:c},(e,t)=>t).filter(e=>e%h===0&&n[e]).map(e=>(0,p.jsx)(`text`,{className:`tick`,x:t===`bar`?m(e,0)+f*r.length/2:u(e),y:212,textAnchor:`middle`,children:YT(n[e],8)},e)),r.map((e,n)=>{let r=XT[n%XT.length];if(t===`bar`)return(0,p.jsx)(`g`,{children:e.points.map(e=>(0,p.jsx)(`rect`,{className:`bar`,x:m(e.idx,n),y:Math.min(l(e.v),l(0)),width:f,height:Math.abs(l(e.v)-l(0)),fill:r},e.idx))},n);let i=e.points.map(e=>[u(e.idx),l(e.v)]),a=BT(i),o=`${a} L${i[i.length-1][0].toFixed(2)} ${l(s.min).toFixed(2)} L${i[0][0].toFixed(2)} ${l(s.min).toFixed(2)} Z`;return(0,p.jsxs)(`g`,{children:[t===`area`&&(0,p.jsx)(`path`,{className:`series-area`,d:o,fill:r,opacity:.18}),(0,p.jsx)(`path`,{className:`series-line`,d:a,fill:`none`,stroke:r,strokeWidth:2,strokeLinejoin:`round`})]},n)})]}),r.length>1&&(0,p.jsx)(`ul`,{className:`legend`,children:r.map((e,t)=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`i`,{style:{background:XT[t%XT.length]}}),(0,p.jsx)(`span`,{children:e.name})]},t))})]})}function rE({props:e}){let t=JT(e.min)??0,n=JT(e.max)??100,r=JT(e.value)??t,i=HT(r,t,n),a=i/240;return(0,p.jsxs)(`div`,{className:`obj-gauge ${a>.95?`gauge-crit`:a>.8?`gauge-warn`:``}`,children:[(0,p.jsxs)(`svg`,{viewBox:`0 0 200 150`,role:`img`,"aria-label":`${KT(e.label)} ${r}`,children:[(0,p.jsx)(`path`,{className:`track`,d:VT(100,100,70,150,390),fill:`none`,strokeWidth:12,strokeLinecap:`round`}),i>0&&(0,p.jsx)(`path`,{className:`value`,d:VT(100,100,70,150,150+i),fill:`none`,strokeWidth:12,strokeLinecap:`round`})]}),(0,p.jsxs)(`div`,{className:`gauge-read`,children:[(0,p.jsx)(`span`,{className:`gauge-value`,children:String(Math.round(r*100)/100)}),KT(e.unit)&&(0,p.jsx)(`small`,{className:`gauge-unit`,children:KT(e.unit)})]}),(0,p.jsx)(`span`,{className:`obj-label`,children:KT(e.label)})]})}function iE({props:e}){let t=qT(e.items).slice(0,30).map(e=>GT(e)?e:{}).map(e=>({time:KT(e.time),title:KT(e.title),detail:KT(e.detail)})).filter(e=>e.title||e.time);return t.length===0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsx)(QT,{text:`Nothing to show`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsx)(`ol`,{className:`obj-timeline`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`time`,{children:e.time}),(0,p.jsx)(`strong`,{children:e.title}),e.detail&&(0,p.jsx)(`span`,{children:e.detail})]},t))})]})}var aE=400,oE=300,sE=12;function cE({props:e}){let t=(0,l.useId)(),n=new Set,r=[];for(let t of qT(e.nodes)){let e=GT(t)?t:{},i=KT(e.id);if(i&&!n.has(i)&&(n.add(i),r.push({id:i,label:KT(e.label)||i}),r.length>=40))break}if(r.length===0)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsx)(QT,{text:`Nothing to show`})]});let i=new Map(r.map((e,t)=>[e.id,WT(r.length,aE,oE)[t]])),a=[];for(let t of qT(e.edges)){let e=GT(t)?t:{},n=KT(e.from),r=KT(e.to);if(i.has(n)&&i.has(r)&&n!==r&&(a.push({from:n,to:r,label:KT(e.label)}),a.length>=80))break}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ZT,{text:KT(e.title)}),(0,p.jsxs)(`svg`,{className:`obj-graph`,viewBox:`0 0 ${aE} ${oE}`,role:`img`,"aria-label":KT(e.title)||`graph`,children:[(0,p.jsx)(`defs`,{children:(0,p.jsx)(`marker`,{id:t,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,p.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,className:`arrow`})})}),a.map((e,n)=>{let{from:r,to:a}=UT(i.get(e.from),i.get(e.to),14,17),o=(r.x+a.x)/2+(aE/2-(r.x+a.x)/2)*.25,s=(r.y+a.y)/2+(oE/2-(r.y+a.y)/2)*.25;return(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`path`,{className:`edge`,d:`M ${r.x.toFixed(1)} ${r.y.toFixed(1)} Q ${o.toFixed(1)} ${s.toFixed(1)} ${a.x.toFixed(1)} ${a.y.toFixed(1)}`,fill:`none`,markerEnd:`url(#${t})`}),e.label&&(0,p.jsx)(`text`,{className:`edge-label`,x:o,y:s,textAnchor:`middle`,children:YT(e.label,12)})]},n)}),r.map(e=>{let t=i.get(e.id);return(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`circle`,{className:`node`,cx:t.x,cy:t.y,r:sE}),(0,p.jsx)(`text`,{className:`node-label`,x:t.x,y:t.y+26,textAnchor:`middle`,children:YT(e.label,18)})]},e.id)})]})]})}var lE=30,uE=e=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):1,dE=new class{current=1;goal=1;from=1;steps=1;n=0;timer=null;subs=new Set;get level(){return this.current}set(e,t=250){if(this.goal=uE(e),t<=0||this.goal===this.current){this.stop(),this.move(this.goal);return}this.from=this.current,this.steps=Math.max(1,Math.ceil(t/lE)),this.n=0,this.timer??=setInterval(()=>this.tick(),lE)}subscribe(e){return this.subs.add(e),()=>void this.subs.delete(e)}tick(){this.n++,this.n>=this.steps?(this.stop(),this.move(this.goal)):this.move(this.from+(this.goal-this.from)*this.n/this.steps)}stop(){this.timer&&clearInterval(this.timer),this.timer=null}move(e){if(e!==this.current){this.current=e;for(let t of[...this.subs])t(e)}}};function fE(e,t=dE){let n=e.volume,r=e.volume,i=!0,a=t=>{i&&(r=uE(n*t),e.volume=r)},o=()=>{if(!i||Math.abs(e.volume-r)<=.002)return;let a=t.level;a>.001&&(n=uE(e.volume/a)),r=e.volume};e.addEventListener(`volumechange`,o);let s=t.subscribe(a);return a(t.level),()=>{i=!1,s(),e.removeEventListener(`volumechange`,o),e.volume=n}}var pE=`https://www.youtube-nocookie.com`;function mE(e,t=dE,n=window){let r=100,i=null,a=!1,o=!0,s=!1,c=t=>e.contentWindow?.postMessage(JSON.stringify(t),pE),l=()=>c({event:`listening`,id:1,channel:`widget`}),u=e=>{i=e,c({event:`command`,func:`setVolume`,args:[e]})},d=e=>{o&&(e<.999?(a=!0,u(Math.round(r*e))):a&&(a=!1,u(Math.round(r))))},f=n=>{if(!o||n.source!==e.contentWindow)return;let c;try{c=JSON.parse(String(n.data)).info}catch{return}if(typeof c?.volume!=`number`)return;s=!0;let l=c.volume;if(i!==null&&Math.abs(l-i)<=1)return;let u=t.level;r=a&&u>.001?l/u:l,i=l};n.addEventListener(`message`,f),e.addEventListener?.(`load`,l),l();let p=setInterval(()=>s?clearInterval(p):l(),1e3),m=t.subscribe(d);return d(t.level),()=>{o=!1,clearInterval(p),m(),n.removeEventListener(`message`,f),e.removeEventListener?.(`load`,l),a&&hE(e,r)}}function hE(e,t){try{e.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`setVolume`,args:[Math.round(t)]}),pE)}catch{}}var gE=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,_E=e=>Array.isArray(e)?e:[],vE=e=>typeof e==`object`&&e?e:{},yE=/^\/api\/media\/[0-9a-f]{32}$/,bE=e=>typeof e==`string`&&yE.test(e)?e:null,xE=/^\/api\/video\/[0-9a-f]{32}$/,SE=e=>typeof e==`string`&&xE.test(e)?e:null,CE=({props:e})=>gE(e.title)?(0,p.jsx)(`h3`,{className:`obj-title`,children:gE(e.title)}):null;function wE({props:e}){let t=(0,l.useMemo)(()=>FT(gE(e.text)),[e.text]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(CE,{props:e}),(0,p.jsx)(`div`,{className:`obj-md obj-doc`,dangerouslySetInnerHTML:{__html:t}})]})}function TE({props:e}){let t=Math.min(100,Math.max(0,Number(e.value)||0));return(0,p.jsxs)(`div`,{className:`obj-progress`,children:[(0,p.jsxs)(`div`,{className:`obj-progress-head`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:gE(e.label)}),(0,p.jsxs)(`span`,{className:`obj-progress-pct`,children:[Math.round(t),`%`]})]}),(0,p.jsx)(`div`,{className:`obj-progress-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(t),"aria-label":gE(e.label)||`Progress`,children:(0,p.jsx)(`i`,{style:{width:`${t}%`}})}),gE(e.detail)&&(0,p.jsx)(`span`,{className:`obj-progress-detail`,children:gE(e.detail)})]})}function EE({props:e}){let t=_E(e.items).map(e=>vE(typeof e==`object`&&e?e:{text:e})),n=t.filter(e=>e.done===!0).length;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(CE,{props:e}),(0,p.jsx)(`ul`,{className:`obj-checklist`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{className:e.done===!0?`done`:void 0,children:[(0,p.jsx)(`span`,{className:`box`,"aria-hidden":`true`,children:e.done===!0?`✓`:``}),(0,p.jsx)(`span`,{children:gE(e.text)})]},t))}),t.length>0&&(0,p.jsxs)(`small`,{className:`obj-progress-detail`,children:[n,` of `,t.length,` done`]})]})}function DE({props:e}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(CE,{props:e}),(0,p.jsx)(`dl`,{className:`obj-kv`,children:_E(e.rows).map((e,t)=>{let n=vE(e);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`dt`,{children:gE(n.key)}),(0,p.jsx)(`dd`,{children:gE(n.value)})]},t)})})]})}var OE=e=>String(Math.floor(e)).padStart(2,`0`);function kE(e){let t=Math.max(0,Math.ceil(e));return`${OE(t/3600)}:${OE(t%3600/60)}:${OE(t%60)}`}function AE({props:e}){let t=(0,l.useRef)(null);if(t.current===null){let n=typeof e.to==`string`?Date.parse(e.to):NaN,r=Number(e.seconds);t.current=Number.isFinite(n)?n:Date.now()+(Number.isFinite(r)?r:0)*1e3}let[n,r]=(0,l.useState)(Date.now());(0,l.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),250);return()=>clearInterval(e)},[]);let i=(t.current-n)/1e3;return(0,p.jsxs)(`div`,{className:`obj-countdown${i<=0?` done`:``}`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:gE(e.title)||gE(e.label)}),(0,p.jsx)(`span`,{className:`obj-countdown-time`,role:`timer`,children:kE(i)})]})}function jE({props:e}){let t=bE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media`,children:[(0,p.jsx)(CE,{props:e}),t?(0,p.jsx)(`img`,{src:t,alt:gE(e.title)||`Picture`,loading:`lazy`}):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This picture is not available.`})]})}function ME({src:e,web:t,title:n}){let[r,i]=(0,l.useState)(t?`loading`:`ready`),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>a.current?fE(a.current):void 0,[r===`failed`]),r===`failed`?(0,p.jsx)(`p`,{className:`obj-empty`,children:`This video could not be played. Ask Friend to try again, or to play it in a window on the PC.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`video`,{ref:a,src:e,controls:!0,playsInline:!0,autoPlay:t,preload:t?`auto`:`metadata`,"aria-label":n,onLoadedData:()=>i(`ready`),onError:()=>i(`failed`)}),t&&r===`loading`&&(0,p.jsx)(`p`,{className:`obj-empty`,children:`Preparing the video…`})]})}var NE=/^[A-Za-z0-9_-]{11}$/;function PE({id:e,start:t,title:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);(0,l.useEffect)(()=>a.current?mE(a.current):void 0,[e]);let o=new URLSearchParams({autoplay:`1`,rel:`0`,playsinline:`1`,modestbranding:`1`,enablejsapi:`1`});return t>0&&o.set(`start`,String(t)),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`iframe`,{ref:a,className:`obj-youtube`,src:`https://www.youtube-nocookie.com/embed/${e}?${o.toString()}`,title:n,allow:`autoplay; encrypted-media; fullscreen; picture-in-picture`,allowFullScreen:!0,referrerPolicy:`strict-origin-when-cross-origin`,onLoad:()=>i(!0)}),!r&&(0,p.jsx)(`p`,{className:`obj-empty`,children:`Loading the player…`})]})}function FE({props:e}){if(e.embed!==void 0){let t=typeof e.embed==`string`&&NE.test(e.embed)?e.embed:null,n=typeof e.start==`number`&&e.start>0&&e.start<=86400?Math.floor(e.start):0;return(0,p.jsxs)(`div`,{className:`obj-media obj-media-fill`,children:[(0,p.jsx)(CE,{props:e}),t?(0,p.jsx)(PE,{id:t,start:n,title:gE(e.title)||`YouTube video`},`${t}-${n}`):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This clip is not available.`})]})}let t=SE(e.src),n=t??bE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media`,children:[(0,p.jsx)(CE,{props:e}),n?(0,p.jsx)(ME,{src:n,web:t!==null,title:gE(e.title)||`Video`},n):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This clip is not available.`})]})}function IE({props:e}){let t=bE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media obj-pdf`,children:[(0,p.jsx)(CE,{props:e}),t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`iframe`,{src:t,title:gE(e.title)||`Document`}),(0,p.jsx)(`a`,{className:`obj-open`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:`Open in a new tab`})]}):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This document is not available.`})]})}function LE({props:e}){let t=_E(e.items).map(vE).filter(e=>bE(e.src)),[n,r]=(0,l.useState)(0),i=Math.min(n,Math.max(0,t.length-1)),a=t[i];if(!a)return(0,p.jsx)(`p`,{className:`obj-empty`,children:`Nothing to show.`});let o=bE(a.src),s=a.kind===`video`;return(0,p.jsxs)(`div`,{className:`obj-media obj-gallery`,children:[(0,p.jsx)(CE,{props:e}),s?(0,p.jsx)(`video`,{src:o,controls:!0,playsInline:!0,preload:`metadata`},o):(0,p.jsx)(`img`,{src:o,alt:gE(a.caption)||`Picture ${i+1}`},o),(0,p.jsxs)(`div`,{className:`obj-gallery-bar`,children:[(0,p.jsx)(`button`,{type:`button`,"aria-label":`Previous`,disabled:t.length<2,onClick:()=>r((i+t.length-1)%t.length),children:`‹`}),(0,p.jsxs)(`span`,{children:[gE(a.caption),(0,p.jsxs)(`small`,{children:[i+1,` / `,t.length]})]}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Next`,disabled:t.length<2,onClick:()=>r((i+1)%t.length),children:`›`})]})]})}var RE=[`default-src 'none'`,`script-src 'unsafe-inline'`,`style-src 'unsafe-inline'`,`img-src data: blob:`,`form-action 'none'`,`base-uri 'none'`].join(`; `),zE=`html,body{margin:0;min-height:100%;background:#050b10;color:var(--ink,#d8f6ff);font:15px/1.5 var(--ui,system-ui,sans-serif)}`,BE=[`--accent`,`--ink`,`--muted`,`--ok`,`--warn`,`--bad`,`--glass`,`--edge`,`--ui`,`--mono`],VE=/^[\w\s#().,%'"/-]+$/;function HE(){if(typeof document>`u`)return``;let e=getComputedStyle(document.documentElement),t=BE.map(t=>[t,e.getPropertyValue(t).trim()]).filter(([,e])=>e&&VE.test(e));return t.length?`:root{${t.map(([e,t])=>`${e}:${t}`).join(`;`)}}`:``}function UE(e,t=``){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${RE}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>${t}${zE}</style></head><body>${e}</body></html>`}function WE({props:e}){let t=typeof e.html==`string`?e.html:``,n=typeof e.title==`string`?e.title:``,r=(0,l.useMemo)(()=>UE(t,HE()),[t]);return(0,p.jsxs)(`div`,{className:`obj-sandbox`,children:[n&&(0,p.jsx)(`h3`,{className:`obj-title`,children:n}),(0,p.jsx)(`iframe`,{title:n||`Page made by Friend`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,allow:``,srcDoc:r})]})}var GE=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,KE=e=>Array.isArray(e)?e:[];function qE({props:e}){let t=(0,l.useMemo)(()=>FT(GE(e.text)),[e.text]);return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`div`,{className:`obj-md`,dangerouslySetInnerHTML:{__html:t}})]})}function JE({props:e}){return(0,p.jsxs)(`div`,{className:`obj-stat`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:GE(e.label)}),(0,p.jsxs)(`span`,{className:`obj-value`,children:[(0,p.jsx)(`span`,{children:GE(e.value)}),GE(e.unit)&&(0,p.jsx)(`small`,{children:GE(e.unit)})]}),GE(e.delta)&&(0,p.jsx)(`span`,{className:`obj-delta`,children:GE(e.delta)})]})}function YE({props:e}){return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`ul`,{className:`obj-list`,children:KE(e.items).map((e,t)=>{let n=typeof e==`object`&&e?e:{text:e};return(0,p.jsx)(`li`,{className:n.done?`done`:void 0,children:GE(n.text)},t)})})]})}function XE({props:e}){let t=KE(e.columns),n=KE(e.rows);return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`div`,{className:`obj-table-wrap`,children:(0,p.jsxs)(`table`,{className:`obj-table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsx)(`tr`,{children:t.map((e,t)=>(0,p.jsx)(`th`,{children:GE(e)},t))})}),(0,p.jsx)(`tbody`,{children:n.map((e,t)=>(0,p.jsx)(`tr`,{children:KE(e).map((e,t)=>(0,p.jsx)(`td`,{children:GE(e)},t))},t))})]})})]})}function ZE({props:e}){return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`pre`,{className:`obj-code`,"data-lang":GE(e.language),children:(0,p.jsx)(`code`,{children:GE(e.code)})})]})}function QE({part:e}){let t=typeof e==`object`&&e?e:{},n=typeof t.type==`string`?t.type:``;if(n===`group`||n===`tabs`||n===`sandbox`)return null;let r=tD[n];return r?(0,p.jsx)(`div`,{className:`obj-part obj-part-${n}`,children:(0,p.jsx)(r,{props:typeof t.props==`object`&&t.props!==null?t.props:{}})}):null}function $E({props:e}){let t=e.layout===`row`||e.layout===`column`?e.layout:`grid`;return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`div`,{className:`obj-group obj-group-${t}`,children:KE(e.items).map((e,t)=>(0,p.jsx)(QE,{part:e},t))})]})}function eD({props:e}){let t=KE(e.tabs).map(e=>typeof e==`object`&&e?e:{}),[n,r]=(0,l.useState)(0),i=Math.min(n,Math.max(0,t.length-1));return(0,p.jsxs)(p.Fragment,{children:[GE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:GE(e.title)}),(0,p.jsx)(`div`,{className:`obj-tabs`,role:`tablist`,children:t.map((e,t)=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===i,className:t===i?`on`:void 0,onClick:()=>r(t),children:GE(e.title)||`Tab ${t+1}`},t))}),t[i]&&(0,p.jsx)(QE,{part:t[i]})]})}var tD={card:qE,stat:JE,list:YE,table:XE,code:ZE,chart:nE,gauge:rE,timeline:iE,graph:cE,sandbox:WE,markdown:wE,image:jE,video:FE,pdf:IE,gallery:LE,group:$E,tabs:eD,progress:TE,checklist:EE,countdown:AE,kv:DE};function nD(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=new Set;for(let t of e){if(i.has(t.object.id))continue;i.add(t.object.id);let e=n.get(t.object.id);r.push(e?{object:e,leaving:!1}:{object:t.object,leaving:!0})}for(let e of t)i.has(e.id)||(i.add(e.id),r.push({object:e,leaving:!1}));return r}function rD(e,t){let[n,r]=(0,l.useState)(()=>e.map(e=>({object:e,leaving:!1}))),i=(0,l.useRef)(new Map);return(0,l.useEffect)(()=>{r(n=>{let a=nD(n,e),o=new Set(n.filter(e=>e.leaving).map(e=>e.object.id));for(let e of a){let n=i.current.get(e.object.id);if(!e.leaving)n&&clearTimeout(n),i.current.delete(e.object.id);else if(!o.has(e.object.id)&&!n){let n=e.object.id;i.current.set(n,setTimeout(()=>{i.current.delete(n),r(e=>e.filter(e=>!(e.object.id===n&&e.leaving)))},Math.max(t,0)))}}return t<=0?a.filter(e=>!e.leaving):a})},[e,t]),(0,l.useEffect)(()=>()=>{for(let e of i.current.values())clearTimeout(e);i.current.clear()},[]),n}var iD=.12,aD=.1,oD=.02,sD=(e,t,n)=>Math.min(Math.max(e,t),n);function cD(e){let t=sD(e.w,iD,1),n=sD(e.h,aD,1);return{x:sD(e.x,0,1-t),y:sD(e.y,0,1-n),w:t,h:n}}function lD(e,t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.width<=0||n.height<=0?null:cD({x:(r.left-n.left)/n.width,y:(r.top-n.top)/n.height,w:r.width/n.width,h:r.height/n.height})}function uD(e,t,n){let r=(0,l.useRef)(null),[i,a]=(0,l.useState)(null),o=(0,l.useCallback)((n,r)=>{let i=cD(r);t({type:`object.place`,id:n,placement:{x:i.x,y:i.y,w:i.w,h:i.h}}),e({type:`stage.move`,objectId:n,rect:i})},[e,t]),s=(0,l.useCallback)((e,t,i)=>{if(e.pointerType===`mouse`&&e.button!==0)return;let o=n(),s=e.currentTarget.closest(`[data-object]`);if(!o||!s||r.current)return;let c=lD(s,o);if(!c)return;let l=o.getBoundingClientRect();r.current={id:t.id,mode:i,pointer:e.pointerId,startX:e.clientX,startY:e.clientY,from:c,stageW:l.width,stageH:l.height};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.stopPropagation(),e.preventDefault(),a({id:t.id,box:c})},[n]),c=(e,t)=>{let n=(t.clientX-e.startX)/e.stageW,r=(t.clientY-e.startY)/e.stageH;return e.mode===`move`?cD({...e.from,x:e.from.x+n,y:e.from.y+r}):cD({...e.from,w:e.from.w+n,h:e.from.h+r})};return{preview:i,begin:s,move:(0,l.useCallback)(e=>{let t=r.current;t&&t.pointer===e.pointerId&&a({id:t.id,box:c(t,e)})},[]),end:(0,l.useCallback)((e,t)=>{let n=r.current;n&&n.pointer===e.pointerId&&(r.current=null,a(null),t||o(n.id,c(n,e)))},[o]),key:(0,l.useCallback)((e,t)=>{let r={ArrowLeft:[-.02,0],ArrowRight:[oD,0],ArrowUp:[0,-.02],ArrowDown:[0,oD]}[e.key],i=n(),a=e.currentTarget.closest(`[data-object]`);if(!r||!i||!a)return;let s=lD(a,i);s&&(e.preventDefault(),o(t.id,e.shiftKey?{...s,w:s.w+r[0],h:s.h+r[1]}:{...s,x:s.x+r[0],y:s.y+r[1]}))},[o,n])}}function dD(e,t){if(e===`auto`)return{position:`relative`};if(t.w<600)return{position:`relative`,width:`100%`};let[n,r,i,a]=typeof e==`string`?lu[e]:[e.x*100,e.y*100,e.w*100,e.h*100],o={position:`absolute`,left:`${n}%`,top:`${r}%`,width:`${i}%`};return e===`top`||e===`bottom`?{...o,maxHeight:`${a}%`}:{...o,height:`${a}%`}}var fD=350,pD=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,mD=class extends l.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?null:this.props.children}};function hD(){let e=()=>({w:window.innerWidth,h:window.innerHeight}),[t,n]=(0,l.useState)(e);return(0,l.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[]),t}var gD=350;function _D({state:e,send:t,dispatch:n,voice:r,slash:i,onMenu:a}){let o=hD(),[s,c]=(0,l.useState)(0),[u,d]=(0,l.useState)(!1),f=ae(),m=o.w<600,h=e.scene===`focus`||e.scene===`multi`,g={"--accent":e.mood.accent,"--intensity":e.mood.intensity},_=e.voice.mode,v=_===`listening`?`listening`:_===`speaking`?`speaking`:_===`transcribing`?`thinking`:e.presence.state,y=jx(e.look.reactivity),b=Math.min(1,(_===`listening`||_===`speaking`?e.voice.level:e.presence.amplitude)*y),x=(0,l.useRef)({timer:null,down:!1,talking:!1,id:null}),S=e=>{if(!(e.target===e.currentTarget||e.target.closest(`[data-presence]`))||e.pointerType===`mouse`&&e.button!==0)return;let t=x.current;if(!(t.down&&t.id!==null&&e.pointerId!==t.id)){t.timer&&clearTimeout(t.timer),t.down=!0,t.talking=!1,t.id=typeof e.pointerId==`number`?e.pointerId:null;try{t.id!==null&&e.currentTarget.setPointerCapture?.(t.id)}catch{}t.timer=r?setTimeout(()=>{t.down&&(t.talking=!0,r.pressStart())},gD):null}},C=(e,t)=>{let n=x.current;n.down&&(n.id===null||typeof e.pointerId!=`number`||e.pointerId===n.id)&&(n.down=!1,n.id=null,n.timer&&clearTimeout(n.timer),n.timer=null,n.talking?(n.talking=!1,t?r?.blur?.():r?.pressEnd()):t||c(e=>e+1))},w=(0,l.useRef)(null),T=uD(t,n,()=>w.current),E=rD(e.objects,pD()?0:fD),D=E.filter(e=>e.object.layer===`overlay`),O=E.filter(e=>e.object.layer!==`overlay`&&e.object.placement===`auto`),k=E.filter(e=>e.object.layer!==`overlay`&&e.object.placement!==`auto`),A=({object:e,leaving:r})=>{let i=tD[e.type];if(!i)return null;let a=e.layer===`overlay`,s=!m&&!r&&!a,c=T.preview?.id===e.id?T.preview.box:null,l=c?{x:c.x,y:c.y,w:c.w,h:c.h}:e.placement;return(0,p.jsxs)(`section`,{"data-object":e.id,className:`obj glass${e.style===`alert`?` alert`:``}${a?` overlay`:``}${e.pinned?` pinned`:``}${c?` dragging`:``}${r?` leaving`:``}`,style:a?void 0:dD(l,o),children:[s&&(0,p.jsx)(`div`,{className:`obj-grip`,role:`button`,tabIndex:0,"aria-label":`Move ${e.id}. Drag, or use the arrow keys; hold Shift to resize.`,onPointerDown:t=>T.begin(t,e,`move`),onPointerMove:T.move,onPointerUp:e=>T.end(e,!1),onPointerCancel:e=>T.end(e,!0),onKeyDown:t=>T.key(t,e)}),!a&&(0,p.jsx)(`button`,{className:`obj-pin${e.pinned?` on`:``}`,"aria-label":e.pinned?`Unpin ${e.id}`:`Pin ${e.id} to the screen`,"aria-pressed":!!e.pinned,title:e.pinned?`Pinned: stays on the screen. Click to unpin.`:`Pin: keep this on the screen.`,disabled:r,onClick:()=>t({type:`stage.pin`,objectId:e.id,pinned:!e.pinned}),children:(0,p.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:e.pinned?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:`M12 17v5M9 3h6l-1 7 3 3H7l3-3-1-7z`})})}),(0,p.jsx)(`button`,{className:`obj-close`,"aria-label":`Dismiss ${e.id}`,title:e.pinned?`Remove this widget`:`Dismiss`,disabled:r,onClick:()=>{t({type:`stage.event`,objectId:e.id,event:`dismiss`}),n({type:`object.dismiss`,id:e.id})},children:`×`}),s&&(0,p.jsx)(`div`,{className:`obj-resize`,"aria-hidden":`true`,onPointerDown:t=>T.begin(t,e,`resize`),onPointerMove:T.move,onPointerUp:e=>T.end(e,!1),onPointerCancel:e=>T.end(e,!0)}),(0,p.jsx)(mD,{children:(0,p.jsx)(i,{props:e.props})})]},e.id)};return(0,p.jsxs)(`div`,{ref:w,"data-testid":`stage`,className:`stage`,style:g,onPointerDown:S,onPointerUp:e=>C(e,!1),onPointerCancel:e=>C(e,!0),onContextMenu:e=>r&&e.preventDefault(),children:[e.look.ambient&&(0,p.jsx)(`div`,{className:`ambient`,"aria-hidden":`true`,style:{opacity:.35+.65*e.mood.intensity}}),(0,p.jsx)(Ax,{state:v,amplitude:b,pulse:e.presence.pulse,mode:h?`corner`:`full`,accent:e.mood.accent,style:e.presence.style,intensity:e.mood.intensity,scale:e.look.size}),(0,p.jsxs)(`div`,{className:m?`objects objects-stack`:`objects`,style:{zIndex:10},children:[O.length>0&&(0,p.jsx)(`div`,{className:`auto-grid`,children:O.map(A)}),k.map(A)]}),D.length>0&&(0,p.jsxs)(`div`,{className:`overlay-layer`,"data-testid":`overlay`,children:[(0,p.jsx)(`div`,{className:`overlay-backdrop`,onClick:()=>D.forEach(({object:e})=>{t({type:`stage.event`,objectId:e.id,event:`dismiss`}),n({type:`object.dismiss`,id:e.id})})}),D.map(A)]}),e.look.captions&&e.captions&&(0,p.jsx)(`p`,{className:`captions captions-${e.look.captionSize}${e.captionDone?` done`:``}`,"aria-live":`polite`,children:e.captions}),f&&r&&!u&&(0,p.jsx)(dS,{voice:r,mode:_,onType:()=>c(e=>e+1),onMenu:()=>a?.()}),(0,p.jsx)(cS,{requestOpen:s,slash:i,onOpenChange:d,onSend:e=>t({type:`chat.send`,text:e})})]})}function vD(){let e=()=>Math.random().toString(36).slice(2,12)+Date.now().toString(36);try{let t=sessionStorage.getItem(`friend.tab`);return t||(t=e(),sessionStorage.setItem(`friend.tab`,t)),t}catch{return e()}}function yD(){return`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`}function bD(e=yD()){let t=null,n=`connecting`,r=!1,i=0,a=!1,o=vD(),s=null,c=new Set,l=new Set,u=e=>{n=e,l.forEach(t=>t(e))};function d(){if(r)return;u(`connecting`);let n=new WebSocket(`${e}${e.includes(`?`)?`&`:`?`}tab=${o}${a?`&takeover=1`:``}`);t=n,n.onopen=()=>{i=0,a=!1,u(`open`)},n.onmessage=e=>{try{let t=JSON.parse(String(e.data));c.forEach(e=>e(t))}catch{}},n.onclose=e=>{if(!r){if(e.code===4401)return u(`unauthorized`);if(e.code===4409||e.code===4410)return u(`elsewhere`);u(`closed`),s=setTimeout(d,Math.min(500*2**i++,8e3))}},n.onerror=()=>{}}return d(),{send(e){t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},onMessage(e){return c.add(e),()=>c.delete(e)},onState(e){return l.add(e),()=>l.delete(e)},state:()=>n,takeOver(){r||n!==`elsewhere`||(a=!0,i=0,d())},close(){r=!0,s&&clearTimeout(s),t?.close()}}}var xD={scene:`conversation`,objects:[],captions:``,captionDone:!0,presence:{state:`idle`,style:`sphere`,amplitude:0,pulse:0},mood:{accent:`#3fd8ff`,intensity:.6},approval:null,alerts:[],connection:`connecting`,chat:[],chatLive:!1,view:`companion`,look:{size:1,reactivity:.7,ambient:!0,captions:!0,captionSize:`medium`},viewKnown:!1,busy:!1,activity:null,deviceOnline:!1,voice:{mode:`idle`,level:0,available:!1,enrolled:!1},challenge:null,camera:{enabled:!1,stream:null},speaker:null,ownerName:``,assistantName:``,hud:null,music:null,hostMusic:null,musicCmd:null,uiOpen:null},SD=200,CD=e=>e.length>SD?e.slice(-200):e,wD=0,TD=e=>Math.min(1,Math.max(0,e));function ED(e,t){switch(t.cmd){case`scene`:return{...e,scene:t.mode};case`show`:{let n=e.objects.findIndex(e=>e.id===t.object.id),r=n===-1?[...e.objects,t.object]:e.objects.map((e,r)=>r===n?t.object:e);return{...e,objects:r}}case`update`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,props:{...e.props,...t.props}}:e)};case`hide`:return{...e,objects:e.objects.filter(e=>e.id!==t.id)};case`clear`:return{...e,objects:e.objects.filter(e=>e.pinned),scene:`conversation`};case`pin`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,pinned:!0}:e)};case`unpin`:return{...e,objects:e.objects.map(e=>e.id===t.id?(({pinned:e,...t})=>t)(e):e)};case`place`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,placement:t.placement}:e)};case`presence`:return{...e,presence:{...e.presence,state:t.state??e.presence.state,style:t.style??e.presence.style}};case`mood`:return{...e,mood:{accent:t.accent??e.mood.accent,intensity:t.intensity??e.mood.intensity}}}}function DD(e,t){let n=t;if(n&&typeof n==`object`){if(n.type===`conn`)return{...e,connection:n.value};if(n.type===`chat.seed`){let t=Array.isArray(n.lines)?n.lines:[];return e.chat.length===0?{...e,chat:CD(t)}:{...e,chat:CD([...t,...e.chat])}}if(n.type===`alert.add`)return{...e,alerts:[...e.alerts.slice(-3),{id:++wD,level:n.level,text:n.text}]};if(n.type===`camera.enable`)return{...e,camera:{enabled:n.value,stream:n.value?e.camera.stream:null}};if(n.type===`camera.open`)return{...e,camera:{...e.camera,stream:n.stream}};if(n.type===`camera.closed`)return{...e,camera:{...e.camera,stream:null}};if(n.type===`challenge.dismiss`)return e.challenge?.id===n.id?{...e,challenge:null}:e;if(n.type===`voice.mode`)return{...e,voice:{...e.voice,mode:n.mode,level:n.mode===`idle`?0:e.voice.level}};if(n.type===`voice.level`){let t=Number.isFinite(n.level)?Math.min(1,Math.max(0,n.level)):0;return{...e,voice:{...e.voice,level:t}}}if(n.type===`object.dismiss`)return{...e,objects:e.objects.filter(e=>e.id!==n.id)};if(n.type===`object.place`)return{...e,objects:e.objects.map(e=>e.id===n.id?{...e,placement:n.placement}:e)};if(n.type===`alert.dismiss`)return{...e,alerts:e.alerts.filter(e=>e.id!==n.id)}}let r=Mu.safeParse(t);if(!r.success)return e;let i=r.data;switch(i.type){case`snapshot`:return{...e,scene:i.stage.scene,objects:i.stage.objects,presence:{...e.presence,state:i.stage.presence.state,style:i.stage.presence.style},mood:i.stage.mood,approval:i.pendingApproval??null};case`stage`:return ED(e,i.command);case`chat.user`:return{...e,chat:CD([...e.chat,{role:`user`,text:i.text}]),chatLive:!1};case`ui.open`:return{...e,uiOpen:{n:(e.uiOpen?.n??0)+1,...i.integration?{integration:i.integration}:{}}};case`ui`:return{...e,view:i.view,look:i.look??e.look,ownerName:i.ownerName??e.ownerName,assistantName:i.assistantName??e.assistantName,hud:i.hud??e.hud,music:i.music??e.music,viewKnown:!0};case`music.host`:return{...e,hostMusic:i.state};case`music.command`:{let{type:t,...n}=i;return{...e,musicCmd:{n:(e.musicCmd?.n??0)+1,command:n}}}case`caption.delta`:{let t=e.captionDone,n=e.chat.at(-1),r=e.chatLive&&n?.role===`assistant`?[...e.chat.slice(0,-1),{role:`assistant`,text:n.text+i.text}]:CD([...e.chat,{role:`assistant`,text:i.text}]);return{...e,chat:r,chatLive:!0,captions:(t?``:e.captions)+i.text,captionDone:!1,presence:{...e.presence,amplitude:TD(.3+i.text.length*.04),pulse:e.presence.pulse+1}}}case`caption.end`:return{...e,chatLive:!1,captionDone:!0,presence:{...e.presence,amplitude:0}};case`approval.request`:{let{type:t,...n}=i;return{...e,approval:n}}case`approval.resolved`:return e.approval?.id===i.id?{...e,approval:null}:e;case`alert`:return{...e,alerts:[...e.alerts.slice(-3),{id:++wD,level:i.level,text:i.text}]};case`activity`:return{...e,activity:i.text};case`status`:return{...e,busy:i.busy,activity:i.busy?e.activity:null,deviceOnline:i.deviceOnline,voice:{...e.voice,available:i.voiceAvailable??e.voice.available,enrolled:i.voiceEnrolled??e.voice.enrolled}};case`error`:return{...e,alerts:[...e.alerts.slice(-3),{id:++wD,level:`error`,text:i.message}]};case`voice.heard`:return{...e,captions:i.trust===`guest`?`Guest: ${i.text}`:i.trust===`member`&&i.speaker?`${i.speaker}: ${i.text}`:i.text,captionDone:!0,speaker:{name:i.trust===`member`?i.speaker??null:null,trust:i.trust??`unverified`,seq:(e.speaker?.seq??0)+1}};case`voice.challenge`:return{...e,challenge:{id:i.id,text:i.text}};case`voice.challenge.end`:return e.challenge?.id===i.id?{...e,challenge:null}:e;case`audio.chunk`:case`audio.stop`:case`audio.duck`:return e;case`camera.request`:case`camera.cancel`:case`screen.request`:case`screen.cancel`:return e}}var OD=1024,kD=.8,AD=300;function jD(e,t){let n=Math.min(1,OD/Math.max(e,t));return{width:Math.round(e*n),height:Math.round(t*n)}}function MD(e){let t=e?.name;return t===`NotAllowedError`||t===`SecurityError`?`permission`:t===`NotFoundError`||t===`OverconstrainedError`?`no-camera`:`busy`}async function ND(){if(!navigator.mediaDevices?.getUserMedia)throw Object.assign(Error(`This browser cannot use the camera here (use localhost or HTTPS).`),{name:`NotFoundError`});return navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280}},audio:!1})}async function PD(e,t=AD){let n=document.createElement(`video`);n.muted=!0,n.playsInline=!0,n.srcObject=e,await n.play(),await new Promise(e=>setTimeout(e,t));let{width:r,height:i}=jD(n.videoWidth||640,n.videoHeight||480),a=document.createElement(`canvas`);return a.width=r,a.height=i,a.getContext(`2d`).drawImage(n,0,0,r,i),n.srcObject=null,new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Could not encode the picture.`)),`image/jpeg`,kD))}var FD=class{opts;active=null;constructor(e){this.opts=e}async handle(e){if(e.type===`camera.cancel`){let t=this.active;t&&t.id===e.id&&(t.cancelled=!0,this.release(t));return}if(!this.opts.enabled())return this.opts.send({type:`camera.denied`,id:e.id,reason:`off`});if(this.active)return this.opts.send({type:`camera.denied`,id:e.id,reason:`busy`});let t={id:e.id,cancelled:!1,stream:null,opened:!1,released:!1};this.active=t;try{let n=await(this.opts.open??ND)();if(t.stream=n,t.cancelled){n.getTracks().forEach(e=>e.stop());return}t.opened=!0,this.opts.dispatch({type:`camera.open`,stream:n});let r=await(this.opts.frame??(e=>PD(e)))(n);if(t.cancelled)return;this.release(t);try{await this.opts.upload(e.id,r)}catch{this.opts.dispatch({type:`alert.add`,level:`warn`,text:`Could not send the camera picture to Friend.`})}}catch(n){t.cancelled||this.opts.send({type:`camera.denied`,id:e.id,reason:MD(n)})}finally{this.release(t),this.active===t&&(this.active=null)}}dispose(){let e=this.active;e&&(e.cancelled=!0,this.release(e))}release(e){e.released||(e.released=!0,e.stream?.getTracks().forEach(e=>e.stop()),e.opened&&this.opts.dispatch({type:`camera.closed`}))}};function ID(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var LD=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function RD(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var zD=null;function BD(e={}){return zD||(e.includeStyleProperties?(zD=e.includeStyleProperties,zD):(zD=RD(window.getComputedStyle(document.documentElement)),zD))}function VD(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function HD(e){let t=VD(e,`border-left-width`),n=VD(e,`border-right-width`);return e.clientWidth+t+n}function UD(e){let t=VD(e,`border-top-width`),n=VD(e,`border-bottom-width`);return e.clientHeight+t+n}function WD(e,t={}){return{width:t.width||HD(e),height:t.height||UD(e)}}function GD(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var KD=16384;function qD(e){(e.width>KD||e.height>KD)&&(e.width>KD&&e.height>KD?e.width>e.height?(e.height*=KD/e.width,e.width=KD):(e.width*=KD/e.height,e.height=KD):e.width>KD?(e.height*=KD/e.width,e.width=KD):(e.width*=KD/e.height,e.height=KD))}function JD(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function YD(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function XD(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),YD(i)}var ZD=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||ZD(n,t)};function QD(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function $D(e,t){return BD(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function eO(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?QD(n):$D(n,r);return document.createTextNode(`${i}{${a}}`)}function tO(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=LD();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(eO(o,n,i,r)),t.appendChild(s)}function nO(e,t,n){tO(e,t,`:before`,n),tO(e,t,`:after`,n)}var rO=`application/font-woff`,iO=`image/jpeg`,aO={woff:rO,woff2:rO,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:iO,jpeg:iO,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function oO(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function sO(e){return aO[oO(e).toLowerCase()]||``}function cO(e){return e.split(/,/)[1]}function lO(e){return e.search(/^(data:)/)!==-1}function uO(e,t){return`data:${t};base64,${e}`}async function dO(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var fO={};function pO(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function mO(e,t,n){let r=pO(e,t,n.includeQueryParams);if(fO[r]!=null)return fO[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=uO(await dO(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,cO(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return fO[r]=i,i}async function hO(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):JD(t)}async function gO(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),JD(t.toDataURL())}let n=e.poster;return JD(await mO(n,sO(n),t))}async function _O(e,t){try{if(e?.contentDocument?.body)return await DO(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function vO(e,t){return ZD(e,HTMLCanvasElement)?hO(e):ZD(e,HTMLVideoElement)?gO(e,t):ZD(e,HTMLIFrameElement)?_O(e,t):e.cloneNode(bO(e))}var yO=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,bO=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function xO(e,t,n){if(bO(t))return t;let r=[];return r=yO(e)&&e.assignedNodes?RD(e.assignedNodes()):ZD(e,HTMLIFrameElement)&&e.contentDocument?.body?RD(e.contentDocument.body.childNodes):RD((e.shadowRoot??e).childNodes),r.length===0||ZD(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>DO(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function SO(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):BD(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),ZD(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function CO(e,t){ZD(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),ZD(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function wO(e,t){if(ZD(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function TO(e,t,n){return ZD(t,Element)&&(SO(e,t,n),nO(e,t,n),CO(e,t),wO(e,t)),t}async function EO(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await DO(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function DO(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>vO(e,t)).then(n=>xO(e,n,t)).then(n=>TO(e,n,t)).then(e=>EO(e,t))}var OO=/url\((['"]?)([^'"]+?)\1\)/g,kO=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,AO=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function jO(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function MO(e){let t=[];return e.replace(OO,(e,n,r)=>(t.push(r),e)),t.filter(e=>!lO(e))}async function NO(e,t,n,r,i){try{let a=n?ID(t,n):t,o=sO(t),s;return s=i?uO(await i(a),o):await mO(a,o,r),e.replace(jO(t),`$1${s}$3`)}catch{}return e}function PO(e,{preferredFontFormat:t}){return t?e.replace(AO,e=>{for(;;){let[n,,r]=kO.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function FO(e){return e.search(OO)!==-1}async function IO(e,t,n){if(!FO(e))return e;let r=PO(e,n);return MO(r).reduce((e,r)=>e.then(e=>NO(e,r,t,n)),Promise.resolve(r))}async function LO(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await IO(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function RO(e,t){await LO(`background`,e,t)||await LO(`background-image`,e,t),await LO(`mask`,e,t)||await LO(`-webkit-mask`,e,t)||await LO(`mask-image`,e,t)||await LO(`-webkit-mask-image`,e,t)}async function zO(e,t){let n=ZD(e,HTMLImageElement);if((!n||lO(e.src))&&(!ZD(e,SVGImageElement)||lO(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await mO(r,sO(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function BO(e,t){let n=RD(e.childNodes).map(e=>VO(e,t));await Promise.all(n).then(()=>e)}async function VO(e,t){ZD(e,Element)&&(await RO(e,t),await zO(e,t),await BO(e,t))}function HO(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var UO={};async function WO(e){let t=UO[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},UO[e]=t,t)}async function GO(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),dO(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function KO(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function qO(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{RD(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=WO(o).then(e=>GO(e,t)).then(e=>KO(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(WO(n.href).then(e=>GO(e,t)).then(e=>KO(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{RD(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function JO(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>FO(e.style.getPropertyValue(`src`)))}async function YO(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return JO(await qO(RD(e.ownerDocument.styleSheets),t))}function XO(e){return e.trim().replace(/["']/g,``)}function ZO(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(XO(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function QO(e,t){let n=await YO(e,t),r=ZO(e);return(await Promise.all(n.filter(e=>r.has(XO(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return IO(e.cssText,n,t)}))).join(`
|
|
4456
|
-
`)}async function $O(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await QO(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function ek(e,t={}){let{width:n,height:r}=WD(e,t),i=await DO(e,t,!0);return await $O(i,t),await VO(i,t),HO(i,t),await XD(i,n,r)}async function tk(e,t={}){let{width:n,height:r}=WD(e,t),i=await JD(await ek(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||GD(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||qD(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}var nk=1600,rk=.85;function ik(e,t){let n=Math.min(1,nk/Math.max(e,t,1));return{width:Math.max(1,Math.round(e*n)),height:Math.max(1,Math.round(t*n))}}async function ak(){let e=document.documentElement.getBoundingClientRect(),t=await tk(document.body,{width:Math.round(e.width),height:Math.round(e.height),pixelRatio:1,backgroundColor:`#050b10`,filter:e=>!(e instanceof HTMLElement&&e.dataset.noCapture!==void 0)}),n=ik(t.width,t.height),r=document.createElement(`canvas`);return r.width=n.width,r.height=n.height,r.getContext(`2d`).drawImage(t,0,0,n.width,n.height),new Promise((e,t)=>r.toBlob(n=>n?e(n):t(Error(`Could not encode the picture.`)),`image/jpeg`,rk))}var ok=class{opts;active=null;constructor(e){this.opts=e}async handle(e){if(e.type===`screen.cancel`){this.active&&this.active.id===e.id&&(this.active.cancelled=!0);return}if(this.active)return this.opts.send({type:`screen.denied`,id:e.id,reason:`busy`});let t={id:e.id,cancelled:!1};this.active=t;try{let n=await(this.opts.capture??ak)();if(t.cancelled)return;try{await this.opts.upload(e.id,n)}catch{this.opts.dispatch({type:`alert.add`,level:`warn`,text:`Could not send the picture of the screen to Friend.`})}}catch(n){t.cancelled||this.opts.send({type:`screen.denied`,id:e.id,reason:sk(n)})}finally{this.active===t&&(this.active=null)}}dispose(){this.active&&(this.active.cancelled=!0)}};function sk(e){return e?.name===`NotSupportedError`?`unsupported`:`failed`}function ck(e,t){let n=(0,l.useRef)(t);n.current=t;let r=(0,l.useRef)(!1),i=(0,l.useRef)(null);(0,l.useEffect)(()=>{let t=e===`listening`||e===`speaking`;i.current&&clearTimeout(i.current),i.current=null,t?r.current||(r.current=!0,n.current({type:`audio.activity`,active:!0})):r.current&&(i.current=setTimeout(()=>{i.current=null,r.current=!1,n.current({type:`audio.activity`,active:!1})},900))},[e]),(0,l.useEffect)(()=>()=>{i.current&&clearTimeout(i.current),r.current&&(r.current=!1,n.current({type:`audio.activity`,active:!1}))},[])}var lk={401:`Please sign in again.`,413:`That recording was too long.`,409:`Friend is busy with the last request. Try again in a moment.`,429:`You're talking too fast. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function uk(e,t,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":t.type||`audio/webm`},body:t,signal:n})}catch(e){throw e.name===`AbortError`?e:Error(`Could not reach Friend. Check the connection.`)}if(!r.ok){let e=``;try{e=(await r.json()).error??``}catch{}throw Error(e||lk[r.status]||`The voice request failed (${r.status}).`)}let i=await r.json();return{text:typeof i.text==`string`?i.text:``,wake:i.wake===!0}}async function dk(e,t){return{text:(await uk(`/api/voice/utterance`,e,t)).text}}async function fk(e,t){let n=await uk(`/api/voice/utterance?wake=1`,e,t);return{text:n.text,wake:n.wake===!0}}var pk=null;function mk(){try{pk??=new AudioContext,pk.resume().catch(()=>{});let e=pk.currentTime;for(let[t,n]of[660,990].entries()){let r=pk.createOscillator(),i=pk.createGain();r.frequency.value=n,i.gain.setValueAtTime(0,e+t*.11),i.gain.linearRampToValueAtTime(.18,e+t*.11+.02),i.gain.exponentialRampToValueAtTime(.001,e+t*.11+.14),r.connect(i).connect(pk.destination),r.start(e+t*.11),r.stop(e+t*.11+.16)}}catch{}}var hk=/busy with the last request|talking too fast/i,gk=3e4,_k=50,vk=class{deps;listener=null;awakeNow=!1;showing=!1;busyWithOne=!1;clock=null;meter=null;abort=null;lastAlert=0;constructor(e){this.deps=e}get enabled(){return this.listener!==null}get awake(){return this.awakeNow}async enable(){if(this.listener)return;let e=this.deps.makeListener({onUtterance:e=>void this.heard(e),onError:e=>{this.drop(),this.alert(e,!0)}});try{await e.start()}catch(e){this.alert(e.message,!0);return}this.listener=e}disable(){this.drop()}sync(){let e=this.listener;if(!e)return;let t=this.busyOther();if(e.pause(t),!this.awakeNow||t){this.clearClock(),this.stopMeter();return}this.deps.mode()===`idle`&&this.show(),this.clock||this.startClock(),this.startMeter()}busyOther(){let e=this.deps.mode();return e!==`listening`&&(this.showing=!1),e===`speaking`||e===`transcribing`||e===`listening`&&!this.showing}show(){this.showing=!0,this.deps.dispatch({type:`voice.mode`,mode:`listening`})}wakeUp(e){this.awakeNow=!0,e&&this.deps.chime(),this.clearClock(),this.show(),this.startClock(),this.startMeter()}sleep(){this.awakeNow=!1,this.clearClock(),this.stopMeter(),this.showing&&this.deps.dispatch({type:`voice.mode`,mode:`idle`}),this.showing=!1}drop(){let e=this.listener;this.listener=null,this.abort?.abort(),this.abort=null,this.busyWithOne=!1,this.sleep(),e?.stop()}startClock(){this.clearClock(),this.clock=setTimeout(()=>{this.clock=null,this.sleep()},this.deps.awakeMs??3e4)}clearClock(){this.clock&&clearTimeout(this.clock),this.clock=null}startMeter(){this.meter||=setInterval(()=>this.deps.dispatch({type:`voice.level`,level:this.listener?.level()??0}),_k)}stopMeter(){this.meter&&clearInterval(this.meter),this.meter=null}async heard(e){if(!this.listener||this.busyWithOne||this.busyOther())return;this.busyWithOne=!0;let t=new AbortController;this.abort=t;try{this.awakeNow?await this.request(e,t.signal):await this.check(e,t.signal)}catch(e){e.name!==`AbortError`&&!hk.test(e.message)&&this.alert(e.message,!1)}finally{this.abort===t&&(this.abort=null),this.busyWithOne=!1,this.listener&&this.awakeNow&&(this.clearClock(),this.deps.mode()===`transcribing`&&this.deps.dispatch({type:`voice.mode`,mode:`idle`}),this.sync())}}async check(e,t){let n=await this.deps.wake(e,t);this.listener&&n.wake&&this.wakeUp(!n.text)}async request(e,t){this.clearClock(),this.stopMeter(),this.showing=!1,this.deps.dispatch({type:`voice.mode`,mode:`transcribing`}),await this.deps.command(e,t)}alert(e,t){let n=Date.now();!t&&n-this.lastAlert<gk||(this.lastAlert=n,this.deps.dispatch({type:`alert.add`,level:`error`,text:e}))}},yk=0,bk=new Set;function xk(e){return bk.add(e),()=>bk.delete(e)}var Sk=e=>bk.forEach(t=>{try{t(e)}catch{}}),Ck=e=>/not compatible|audio capture|audiosession/i.test(String(e?.message??e));function wk(e){try{let t=navigator.audioSession;t&&t.type!==e&&(t.type=e)}catch{}}function Tk(){yk===0&&wk(`playback`)}function Ek(){yk++,yk===1&&Sk(!0),wk(`play-and-record`);let e=!1;return()=>{e||(e=!0,yk=Math.max(0,yk-1),yk===0&&(wk(`playback`),Sk(!1)))}}var Dk=3,Ok=.02,kk=.04,Ak=class{minSpeechMs;endSilenceMs;maxMs;floor=null;loudSince=null;speaking=!1;startedAt=0;lastLoud=0;lastFeed=0;speechMs=0;constructor(e={}){this.minSpeechMs=e.minSpeechMs??300,this.endSilenceMs=e.endSilenceMs??800,this.maxMs=e.maxMs??8e3}get inSpeech(){return this.speaking}get maybeSpeech(){return this.loudSince!==null}feed(e,t){this.floor===null&&(this.floor=e);let n=e>Math.max(this.floor*Dk+Ok,kk),r=Math.min(100,Math.max(0,t-this.lastFeed));if(this.lastFeed=t,!this.speaking)return n?(this.loudSince??=t,t-this.loudSince<this.minSpeechMs?null:(this.speaking=!0,this.startedAt=this.loudSince,this.lastLoud=t,this.speechMs=t-this.loudSince,{type:`start`})):(this.loudSince=null,this.floor+=(e-this.floor)*(e<this.floor?.3:.02),null);n&&(this.lastLoud=t,this.speechMs+=r);let i=t-this.startedAt>=this.maxMs;if(!i&&t-this.lastLoud<this.endSilenceMs)return null;let a={type:`end`,ms:t-this.startedAt,speechMs:this.speechMs,forced:i};return this.speaking=!1,this.loudSince=null,i&&n&&(this.floor=e),a}reset(){this.speaking=!1,this.loudSince=null}},jk=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`],Mk=50,Nk=2e3,Pk=2e3,Fk=400,Ik=e=>{let t=e?.name;return t===`NotAllowedError`||t===`SecurityError`?`Microphone permission was denied. Allow it in the browser to use hands-free.`:t===`NotFoundError`||t===`OverconstrainedError`?`No microphone was found.`:e?.message||`Could not open the microphone.`},Lk=class{opts;stream=null;ctx=null;analyser=null;rec=null;chunks=[];recStartedAt=0;timer=null;seg;leaveSession=null;paused=!1;starting=!1;finishing=!1;opened=!1;now;constructor(e){this.opts=e,this.seg=new Ak(e),this.now=e.now??(()=>Date.now())}static supported(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`}get listening(){return this.opened}async start(){if(!(this.opened||this.starting)){this.starting=!0;try{this.leaveSession=Ek();try{this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(e){throw this.leaveSession?.(),this.leaveSession=null,Error(Ik(e))}for(let e of this.stream.getTracks())e.onended=()=>this.broke(`The microphone stopped working.`);try{this.ctx=new AudioContext,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.ctx.createMediaStreamSource(this.stream).connect(this.analyser),this.ctx.resume().catch(()=>{})}catch{throw this.release(),Error(`This browser cannot listen continuously here.`)}this.seg.reset(),this.beginRecording(),this.opened=!0,this.timer=setInterval(()=>this.tick(),Mk)}finally{this.starting=!1}}}stop(){this.opened=!1,this.release()}pause(e){this.paused!==e&&(this.paused=e,this.seg.reset(),!e&&this.opened&&this.restartRecording())}level(){if(!this.analyser)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}tick(){if(!this.opened)return;let e=this.now();if(this.ctx&&this.ctx.state!==`running`&&this.ctx.resume().catch(()=>{}),this.paused){e-this.recStartedAt>=Nk&&this.restartRecording();return}let t=this.seg.feed(this.level(),e);t?.type===`end`?this.finish(t.ms,t.speechMs):!t&&!this.seg.inSpeech&&!this.seg.maybeSpeech&&e-this.recStartedAt>=Nk&&this.restartRecording()}beginRecording(){if(!this.stream)return;let e=jk.find(e=>MediaRecorder.isTypeSupported(e));this.chunks=[];let t=new MediaRecorder(this.stream,e?{mimeType:e}:void 0);t.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},t.onerror=()=>this.broke(`The microphone stopped working.`),t.start(250),this.rec=t,this.recStartedAt=this.now()}restartRecording(){let e=this.rec;if(this.rec=null,e){e.ondataavailable=null,e.onstop=null,e.onerror=null;try{e.state!==`inactive`&&e.stop()}catch{}}this.opened&&this.beginRecording()}async finish(e,t){let n=this.rec;if(!n||this.finishing)return;this.finishing=!0;let r=n.mimeType||`audio/webm`,i=await new Promise(e=>{let t=!1,i=()=>{t||(t=!0,e(new Blob(this.chunks,{type:r})))},a=setTimeout(i,Pk);n.onstop=()=>{clearTimeout(a),i()};try{n.state===`inactive`?i():n.stop()}catch{i()}});this.finishing=!1,this.rec=null,this.opened&&(this.beginRecording(),!this.paused&&e>=Fk&&t>=Fk/2&&i.size>0&&this.opts.onUtterance(i))}broke(e){this.opened&&(this.stop(),this.opts.onError(e))}release(){if(this.timer&&clearInterval(this.timer),this.timer=null,this.rec){this.rec.ondataavailable=null,this.rec.onstop=null,this.rec.onerror=null;try{this.rec.state!==`inactive`&&this.rec.stop()}catch{}}this.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.ctx?.close().catch(()=>{}),this.stream=null,this.ctx=null,this.analyser=null,this.rec=null,this.chunks=[],this.leaveSession?.(),this.leaveSession=null}},Rk=4096,zk=8,Bk=20,Vk=6e6;function Hk(e){try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}}var Uk=class{ctx=null;analyser=null;pending=new Map;queue=[];current=null;busy=!1;gen=0;isPlaying=!1;unwatch=null;listeners=new Set;unlock(){Tk();let e=this.ensureContext();e.state!==`running`&&e.resume().catch(()=>{})}locked(){return!this.ctx||this.ctx.state!==`running`}enqueue(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>Rk)return;let t=Hk(e.data);if(!t)return;let n=this.pending.get(e.id);if(n||(this.pending.size>=zk&&this.pending.delete(this.pending.keys().next().value),n={parts:new Map,lastSeq:null,bytes:0},this.pending.set(e.id,n)),n.bytes+=t.length,n.bytes>Vk){this.pending.delete(e.id);return}if(n.parts.set(e.seq,t),e.last&&(n.lastSeq=e.seq),n.lastSeq===null||n.parts.size!==n.lastSeq+1)return;this.pending.delete(e.id);let r=new Uint8Array([...n.parts.values()].reduce((e,t)=>e+t.length,0)),i=0;for(let e=0;e<=n.lastSeq;e++){let t=n.parts.get(e);if(!t)return;r.set(t,i),i+=t.length}for(this.queue.push(r.buffer);this.queue.length>Bk;)this.queue.shift();this.pump()}stop(){this.gen++,this.queue=[],this.pending.clear(),this.busy=!1;let e=this.current;if(this.current=null,e){e.onended=null;try{e.stop()}catch{}}this.setPlaying(!1)}dispose(){this.stop(),this.ctx?.close().catch(()=>{}),this.unwatch?.(),this.unwatch=null,this.ctx=null,this.analyser=null}playing(){return this.isPlaying}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}level(){if(!this.analyser||!this.isPlaying)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}ensureContext(){if(!this.ctx){let e=window.AudioContext??window.webkitAudioContext;this.ctx=new e,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.analyser.connect(this.ctx.destination);let t=this.ctx;this.unwatch?.(),this.unwatch=xk(e=>{e&&t.state===`running`?t.suspend().catch(()=>{}):!e&&t.state!==`running`&&t.state!==`closed`&&t.resume().catch(()=>{})})}return this.ctx}setPlaying(e){this.isPlaying!==e&&(this.isPlaying=e,this.listeners.forEach(t=>t(e)))}async pump(){if(this.busy)return;let e=this.queue.shift();if(!e){this.setPlaying(!1);return}this.busy=!0;let t=this.gen;try{let n=this.ensureContext();if(n.state!==`running`){try{await n.resume()}catch{}if(t!==this.gen)return;if(n.state!==`running`){this.queue.unshift(e),this.busy=!1;return}}let r=await n.decodeAudioData(e);if(t!==this.gen)return;let i=n.createBufferSource();i.buffer=r,i.connect(this.analyser),i.onended=()=>{this.current===i&&(this.current=null,this.busy=!1,this.pump())},this.current=i,this.setPlaying(!0),i.start()}catch{if(t!==this.gen)return;this.busy=!1,this.pump()}}},Wk=e=>new Promise(t=>setTimeout(t,e)),Gk=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`],Kk=3e3;function qk(e){let t=e;return t?.name===`NotAllowedError`||t?.name===`SecurityError`?Error(`Microphone permission was denied. Allow it in the browser to talk.`):t?.name===`NotFoundError`||t?.name===`OverconstrainedError`?Error(`No microphone was found.`):Error(t?.message||`Could not open the microphone.`)}var Jk=class e{opts;stream=null;rec=null;chunks=[];ctx=null;analyser=null;timer=null;starting=!1;leaveSession=null;constructor(e={}){this.opts=e}static supported(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`}get active(){return this.rec!==null}async start(){if(!(this.rec||this.starting)){if(!e.supported())throw Error(`This browser cannot record audio here (use localhost or HTTPS).`);this.starting=!0;try{this.leaveSession=Ek();try{let e=()=>navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});try{this.stream=await e()}catch(t){if(!Ck(t))throw t;await Wk(250),this.leaveSession?.(),this.leaveSession=Ek(),this.stream=await e()}}catch(e){throw this.leaveSession?.(),this.leaveSession=null,qk(e)}try{let e=Gk.find(e=>MediaRecorder.isTypeSupported(e));this.chunks=[];let t=new MediaRecorder(this.stream,e?{mimeType:e}:void 0);t.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},t.onerror=()=>this.failed();for(let e of this.stream.getTracks())e.onended=()=>this.failed();this.openMeter(this.stream),t.start(250),this.rec=t,this.opts.maxMs&&(this.timer=setTimeout(()=>{this.timer=null,this.opts.onLimit?.()},this.opts.maxMs))}catch(e){throw this.release(),qk(e)}}finally{this.starting=!1}}}stop(){let e=this.rec;return e?new Promise(t=>{let n=!1,r=null,i=()=>{if(n)return;n=!0,r&&clearTimeout(r);let i=new Blob(this.chunks,{type:e.mimeType||`audio/webm`});this.release(),t(i)};if(r=setTimeout(i,Kk),e.onstop=i,e.state===`inactive`)return i();try{e.stop()}catch{i()}}):Promise.reject(Error(`Not recording.`))}cancel(){let e=this.rec;if(e){e.ondataavailable=null,e.onstop=null,e.onerror=null;try{e.state!==`inactive`&&e.stop()}catch{}}this.release()}level(){if(!this.analyser||!this.rec)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}failed(){this.rec&&(this.cancel(),this.opts.onError?.())}openMeter(e){try{this.ctx=new AudioContext,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.ctx.createMediaStreamSource(e).connect(this.analyser)}catch{this.analyser=null}}release(){this.timer&&clearTimeout(this.timer),this.timer=null,this.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.ctx?.close().catch(()=>{}),this.stream=null,this.rec=null,this.ctx=null,this.analyser=null,this.chunks=[],this.leaveSession?.(),this.leaveSession=null}},Yk=2e3,Xk=()=>typeof window<`u`&&window.isSecureContext===!1,Zk=50,Qk=class{deps;recorder;player;mode=`idle`;pressed=!1;disposed=!1;uploads=0;toldAboutSound=!1;abort=null;poll=null;unsubscribe;constructor(e){this.deps=e;let t=()=>this.recorderFailed();this.recorder=e.recorder??e.makeRecorder?.(t)??new Jk({maxMs:6e4,onLimit:()=>void this.pressEnd(),onError:t}),this.player=e.player??new Uk,this.unsubscribe=this.player.onChange(e=>{this.mode!==`listening`&&this.mode!==`transcribing`&&this.setMode(e?`speaking`:`idle`)})}async pressStart(){if(!(this.pressed||this.disposed)){if(!this.deps.available()){this.alert(`warn`,`Voice is not available. Run: friend voice setup`);return}if(!(this.deps.supported?.()??Jk.supported())){this.alert(`warn`,Xk()?`This page is not secure, so the browser blocks the microphone. On the PC run: friend lan https on, restart Friend, and open the https:// address.`:`This browser cannot record audio here (use localhost or HTTPS).`);return}this.pressed=!0,this.player.unlock(),this.player.playing()&&(this.deps.send({type:`voice.interrupt`}),this.player.stop());try{await this.recorder.start()}catch(e){this.pressed=!1,this.alert(`error`,e.message),this.setMode(`idle`);return}if(!this.pressed){this.recorder.cancel(),this.setMode(`idle`);return}this.setMode(`listening`)}}async pressEnd(){if(!this.pressed||(this.pressed=!1,!this.recorder.active))return;let e=await this.recorder.stop();if(e.size<Yk){this.alert(`info`,`Hold the key a little longer while you speak.`),this.setMode(`idle`);return}this.setMode(`transcribing`);let t=new AbortController;this.abort=t,this.uploads++;try{let{text:n}=await this.deps.post(e,t.signal);n.trim()||this.alert(`info`,`I didn't catch that.`)}catch(e){e.name!==`AbortError`&&this.alert(`error`,e.message)}finally{this.uploads--,this.abort===t&&(this.abort=null),this.settle()}}blur(){this.pressed&&(this.pressed=!1,this.recorder.cancel(),this.setMode(`idle`))}handleServer(e){if(e.type!==`audio.chunk`)return this.player.stop();this.player.enqueue(e),!this.toldAboutSound&&this.player.locked?.()&&(this.toldAboutSound=!0,this.deps.dispatch({type:`alert.add`,level:`info`,text:`Sound is blocked by the browser. Click or press a key once anywhere on the page to hear me.`}))}unlock(){this.player.unlock()}dispose(){this.disposed=!0,this.pressed=!1,this.stopPolling(),this.abort?.abort(),this.recorder.cancel(),this.player.stop(),this.player.dispose?.(),this.unsubscribe()}recorderFailed(){this.pressed=!1,this.recorder.cancel(),this.alert(`error`,`The microphone stopped working.`),this.setMode(`idle`)}settle(){this.uploads>0||this.mode!==`transcribing`||this.setMode(this.player.playing()?`speaking`:`idle`)}setMode(e){this.disposed||(this.mode=e,this.deps.dispatch({type:`voice.mode`,mode:e}),e===`listening`||e===`speaking`?this.startPolling():this.stopPolling())}startPolling(){this.stopPolling(),this.poll=setInterval(()=>{let e=this.mode===`listening`?this.recorder.level():this.player.level();this.deps.dispatch({type:`voice.level`,level:e})},Zk)}stopPolling(){this.poll&&clearInterval(this.poll),this.poll=null}alert(e,t){this.disposed||this.deps.dispatch({type:`alert.add`,level:e,text:t})}};function $k(e){let[t,n]=(0,l.useReducer)(DD,xD),r=(0,l.useRef)(null),i=(0,l.useRef)(null),a=(0,l.useRef)(null),o=(0,l.useRef)(null),[s,c]=(0,l.useState)(!1),u=(0,l.useRef)(e);u.current=e;let d=(0,l.useRef)(t);d.current=t,(0,l.useEffect)(()=>{let e=bD();r.current=e;let t=new Qk({send:t=>e.send(t),dispatch:e=>n(e),post:dk,available:()=>d.current.voice.available});i.current=t;let s=new vk({makeListener:e=>new Lk(e),wake:fk,command:dk,mode:()=>d.current.voice.mode,chime:mk,dispatch:e=>n(e)});o.current=s;let l=new FD({send:t=>e.send(t),dispatch:e=>n(e),enabled:()=>d.current.camera.enabled,upload:async(e,t)=>{let n=await fetch(`/api/camera/frame/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`image/jpeg`},body:t});if(!n.ok)throw Error(`upload failed (${n.status})`)}});a.current=l;let f=new ok({send:t=>e.send(t),dispatch:e=>n(e),upload:async(e,t)=>{let n=await fetch(`/api/screen/frame/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`image/jpeg`},body:t});if(!n.ok)throw Error(`upload failed (${n.status})`)}}),p=e.onMessage(e=>{n(e);let r=e?.type,i=e?.id;(r===`camera.request`||r===`camera.cancel`)&&typeof i==`string`&&l.handle({type:r,id:i}),(r===`screen.request`||r===`screen.cancel`)&&typeof i==`string`&&f.handle({type:r,id:i}),r===`audio.duck`&&dE.set(e.level??1),(r===`audio.chunk`||r===`audio.stop`)&&t.handleServer(e)}),m=e.onState(e=>{n({type:`conn`,value:e}),e!==`open`&&dE.set(1,0),e===`unauthorized`&&u.current(),e===`elsewhere`&&(s.disable(),c(!1),t.blur(),l.dispose(),f.dispose())});return()=>{p(),m(),s.disable(),o.current=null,t.dispose(),l.dispose(),f.dispose(),e.close(),i.current=null,a.current=null,r.current=null}},[]),(0,l.useEffect)(()=>{t.camera.enabled||a.current?.dispose()},[t.camera.enabled]),(0,l.useEffect)(()=>{o.current?.sync()},[t.voice.mode]);let f=(0,l.useCallback)(async e=>{let t=o.current;if(t){e?await t.enable():t.disable(),c(t.enabled);try{localStorage.setItem(`friend.handsFree`,t.enabled?`1`:`0`)}catch{}}},[]),p=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!p.current&&t.voice.available){p.current=!0;try{localStorage.getItem(`friend.handsFree`)===`1`&&Lk.supported()&&f(!0)}catch{}}},[t.voice.available,f]);let m=(0,l.useMemo)(()=>({on:s,supported:Lk.supported(),toggle:()=>void f(!o.current?.enabled)}),[s,f]),h=(0,l.useCallback)(e=>r.current?.send(e),[]);return ck(t.voice.mode,h),{state:t,send:h,dispatch:(0,l.useCallback)(e=>n(e),[]),voice:(0,l.useMemo)(()=>({pressStart:()=>void i.current?.pressStart(),pressEnd:()=>void i.current?.pressEnd(),blur:()=>i.current?.blur(),unlock:()=>i.current?.unlock()}),[]),handsFree:m,useHere:(0,l.useCallback)(()=>r.current?.takeOver(),[])}}var eA={401:`Please sign in again.`,403:`Incorrect PIN.`,413:`That recording was too long.`,429:`Too many attempts. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function tA(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||eA[n.status]||`The request failed (${n.status}).`)}return await n.json()}var nA=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),rA={state:()=>tA(`/api/voice/enroll`,{}),sample:e=>tA(`/api/voice/enroll/sample`,{method:`POST`,headers:{"content-type":e.type||`audio/webm`},body:e}),finish:e=>tA(`/api/voice/enroll/finish`,nA(`POST`,{pin:e})),cancel:async()=>{await tA(`/api/voice/enroll/cancel`,nA(`POST`,{}))},remove:async e=>{await tA(`/api/voice/enroll`,nA(`DELETE`,{pin:e}))}},iA=[`Friend, good evening. It is a pleasant day to get things done.`,`Open my projects and show me what changed today.`,`My voice is my key, so please remember it well.`,`Check the weather and read me the latest headlines.`,`Always protect the boss, and never trust a stranger.`],aA=15e3;function oA({api:e=rA,createRecorder:t=e=>new Jk(e),onClose:n,who:r}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),[f,m]=(0,l.useState)(`record`),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(``),C=(0,l.useRef)(!0),w=(0,l.useRef)(null);(0,l.useEffect)(()=>(C.current=!0,e.state().then(e=>{C.current&&(a(e),s(e.samples))}).catch(e=>C.current&&b(e.message)),()=>{C.current=!1,w.current?.cancel(),w.current=null}),[e]);let E=(0,l.useCallback)(async()=>{let t=w.current;if(t){w.current=null,g(!1),v(!0);try{let n=await t.stop(),r=await e.sample(n);if(!C.current)return;s(r.count),u(r.note)}catch(e){C.current&&b(e.message)}finally{C.current&&v(!1)}}},[e]),D=async()=>{b(null),u(null);let e=t({maxMs:aA,onLimit:()=>void E(),onError:()=>{w.current=null,C.current&&(g(!1),b(`The microphone stopped working. Try again.`))}});try{await e.start()}catch(e){C.current&&b(e.message);return}if(!C.current)return e.cancel();w.current=e,g(!0)},O=async e=>{b(null),v(!0);try{await e()}catch(e){C.current&&b(e.message)}finally{C.current&&(v(!1),S(``))}},k=async()=>{w.current?.cancel(),w.current=null,await e.cancel().catch(()=>{}),n()},A=i?.min??3,j=o%iA.length,ee=o<iA.length?`Phrase ${o+1} of ${iA.length}`:`Extra recording (${o} so far)`;return(0,p.jsxs)(`div`,{className:`approval enroll glass`,role:`dialog`,"aria-label":`Voice enrollment`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:r?`Teach Friend ${r}'s voice`:`Teach Friend your voice`})}),f===`record`&&(0,p.jsxs)(p.Fragment,{children:[!r&&i?.enrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Your voice is already saved. Saving a new one replaces it.`}),r&&(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Hand the device to `,r,`. `,r,` reads each sentence aloud, close to the microphone, in a quiet room.`]}),(0,p.jsxs)(`p`,{className:`auth-note`,children:[ee,`. Press Record, read this aloud in a quiet room, then press Stop.`]}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`enroll-phrase`,style:{whiteSpace:`pre-wrap`},children:iA[j]}),(0,p.jsxs)(`div`,{role:`status`,className:`auth-note`,children:[o,` recorded`,o>=A?` — enough to save`:` — at least ${A} needed`,`.`,c?` ${c}`:``]}),y&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:y}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[h?(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>void E(),children:`Stop`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:_||!i||o>=(i?.max??8),onClick:()=>void D(),children:_?`Uploading…`:`Record`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:h||_||o<A,onClick:()=>m(`pin-save`),children:r?`Save ${r}'s voice`:`Save my voice`}),!r&&i?.enrolled&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:h||_,onClick:()=>m(`pin-delete`),children:`Delete my voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>void k(),children:`Cancel`})]})]}),(f===`pin-save`||f===`pin-delete`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:f===`pin-save`?r?`Enter your PIN to save ${r}'s voice.`:`Enter your PIN to save your voice.`:`Enter your PIN to delete your saved voice.`}),(0,p.jsx)(T,{pin:x,onChange:S,onSubmit:f===`pin-save`?()=>!_&&void O(async()=>{await e.finish(x),C.current&&m(`saved`)}):void 0}),y&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:y}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[f===`pin-save`?(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:_||x.length<6,onClick:()=>void O(async()=>{await e.finish(x),C.current&&m(`saved`)}),children:`Save`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:_||x.length<6,onClick:()=>void O(async()=>{await e.remove(x),C.current&&m(`deleted`)}),children:`Delete`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{S(``),b(null),m(`record`)},children:`Back`})]})]}),(f===`saved`||f===`deleted`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:f===`saved`?r?`${r}'s voice is saved. From now on I will know when ${r} is talking.`:`Your voice is saved. From now on I will tell you apart from other speakers.`:`Your voice was deleted. Every voice is treated as yours until you enroll again.`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:n,children:`Done`})})]})]})}var sA=new Set([`INPUT`,`TEXTAREA`,`SELECT`,`BUTTON`,`A`,`SUMMARY`]),cA=new Set([`button`,`checkbox`,`switch`,`tab`,`menuitem`,`link`,`radio`,`option`,`textbox`,`combobox`,`slider`]),lA=e=>e instanceof HTMLElement&&(sA.has(e.tagName)||e.isContentEditable||cA.has(e.getAttribute(`role`)??``)),uA=e=>e.code===`Space`||e.key===` `;function dA(e){let t=(0,l.useRef)(e);t.current=e,(0,l.useEffect)(()=>{let e=!1,n=n=>{!uA(n)||n.ctrlKey||n.metaKey||n.altKey||lA(n.target)||lA(document.activeElement)||(n.preventDefault(),!(n.repeat||e)&&(e=!0,t.current.pressStart()))},r=n=>{uA(n)&&e&&(e=!1,n.preventDefault(),t.current.pressEnd())},i=()=>{e=!1,t.current.blur()},a=()=>{document.hidden&&i()};return window.addEventListener(`keydown`,n),window.addEventListener(`keyup`,r),window.addEventListener(`blur`,i),document.addEventListener(`visibilitychange`,a),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`keyup`,r),window.removeEventListener(`blur`,i),document.removeEventListener(`visibilitychange`,a)}},[])}function fA(e){let t=(0,l.useRef)(e);t.current=e,(0,l.useEffect)(()=>{let e=()=>t.current.unlock(),n=[`pointerdown`,`keydown`,`touchend`];for(let t of n)window.addEventListener(t,e,{passive:!0});return()=>{for(let t of n)window.removeEventListener(t,e)}},[])}function pA({onUseHere:e}){return(0,p.jsx)(`div`,{className:`elsewhere`,role:`alertdialog`,"aria-labelledby":`elsewhere-title`,"data-testid":`elsewhere`,children:(0,p.jsxs)(`div`,{className:`elsewhere-card`,children:[(0,p.jsx)(`h2`,{id:`elsewhere-title`,children:`Friend is open in another window`}),(0,p.jsx)(`p`,{children:`Friend works in one window at a time. Click “Use here” to use it in this window instead; the other one will stop.`}),(0,p.jsx)(`button`,{type:`button`,className:`elsewhere-btn`,onClick:e,autoFocus:!0,children:`Use here`})]})})}function mA(e,t,n){let r=Math.max(100,Math.round(e)),i=Math.max(100,Math.round(t));return{width:r,height:i,kind:r<=599?`phone`:n||r<1024?`tablet`:`desktop`,orientation:i>r?`portrait`:`landscape`,touch:n}}var hA=()=>typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches;function gA(){return mA(window.innerWidth,window.innerHeight,hA())}var _A=(e,t)=>!!e&&e.width===t.width&&e.height===t.height&&e.kind===t.kind&&e.orientation===t.orientation&&e.touch===t.touch;function vA(e,t){let n=(0,l.useRef)(null),r=(0,l.useRef)(e);r.current=e,(0,l.useEffect)(()=>{if(t!==`open`){n.current=null;return}let e=()=>{let e=gA();_A(n.current,e)||(n.current=e,r.current({type:`ui.screen`,...e}))};e();let i=null,a=()=>{i&&clearTimeout(i),i=setTimeout(e,400)};return window.addEventListener(`resize`,a),window.addEventListener(`orientationchange`,a),()=>{i&&clearTimeout(i),window.removeEventListener(`resize`,a),window.removeEventListener(`orientationchange`,a)}},[t])}var yA={401:`Please sign in again.`,403:`Incorrect PIN.`,413:`That recording was too long.`,429:`Too many attempts. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function bA(e,t={}){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||yA[n.status]||`The request failed (${n.status}).`)}return await n.json()}var xA=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),SA={overview:()=>bA(`/api/voice/people`),begin:e=>bA(`/api/voice/people/begin`,xA(`POST`,{name:e})),recording:{state:async()=>(await bA(`/api/voice/people`)).enrolling??{enrolled:!1,samples:0,min:3,max:8},sample:e=>bA(`/api/voice/people/sample`,{method:`POST`,headers:{"content-type":e.type||`audio/webm`},body:e}),finish:e=>bA(`/api/voice/people/finish`,xA(`POST`,{pin:e})),cancel:async()=>{await bA(`/api/voice/people/cancel`,xA(`POST`,{}))},remove:async()=>{}},removePerson:async(e,t)=>{await bA(`/api/voice/people/${e}`,xA(`DELETE`,{pin:t}))}};function CA({api:e=SA,createRecorder:t,onClose:n}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)({kind:`list`}),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(``),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(null),v=(0,l.useRef)(!0),y=(0,l.useCallback)(()=>{e.overview().then(e=>v.current&&i(e)).catch(e=>v.current&&_(e.message))},[e]);(0,l.useEffect)(()=>(v.current=!0,y(),()=>{v.current=!1}),[y]);let b=async()=>{_(null),h(!0);try{let t=await e.begin(s.trim());v.current&&o({kind:`record`,name:t.name})}catch(e){v.current&&_(e.message)}finally{v.current&&h(!1)}},x=async t=>{_(null),h(!0);try{if(await e.removePerson(t.id,u),!v.current)return;o({kind:`list`}),y()}catch(e){v.current&&_(e.message)}finally{v.current&&(h(!1),f(``))}};return a.kind===`record`?(0,p.jsx)(oA,{api:e.recording,who:a.name,...t?{createRecorder:t}:{},onClose:()=>{c(``),o({kind:`list`}),y()}}):(0,p.jsxs)(`div`,{className:`approval enroll glass`,role:`dialog`,"aria-label":`Family voices`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Family voices`})}),a.kind===`list`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend knows your voice. Add the people at home, so it knows who is talking and answers them by name. They can chat and ask for the weather, but cannot use your PC or see your private things.`}),r&&!r.ownerEnrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`First teach Friend your own voice (Esc, then Enroll my voice).`}),r&&r.people.length===0&&r.ownerEnrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nobody added yet.`}),r&&r.people.length>0&&(0,p.jsx)(`ul`,{className:`household-list`,"aria-label":`People Friend knows`,children:r.people.map(e=>(0,p.jsxs)(`li`,{className:`household-row`,children:[(0,p.jsx)(`span`,{children:e.name}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>o({kind:`remove`,person:e}),"aria-label":`Remove ${e.name}`,children:`Remove`})]},e.id))}),r&&r.ownerEnrolled&&r.people.length<r.max&&(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Add a person`}),(0,p.jsx)(`input`,{value:s,maxLength:40,placeholder:`Name, for example Priya`,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s.trim()&&!m&&void b()})]}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[r&&r.ownerEnrolled&&r.people.length<r.max&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m||!s.trim(),onClick:()=>void b(),children:`Record their voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:n,children:`Close`})]})]}),a.kind===`remove`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN to remove `,a.person.name,`’s voice. Friend will treat their voice as a stranger’s.`]}),(0,p.jsx)(T,{pin:u,onChange:f}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:m||u.length<6,onClick:()=>void x(a.person),children:`Remove`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{f(``),_(null),o({kind:`list`})},children:`Back`})]})]})]})}var wA=`▌▍▎▏█▓▒░<>/\\|+-=*#%&0123456789ABCDEF`;function TA(e,t,n=Math.random){let r=[...e];if(t>=1)return e;let i=Math.floor(r.length*Math.max(0,t));return r.map((e,t)=>t<i||e===` `?e:wA[Math.floor(n()*36)]).join(``)}var EA=e=>e.length===0?0:Math.min(24,Math.max(6,Math.ceil([...e].length/2)));function DA(e,t){let[n,r]=(0,l.useState)(e),i=(0,l.useRef)(e);return(0,l.useEffect)(()=>{if(!t||e===i.current){i.current=e,r(e);return}i.current=e;let n=EA(e);if(n===0){r(e);return}let a=0,o=setInterval(()=>{a++,r(TA(e,a/n)),a>=n&&clearInterval(o)},320/n);return()=>clearInterval(o)},[e,t]),n}function OA(e){let t=e.currentTarget,n=t.getBoundingClientRect(),r=document.createElement(`span`);r.className=`hud-ripple`;let i=Math.max(n.width,n.height)*2;r.style.width=r.style.height=`${i}px`,r.style.left=`${e.clientX-n.left-i/2}px`,r.style.top=`${e.clientY-n.top-i/2}px`,t.appendChild(r),r.addEventListener(`animationend`,()=>r.remove(),{once:!0}),setTimeout(()=>r.remove(),900)}function kA({items:e,animations:t,onAction:n}){let[r,i]=(0,l.useState)(null),a=(0,l.useRef)(void 0);if((0,l.useEffect)(()=>()=>clearTimeout(a.current),[]),e.length===0)return null;let o=e=>{t!==`off`&&(i(e.id),clearTimeout(a.current),a.current=setTimeout(()=>i(null),650)),n(e)};return(0,p.jsxs)(he,{id:`launcher`,label:`Quick launch`,wholeBox:!0,testId:`launcher`,className:`hud hud-launcher${t===`full`?` hud-boot`:``}`,children:[(0,p.jsx)(`div`,{className:`hud-kicker`,children:`Quick launch`}),(0,p.jsx)(`ul`,{className:`hud-stack`,children:e.map((e,n)=>(0,p.jsx)(`li`,{className:`hud-tab hud-cut${r===e.id?` engaged`:``}${t===`full`?` hud-boot`:``}`,style:{"--i":n+1},children:(0,p.jsxs)(`button`,{type:`button`,className:`hud-tab-main`,"aria-label":e.label,onPointerDown:t===`off`?void 0:OA,onClick:()=>o(e),children:[(0,p.jsx)(`span`,{className:`hud-icon`,"aria-hidden":`true`,children:e.icon}),(0,p.jsx)(`span`,{className:`hud-tab-label`,children:e.label}),(0,p.jsx)(`span`,{className:`hud-tab-engaged`,"aria-hidden":`true`,children:`ENGAGED`}),(0,p.jsx)(`span`,{className:`hud-sweep`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`hud-scan`,"aria-hidden":`true`})]})},e.id))})]})}var AA=(e,t=18)=>(0,p.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e}),jA=()=>AA((0,p.jsx)(`path`,{d:`M7 4.5v15l12-7.5z`,fill:`currentColor`})),MA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`rect`,{x:`6`,y:`4.5`,width:`4`,height:`15`,fill:`currentColor`}),(0,p.jsx)(`rect`,{x:`14`,y:`4.5`,width:`4`,height:`15`,fill:`currentColor`})]})),NA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M5 5v14l10-7z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M18 5v14`})]})),PA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M19 5v14L9 12z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M6 5v14`})]})),FA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M3 7h3.5c3 0 4 2 5.5 5s2.500 5 5.500 5H21`}),(0,p.jsx)(`path`,{d:`M3 17h3.5c1.500 0 2.500-.6 3.400-1.800M13.500 8.800C14.500 7.600 15.500 7 17 7h4`}),(0,p.jsx)(`path`,{d:`m18.500 4.500 2.500 2.500-2.500 2.500M18.500 14.500l2.500 2.500-2.500 2.500`})]})),IA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M17 3l3 3-3 3`}),(0,p.jsx)(`path`,{d:`M4 11V9a3 3 0 0 1 3-3h13M7 21l-3-3 3-3`}),(0,p.jsx)(`path`,{d:`M20 13v2a3 3 0 0 1-3 3H4`})]})),LA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M4 9.500v5h3.500L12 18.500v-13L7.500 9.500z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M15.500 9a4 4 0 0 1 0 6M18 6.500a7.500 7.500 0 0 1 0 11`})]})),RA=()=>AA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M4 9.500v5h3.500L12 18.500v-13L7.500 9.500z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`m16 9 5 6M21 9l-5 6`})]})),zA=()=>AA((0,p.jsx)(`path`,{d:`M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5`})),BA=()=>AA((0,p.jsx)(`path`,{d:`M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5`})),VA=()=>AA((0,p.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})),HA=()=>AA((0,p.jsx)(`path`,{d:`M9 18V6l10-2v12`}),22),UA=56,WA=()=>({bars:new Float32Array(UA),bass:0,left:0,right:0});function GA(e,t,n,r,i){let a=n?.82:.9;if(t&&n){t.getByteFrequencyData(i);let n=Math.min(i.length,96);for(let t=0;t<UA;t++){let r=Math.min(n-1,Math.floor((t/UA)**1.6*n));e.bars[t]=Math.max((i[r]??0)/255,e.bars[t]*a)}}else if(n)for(let t=0;t<UA;t++)e.bars[t]=Math.max(.12+.28*Math.abs(Math.sin(r/420+t*.55)*Math.cos(r/900+t*.21)),e.bars[t]*a);else for(let t=0;t<UA;t++)e.bars[t]=e.bars[t]*a;let o=0;for(let t=0;t<6;t++)o+=e.bars[t];e.bass=Math.min(1,o/6*1.15);let s=0,c=0;for(let t=0;t<UA/2;t++)s+=e.bars[t],c+=e.bars[t+UA/2];e.left=Math.min(1,s/(UA/2)*1.6),e.right=Math.min(1,c/(UA/2)*3.2)}function KA({progress:e,playing:t,cover:n,analyser:r,levels:i,visualizer:a,animate:o,size:s}){let c=(0,l.useRef)(null),u=(0,l.useRef)(null),d=(0,l.useRef)(new Uint8Array(new ArrayBuffer(128)));(0,l.useEffect)(()=>{let e=c.current,n=e?.getContext(`2d`);if(!e||!n||!o)return;let l=0,f=Math.min(2,window.devicePixelRatio||1);e.width=e.height=Math.round(s*f);let p=getComputedStyle(e).getPropertyValue(`--accent`).trim()||`#3fd8ff`,m=e=>{if(GA(i,r,t,e,d.current),u.current?.style.setProperty(`--bass`,i.bass.toFixed(3)),n.setTransform(f,0,0,f,0,0),n.clearRect(0,0,s,s),a){let e=s/2,t=s*.335,r=s*.135;n.lineCap=`round`,n.lineWidth=Math.max(1.5,s/90);for(let a=0;a<UA;a++){let o=a/UA*Math.PI*2-Math.PI/2,s=i.bars[a],c=2+s*r;n.strokeStyle=p,n.globalAlpha=.35+s*.65,n.beginPath(),n.moveTo(e+Math.cos(o)*t,e+Math.sin(o)*t),n.lineTo(e+Math.cos(o)*(t+c),e+Math.sin(o)*(t+c)),n.stroke()}n.globalAlpha=1}(t||!i.bars.every(e=>e<.01)||a)&&(l=requestAnimationFrame(m))};return l=requestAnimationFrame(m),()=>cancelAnimationFrame(l)},[r,t,a,o,s,i]);let f=Math.max(0,Math.min(1,e))*100;return(0,p.jsxs)(`div`,{ref:u,className:`hud-dial${t?` playing`:``}`,style:{width:s,height:s},role:`img`,"aria-label":`Playback dial`,children:[(0,p.jsxs)(`svg`,{className:`hud-dial-svg`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{className:`hud-dial-ticks`,cx:`100`,cy:`100`,r:`96`}),(0,p.jsx)(`circle`,{className:`hud-dial-track`,cx:`100`,cy:`100`,r:`88`}),(0,p.jsx)(`circle`,{className:`hud-dial-arc`,cx:`100`,cy:`100`,r:`88`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 100 100)`}),(0,p.jsx)(`circle`,{className:`hud-dial-inner`,cx:`100`,cy:`100`,r:`62`}),(0,p.jsxs)(`g`,{className:`hud-needle`,children:[(0,p.jsx)(`line`,{x1:`100`,y1:`100`,x2:`100`,y2:`14`}),(0,p.jsx)(`circle`,{cx:`100`,cy:`14`,r:`2.500`})]})]}),(0,p.jsx)(`canvas`,{ref:c,className:`hud-spectrum`,style:{width:s,height:s},"aria-hidden":`true`}),(0,p.jsx)(`div`,{className:`hud-cover`,style:n?{backgroundImage:`url("${n}")`}:void 0,children:!n&&(0,p.jsx)(HA,{})})]})}var qA=e=>{let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},JA=new Map,YA=e=>{let t=Su(e);return t&&t.source===`local`?t.id:null},XA=e=>Su(e)?.source===`spotify`,ZA=e=>Su(e)?.source===`soundcloud`,QA=e=>Su(e)?.source===`audius`,$A={spotify:`Spotify`,soundcloud:`SoundCloud`,audius:`Audius`};function ej(e){let[t,n]=(0,l.useState)(e?JA.get(e)??!1:!1);return(0,l.useEffect)(()=>{if(!e)return n(!1);if(JA.has(e))return n(JA.get(e));let t=!0,r=new Image;r.onload=()=>{JA.set(e,!0),t&&n(!0)},r.onerror=()=>{JA.set(e,!1),t&&n(!1)};let i=YA(e);return i?(r.src=`/api/music/cover/${i}`,()=>{t=!1}):n(!1)},[e]),e&&t?`/api/music/cover/${YA(e)}`:null}async function tj(e,t){let n=await fetch(`/api/music/library?q=${encodeURIComponent(e)}&limit=${t}`);return n.ok?await n.json():{tracks:[],total:0}}function nj(){let[e,t]=(0,l.useState)(null);return(0,l.useEffect)(()=>{let e=!0;return fetch(`/api/music/sources`).then(e=>e.ok?e.json():null).then(n=>{let r={};for(let e of[`spotify`,`soundcloud`,`audius`]){let t=n?.sources?.find(t=>t.id===e)?.status;t&&(r[e]={connected:t.connected,needs:t.needs})}e&&n&&t(r)}).catch(()=>{}),()=>{e=!1}},[]),e}async function rj(e,t,n){let r=await fetch(`/api/music/search?q=${encodeURIComponent(t)}&source=${e}&limit=${n}`);if(!r.ok)return{tracks:[],total:0};let i=((await r.json()).tracks??[]).map(e=>({id:e.ref,title:e.title,artist:e.artist,album:e.album,durationSec:e.durationSec}));return{tracks:i,total:i.length}}var ij=e=>({id:e.id,title:e.title,artist:e.artist,album:e.album,durationSec:e.durationSec});function aj({levels:e,animate:t,side:n}){let r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!t)return;let i=0,a=r.current,o=()=>{if(a){let t=n===`left`?e.left:e.right,r=Math.round(t*12);a.querySelectorAll(`i`).forEach((e,t)=>e.classList.toggle(`on`,t<r))}i=requestAnimationFrame(o)};return i=requestAnimationFrame(o),()=>cancelAnimationFrame(i)},[e,t,n]),(0,p.jsx)(`div`,{ref:r,className:`hud-levels ${n}`,"aria-hidden":`true`,children:Array.from({length:12},(e,t)=>(0,p.jsx)(`i`,{},t))})}function oj({player:e,anim:t}){let{state:n,dispatch:r}=e,i=(0,l.useCallback)(async()=>{if(n.queue.length>0)return r({type:`resume`});let e=await tj(``,500);r({type:`play`,tracks:e.tracks.map(ij),mode:`replace`,...n.shuffle?{shuffle:!0}:{}})},[n.queue.length,n.shuffle,r]),a=e=>n=>{t!==`off`&&OA(n),e()};return(0,p.jsxs)(`div`,{className:`hud-controls`,role:`group`,"aria-label":`Player controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Shuffle`,"aria-pressed":n.shuffle,title:`Shuffle`,onClick:()=>r({type:`shuffle`}),children:(0,p.jsx)(FA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Previous track`,title:`Previous`,onPointerDown:a(()=>{}),onClick:()=>r({type:`previous`}),children:(0,p.jsx)(PA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn hud-btn-main`,"aria-label":n.playing?`Pause`:`Play`,title:n.playing?`Pause`:`Play`,onPointerDown:a(()=>{}),onClick:()=>n.playing?r({type:`pause`}):void i(),children:n.playing?(0,p.jsx)(MA,{}):(0,p.jsx)(jA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Next track`,title:`Next`,onPointerDown:a(()=>{}),onClick:()=>r({type:`next`}),children:(0,p.jsx)(NA,{})}),(0,p.jsxs)(`button`,{type:`button`,className:`hud-btn${n.repeat===`off`?``:` on`}`,"aria-label":`Repeat: ${n.repeat}`,title:`Repeat: ${n.repeat}`,onClick:()=>r({type:`repeat`,mode:n.repeat===`off`?`all`:n.repeat===`all`?`one`:`off`}),children:[(0,p.jsx)(IA,{}),n.repeat===`one`&&(0,p.jsx)(`sup`,{children:`1`})]})]})}function sj({player:e}){let{state:t,dispatch:n}=e,r=t.duration>0?t.position/t.duration*100:0;return(0,p.jsxs)(`div`,{className:`hud-timeline`,children:[(0,p.jsx)(`span`,{className:`hud-time`,children:qA(t.position)}),(0,p.jsx)(`input`,{type:`range`,className:`hud-range`,"aria-label":`Position`,min:0,max:Math.max(1,Math.floor(t.duration)),step:1,value:Math.min(Math.floor(t.position),Math.max(1,Math.floor(t.duration))),style:{"--fill":`${r}%`},disabled:t.duration<=0,onChange:e=>n({type:`seek`,seconds:Number(e.target.value)})}),(0,p.jsxs)(`span`,{className:`hud-time`,children:[`-`,qA(Math.max(0,t.duration-t.position))]})]})}function cj({player:e}){let{state:t,dispatch:n}=e;return(0,p.jsxs)(`div`,{className:`hud-volume`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":t.muted?`Unmute`:`Mute`,onClick:()=>n({type:`mute`}),children:t.muted||t.volume===0?(0,p.jsx)(RA,{}):(0,p.jsx)(LA,{})}),(0,p.jsx)(`input`,{type:`range`,className:`hud-range`,"aria-label":`Volume`,min:0,max:100,value:t.muted?0:t.volume,style:{"--fill":`${t.muted?0:t.volume}%`},onChange:e=>n({type:`volume`,level:Number(e.target.value)})})]})}function lj({player:e,anim:t}){let{state:n,dispatch:r}=e,[i,a]=(0,l.useState)(n.queue.length?`queue`:`library`),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(`folder`),[d,f]=(0,l.useState)(null),m=nj(),h=[`spotify`,`soundcloud`,`audius`].filter(e=>m?.[e]?.connected),g=c!==`folder`&&h.includes(c)?c:null,_=g?m?.[g]?.needs:null;(0,l.useEffect)(()=>{if(i!==`library`)return;let e=!0;if(g&&!o.trim()){f(null);return}let t=()=>g?rj(g,o.trim(),30):tj(o,100),n=setTimeout(()=>void t().then(t=>e&&f(t)),o?250:0);return()=>{e=!1,clearTimeout(n)}},[i,o,g]);let v=i===`queue`?n.queue.map((e,t)=>({track:e,index:t})):(d?.tracks??[]).map((e,t)=>({track:ij(e),index:t}));return(0,p.jsxs)(`div`,{className:`hud-playlist`,children:[(0,p.jsxs)(`div`,{className:`hud-tabs`,role:`tablist`,children:[[`queue`,`library`].map(e=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,className:`hud-chip${i===e?` on`:``}`,onClick:()=>a(e),children:e===`queue`?`Queue (${n.queue.length})`:`Library`},e)),i===`queue`&&n.queue.length>0&&(0,p.jsx)(`button`,{type:`button`,className:`hud-chip`,onClick:()=>r({type:`clear`}),children:`Clear`})]}),i===`library`&&h.length>0&&(0,p.jsx)(`div`,{className:`hud-tabs`,role:`tablist`,"aria-label":`Where to look`,children:[`folder`,...h].map(e=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":c===e,className:`hud-chip${c===e?` on`:``}`,onClick:()=>{u(e),f(null)},children:e===`folder`?`Folder`:$A[e]},e))}),i===`library`&&(0,p.jsx)(`input`,{className:`hud-search`,type:`search`,placeholder:`Search title, artist or album`,"aria-label":`Search the music`,value:o,onChange:e=>s(e.target.value)}),(0,p.jsxs)(`ul`,{className:`hud-list`,children:[v.length===0&&(0,p.jsx)(`li`,{className:`hud-empty`,children:i===`queue`?`The queue is empty.`:g&&!o.trim()?`Type to search ${$A[g]}.`:d?`No music matches.`:`Loading…`}),i===`library`&&g&&_&&(0,p.jsx)(`li`,{className:`hud-empty`,children:_}),v.map(({track:e,index:a},o)=>{let s=i===`queue`&&a===n.index;return(0,p.jsxs)(`li`,{className:`hud-tab hud-cut${s?` current`:``}${t===`full`?` hud-boot`:``}`,style:{"--i":Math.min(o,12)},children:[(0,p.jsxs)(`button`,{type:`button`,className:`hud-tab-main`,"aria-current":s?`true`:void 0,onPointerDown:t===`off`?void 0:OA,onClick:()=>r(i===`queue`?{type:`jump`,index:a}:{type:`play`,tracks:(d?.tracks??[]).map(ij),mode:`replace`,start:a}),children:[(0,p.jsx)(`span`,{className:`hud-tab-title`,children:e.title}),(0,p.jsxs)(`small`,{children:[e.artist||e.album,XA(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SPOTIFY`}),ZA(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SOUNDCLOUD`}),QA(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`AUDIUS`})]})]}),i===`library`&&(0,p.jsx)(`button`,{type:`button`,className:`hud-mini`,"aria-label":`Add ${e.title} to the queue`,title:`Add to the queue`,onClick:()=>r({type:`play`,tracks:[e],mode:`add`}),children:`+`}),i===`queue`&&(0,p.jsx)(`button`,{type:`button`,className:`hud-mini`,"aria-label":`Remove ${e.title} from the queue`,title:`Remove`,onClick:()=>r({type:`remove`,index:a}),children:`×`})]},`${e.id}-${a}`)})]})]})}function uj({player:e,music:t,animations:n}){let{state:r,dispatch:i,current:a,blocked:o,notice:s,analyser:c,unlock:u}=e,d=(0,l.useMemo)(WA,[]),f=ej(a?.id),m=r.view===`full`,h=DA(a?.title??``,n===`full`);if(!t?.folderSet||r.view===`hidden`)return null;let g=r.duration>0?r.position/r.duration:0,_=n!==`off`;return(0,p.jsxs)(he,{id:`music`,label:`Music player`,wholeBox:!0,testId:`music`,className:`hud hud-music hud-cut ${m?`full`:`mini`}${r.playing?` playing`:``}${n===`full`?` hud-boot`:``}`,children:[(0,p.jsxs)(`header`,{className:`hud-music-head`,children:[(0,p.jsx)(`span`,{className:`hud-kicker`,children:`Media player`}),(0,p.jsxs)(`span`,{className:`hud-head-actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":m?`Smaller player`:`Bigger player`,title:m?`Smaller`:`Bigger`,onClick:()=>i({type:`view`,view:m?`mini`:`full`}),children:m?(0,p.jsx)(BA,{}):(0,p.jsx)(zA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Hide the player`,title:`Hide (the music keeps playing)`,onClick:()=>i({type:`view`,view:`hidden`}),children:(0,p.jsx)(VA,{})})]})]}),(0,p.jsxs)(`div`,{className:`hud-music-body`,children:[(0,p.jsxs)(`div`,{className:`hud-music-left`,children:[m&&(0,p.jsx)(aj,{levels:d,animate:_,side:`left`}),(0,p.jsx)(KA,{progress:g,playing:r.playing,cover:f,analyser:c,levels:d,visualizer:t.visualizer,animate:_,size:m?250:112}),m&&(0,p.jsx)(aj,{levels:d,animate:_,side:`right`})]}),(0,p.jsxs)(`div`,{className:`hud-music-main`,children:[(0,p.jsxs)(`div`,{className:`hud-now`,"aria-live":`polite`,children:[(0,p.jsx)(`b`,{className:`hud-title`,children:a?h:`Nothing playing`}),(0,p.jsxs)(`small`,{className:`hud-sub`,children:[a?[a.artist,a.album].filter(Boolean).join(` — `):`Press play, or ask for some music.`,a&&XA(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SPOTIFY`}),a&&ZA(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SOUNDCLOUD`}),a&&QA(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`AUDIUS`}),e.remote&&(0,p.jsx)(`em`,{className:`hud-source`,children:`THIS PC`})]})]}),(0,p.jsx)(sj,{player:e}),(0,p.jsx)(oj,{player:e,anim:n}),m&&(0,p.jsx)(cj,{player:e}),s&&(0,p.jsx)(`p`,{className:`hud-notice`,role:`status`,children:s}),o&&(0,p.jsx)(`button`,{type:`button`,className:`hud-unlock`,onClick:u,children:`Tap to enable sound`})]}),m&&(0,p.jsx)(lj,{player:e,anim:n})]})]})}var dj=/^spotify:/,fj=class{local;makeSpotify;active;spotify=null;listeners=new Map;wrapped=new Map;vol=1;mute=!1;pre=``;constructor(e,t){this.local=e,this.makeSpotify=t,this.active=e}get element(){return this.local}get error(){return this.active.error??null}wrap(e){let t=this.wrapped.get(e);return t||(t={local:()=>{this.active===this.local&&e()},spot:()=>{this.spotify&&this.active===this.spotify&&e()}},this.wrapped.set(e,t)),t}spot(){if(!this.spotify){let e=this.makeSpotify();e.volume=this.vol,e.muted=this.mute,e.preload=this.pre;for(let[t,n]of this.listeners)for(let r of n)e.addEventListener(t,this.wrap(r).spot);this.spotify=e}return this.spotify}dispose(){this.spotify?.dispose?.(),this.spotify=null,this.active=this.local}get src(){return this.active.src}set src(e){let t=dj.test(e)?this.spot():this.local;t===this.active?e===``&&this.active.pause():(this.active.pause(),this.active=t),this.active.src=e}get currentTime(){return this.active.currentTime}set currentTime(e){this.active.currentTime=e}get duration(){return this.active.duration}get paused(){return this.active.paused}get volume(){return this.vol}set volume(e){this.vol=e,this.local.volume=e,this.spotify&&(this.spotify.volume=e)}get muted(){return this.mute}set muted(e){this.mute=e,this.local.muted=e,this.spotify&&(this.spotify.muted=e)}get preload(){return this.pre}set preload(e){this.pre=e,this.local.preload=e,this.spotify&&(this.spotify.preload=e)}play(){return this.active.play()}pause(){this.active.pause()}addEventListener(e,t){let n=this.listeners.get(e);n||this.listeners.set(e,n=new Set),n.add(t);let r=this.wrap(t);this.local.addEventListener(e,r.local),this.spotify?.addEventListener(e,r.spot)}removeEventListener(e,t){this.listeners.get(e)?.delete(t);let n=this.wrap(t);this.local.removeEventListener(e,n.local),this.spotify?.removeEventListener(e,n.spot)}},pj=/^spotify:([A-Za-z0-9_-]{1,64})$/,mj=`Spotify Premium is needed to play on this screen.`;async function hj(){let e=await fetch(`/api/music/spotify/token`,{cache:`no-store`});if(!e.ok)throw Error(`Spotify is not connected.`);return(await e.json()).accessToken}function gj(){let e=window;return e.Spotify?Promise.resolve(e.Spotify):new Promise((t,n)=>{e.onSpotifyWebPlaybackSDKReady=()=>e.Spotify?t(e.Spotify):n(Error(`no sdk`));let r=document.createElement(`script`);r.src=`https://sdk.scdn.co/spotify-player.js`,r.async=!0,r.onerror=()=>n(Error(`blocked`)),document.head.appendChild(r)})}function _j(e){let t=e.fetch??((...e)=>fetch(...e)),n=e.now??Date.now,r=new Map,i=null,a=null,o=null,s=null,c=!1,l=null,u=null,d=0,f=0,p=0,m=!0,h=1,g=!1,_,v=e=>{for(let t of r.get(e)??[])t()},y=()=>g?0:h,b=()=>{_&&clearInterval(_),_=void 0},x=()=>{_||=setInterval(()=>v(`timeupdate`),250)},S={error:null,preload:``,get src(){return s??``},set src(e){let t=pj.exec(e);c=e!==``&&!t,s=t?e:null,l=null,u=null,d=0,p=0,S.error=null,t||b()},get currentTime(){return m?d:d+(n()-f)/1e3},set currentTime(e){d=e,f=n(),i?.seek(Math.round(e*1e3)).catch(()=>{})},get duration(){return p},get paused(){return m},get volume(){return h},set volume(e){h=e,i?.setVolume(y()).catch(()=>{})},get muted(){return g},set muted(e){g=e,i?.setVolume(y()).catch(()=>{})},async play(){if(c||!s)throw Error(`That is not a Spotify track.`);let r=pj.exec(s),a=s,o=await T();if(s!==a)return;if(l===s){await i?.resume().catch(()=>{}),m=!1,f=n(),x();return}let u=await e.getToken().catch(()=>null);if(!u)throw C(`Spotify is not connected. Connect it in Plugins, Spotify.`);let d;try{d=await t(`https://api.spotify.com/v1/me/player/play?device_id=${encodeURIComponent(o)}`,{method:`PUT`,headers:{authorization:`Bearer ${u}`,"content-type":`application/json`},body:JSON.stringify({uris:[`spotify:track:${r[1]}`]})})}catch{throw C(`Friend could not reach Spotify right now.`)}if(d.status===403)throw C(mj);if(d.status===401)throw C(`Spotify sign-in has ended. Reconnect Spotify in Plugins, Spotify.`);if(d.status===404)throw C(`Spotify could not find this screen or that track.`);if(d.status===429)throw C(`Spotify is asking Friend to slow down. Try again in a minute.`);if(!d.ok)throw C(`Spotify could not play that.`);s===a&&(l=a,m=!1,f=n(),x())},pause(){m=!0,d+=(n()-f)/1e3,f=n(),b(),i?.pause().catch(()=>{})},dispose(){b();try{i?.disconnect()}catch{}i=null,a=null,s=null,l=null},addEventListener(e,t){let n=r.get(e);n||r.set(e,n=new Set),n.add(t)},removeEventListener(e,t){r.get(e)?.delete(t)}};function C(e){S.error=e,m=!0,b(),v(`error`);let t=Error(e),n=o;return o=null,n?.reject(t),t}function w(e){if(!e)return;d=e.position/1e3,f=n(),p=e.duration/1e3,m=e.paused,v(`timeupdate`),v(`loadedmetadata`),v(`durationchange`);let t=s?pj.exec(s)?.[1]:void 0;t&&e.paused&&e.position===0&&u!==s&&(e.track_window.previous_tracks??[]).some(e=>e.id===t)&&(u=s,b(),v(`ended`))}function T(){if(a)return Promise.resolve(a);if(o)return o.promise;let t,n,r=new Promise((e,r)=>{t=e,n=r}),s={promise:r,resolve:t,reject:n};o=s;let c=setTimeout(()=>{o===s&&C(`Spotify's player did not start. Check that this browser allows Spotify's player, then try again.`)},e.readyTimeoutMs??15e3),l=()=>clearTimeout(c);return r.then(l,l),(async()=>{try{if(!i){let t;try{t=await(e.loadSdk??gj)()}catch{o===s&&C(`Spotify's player could not be loaded. Check that nothing blocks sdk.scdn.co.`);return}let n=new t.Player({name:e.deviceName??`Friend`,volume:y(),getOAuthToken:t=>{e.getToken().then(t,()=>{})}});i=n,n.addListener(`ready`,(e=>{a=e.device_id;let t=o;o=null,t?.resolve(e.device_id)})),n.addListener(`not_ready`,(()=>{a=null})),n.addListener(`player_state_changed`,(e=>w(e))),n.addListener(`account_error`,(()=>void C(mj))),n.addListener(`authentication_error`,(()=>void C(`Spotify sign-in has ended. Reconnect Spotify in Plugins, Spotify.`))),n.addListener(`initialization_error`,(()=>void C(`Spotify's player does not work in this browser.`))),n.addListener(`playback_error`,(()=>void C(`Spotify could not play that.`)))}!await i.connect()&&o===s&&C(`Spotify's player could not connect.`)}catch{o===s&&C(`Spotify's player could not connect.`)}})(),r}return S}var vj=e=>{let t=Su(e);return t?t.source===`local`?`/api/music/track/${t.id}`:t.source===`soundcloud`||t.source===`audius`?`/api/music/stream/${e}`:e:`/api/music/track/${e}`},yj=(e,t)=>Xu(e,t),bj=`friend.music`,xj=1e3,Sj=1.5,Cj=()=>{try{return JSON.parse(localStorage.getItem(bj)??`{}`)}catch{return{}}},wj=e=>{try{localStorage.setItem(bj,JSON.stringify({volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:e.view}))}catch{}};function Tj({music:e,cmd:t,send:n,connection:r,createAudio:i,createSpotify:a,remote:o=!1}){let[s,c]=(0,l.useReducer)(yj,void 0,()=>{let e=Cj();return Ku({volume:e.volume??70,shuffle:e.shuffle??!1,repeat:e.repeat??`all`,view:e.view??`mini`})}),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useRef)(!1),v=(0,l.useRef)(s);v.current=s;let y=(0,l.useRef)(!1),b=(0,l.useRef)(null),x=(0,l.useRef)(0),S=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!e||S.current)return;S.current=!0;let t=Cj();c({type:`volume`,level:t.volume??e.volume}),c({type:`repeat`,mode:t.repeat??e.repeat}),(t.shuffle??e.shuffle)&&c({type:`shuffle`,on:!0}),c({type:`view`,view:t.view??e.startView}),t.muted&&c({type:`mute`,on:!0})},[e]);let C=()=>{if(!g.current){let e=new fj(i?i():new Audio,a??(()=>_j({getToken:hj})));e.preload=`auto`,g.current=e}return g.current},w=(0,l.useRef)(!1),T=(0,l.useCallback)(()=>{let e=g.current;if(e&&e.src){w.current=!0;try{let t=e.play();t&&typeof t.then==`function`?t.then(()=>{w.current=!1,d(!1)},()=>{w.current=!1;let e=g.current?.error??null;e?p(e):d(!0)}):(w.current=!1,d(!1))}catch{w.current=!1,d(!0)}E.current||O()}},[]),E=(0,l.useRef)(!1),D=(0,l.useRef)(null),O=()=>{let e=g.current,t=e instanceof fj?e.element:e,n=typeof window<`u`?window.AudioContext??window.webkitAudioContext:void 0;if(t&&n&&typeof t.play==`function`)try{let e=new n;D.current=e;let r=e.createMediaElementSource(t),i=e.createAnalyser();i.fftSize=256,i.smoothingTimeConstant=.82,r.connect(i),i.connect(e.destination),E.current=!0,h(i)}catch{E.current=!0}};(0,l.useEffect)(()=>{if(o)return;let e=C(),t=0,n=()=>{let n=Date.now();n-t<250||(t=n,c({type:`time`,position:e.currentTime||0,duration:Number.isFinite(e.duration)?e.duration:0}))},r=()=>c({type:`time`,position:e.currentTime||0,duration:Number.isFinite(e.duration)?e.duration:0}),i=()=>c({type:`ended`}),a=()=>{let t=e.error??null;p(t),c(t?{type:`pause`}:{type:`failed`})};return e.addEventListener(`timeupdate`,n),e.addEventListener(`loadedmetadata`,r),e.addEventListener(`durationchange`,r),e.addEventListener(`ended`,i),e.addEventListener(`error`,a),()=>{e.removeEventListener(`timeupdate`,n),e.removeEventListener(`loadedmetadata`,r),e.removeEventListener(`durationchange`,r),e.removeEventListener(`ended`,i),e.removeEventListener(`error`,a),e.pause(),D.current?.close().catch(()=>{}),D.current=null,e.dispose(),b.current=null,g.current=null,E.current=!1,h(null)}},[o]),(0,l.useEffect)(()=>{o&&c({type:`stop`})},[o]);let k=s.index>=0?s.queue[s.index]??null:null;(0,l.useEffect)(()=>{let e=g.current;if(o||!e)return;let t=k?.id??null;if(t!==b.current){if(b.current=t,!t){e.pause(),e.src=``;return}p(null),e.src=vj(t),s.playing&&T()}},[k?.id,s.playing,T,o]),(0,l.useEffect)(()=>{let e=g.current;!o&&e&&e.src&&(s.playing&&e.paused&&!_.current&&!w.current?T():!s.playing&&!e.paused&&e.pause())},[s.playing,s.position,T,o]),(0,l.useEffect)(()=>{let e=g.current;e&&(e.volume=s.volume/100*dE.level,e.muted=s.muted)},[s.volume,s.muted]),(0,l.useEffect)(()=>dE.subscribe(e=>{let t=g.current;t&&(t.volume=v.current.volume/100*e)}),[]),(0,l.useEffect)(()=>{let e=g.current;e&&e.src&&Math.abs((e.currentTime||0)-s.position)>Sj&&(e.currentTime=s.position)},[s.position]),(0,l.useEffect)(()=>wj(s),[s.volume,s.muted,s.shuffle,s.repeat,s.view]),(0,l.useEffect)(()=>{if(!t||t.n===x.current)return;x.current=t.n;let e=Zu(t.command);e&&c(e)},[t]),(0,l.useEffect)(()=>{let e=()=>{y.current=!0,_.current&&T()};return window.addEventListener(`pointerdown`,e,{passive:!0}),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[T]),_.current=u;let A=(0,l.useRef)(0);return(0,l.useEffect)(()=>{if(r!==`open`||o)return;let e=()=>{let e=v.current,t=e.index>=0?e.queue[e.index]:void 0;A.current=Date.now(),n({type:`music.state`,state:{playing:e.playing,trackId:t?.id??null,title:t?.title??``,artist:t?.artist??``,album:t?.album??``,position:e.position,duration:e.duration,volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:e.view,queue:e.queue.slice(0,50).map(e=>({id:e.id,title:e.title.slice(0,200)})),index:e.index,active:(typeof document>`u`||document.visibilityState===`visible`)&&y.current}})};e();let t=setInterval(()=>s.playing&&Date.now()-A.current>=xj&&e(),xj);return()=>clearInterval(t)},[r,o,k?.id,s.playing,s.volume,s.muted,s.shuffle,s.repeat,s.view,s.queue.length,s.index]),(0,l.useEffect)(()=>{let e=typeof navigator<`u`?navigator.mediaSession:void 0;if(e&&!o)try{k&&typeof MediaMetadata<`u`&&(e.metadata=new MediaMetadata({title:k.title,artist:k.artist,album:k.album,artwork:[{src:`/api/music/cover/${k.id}`}]})),e.playbackState=s.playing?`playing`:k?`paused`:`none`,e.setActionHandler(`play`,()=>c({type:`resume`})),e.setActionHandler(`pause`,()=>c({type:`pause`})),e.setActionHandler(`previoustrack`,()=>c({type:`previous`})),e.setActionHandler(`nexttrack`,()=>c({type:`next`})),e.setActionHandler(`seekto`,e=>typeof e.seekTime==`number`&&c({type:`seek`,seconds:e.seekTime}))}catch{}},[k?.id,s.playing,o]),{remote:!1,state:s,dispatch:c,current:k,blocked:u,notice:f,analyser:m,unlock:T,audio:g}}function Ej(e,t){if(!e)return{state:{queue:[],index:-1,playing:!1,position:0,duration:0,volume:70,muted:!1,shuffle:!1,repeat:`all`,view:t},current:null};let n=e.queue.map((t,n)=>n===e.index?{id:t.id,title:e.title||t.title,artist:e.artist,album:e.album,durationSec:e.duration>0?e.duration:null}:{id:t.id,title:t.title,artist:``,album:``,durationSec:null});return{state:{queue:n,index:e.index,playing:e.playing,position:e.position,duration:e.duration,volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:t},current:e.index>=0?n[e.index]??null:null}}function Dj({local:e,host:t,send:n}){let r=e.state.view,{state:i,current:a}=(0,l.useMemo)(()=>Ej(t,r),[t,r]),o=e.dispatch,s=(0,l.useCallback)(e=>{if(e.type===`view`)return o(e);let t=Qu(e);t&&n({type:`music.remote`,command:t})},[o,n]);return(0,l.useMemo)(()=>({...e,remote:!0,state:i,dispatch:s,current:a,blocked:!1,notice:null,analyser:null,unlock:()=>{}}),[e,i,s,a])}function Oj(e){let t=new URLSearchParams(e).get(`music`);return t===`connected`?{level:`info`,text:`Spotify is connected. Ask Friend to play something.`}:t===`failed`?{level:`warn`,text:`Spotify did not connect. Open Plugins, Spotify and press Connect again.`}:null}function kj({onSignedOut:e}){let{state:t,send:n,dispatch:r,voice:i,handsFree:a,useHere:o}=$k(e);dA(i),fA(i),vA(n,t.connection);let[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(void 0),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(be),C=e=>{U(e),S(e)},w=x===`orb`?We:xe,[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(0),[k,A]=(0,l.useState)(null),j=fe(t.view),ee=t.music?.output===`host`,M=Tj({music:t.music,cmd:t.musicCmd,send:n,connection:t.connection,remote:ee}),P=Dj({local:M,host:t.hostMusic,send:n}),F=ee?P:M,te=t.hud?.animations??`full`,I=e=>{let{type:i,value:a}=e.action;if(i===`url`)window.open(a,`_blank`,`noopener,noreferrer`);else if(i===`prompt`)n({type:`chat.send`,text:a});else if(i===`music`||i===`panel`&&a===`music`){if(!t.music?.folderSet){r({type:`alert.add`,level:`info`,text:`No music folder is chosen yet. Pick one in Settings, Widgets, and the player opens.`}),b(`widgets`);return}if(i===`panel`){j.toggle(`music`,!0),F.state.view===`hidden`&&F.dispatch({type:`view`,view:`mini`});return}let e=Zu({action:a});e&&F.dispatch(e)}else a===`plugins`?g(!0):a===`settings`?b(`model`):(a===`chat`||a===`tasks`)&&j.toggle(a,!0)},ne=(0,l.useMemo)(()=>s?{...t,objects:[],captions:``}:t,[s,t]),ie=(0,l.useRef)(!1);(0,l.useEffect)(()=>{ie.current||!t.voice.available||t.voice.enrolled||(ie.current=!0,r({type:`alert.add`,level:`info`,text:`Voice recognition is not set up. Press Esc, then Enroll my voice.`}))},[t.voice.available,t.voice.enrolled,r]);let oe=ae(),se=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!oe||se.current||t.connection!==`open`)return;se.current=!0;let e=!1;try{e=localStorage.getItem(`friend.touchHint`)===`1`,localStorage.setItem(`friend.touchHint`,`1`)}catch{}e||r({type:`alert.add`,level:`info`,text:`Hold the round mic button to talk, or tap it once to start and again to send. The keyboard button types; the menu button opens settings.`})},[oe,t.connection,r]);let ce=t.uiOpen?.n??0,le=t.uiOpen?.integration;(0,l.useEffect)(()=>{ce!==0&&(v(le),g(!0))},[ce,le]);let ue=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(ue.current)return;ue.current=!0;let e=Oj(window.location.search);e&&(r({type:`alert.add`,level:e.level,text:e.text}),window.history.replaceState(null,``,window.location.pathname))},[r]);let de=(0,l.useRef)(!1);(0,l.useEffect)(()=>{de.current||t.connection!==`open`||(de.current=!0,fetch(`/api/history`).then(e=>e.ok?e.json():[]).then(e=>r({type:`chat.seed`,lines:e})).catch(()=>{}))},[t.connection,r]),(0,l.useEffect)(()=>{t.connection===`open`&&n({type:`ui.panels`,open:[...j.show.chat?[`chat`]:[],...j.show.tasks?[`tasks`]:[]]})},[t.connection,j.show.chat,j.show.tasks,n]);let R=(0,l.useRef)(!1);(0,l.useEffect)(()=>{t.viewKnown&&t.view===`minimal`&&!R.current&&(R.current=!0,r({type:`alert.add`,level:`info`,text:`The view is Minimal, so the status line and clock are hidden. Press Esc, then View, to bring them back.`}))},[t.viewKnown,t.view,r]);let z=e=>{ht.save({view:e}).catch(e=>r({type:`alert.add`,level:`warn`,text:e.message}))},pe=(0,l.useMemo)(()=>L({notify:e=>r({type:`alert.add`,level:`info`,text:e}),openSettings:()=>b(`model`),openLook:()=>b(`look`),openConnectors:()=>E(!0),openPlugins:()=>g(!0),openVoice:t.voice.available?()=>d(!0):null,muted:s,setMuted:c,cameraOn:t.camera.enabled,setCamera:e=>r({type:`camera.enable`,value:e}),clearScreen:()=>{for(let e of t.objects)n({type:`stage.event`,objectId:e.id,event:`dismiss`})},statusLine:()=>nt({connection:t.connection,deviceOnline:t.deviceOnline,approval:t.approval,voiceMode:t.voice.mode,busy:t.busy,activity:t.activity}).text,endSession:t=>{fetch(t===`lock`?`/api/lock`:`/api/logout`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).catch(()=>{}).finally(e)},panelOn:e=>j.show[e],setPanel:(e,t)=>j.toggle(e,t),view:t.view,setView:z,openHelp:A,resetLayout:()=>{B(),window.location.reload()}}),[r,n,s,e,j.show,j.toggle,t.view,t.voice.available,t.voice.mode,t.camera.enabled,t.objects,t.connection,t.deviceOnline,t.approval,t.busy,t.activity]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(_D,{state:ne,send:n,dispatch:r,voice:i,slash:pe,onMenu:()=>O(e=>e+1)}),(0,p.jsxs)(at,{approval:t.approval,challenge:t.challenge,cameraStream:t.camera.stream,alerts:t.alerts,connection:t.connection,deviceOnline:t.deviceOnline,voiceMode:t.voice.mode,busy:t.busy,activity:t.activity,showStatus:t.viewKnown&&j.show.status,showClock:t.viewKnown&&j.show.clock,profile:t.viewKnown&&j.show.profile?{ownerName:t.ownerName,speaker:t.speaker}:null,assistantName:t.assistantName,hud:t.hud,send:n,dispatch:r,children:[t.viewKnown&&j.show.chat&&(0,p.jsx)(ge,{lines:t.chat,live:t.chatLive,onSend:e=>n({type:`chat.send`,text:e}),onClose:()=>j.toggle(`chat`,!1)}),t.viewKnown&&j.show.tasks&&(0,p.jsx)(ve,{busy:t.busy,onClose:()=>j.toggle(`tasks`,!1)}),t.viewKnown&&j.show.launcher&&t.hud&&(0,p.jsx)(kA,{items:t.hud.launcher,animations:te,onAction:I}),t.viewKnown&&j.show.music&&(0,p.jsx)(uj,{player:F,music:t.music,animations:te}),u&&(0,p.jsx)(oA,{onClose:()=>d(!1)}),f&&(0,p.jsx)(CA,{onClose:()=>m(!1)}),h&&(0,p.jsx)($d,{variant:x===`orb`?`holo`:`classic`,..._?{initialConfigure:_}:{},onClose:()=>{g(!1),v(void 0)}}),y&&(0,p.jsx)(oS,{initialTab:y,variant:x===`orb`?`holo`:`classic`,onClose:()=>b(null)}),T&&(0,p.jsx)(N,{variant:x===`orb`?`holo`:`classic`,onClose:()=>E(!1)}),k&&(0,p.jsx)(re,{commands:k,onClose:()=>A(null)})]}),(0,p.jsx)(w,{voiceMode:t.voice.mode,busy:t.busy,onClassic:()=>C(`classic`),onOrb:()=>C(`orb`),muted:s,onToggleMute:()=>c(e=>!e),onSignedOut:e,voiceAvailable:t.voice.available,voiceEnrolled:t.voice.enrolled,onEnroll:()=>d(!0),onHousehold:()=>m(!0),handsFreeOn:a.on,onToggleHandsFree:a.supported?a.toggle:void 0,assistantName:t.assistantName,onPlugins:()=>g(!0),onSettings:e=>b(e??`model`),onConnectors:()=>E(!0),cameraOn:t.camera.enabled,onToggleCamera:()=>r({type:`camera.enable`,value:!t.camera.enabled}),chatOn:j.show.chat,onToggleChat:()=>j.toggle(`chat`),tasksOn:j.show.tasks,onToggleTasks:()=>j.toggle(`tasks`),musicOn:j.show.music,onToggleMusic:()=>j.toggle(`music`),launcherOn:j.show.launcher,onToggleLauncher:()=>j.toggle(`launcher`),view:t.view,onView:z,openRequest:D}),t.connection===`elsewhere`&&(0,p.jsx)(pA,{onUseHere:o})]})}function Aj(){let[e,t]=(0,l.useState)(`loading`);return(0,l.useEffect)(()=>{let e=!0,n=n=>e&&t(n);return(async()=>{try{if(!(await(await fetch(`/api/state`)).json()).hasOwner)return n(`setup`);let e=await(await fetch(`/api/session`,{cache:`no-store`})).json();n(e.signedIn===!0?`stage`:`login`)}catch{n(`login`)}})(),()=>{e=!1}},[]),e===`loading`?(0,p.jsx)(`div`,{className:`boot`,"aria-busy":`true`}):e===`setup`?(0,p.jsx)(g,{onDone:()=>t(`login`)}):e===`login`?(0,p.jsx)(h,{onLoggedIn:()=>t(`stage`)}):(0,p.jsx)(kj,{onSignedOut:()=>t(`login`)})}(0,u.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(l.StrictMode,{children:(0,p.jsx)(Aj,{})}));
|
|
4454
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${_T(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?_T(n,!0):this.parser.parseInline(r),o=yT(e);if(o===null)return a;e=_T(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+_T(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=yT(e);if(i===null)return _T(n);e=i;let a=`<img src="${_T(e)}" alt="${_T(n)}"`;return t&&(a+=` title="${_T(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:_T(e.text)}},MT=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},NT=class e{options;renderer;textRenderer;constructor(e){this.options=e||qC,this.options.renderer=this.options.renderer||new jT,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new MT}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},PT=class{options;block;constructor(e){this.options=e||qC}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?AT.lex:AT.lexInline}provideParser(e=this.block){return e?NT.parse:NT.parseInline}},FT=new class{defaults=KC();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=NT;Renderer=jT;TextRenderer=MT;Lexer=AT;Tokenizer=kT;Hooks=PT;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new jT(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new kT(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new PT;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=PT.passThroughHooks.has(n)?e=>{if(this.defaults.async&&PT.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return AT.lex(e,t??this.defaults)}parser(e,t){return NT.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?AT.lex:AT.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?NT.parse:NT.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?AT.lex:AT.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?NT.parse:NT.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
4455
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+_T(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function IT(e,t){return FT.parse(e,t)}IT.options=IT.setOptions=function(e){return FT.setOptions(e),IT.defaults=FT.defaults,JC(IT.defaults),IT},IT.getDefaults=KC,IT.defaults=qC;function LT(...e){return FT.use(...e),IT.defaults=FT.defaults,JC(IT.defaults),IT}IT.use=LT,IT.walkTokens=function(e,t){return FT.walkTokens(e,t)},IT.parseInline=FT.parseInline,IT.Parser=NT,IT.parser=NT.parse,IT.Renderer=jT,IT.TextRenderer=MT,IT.Lexer=AT,IT.lexer=AT.lex,IT.Tokenizer=kT,IT.Hooks=PT,IT.parse=IT,IT.options,IT.setOptions,IT.walkTokens,IT.parseInline,NT.parse,AT.lex;var RT=!1;function zT(){RT||(RT=!0,GC.addHook(`afterSanitizeAttributes`,e=>{e instanceof Element&&e.tagName===`A`&&(e.setAttribute(`rel`,`noopener noreferrer`),e.setAttribute(`target`,`_blank`))}))}function BT(e){zT();let t=IT.parse(e,{async:!1,breaks:!0});return GC.sanitize(t,{ALLOWED_TAGS:[`p`,`br`,`strong`,`em`,`code`,`pre`,`ul`,`ol`,`li`,`a`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`blockquote`,`hr`,`del`,`table`,`thead`,`tbody`,`tr`,`th`,`td`],ALLOWED_ATTR:[`href`,`rel`,`target`],ALLOWED_URI_REGEXP:/^(?:https?:|mailto:)/i})}var VT=e=>Number.isFinite(e);function HT(e){let t=Math.floor(Math.log10(e)),n=e/10**t;return(n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10)*10**t}function UT(e,t,n=5){let r=VT(e)?e:0,i=VT(t)?t:r+1;r>i&&([r,i]=[i,r]),r===i&&(i=r+(Math.abs(r)||1));let a=HT((i-r)/Math.max(1,n-1)),o=Math.floor(r/a)*a,s=Math.ceil(i/a)*a,c=[];for(let e=o;e<=s+a/2;e+=a)c.push(Math.round(e*1e9)/1e9);return{min:o,max:s,ticks:c}}function WT(e,t){let[n,r]=e,[i,a]=t;return r===n?()=>i:e=>i+(e-n)/(r-n)*(a-i)}function GT(e){return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e.toFixed(2)} ${t.toFixed(2)}`).join(` `)}function KT(e,t,n,r,i){let a=r=>{let i=r*Math.PI/180;return`${(e+n*Math.cos(i)).toFixed(2)} ${(t+n*Math.sin(i)).toFixed(2)}`},o=+(Math.abs(i-r)>180);return`M ${a(r)} A ${n} ${n} 0 ${o} 1 ${a(i)}`}function qT(e,t,n){return!VT(e)||!VT(t)||!VT(n)||n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))*240}function JT(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a);if(o===0||o<=n+r)return{from:{...e},to:{...t}};let s=i/o,c=a/o;return{from:{x:e.x+s*n,y:e.y+c*n},to:{x:t.x-s*r,y:t.y-c*r}}}function YT(e,t,n){if(e<=0)return[];if(e===1)return[{x:t/2,y:n/2}];let r=Math.min(t,n)*.36;return Array.from({length:e},(i,a)=>{let o=-Math.PI/2+a*2*Math.PI/e;return{x:t/2+r*Math.cos(o),y:n/2+r*Math.sin(o)}})}var XT=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ZT=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,QT=e=>Array.isArray(e)?e:[],$T=e=>typeof e==`number`?Number.isFinite(e)?e:null:typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):null,eE=(e,t)=>e.length>t?e.slice(0,t)+`…`:e,tE=[`var(--accent)`,`#ffb454`,`#7b8cff`,`#5ef0b0`,`#ff6b7a`,`#c792ea`],nE=({text:e})=>e?(0,p.jsx)(`h3`,{className:`obj-title`,children:e}):null,rE=({text:e=`No data`})=>(0,p.jsx)(`p`,{className:`obj-empty`,children:e}),iE=400,aE=220,oE={l:44,r:12,t:10,b:28};function sE({props:e}){let t=e.kind===`bar`||e.kind===`area`?e.kind:`line`,n=QT(e.labels).slice(0,120).map(ZT),r=QT(e.series).slice(0,6).map((e,t)=>{let n=XT(e)?e:{},r=QT(n.values).slice(0,120).map((e,t)=>({idx:t,v:$T(e)})).filter(e=>e.v!==null);return{name:ZT(n.name)||`series ${t+1}`,points:r}}).filter(e=>e.points.length>0);if(r.length===0)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsx)(rE,{})]});let i=r.flatMap(e=>e.points.map(e=>e.v)),a=Math.min(...i),o=Math.max(...i),s=UT(t===`line`?a:Math.min(0,a),t===`line`?o:Math.max(0,o),5),c=Math.max(n.length,...r.map(e=>e.points[e.points.length-1].idx+1),2),l=WT([s.min,s.max],[aE-oE.b,oE.t]),u=WT([0,c-1],[oE.l,iE-oE.r]),d=(iE-oE.l-oE.r)/c,f=Math.max(1,d*.7/r.length),m=(e,t)=>oE.l+e*d+d*.15+t*f,h=Math.max(1,Math.ceil(c/6)),g=ZT(e.unit);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsxs)(`svg`,{className:`obj-chart`,viewBox:`0 0 ${iE} ${aE}`,role:`img`,"aria-label":ZT(e.title)||`chart`,children:[s.ticks.map(e=>(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`line`,{className:`grid`,x1:oE.l,x2:iE-oE.r,y1:l(e),y2:l(e)}),(0,p.jsxs)(`text`,{className:`tick`,x:oE.l-6,y:l(e)+3,textAnchor:`end`,children:[e,g&&e===s.max?g:``]})]},e)),Array.from({length:c},(e,t)=>t).filter(e=>e%h===0&&n[e]).map(e=>(0,p.jsx)(`text`,{className:`tick`,x:t===`bar`?m(e,0)+f*r.length/2:u(e),y:212,textAnchor:`middle`,children:eE(n[e],8)},e)),r.map((e,n)=>{let r=tE[n%tE.length];if(t===`bar`)return(0,p.jsx)(`g`,{children:e.points.map(e=>(0,p.jsx)(`rect`,{className:`bar`,x:m(e.idx,n),y:Math.min(l(e.v),l(0)),width:f,height:Math.abs(l(e.v)-l(0)),fill:r},e.idx))},n);let i=e.points.map(e=>[u(e.idx),l(e.v)]),a=GT(i),o=`${a} L${i[i.length-1][0].toFixed(2)} ${l(s.min).toFixed(2)} L${i[0][0].toFixed(2)} ${l(s.min).toFixed(2)} Z`;return(0,p.jsxs)(`g`,{children:[t===`area`&&(0,p.jsx)(`path`,{className:`series-area`,d:o,fill:r,opacity:.18}),(0,p.jsx)(`path`,{className:`series-line`,d:a,fill:`none`,stroke:r,strokeWidth:2,strokeLinejoin:`round`})]},n)})]}),r.length>1&&(0,p.jsx)(`ul`,{className:`legend`,children:r.map((e,t)=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`i`,{style:{background:tE[t%tE.length]}}),(0,p.jsx)(`span`,{children:e.name})]},t))})]})}function cE({props:e}){let t=$T(e.min)??0,n=$T(e.max)??100,r=$T(e.value)??t,i=qT(r,t,n),a=i/240;return(0,p.jsxs)(`div`,{className:`obj-gauge ${a>.95?`gauge-crit`:a>.8?`gauge-warn`:``}`,children:[(0,p.jsxs)(`svg`,{viewBox:`0 0 200 150`,role:`img`,"aria-label":`${ZT(e.label)} ${r}`,children:[(0,p.jsx)(`path`,{className:`track`,d:KT(100,100,70,150,390),fill:`none`,strokeWidth:12,strokeLinecap:`round`}),i>0&&(0,p.jsx)(`path`,{className:`value`,d:KT(100,100,70,150,150+i),fill:`none`,strokeWidth:12,strokeLinecap:`round`})]}),(0,p.jsxs)(`div`,{className:`gauge-read`,children:[(0,p.jsx)(`span`,{className:`gauge-value`,children:String(Math.round(r*100)/100)}),ZT(e.unit)&&(0,p.jsx)(`small`,{className:`gauge-unit`,children:ZT(e.unit)})]}),(0,p.jsx)(`span`,{className:`obj-label`,children:ZT(e.label)})]})}function lE({props:e}){let t=QT(e.items).slice(0,30).map(e=>XT(e)?e:{}).map(e=>({time:ZT(e.time),title:ZT(e.title),detail:ZT(e.detail)})).filter(e=>e.title||e.time);return t.length===0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsx)(rE,{text:`Nothing to show`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsx)(`ol`,{className:`obj-timeline`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`time`,{children:e.time}),(0,p.jsx)(`strong`,{children:e.title}),e.detail&&(0,p.jsx)(`span`,{children:e.detail})]},t))})]})}var uE=400,dE=300,fE=12;function pE({props:e}){let t=(0,l.useId)(),n=new Set,r=[];for(let t of QT(e.nodes)){let e=XT(t)?t:{},i=ZT(e.id);if(i&&!n.has(i)&&(n.add(i),r.push({id:i,label:ZT(e.label)||i}),r.length>=40))break}if(r.length===0)return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsx)(rE,{text:`Nothing to show`})]});let i=new Map(r.map((e,t)=>[e.id,YT(r.length,uE,dE)[t]])),a=[];for(let t of QT(e.edges)){let e=XT(t)?t:{},n=ZT(e.from),r=ZT(e.to);if(i.has(n)&&i.has(r)&&n!==r&&(a.push({from:n,to:r,label:ZT(e.label)}),a.length>=80))break}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nE,{text:ZT(e.title)}),(0,p.jsxs)(`svg`,{className:`obj-graph`,viewBox:`0 0 ${uE} ${dE}`,role:`img`,"aria-label":ZT(e.title)||`graph`,children:[(0,p.jsx)(`defs`,{children:(0,p.jsx)(`marker`,{id:t,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,p.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,className:`arrow`})})}),a.map((e,n)=>{let{from:r,to:a}=JT(i.get(e.from),i.get(e.to),14,17),o=(r.x+a.x)/2+(uE/2-(r.x+a.x)/2)*.25,s=(r.y+a.y)/2+(dE/2-(r.y+a.y)/2)*.25;return(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`path`,{className:`edge`,d:`M ${r.x.toFixed(1)} ${r.y.toFixed(1)} Q ${o.toFixed(1)} ${s.toFixed(1)} ${a.x.toFixed(1)} ${a.y.toFixed(1)}`,fill:`none`,markerEnd:`url(#${t})`}),e.label&&(0,p.jsx)(`text`,{className:`edge-label`,x:o,y:s,textAnchor:`middle`,children:eE(e.label,12)})]},n)}),r.map(e=>{let t=i.get(e.id);return(0,p.jsxs)(`g`,{children:[(0,p.jsx)(`circle`,{className:`node`,cx:t.x,cy:t.y,r:fE}),(0,p.jsx)(`text`,{className:`node-label`,x:t.x,y:t.y+26,textAnchor:`middle`,children:eE(e.label,18)})]},e.id)})]})]})}var mE=30,hE=e=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):1,gE=new class{current=1;goal=1;from=1;steps=1;n=0;timer=null;subs=new Set;get level(){return this.current}set(e,t=250){if(this.goal=hE(e),t<=0||this.goal===this.current){this.stop(),this.move(this.goal);return}this.from=this.current,this.steps=Math.max(1,Math.ceil(t/mE)),this.n=0,this.timer??=setInterval(()=>this.tick(),mE)}subscribe(e){return this.subs.add(e),()=>void this.subs.delete(e)}tick(){this.n++,this.n>=this.steps?(this.stop(),this.move(this.goal)):this.move(this.from+(this.goal-this.from)*this.n/this.steps)}stop(){this.timer&&clearInterval(this.timer),this.timer=null}move(e){if(e!==this.current){this.current=e;for(let t of[...this.subs])t(e)}}};function _E(e,t=gE){let n=e.volume,r=e.volume,i=!0,a=t=>{i&&(r=hE(n*t),e.volume=r)},o=()=>{if(!i||Math.abs(e.volume-r)<=.002)return;let a=t.level;a>.001&&(n=hE(e.volume/a)),r=e.volume};e.addEventListener(`volumechange`,o);let s=t.subscribe(a);return a(t.level),()=>{i=!1,s(),e.removeEventListener(`volumechange`,o),e.volume=n}}var vE=`https://www.youtube-nocookie.com`;function yE(e,t=gE,n=window){let r=100,i=null,a=!1,o=!0,s=!1,c=t=>e.contentWindow?.postMessage(JSON.stringify(t),vE),l=()=>c({event:`listening`,id:1,channel:`widget`}),u=e=>{i=e,c({event:`command`,func:`setVolume`,args:[e]})},d=e=>{o&&(e<.999?(a=!0,u(Math.round(r*e))):a&&(a=!1,u(Math.round(r))))},f=n=>{if(!o||n.source!==e.contentWindow)return;let c;try{c=JSON.parse(String(n.data)).info}catch{return}if(typeof c?.volume!=`number`)return;s=!0;let l=c.volume;if(i!==null&&Math.abs(l-i)<=1)return;let u=t.level;r=a&&u>.001?l/u:l,i=l};n.addEventListener(`message`,f),e.addEventListener?.(`load`,l),l();let p=setInterval(()=>s?clearInterval(p):l(),1e3),m=t.subscribe(d);return d(t.level),()=>{o=!1,clearInterval(p),m(),n.removeEventListener(`message`,f),e.removeEventListener?.(`load`,l),a&&bE(e,r)}}function bE(e,t){try{e.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`setVolume`,args:[Math.round(t)]}),vE)}catch{}}var xE=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,SE=e=>Array.isArray(e)?e:[],CE=e=>typeof e==`object`&&e?e:{},wE=/^\/api\/media\/[0-9a-f]{32}$/,TE=e=>typeof e==`string`&&wE.test(e)?e:null,EE=/^\/api\/video\/[0-9a-f]{32}$/,DE=e=>typeof e==`string`&&EE.test(e)?e:null,OE=({props:e})=>xE(e.title)?(0,p.jsx)(`h3`,{className:`obj-title`,children:xE(e.title)}):null;function kE({props:e}){let t=(0,l.useMemo)(()=>BT(xE(e.text)),[e.text]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(OE,{props:e}),(0,p.jsx)(`div`,{className:`obj-md obj-doc`,dangerouslySetInnerHTML:{__html:t}})]})}function AE({props:e}){let t=Math.min(100,Math.max(0,Number(e.value)||0));return(0,p.jsxs)(`div`,{className:`obj-progress`,children:[(0,p.jsxs)(`div`,{className:`obj-progress-head`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:xE(e.label)}),(0,p.jsxs)(`span`,{className:`obj-progress-pct`,children:[Math.round(t),`%`]})]}),(0,p.jsx)(`div`,{className:`obj-progress-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(t),"aria-label":xE(e.label)||`Progress`,children:(0,p.jsx)(`i`,{style:{width:`${t}%`}})}),xE(e.detail)&&(0,p.jsx)(`span`,{className:`obj-progress-detail`,children:xE(e.detail)})]})}function jE({props:e}){let t=SE(e.items).map(e=>CE(typeof e==`object`&&e?e:{text:e})),n=t.filter(e=>e.done===!0).length;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(OE,{props:e}),(0,p.jsx)(`ul`,{className:`obj-checklist`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{className:e.done===!0?`done`:void 0,children:[(0,p.jsx)(`span`,{className:`box`,"aria-hidden":`true`,children:e.done===!0?`✓`:``}),(0,p.jsx)(`span`,{children:xE(e.text)})]},t))}),t.length>0&&(0,p.jsxs)(`small`,{className:`obj-progress-detail`,children:[n,` of `,t.length,` done`]})]})}function ME({props:e}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(OE,{props:e}),(0,p.jsx)(`dl`,{className:`obj-kv`,children:SE(e.rows).map((e,t)=>{let n=CE(e);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`dt`,{children:xE(n.key)}),(0,p.jsx)(`dd`,{children:xE(n.value)})]},t)})})]})}var NE=e=>String(Math.floor(e)).padStart(2,`0`);function PE(e){let t=Math.max(0,Math.ceil(e));return`${NE(t/3600)}:${NE(t%3600/60)}:${NE(t%60)}`}function FE({props:e}){let t=(0,l.useRef)(null);if(t.current===null){let n=typeof e.to==`string`?Date.parse(e.to):NaN,r=Number(e.seconds);t.current=Number.isFinite(n)?n:Date.now()+(Number.isFinite(r)?r:0)*1e3}let[n,r]=(0,l.useState)(Date.now());(0,l.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),250);return()=>clearInterval(e)},[]);let i=(t.current-n)/1e3;return(0,p.jsxs)(`div`,{className:`obj-countdown${i<=0?` done`:``}`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:xE(e.title)||xE(e.label)}),(0,p.jsx)(`span`,{className:`obj-countdown-time`,role:`timer`,children:PE(i)})]})}function IE({props:e}){let t=TE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media`,children:[(0,p.jsx)(OE,{props:e}),t?(0,p.jsx)(`img`,{src:t,alt:xE(e.title)||`Picture`,loading:`lazy`}):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This picture is not available.`})]})}function LE({src:e,web:t,title:n}){let[r,i]=(0,l.useState)(t?`loading`:`ready`),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>a.current?_E(a.current):void 0,[r===`failed`]),r===`failed`?(0,p.jsx)(`p`,{className:`obj-empty`,children:`This video could not be played. Ask Friend to try again, or to play it in a window on the PC.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`video`,{ref:a,src:e,controls:!0,playsInline:!0,autoPlay:t,preload:t?`auto`:`metadata`,"aria-label":n,onLoadedData:()=>i(`ready`),onError:()=>i(`failed`)}),t&&r===`loading`&&(0,p.jsx)(`p`,{className:`obj-empty`,children:`Preparing the video…`})]})}var RE=/^[A-Za-z0-9_-]{11}$/;function zE({id:e,start:t,title:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);(0,l.useEffect)(()=>a.current?yE(a.current):void 0,[e]);let o=new URLSearchParams({autoplay:`1`,rel:`0`,playsinline:`1`,modestbranding:`1`,enablejsapi:`1`});return t>0&&o.set(`start`,String(t)),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`iframe`,{ref:a,className:`obj-youtube`,src:`https://www.youtube-nocookie.com/embed/${e}?${o.toString()}`,title:n,allow:`autoplay; encrypted-media; fullscreen; picture-in-picture`,allowFullScreen:!0,referrerPolicy:`strict-origin-when-cross-origin`,onLoad:()=>i(!0)}),!r&&(0,p.jsx)(`p`,{className:`obj-empty`,children:`Loading the player…`})]})}function BE({props:e}){if(e.embed!==void 0){let t=typeof e.embed==`string`&&RE.test(e.embed)?e.embed:null,n=typeof e.start==`number`&&e.start>0&&e.start<=86400?Math.floor(e.start):0;return(0,p.jsxs)(`div`,{className:`obj-media obj-media-fill`,children:[(0,p.jsx)(OE,{props:e}),t?(0,p.jsx)(zE,{id:t,start:n,title:xE(e.title)||`YouTube video`},`${t}-${n}`):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This clip is not available.`})]})}let t=DE(e.src),n=t??TE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media`,children:[(0,p.jsx)(OE,{props:e}),n?(0,p.jsx)(LE,{src:n,web:t!==null,title:xE(e.title)||`Video`},n):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This clip is not available.`})]})}function VE({props:e}){let t=TE(e.src);return(0,p.jsxs)(`div`,{className:`obj-media obj-pdf`,children:[(0,p.jsx)(OE,{props:e}),t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`iframe`,{src:t,title:xE(e.title)||`Document`}),(0,p.jsx)(`a`,{className:`obj-open`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:`Open in a new tab`})]}):(0,p.jsx)(`p`,{className:`obj-empty`,children:`This document is not available.`})]})}function HE({props:e}){let t=SE(e.items).map(CE).filter(e=>TE(e.src)),[n,r]=(0,l.useState)(0),i=Math.min(n,Math.max(0,t.length-1)),a=t[i];if(!a)return(0,p.jsx)(`p`,{className:`obj-empty`,children:`Nothing to show.`});let o=TE(a.src),s=a.kind===`video`;return(0,p.jsxs)(`div`,{className:`obj-media obj-gallery`,children:[(0,p.jsx)(OE,{props:e}),s?(0,p.jsx)(`video`,{src:o,controls:!0,playsInline:!0,preload:`metadata`},o):(0,p.jsx)(`img`,{src:o,alt:xE(a.caption)||`Picture ${i+1}`},o),(0,p.jsxs)(`div`,{className:`obj-gallery-bar`,children:[(0,p.jsx)(`button`,{type:`button`,"aria-label":`Previous`,disabled:t.length<2,onClick:()=>r((i+t.length-1)%t.length),children:`‹`}),(0,p.jsxs)(`span`,{children:[xE(a.caption),(0,p.jsxs)(`small`,{children:[i+1,` / `,t.length]})]}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Next`,disabled:t.length<2,onClick:()=>r((i+1)%t.length),children:`›`})]})]})}var UE=[`default-src 'none'`,`script-src 'unsafe-inline'`,`style-src 'unsafe-inline'`,`img-src data: blob:`,`form-action 'none'`,`base-uri 'none'`].join(`; `),WE=`html,body{margin:0;min-height:100%;background:#050b10;color:var(--ink,#d8f6ff);font:15px/1.5 var(--ui,system-ui,sans-serif)}`,GE=[`--accent`,`--ink`,`--muted`,`--ok`,`--warn`,`--bad`,`--glass`,`--edge`,`--ui`,`--mono`],KE=/^[\w\s#().,%'"/-]+$/;function qE(){if(typeof document>`u`)return``;let e=getComputedStyle(document.documentElement),t=GE.map(t=>[t,e.getPropertyValue(t).trim()]).filter(([,e])=>e&&KE.test(e));return t.length?`:root{${t.map(([e,t])=>`${e}:${t}`).join(`;`)}}`:``}function JE(e,t=``){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${UE}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>${t}${WE}</style></head><body>${e}</body></html>`}function YE({props:e}){let t=typeof e.html==`string`?e.html:``,n=typeof e.title==`string`?e.title:``,r=(0,l.useMemo)(()=>JE(t,qE()),[t]);return(0,p.jsxs)(`div`,{className:`obj-sandbox`,children:[n&&(0,p.jsx)(`h3`,{className:`obj-title`,children:n}),(0,p.jsx)(`iframe`,{title:n||`Page made by Friend`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,allow:``,srcDoc:r})]})}var XE=e=>typeof e==`string`?e:typeof e==`number`?String(e):``,ZE=e=>Array.isArray(e)?e:[];function QE({props:e}){let t=(0,l.useMemo)(()=>BT(XE(e.text)),[e.text]);return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`div`,{className:`obj-md`,dangerouslySetInnerHTML:{__html:t}})]})}function $E({props:e}){return(0,p.jsxs)(`div`,{className:`obj-stat`,children:[(0,p.jsx)(`span`,{className:`obj-label`,children:XE(e.label)}),(0,p.jsxs)(`span`,{className:`obj-value`,children:[(0,p.jsx)(`span`,{children:XE(e.value)}),XE(e.unit)&&(0,p.jsx)(`small`,{children:XE(e.unit)})]}),XE(e.delta)&&(0,p.jsx)(`span`,{className:`obj-delta`,children:XE(e.delta)})]})}function eD({props:e}){return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`ul`,{className:`obj-list`,children:ZE(e.items).map((e,t)=>{let n=typeof e==`object`&&e?e:{text:e};return(0,p.jsx)(`li`,{className:n.done?`done`:void 0,children:XE(n.text)},t)})})]})}function tD({props:e}){let t=ZE(e.columns),n=ZE(e.rows);return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`div`,{className:`obj-table-wrap`,children:(0,p.jsxs)(`table`,{className:`obj-table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsx)(`tr`,{children:t.map((e,t)=>(0,p.jsx)(`th`,{children:XE(e)},t))})}),(0,p.jsx)(`tbody`,{children:n.map((e,t)=>(0,p.jsx)(`tr`,{children:ZE(e).map((e,t)=>(0,p.jsx)(`td`,{children:XE(e)},t))},t))})]})})]})}function nD({props:e}){return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`pre`,{className:`obj-code`,"data-lang":XE(e.language),children:(0,p.jsx)(`code`,{children:XE(e.code)})})]})}function rD({part:e}){let t=typeof e==`object`&&e?e:{},n=typeof t.type==`string`?t.type:``;if(n===`group`||n===`tabs`||n===`sandbox`)return null;let r=oD[n];return r?(0,p.jsx)(`div`,{className:`obj-part obj-part-${n}`,children:(0,p.jsx)(r,{props:typeof t.props==`object`&&t.props!==null?t.props:{}})}):null}function iD({props:e}){let t=e.layout===`row`||e.layout===`column`?e.layout:`grid`;return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`div`,{className:`obj-group obj-group-${t}`,children:ZE(e.items).map((e,t)=>(0,p.jsx)(rD,{part:e},t))})]})}function aD({props:e}){let t=ZE(e.tabs).map(e=>typeof e==`object`&&e?e:{}),[n,r]=(0,l.useState)(0),i=Math.min(n,Math.max(0,t.length-1));return(0,p.jsxs)(p.Fragment,{children:[XE(e.title)&&(0,p.jsx)(`h3`,{className:`obj-title`,children:XE(e.title)}),(0,p.jsx)(`div`,{className:`obj-tabs`,role:`tablist`,children:t.map((e,t)=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===i,className:t===i?`on`:void 0,onClick:()=>r(t),children:XE(e.title)||`Tab ${t+1}`},t))}),t[i]&&(0,p.jsx)(rD,{part:t[i]})]})}var oD={card:QE,stat:$E,list:eD,table:tD,code:nD,chart:sE,gauge:cE,timeline:lE,graph:pE,sandbox:YE,markdown:kE,image:IE,video:BE,pdf:VE,gallery:HE,group:iD,tabs:aD,progress:AE,checklist:jE,countdown:FE,kv:ME};function sD(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=new Set;for(let t of e){if(i.has(t.object.id))continue;i.add(t.object.id);let e=n.get(t.object.id);r.push(e?{object:e,leaving:!1}:{object:t.object,leaving:!0})}for(let e of t)i.has(e.id)||(i.add(e.id),r.push({object:e,leaving:!1}));return r}function cD(e,t){let[n,r]=(0,l.useState)(()=>e.map(e=>({object:e,leaving:!1}))),i=(0,l.useRef)(new Map);return(0,l.useEffect)(()=>{r(n=>{let a=sD(n,e),o=new Set(n.filter(e=>e.leaving).map(e=>e.object.id));for(let e of a){let n=i.current.get(e.object.id);if(!e.leaving)n&&clearTimeout(n),i.current.delete(e.object.id);else if(!o.has(e.object.id)&&!n){let n=e.object.id;i.current.set(n,setTimeout(()=>{i.current.delete(n),r(e=>e.filter(e=>!(e.object.id===n&&e.leaving)))},Math.max(t,0)))}}return t<=0?a.filter(e=>!e.leaving):a})},[e,t]),(0,l.useEffect)(()=>()=>{for(let e of i.current.values())clearTimeout(e);i.current.clear()},[]),n}var lD=.12,uD=.1,dD=.02,fD=(e,t,n)=>Math.min(Math.max(e,t),n);function pD(e){let t=fD(e.w,lD,1),n=fD(e.h,uD,1);return{x:fD(e.x,0,1-t),y:fD(e.y,0,1-n),w:t,h:n}}function mD(e,t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.width<=0||n.height<=0?null:pD({x:(r.left-n.left)/n.width,y:(r.top-n.top)/n.height,w:r.width/n.width,h:r.height/n.height})}function hD(e,t,n){let r=(0,l.useRef)(null),[i,a]=(0,l.useState)(null),o=(0,l.useCallback)((n,r)=>{let i=pD(r);t({type:`object.place`,id:n,placement:{x:i.x,y:i.y,w:i.w,h:i.h}}),e({type:`stage.move`,objectId:n,rect:i})},[e,t]),s=(0,l.useCallback)((e,t,i)=>{if(e.pointerType===`mouse`&&e.button!==0)return;let o=n(),s=e.currentTarget.closest(`[data-object]`);if(!o||!s||r.current)return;let c=mD(s,o);if(!c)return;let l=o.getBoundingClientRect();r.current={id:t.id,mode:i,pointer:e.pointerId,startX:e.clientX,startY:e.clientY,from:c,stageW:l.width,stageH:l.height};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.stopPropagation(),e.preventDefault(),a({id:t.id,box:c})},[n]),c=(e,t)=>{let n=(t.clientX-e.startX)/e.stageW,r=(t.clientY-e.startY)/e.stageH;return e.mode===`move`?pD({...e.from,x:e.from.x+n,y:e.from.y+r}):pD({...e.from,w:e.from.w+n,h:e.from.h+r})};return{preview:i,begin:s,move:(0,l.useCallback)(e=>{let t=r.current;t&&t.pointer===e.pointerId&&a({id:t.id,box:c(t,e)})},[]),end:(0,l.useCallback)((e,t)=>{let n=r.current;n&&n.pointer===e.pointerId&&(r.current=null,a(null),t||o(n.id,c(n,e)))},[o]),key:(0,l.useCallback)((e,t)=>{let r={ArrowLeft:[-.02,0],ArrowRight:[dD,0],ArrowUp:[0,-.02],ArrowDown:[0,dD]}[e.key],i=n(),a=e.currentTarget.closest(`[data-object]`);if(!r||!i||!a)return;let s=mD(a,i);s&&(e.preventDefault(),o(t.id,e.shiftKey?{...s,w:s.w+r[0],h:s.h+r[1]}:{...s,x:s.x+r[0],y:s.y+r[1]}))},[o,n])}}function gD(e,t){if(e===`auto`)return{position:`relative`};if(t.w<600)return{position:`relative`,width:`100%`};let[n,r,i,a]=typeof e==`string`?lu[e]:[e.x*100,e.y*100,e.w*100,e.h*100],o={position:`absolute`,left:`${n}%`,top:`${r}%`,width:`${i}%`};return e===`top`||e===`bottom`?{...o,maxHeight:`${a}%`}:{...o,height:`${a}%`}}var _D=350,vD=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,yD=class extends l.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?null:this.props.children}};function bD(){let e=()=>({w:window.innerWidth,h:window.innerHeight}),[t,n]=(0,l.useState)(e);return(0,l.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[]),t}var xD=350;function SD({state:e,send:t,dispatch:n,voice:r,slash:i,onMenu:a}){let o=bD(),[s,c]=(0,l.useState)(0),[u,d]=(0,l.useState)(!1),f=ae(),m=o.w<600,h=e.scene===`focus`||e.scene===`multi`,g={"--accent":e.mood.accent,"--intensity":e.mood.intensity},_=e.voice.mode,v=_===`listening`?`listening`:_===`speaking`?`speaking`:_===`transcribing`?`thinking`:e.presence.state,y=jx(e.look.reactivity),b=Math.min(1,(_===`listening`||_===`speaking`?e.voice.level:e.presence.amplitude)*y),x=(0,l.useRef)({timer:null,down:!1,talking:!1,id:null}),S=e=>{if(!(e.target===e.currentTarget||e.target.closest(`[data-presence]`))||e.pointerType===`mouse`&&e.button!==0)return;let t=x.current;if(!(t.down&&t.id!==null&&e.pointerId!==t.id)){t.timer&&clearTimeout(t.timer),t.down=!0,t.talking=!1,t.id=typeof e.pointerId==`number`?e.pointerId:null;try{t.id!==null&&e.currentTarget.setPointerCapture?.(t.id)}catch{}t.timer=r?setTimeout(()=>{t.down&&(t.talking=!0,r.pressStart())},xD):null}},C=(e,t)=>{let n=x.current;n.down&&(n.id===null||typeof e.pointerId!=`number`||e.pointerId===n.id)&&(n.down=!1,n.id=null,n.timer&&clearTimeout(n.timer),n.timer=null,n.talking?(n.talking=!1,t?r?.blur?.():r?.pressEnd()):t||c(e=>e+1))},w=(0,l.useRef)(null),T=hD(t,n,()=>w.current),E=cD(e.objects,vD()?0:_D),D=E.filter(e=>e.object.layer===`overlay`),O=E.filter(e=>e.object.layer!==`overlay`&&e.object.placement===`auto`),k=E.filter(e=>e.object.layer!==`overlay`&&e.object.placement!==`auto`),A=({object:e,leaving:r})=>{let i=oD[e.type];if(!i)return null;let a=e.layer===`overlay`,s=!m&&!r&&!a,c=T.preview?.id===e.id?T.preview.box:null,l=c?{x:c.x,y:c.y,w:c.w,h:c.h}:e.placement;return(0,p.jsxs)(`section`,{"data-object":e.id,className:`obj glass${e.style===`alert`?` alert`:``}${a?` overlay`:``}${e.pinned?` pinned`:``}${c?` dragging`:``}${r?` leaving`:``}`,style:a?void 0:gD(l,o),children:[s&&(0,p.jsx)(`div`,{className:`obj-grip`,role:`button`,tabIndex:0,"aria-label":`Move ${e.id}. Drag, or use the arrow keys; hold Shift to resize.`,onPointerDown:t=>T.begin(t,e,`move`),onPointerMove:T.move,onPointerUp:e=>T.end(e,!1),onPointerCancel:e=>T.end(e,!0),onKeyDown:t=>T.key(t,e)}),!a&&(0,p.jsx)(`button`,{className:`obj-pin${e.pinned?` on`:``}`,"aria-label":e.pinned?`Unpin ${e.id}`:`Pin ${e.id} to the screen`,"aria-pressed":!!e.pinned,title:e.pinned?`Pinned: stays on the screen. Click to unpin.`:`Pin: keep this on the screen.`,disabled:r,onClick:()=>t({type:`stage.pin`,objectId:e.id,pinned:!e.pinned}),children:(0,p.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:e.pinned?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:`M12 17v5M9 3h6l-1 7 3 3H7l3-3-1-7z`})})}),(0,p.jsx)(`button`,{className:`obj-close`,"aria-label":`Dismiss ${e.id}`,title:e.pinned?`Remove this widget`:`Dismiss`,disabled:r,onClick:()=>{t({type:`stage.event`,objectId:e.id,event:`dismiss`}),n({type:`object.dismiss`,id:e.id})},children:`×`}),s&&(0,p.jsx)(`div`,{className:`obj-resize`,"aria-hidden":`true`,onPointerDown:t=>T.begin(t,e,`resize`),onPointerMove:T.move,onPointerUp:e=>T.end(e,!1),onPointerCancel:e=>T.end(e,!0)}),(0,p.jsx)(yD,{children:(0,p.jsx)(i,{props:e.props})})]},e.id)};return(0,p.jsxs)(`div`,{ref:w,"data-testid":`stage`,className:`stage`,style:g,onPointerDown:S,onPointerUp:e=>C(e,!1),onPointerCancel:e=>C(e,!0),onContextMenu:e=>r&&e.preventDefault(),children:[e.look.ambient&&(0,p.jsx)(`div`,{className:`ambient`,"aria-hidden":`true`,style:{opacity:.35+.65*e.mood.intensity}}),(0,p.jsx)(Ax,{state:v,amplitude:b,pulse:e.presence.pulse,mode:h?`corner`:`full`,accent:e.mood.accent,style:e.presence.style,intensity:e.mood.intensity,scale:e.look.size}),(0,p.jsxs)(`div`,{className:m?`objects objects-stack`:`objects`,style:{zIndex:10},children:[O.length>0&&(0,p.jsx)(`div`,{className:`auto-grid`,children:O.map(A)}),k.map(A)]}),D.length>0&&(0,p.jsxs)(`div`,{className:`overlay-layer`,"data-testid":`overlay`,children:[(0,p.jsx)(`div`,{className:`overlay-backdrop`,onClick:()=>D.forEach(({object:e})=>{t({type:`stage.event`,objectId:e.id,event:`dismiss`}),n({type:`object.dismiss`,id:e.id})})}),D.map(A)]}),e.look.captions&&e.captions&&(0,p.jsx)(`p`,{className:`captions captions-${e.look.captionSize}${e.captionDone?` done`:``}`,"aria-live":`polite`,children:e.captions}),f&&r&&!u&&(0,p.jsx)(gS,{voice:r,mode:_,onType:()=>c(e=>e+1),onMenu:()=>a?.()}),(0,p.jsx)(pS,{requestOpen:s,slash:i,onOpenChange:d,onSend:e=>t({type:`chat.send`,text:e})})]})}function CD(){let e=()=>Math.random().toString(36).slice(2,12)+Date.now().toString(36);try{let t=sessionStorage.getItem(`friend.tab`);return t||(t=e(),sessionStorage.setItem(`friend.tab`,t)),t}catch{return e()}}function wD(){return`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`}function TD(e=wD()){let t=null,n=`connecting`,r=!1,i=0,a=!1,o=CD(),s=null,c=new Set,l=new Set,u=e=>{n=e,l.forEach(t=>t(e))};function d(){if(r)return;u(`connecting`);let n=new WebSocket(`${e}${e.includes(`?`)?`&`:`?`}tab=${o}${a?`&takeover=1`:``}`);t=n,n.onopen=()=>{i=0,a=!1,u(`open`)},n.onmessage=e=>{try{let t=JSON.parse(String(e.data));c.forEach(e=>e(t))}catch{}},n.onclose=e=>{if(!r){if(e.code===4401)return u(`unauthorized`);if(e.code===4409||e.code===4410)return u(`elsewhere`);u(`closed`),s=setTimeout(d,Math.min(500*2**i++,8e3))}},n.onerror=()=>{}}return d(),{send(e){t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},onMessage(e){return c.add(e),()=>c.delete(e)},onState(e){return l.add(e),()=>l.delete(e)},state:()=>n,takeOver(){r||n!==`elsewhere`||(a=!0,i=0,d())},close(){r=!0,s&&clearTimeout(s),t?.close()}}}var ED={scene:`conversation`,objects:[],captions:``,captionDone:!0,presence:{state:`idle`,style:`sphere`,amplitude:0,pulse:0},mood:{accent:`#3fd8ff`,intensity:.6},approval:null,alerts:[],connection:`connecting`,chat:[],chatLive:!1,view:`companion`,look:{size:1,reactivity:.7,ambient:!0,captions:!0,captionSize:`medium`},viewKnown:!1,busy:!1,activity:null,deviceOnline:!1,voice:{mode:`idle`,level:0,available:!1,enrolled:!1},challenge:null,camera:{enabled:!1,stream:null},speaker:null,ownerName:``,assistantName:``,hud:null,music:null,hostMusic:null,musicCmd:null,uiOpen:null},DD=200,OD=e=>e.length>DD?e.slice(-200):e,kD=0,AD=e=>Math.min(1,Math.max(0,e));function jD(e,t){switch(t.cmd){case`scene`:return{...e,scene:t.mode};case`show`:{let n=e.objects.findIndex(e=>e.id===t.object.id),r=n===-1?[...e.objects,t.object]:e.objects.map((e,r)=>r===n?t.object:e);return{...e,objects:r}}case`update`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,props:{...e.props,...t.props}}:e)};case`hide`:return{...e,objects:e.objects.filter(e=>e.id!==t.id)};case`clear`:return{...e,objects:e.objects.filter(e=>e.pinned),scene:`conversation`};case`pin`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,pinned:!0}:e)};case`unpin`:return{...e,objects:e.objects.map(e=>e.id===t.id?(({pinned:e,...t})=>t)(e):e)};case`place`:return{...e,objects:e.objects.map(e=>e.id===t.id?{...e,placement:t.placement}:e)};case`presence`:return{...e,presence:{...e.presence,state:t.state??e.presence.state,style:t.style??e.presence.style}};case`mood`:return{...e,mood:{accent:t.accent??e.mood.accent,intensity:t.intensity??e.mood.intensity}}}}function MD(e,t){let n=t;if(n&&typeof n==`object`){if(n.type===`conn`)return{...e,connection:n.value};if(n.type===`chat.seed`){let t=Array.isArray(n.lines)?n.lines:[];return e.chat.length===0?{...e,chat:OD(t)}:{...e,chat:OD([...t,...e.chat])}}if(n.type===`alert.add`)return{...e,alerts:[...e.alerts.slice(-3),{id:++kD,level:n.level,text:n.text}]};if(n.type===`camera.enable`)return{...e,camera:{enabled:n.value,stream:n.value?e.camera.stream:null}};if(n.type===`camera.open`)return{...e,camera:{...e.camera,stream:n.stream}};if(n.type===`camera.closed`)return{...e,camera:{...e.camera,stream:null}};if(n.type===`challenge.dismiss`)return e.challenge?.id===n.id?{...e,challenge:null}:e;if(n.type===`voice.mode`)return{...e,voice:{...e.voice,mode:n.mode,level:n.mode===`idle`?0:e.voice.level}};if(n.type===`voice.level`){let t=Number.isFinite(n.level)?Math.min(1,Math.max(0,n.level)):0;return{...e,voice:{...e.voice,level:t}}}if(n.type===`object.dismiss`)return{...e,objects:e.objects.filter(e=>e.id!==n.id)};if(n.type===`object.place`)return{...e,objects:e.objects.map(e=>e.id===n.id?{...e,placement:n.placement}:e)};if(n.type===`alert.dismiss`)return{...e,alerts:e.alerts.filter(e=>e.id!==n.id)}}let r=Mu.safeParse(t);if(!r.success)return e;let i=r.data;switch(i.type){case`snapshot`:return{...e,scene:i.stage.scene,objects:i.stage.objects,presence:{...e.presence,state:i.stage.presence.state,style:i.stage.presence.style},mood:i.stage.mood,approval:i.pendingApproval??null};case`stage`:return jD(e,i.command);case`chat.user`:return{...e,chat:OD([...e.chat,{role:`user`,text:i.text}]),chatLive:!1};case`ui.open`:return{...e,uiOpen:{n:(e.uiOpen?.n??0)+1,...i.integration?{integration:i.integration}:{}}};case`ui`:return{...e,view:i.view,look:i.look??e.look,ownerName:i.ownerName??e.ownerName,assistantName:i.assistantName??e.assistantName,hud:i.hud??e.hud,music:i.music??e.music,viewKnown:!0};case`music.host`:return{...e,hostMusic:i.state};case`music.command`:{let{type:t,...n}=i;return{...e,musicCmd:{n:(e.musicCmd?.n??0)+1,command:n}}}case`caption.delta`:{let t=e.captionDone,n=e.chat.at(-1),r=e.chatLive&&n?.role===`assistant`?[...e.chat.slice(0,-1),{role:`assistant`,text:n.text+i.text}]:OD([...e.chat,{role:`assistant`,text:i.text}]);return{...e,chat:r,chatLive:!0,captions:(t?``:e.captions)+i.text,captionDone:!1,presence:{...e.presence,amplitude:AD(.3+i.text.length*.04),pulse:e.presence.pulse+1}}}case`caption.end`:return{...e,chatLive:!1,captionDone:!0,presence:{...e.presence,amplitude:0}};case`approval.request`:{let{type:t,...n}=i;return{...e,approval:n}}case`approval.resolved`:return e.approval?.id===i.id?{...e,approval:null}:e;case`alert`:return{...e,alerts:[...e.alerts.slice(-3),{id:++kD,level:i.level,text:i.text}]};case`activity`:return{...e,activity:i.text};case`status`:return{...e,busy:i.busy,activity:i.busy?e.activity:null,deviceOnline:i.deviceOnline,voice:{...e.voice,available:i.voiceAvailable??e.voice.available,enrolled:i.voiceEnrolled??e.voice.enrolled}};case`error`:return{...e,alerts:[...e.alerts.slice(-3),{id:++kD,level:`error`,text:i.message}]};case`voice.heard`:return{...e,captions:i.trust===`guest`?`Guest: ${i.text}`:i.trust===`member`&&i.speaker?`${i.speaker}: ${i.text}`:i.text,captionDone:!0,speaker:{name:i.trust===`member`?i.speaker??null:null,trust:i.trust??`unverified`,seq:(e.speaker?.seq??0)+1}};case`voice.challenge`:return{...e,challenge:{id:i.id,text:i.text}};case`voice.challenge.end`:return e.challenge?.id===i.id?{...e,challenge:null}:e;case`audio.chunk`:case`audio.stop`:case`audio.duck`:return e;case`camera.request`:case`camera.cancel`:case`screen.request`:case`screen.cancel`:return e}}var ND=1024,PD=.8,FD=300;function ID(e,t){let n=Math.min(1,ND/Math.max(e,t));return{width:Math.round(e*n),height:Math.round(t*n)}}function LD(e){let t=e?.name;return t===`NotAllowedError`||t===`SecurityError`?`permission`:t===`NotFoundError`||t===`OverconstrainedError`?`no-camera`:`busy`}async function RD(){if(!navigator.mediaDevices?.getUserMedia)throw Object.assign(Error(`This browser cannot use the camera here (use localhost or HTTPS).`),{name:`NotFoundError`});return navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280}},audio:!1})}async function zD(e,t=FD){let n=document.createElement(`video`);n.muted=!0,n.playsInline=!0,n.srcObject=e,await n.play(),await new Promise(e=>setTimeout(e,t));let{width:r,height:i}=ID(n.videoWidth||640,n.videoHeight||480),a=document.createElement(`canvas`);return a.width=r,a.height=i,a.getContext(`2d`).drawImage(n,0,0,r,i),n.srcObject=null,new Promise((e,t)=>a.toBlob(n=>n?e(n):t(Error(`Could not encode the picture.`)),`image/jpeg`,PD))}var BD=class{opts;active=null;constructor(e){this.opts=e}async handle(e){if(e.type===`camera.cancel`){let t=this.active;t&&t.id===e.id&&(t.cancelled=!0,this.release(t));return}if(!this.opts.enabled())return this.opts.send({type:`camera.denied`,id:e.id,reason:`off`});if(this.active)return this.opts.send({type:`camera.denied`,id:e.id,reason:`busy`});let t={id:e.id,cancelled:!1,stream:null,opened:!1,released:!1};this.active=t;try{let n=await(this.opts.open??RD)();if(t.stream=n,t.cancelled){n.getTracks().forEach(e=>e.stop());return}t.opened=!0,this.opts.dispatch({type:`camera.open`,stream:n});let r=await(this.opts.frame??(e=>zD(e)))(n);if(t.cancelled)return;this.release(t);try{await this.opts.upload(e.id,r)}catch{this.opts.dispatch({type:`alert.add`,level:`warn`,text:`Could not send the camera picture to Friend.`})}}catch(n){t.cancelled||this.opts.send({type:`camera.denied`,id:e.id,reason:LD(n)})}finally{this.release(t),this.active===t&&(this.active=null)}}dispose(){let e=this.active;e&&(e.cancelled=!0,this.release(e))}release(e){e.released||(e.released=!0,e.stream?.getTracks().forEach(e=>e.stop()),e.opened&&this.opts.dispatch({type:`camera.closed`}))}};function VD(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var HD=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function UD(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var WD=null;function GD(e={}){return WD||(e.includeStyleProperties?(WD=e.includeStyleProperties,WD):(WD=UD(window.getComputedStyle(document.documentElement)),WD))}function KD(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function qD(e){let t=KD(e,`border-left-width`),n=KD(e,`border-right-width`);return e.clientWidth+t+n}function JD(e){let t=KD(e,`border-top-width`),n=KD(e,`border-bottom-width`);return e.clientHeight+t+n}function YD(e,t={}){return{width:t.width||qD(e),height:t.height||JD(e)}}function XD(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var ZD=16384;function QD(e){(e.width>ZD||e.height>ZD)&&(e.width>ZD&&e.height>ZD?e.width>e.height?(e.height*=ZD/e.width,e.width=ZD):(e.width*=ZD/e.height,e.height=ZD):e.width>ZD?(e.height*=ZD/e.width,e.width=ZD):(e.width*=ZD/e.height,e.height=ZD))}function $D(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function eO(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function tO(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),eO(i)}var nO=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||nO(n,t)};function rO(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function iO(e,t){return GD(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function aO(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?rO(n):iO(n,r);return document.createTextNode(`${i}{${a}}`)}function oO(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=HD();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(aO(o,n,i,r)),t.appendChild(s)}function sO(e,t,n){oO(e,t,`:before`,n),oO(e,t,`:after`,n)}var cO=`application/font-woff`,lO=`image/jpeg`,uO={woff:cO,woff2:cO,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:lO,jpeg:lO,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function dO(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function fO(e){return uO[dO(e).toLowerCase()]||``}function pO(e){return e.split(/,/)[1]}function mO(e){return e.search(/^(data:)/)!==-1}function hO(e,t){return`data:${t};base64,${e}`}async function gO(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var _O={};function vO(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function yO(e,t,n){let r=vO(e,t,n.includeQueryParams);if(_O[r]!=null)return _O[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=hO(await gO(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,pO(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return _O[r]=i,i}async function bO(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):$D(t)}async function xO(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),$D(t.toDataURL())}let n=e.poster;return $D(await yO(n,fO(n),t))}async function SO(e,t){try{if(e?.contentDocument?.body)return await MO(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function CO(e,t){return nO(e,HTMLCanvasElement)?bO(e):nO(e,HTMLVideoElement)?xO(e,t):nO(e,HTMLIFrameElement)?SO(e,t):e.cloneNode(TO(e))}var wO=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,TO=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function EO(e,t,n){if(TO(t))return t;let r=[];return r=wO(e)&&e.assignedNodes?UD(e.assignedNodes()):nO(e,HTMLIFrameElement)&&e.contentDocument?.body?UD(e.contentDocument.body.childNodes):UD((e.shadowRoot??e).childNodes),r.length===0||nO(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>MO(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function DO(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):GD(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),nO(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function OO(e,t){nO(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),nO(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function kO(e,t){if(nO(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function AO(e,t,n){return nO(t,Element)&&(DO(e,t,n),sO(e,t,n),OO(e,t),kO(e,t)),t}async function jO(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await MO(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function MO(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>CO(e,t)).then(n=>EO(e,n,t)).then(n=>AO(e,n,t)).then(e=>jO(e,t))}var NO=/url\((['"]?)([^'"]+?)\1\)/g,PO=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,FO=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function IO(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function LO(e){let t=[];return e.replace(NO,(e,n,r)=>(t.push(r),e)),t.filter(e=>!mO(e))}async function RO(e,t,n,r,i){try{let a=n?VD(t,n):t,o=fO(t),s;return s=i?hO(await i(a),o):await yO(a,o,r),e.replace(IO(t),`$1${s}$3`)}catch{}return e}function zO(e,{preferredFontFormat:t}){return t?e.replace(FO,e=>{for(;;){let[n,,r]=PO.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function BO(e){return e.search(NO)!==-1}async function VO(e,t,n){if(!BO(e))return e;let r=zO(e,n);return LO(r).reduce((e,r)=>e.then(e=>RO(e,r,t,n)),Promise.resolve(r))}async function HO(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await VO(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function UO(e,t){await HO(`background`,e,t)||await HO(`background-image`,e,t),await HO(`mask`,e,t)||await HO(`-webkit-mask`,e,t)||await HO(`mask-image`,e,t)||await HO(`-webkit-mask-image`,e,t)}async function WO(e,t){let n=nO(e,HTMLImageElement);if((!n||mO(e.src))&&(!nO(e,SVGImageElement)||mO(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await yO(r,fO(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function GO(e,t){let n=UD(e.childNodes).map(e=>KO(e,t));await Promise.all(n).then(()=>e)}async function KO(e,t){nO(e,Element)&&(await UO(e,t),await WO(e,t),await GO(e,t))}function qO(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var JO={};async function YO(e){let t=JO[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},JO[e]=t,t)}async function XO(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),gO(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function ZO(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function QO(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{UD(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=YO(o).then(e=>XO(e,t)).then(e=>ZO(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(YO(n.href).then(e=>XO(e,t)).then(e=>ZO(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{UD(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function $O(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>BO(e.style.getPropertyValue(`src`)))}async function ek(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return $O(await QO(UD(e.ownerDocument.styleSheets),t))}function tk(e){return e.trim().replace(/["']/g,``)}function nk(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(tk(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function rk(e,t){let n=await ek(e,t),r=nk(e);return(await Promise.all(n.filter(e=>r.has(tk(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return VO(e.cssText,n,t)}))).join(`
|
|
4456
|
+
`)}async function ik(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await rk(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function ak(e,t={}){let{width:n,height:r}=YD(e,t),i=await MO(e,t,!0);return await ik(i,t),await KO(i,t),qO(i,t),await tO(i,n,r)}async function ok(e,t={}){let{width:n,height:r}=YD(e,t),i=await $D(await ak(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||XD(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||QD(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}var sk=1600,ck=.85;function lk(e,t){let n=Math.min(1,sk/Math.max(e,t,1));return{width:Math.max(1,Math.round(e*n)),height:Math.max(1,Math.round(t*n))}}async function uk(){let e=document.documentElement.getBoundingClientRect(),t=await ok(document.body,{width:Math.round(e.width),height:Math.round(e.height),pixelRatio:1,backgroundColor:`#050b10`,filter:e=>!(e instanceof HTMLElement&&e.dataset.noCapture!==void 0)}),n=lk(t.width,t.height),r=document.createElement(`canvas`);return r.width=n.width,r.height=n.height,r.getContext(`2d`).drawImage(t,0,0,n.width,n.height),new Promise((e,t)=>r.toBlob(n=>n?e(n):t(Error(`Could not encode the picture.`)),`image/jpeg`,ck))}var dk=class{opts;active=null;constructor(e){this.opts=e}async handle(e){if(e.type===`screen.cancel`){this.active&&this.active.id===e.id&&(this.active.cancelled=!0);return}if(this.active)return this.opts.send({type:`screen.denied`,id:e.id,reason:`busy`});let t={id:e.id,cancelled:!1};this.active=t;try{let n=await(this.opts.capture??uk)();if(t.cancelled)return;try{await this.opts.upload(e.id,n)}catch{this.opts.dispatch({type:`alert.add`,level:`warn`,text:`Could not send the picture of the screen to Friend.`})}}catch(n){t.cancelled||this.opts.send({type:`screen.denied`,id:e.id,reason:fk(n)})}finally{this.active===t&&(this.active=null)}}dispose(){this.active&&(this.active.cancelled=!0)}};function fk(e){return e?.name===`NotSupportedError`?`unsupported`:`failed`}function pk(e,t){let n=(0,l.useRef)(t);n.current=t;let r=(0,l.useRef)(!1),i=(0,l.useRef)(null);(0,l.useEffect)(()=>{let t=e===`listening`||e===`speaking`;i.current&&clearTimeout(i.current),i.current=null,t?r.current||(r.current=!0,n.current({type:`audio.activity`,active:!0})):r.current&&(i.current=setTimeout(()=>{i.current=null,r.current=!1,n.current({type:`audio.activity`,active:!1})},900))},[e]),(0,l.useEffect)(()=>()=>{i.current&&clearTimeout(i.current),r.current&&(r.current=!1,n.current({type:`audio.activity`,active:!1}))},[])}var mk={401:`Please sign in again.`,413:`That recording was too long.`,409:`Friend is busy with the last request. Try again in a moment.`,429:`You're talking too fast. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function hk(e,t,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":t.type||`audio/webm`},body:t,signal:n})}catch(e){throw e.name===`AbortError`?e:Error(`Could not reach Friend. Check the connection.`)}if(!r.ok){let e=``;try{e=(await r.json()).error??``}catch{}throw Error(e||mk[r.status]||`The voice request failed (${r.status}).`)}let i=await r.json();return{text:typeof i.text==`string`?i.text:``,wake:i.wake===!0}}async function gk(e,t){return{text:(await hk(`/api/voice/utterance`,e,t)).text}}async function _k(e,t){let n=await hk(`/api/voice/utterance?wake=1`,e,t);return{text:n.text,wake:n.wake===!0}}var vk=null;function yk(){try{vk??=new AudioContext,vk.resume().catch(()=>{});let e=vk.currentTime;for(let[t,n]of[660,990].entries()){let r=vk.createOscillator(),i=vk.createGain();r.frequency.value=n,i.gain.setValueAtTime(0,e+t*.11),i.gain.linearRampToValueAtTime(.18,e+t*.11+.02),i.gain.exponentialRampToValueAtTime(.001,e+t*.11+.14),r.connect(i).connect(vk.destination),r.start(e+t*.11),r.stop(e+t*.11+.16)}}catch{}}var bk=/busy with the last request|talking too fast/i,xk=3e4,Sk=50,Ck=class{deps;listener=null;awakeNow=!1;showing=!1;busyWithOne=!1;clock=null;meter=null;abort=null;lastAlert=0;constructor(e){this.deps=e}get enabled(){return this.listener!==null}get awake(){return this.awakeNow}async enable(){if(this.listener)return;let e=this.deps.makeListener({onUtterance:e=>void this.heard(e),onError:e=>{this.drop(),this.alert(e,!0)}});try{await e.start()}catch(e){this.alert(e.message,!0);return}this.listener=e}disable(){this.drop()}sync(){let e=this.listener;if(!e)return;let t=this.busyOther();if(e.pause(t),!this.awakeNow||t){this.clearClock(),this.stopMeter();return}this.deps.mode()===`idle`&&this.show(),this.clock||this.startClock(),this.startMeter()}busyOther(){let e=this.deps.mode();return e!==`listening`&&(this.showing=!1),e===`speaking`||e===`transcribing`||e===`listening`&&!this.showing}show(){this.showing=!0,this.deps.dispatch({type:`voice.mode`,mode:`listening`})}wakeUp(e){this.awakeNow=!0,e&&this.deps.chime(),this.clearClock(),this.show(),this.startClock(),this.startMeter()}sleep(){this.awakeNow=!1,this.clearClock(),this.stopMeter(),this.showing&&this.deps.dispatch({type:`voice.mode`,mode:`idle`}),this.showing=!1}drop(){let e=this.listener;this.listener=null,this.abort?.abort(),this.abort=null,this.busyWithOne=!1,this.sleep(),e?.stop()}startClock(){this.clearClock(),this.clock=setTimeout(()=>{this.clock=null,this.sleep()},this.deps.awakeMs??3e4)}clearClock(){this.clock&&clearTimeout(this.clock),this.clock=null}startMeter(){this.meter||=setInterval(()=>this.deps.dispatch({type:`voice.level`,level:this.listener?.level()??0}),Sk)}stopMeter(){this.meter&&clearInterval(this.meter),this.meter=null}async heard(e){if(!this.listener||this.busyWithOne||this.busyOther())return;this.busyWithOne=!0;let t=new AbortController;this.abort=t;try{this.awakeNow?await this.request(e,t.signal):await this.check(e,t.signal)}catch(e){e.name!==`AbortError`&&!bk.test(e.message)&&this.alert(e.message,!1)}finally{this.abort===t&&(this.abort=null),this.busyWithOne=!1,this.listener&&this.awakeNow&&(this.clearClock(),this.deps.mode()===`transcribing`&&this.deps.dispatch({type:`voice.mode`,mode:`idle`}),this.sync())}}async check(e,t){let n=await this.deps.wake(e,t);this.listener&&n.wake&&this.wakeUp(!n.text)}async request(e,t){this.clearClock(),this.stopMeter(),this.showing=!1,this.deps.dispatch({type:`voice.mode`,mode:`transcribing`}),await this.deps.command(e,t)}alert(e,t){let n=Date.now();!t&&n-this.lastAlert<xk||(this.lastAlert=n,this.deps.dispatch({type:`alert.add`,level:`error`,text:e}))}},wk=0,Tk=new Set;function Ek(e){return Tk.add(e),()=>Tk.delete(e)}var Dk=e=>Tk.forEach(t=>{try{t(e)}catch{}}),Ok=e=>/not compatible|audio capture|audiosession/i.test(String(e?.message??e));function kk(e){try{let t=navigator.audioSession;t&&t.type!==e&&(t.type=e)}catch{}}function Ak(){wk===0&&kk(`playback`)}function jk(){wk++,wk===1&&Dk(!0),kk(`play-and-record`);let e=!1;return()=>{e||(e=!0,wk=Math.max(0,wk-1),wk===0&&(kk(`playback`),Dk(!1)))}}var Mk=3,Nk=.02,Pk=.04,Fk=class{minSpeechMs;endSilenceMs;maxMs;floor=null;loudSince=null;speaking=!1;startedAt=0;lastLoud=0;lastFeed=0;speechMs=0;constructor(e={}){this.minSpeechMs=e.minSpeechMs??300,this.endSilenceMs=e.endSilenceMs??800,this.maxMs=e.maxMs??8e3}get inSpeech(){return this.speaking}get maybeSpeech(){return this.loudSince!==null}feed(e,t){this.floor===null&&(this.floor=e);let n=e>Math.max(this.floor*Mk+Nk,Pk),r=Math.min(100,Math.max(0,t-this.lastFeed));if(this.lastFeed=t,!this.speaking)return n?(this.loudSince??=t,t-this.loudSince<this.minSpeechMs?null:(this.speaking=!0,this.startedAt=this.loudSince,this.lastLoud=t,this.speechMs=t-this.loudSince,{type:`start`})):(this.loudSince=null,this.floor+=(e-this.floor)*(e<this.floor?.3:.02),null);n&&(this.lastLoud=t,this.speechMs+=r);let i=t-this.startedAt>=this.maxMs;if(!i&&t-this.lastLoud<this.endSilenceMs)return null;let a={type:`end`,ms:t-this.startedAt,speechMs:this.speechMs,forced:i};return this.speaking=!1,this.loudSince=null,i&&n&&(this.floor=e),a}reset(){this.speaking=!1,this.loudSince=null}},Ik=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`],Lk=50,Rk=2e3,zk=2e3,Bk=400,Vk=e=>{let t=e?.name;return t===`NotAllowedError`||t===`SecurityError`?`Microphone permission was denied. Allow it in the browser to use hands-free.`:t===`NotFoundError`||t===`OverconstrainedError`?`No microphone was found.`:e?.message||`Could not open the microphone.`},Hk=class{opts;stream=null;ctx=null;analyser=null;rec=null;chunks=[];recStartedAt=0;timer=null;seg;leaveSession=null;paused=!1;starting=!1;finishing=!1;opened=!1;now;constructor(e){this.opts=e,this.seg=new Fk(e),this.now=e.now??(()=>Date.now())}static supported(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`}get listening(){return this.opened}async start(){if(!(this.opened||this.starting)){this.starting=!0;try{this.leaveSession=jk();try{this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(e){throw this.leaveSession?.(),this.leaveSession=null,Error(Vk(e))}for(let e of this.stream.getTracks())e.onended=()=>this.broke(`The microphone stopped working.`);try{this.ctx=new AudioContext,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.ctx.createMediaStreamSource(this.stream).connect(this.analyser),this.ctx.resume().catch(()=>{})}catch{throw this.release(),Error(`This browser cannot listen continuously here.`)}this.seg.reset(),this.beginRecording(),this.opened=!0,this.timer=setInterval(()=>this.tick(),Lk)}finally{this.starting=!1}}}stop(){this.opened=!1,this.release()}pause(e){this.paused!==e&&(this.paused=e,this.seg.reset(),!e&&this.opened&&this.restartRecording())}level(){if(!this.analyser)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}tick(){if(!this.opened)return;let e=this.now();if(this.ctx&&this.ctx.state!==`running`&&this.ctx.resume().catch(()=>{}),this.paused){e-this.recStartedAt>=Rk&&this.restartRecording();return}let t=this.seg.feed(this.level(),e);t?.type===`end`?this.finish(t.ms,t.speechMs):!t&&!this.seg.inSpeech&&!this.seg.maybeSpeech&&e-this.recStartedAt>=Rk&&this.restartRecording()}beginRecording(){if(!this.stream)return;let e=Ik.find(e=>MediaRecorder.isTypeSupported(e));this.chunks=[];let t=new MediaRecorder(this.stream,e?{mimeType:e}:void 0);t.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},t.onerror=()=>this.broke(`The microphone stopped working.`),t.start(250),this.rec=t,this.recStartedAt=this.now()}restartRecording(){let e=this.rec;if(this.rec=null,e){e.ondataavailable=null,e.onstop=null,e.onerror=null;try{e.state!==`inactive`&&e.stop()}catch{}}this.opened&&this.beginRecording()}async finish(e,t){let n=this.rec;if(!n||this.finishing)return;this.finishing=!0;let r=n.mimeType||`audio/webm`,i=await new Promise(e=>{let t=!1,i=()=>{t||(t=!0,e(new Blob(this.chunks,{type:r})))},a=setTimeout(i,zk);n.onstop=()=>{clearTimeout(a),i()};try{n.state===`inactive`?i():n.stop()}catch{i()}});this.finishing=!1,this.rec=null,this.opened&&(this.beginRecording(),!this.paused&&e>=Bk&&t>=Bk/2&&i.size>0&&this.opts.onUtterance(i))}broke(e){this.opened&&(this.stop(),this.opts.onError(e))}release(){if(this.timer&&clearInterval(this.timer),this.timer=null,this.rec){this.rec.ondataavailable=null,this.rec.onstop=null,this.rec.onerror=null;try{this.rec.state!==`inactive`&&this.rec.stop()}catch{}}this.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.ctx?.close().catch(()=>{}),this.stream=null,this.ctx=null,this.analyser=null,this.rec=null,this.chunks=[],this.leaveSession?.(),this.leaveSession=null}},Uk=4096,Wk=8,Gk=20,Kk=6e6;function qk(e){try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}}var Jk=class{ctx=null;analyser=null;pending=new Map;queue=[];current=null;busy=!1;gen=0;isPlaying=!1;unwatch=null;listeners=new Set;unlock(){Ak();let e=this.ensureContext();e.state!==`running`&&e.resume().catch(()=>{})}locked(){return!this.ctx||this.ctx.state!==`running`}enqueue(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>Uk)return;let t=qk(e.data);if(!t)return;let n=this.pending.get(e.id);if(n||(this.pending.size>=Wk&&this.pending.delete(this.pending.keys().next().value),n={parts:new Map,lastSeq:null,bytes:0},this.pending.set(e.id,n)),n.bytes+=t.length,n.bytes>Kk){this.pending.delete(e.id);return}if(n.parts.set(e.seq,t),e.last&&(n.lastSeq=e.seq),n.lastSeq===null||n.parts.size!==n.lastSeq+1)return;this.pending.delete(e.id);let r=new Uint8Array([...n.parts.values()].reduce((e,t)=>e+t.length,0)),i=0;for(let e=0;e<=n.lastSeq;e++){let t=n.parts.get(e);if(!t)return;r.set(t,i),i+=t.length}for(this.queue.push(r.buffer);this.queue.length>Gk;)this.queue.shift();this.pump()}stop(){this.gen++,this.queue=[],this.pending.clear(),this.busy=!1;let e=this.current;if(this.current=null,e){e.onended=null;try{e.stop()}catch{}}this.setPlaying(!1)}dispose(){this.stop(),this.ctx?.close().catch(()=>{}),this.unwatch?.(),this.unwatch=null,this.ctx=null,this.analyser=null}playing(){return this.isPlaying}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}level(){if(!this.analyser||!this.isPlaying)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}ensureContext(){if(!this.ctx){let e=window.AudioContext??window.webkitAudioContext;this.ctx=new e,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.analyser.connect(this.ctx.destination);let t=this.ctx;this.unwatch?.(),this.unwatch=Ek(e=>{e&&t.state===`running`?t.suspend().catch(()=>{}):!e&&t.state!==`running`&&t.state!==`closed`&&t.resume().catch(()=>{})})}return this.ctx}setPlaying(e){this.isPlaying!==e&&(this.isPlaying=e,this.listeners.forEach(t=>t(e)))}async pump(){if(this.busy)return;let e=this.queue.shift();if(!e){this.setPlaying(!1);return}this.busy=!0;let t=this.gen;try{let n=this.ensureContext();if(n.state!==`running`){try{await n.resume()}catch{}if(t!==this.gen)return;if(n.state!==`running`){this.queue.unshift(e),this.busy=!1;return}}let r=await n.decodeAudioData(e);if(t!==this.gen)return;let i=n.createBufferSource();i.buffer=r,i.connect(this.analyser),i.onended=()=>{this.current===i&&(this.current=null,this.busy=!1,this.pump())},this.current=i,this.setPlaying(!0),i.start()}catch{if(t!==this.gen)return;this.busy=!1,this.pump()}}},Yk=e=>new Promise(t=>setTimeout(t,e)),Xk=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`],Zk=3e3;function Qk(e){let t=e;return t?.name===`NotAllowedError`||t?.name===`SecurityError`?Error(`Microphone permission was denied. Allow it in the browser to talk.`):t?.name===`NotFoundError`||t?.name===`OverconstrainedError`?Error(`No microphone was found.`):Error(t?.message||`Could not open the microphone.`)}var $k=class e{opts;stream=null;rec=null;chunks=[];ctx=null;analyser=null;timer=null;starting=!1;leaveSession=null;constructor(e={}){this.opts=e}static supported(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`}get active(){return this.rec!==null}async start(){if(!(this.rec||this.starting)){if(!e.supported())throw Error(`This browser cannot record audio here (use localhost or HTTPS).`);this.starting=!0;try{this.leaveSession=jk();try{let e=()=>navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});try{this.stream=await e()}catch(t){if(!Ok(t))throw t;await Yk(250),this.leaveSession?.(),this.leaveSession=jk(),this.stream=await e()}}catch(e){throw this.leaveSession?.(),this.leaveSession=null,Qk(e)}try{let e=Xk.find(e=>MediaRecorder.isTypeSupported(e));this.chunks=[];let t=new MediaRecorder(this.stream,e?{mimeType:e}:void 0);t.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},t.onerror=()=>this.failed();for(let e of this.stream.getTracks())e.onended=()=>this.failed();this.openMeter(this.stream),t.start(250),this.rec=t,this.opts.maxMs&&(this.timer=setTimeout(()=>{this.timer=null,this.opts.onLimit?.()},this.opts.maxMs))}catch(e){throw this.release(),Qk(e)}}finally{this.starting=!1}}}stop(){let e=this.rec;return e?new Promise(t=>{let n=!1,r=null,i=()=>{if(n)return;n=!0,r&&clearTimeout(r);let i=new Blob(this.chunks,{type:e.mimeType||`audio/webm`});this.release(),t(i)};if(r=setTimeout(i,Zk),e.onstop=i,e.state===`inactive`)return i();try{e.stop()}catch{i()}}):Promise.reject(Error(`Not recording.`))}cancel(){let e=this.rec;if(e){e.ondataavailable=null,e.onstop=null,e.onerror=null;try{e.state!==`inactive`&&e.stop()}catch{}}this.release()}level(){if(!this.analyser||!this.rec)return 0;let e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(let n of e)t+=((n-128)/128)**2;return Math.min(1,Math.sqrt(t/e.length)*4)}failed(){this.rec&&(this.cancel(),this.opts.onError?.())}openMeter(e){try{this.ctx=new AudioContext,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.ctx.createMediaStreamSource(e).connect(this.analyser)}catch{this.analyser=null}}release(){this.timer&&clearTimeout(this.timer),this.timer=null,this.stream?.getTracks().forEach(e=>{e.onended=null,e.stop()}),this.ctx?.close().catch(()=>{}),this.stream=null,this.rec=null,this.ctx=null,this.analyser=null,this.chunks=[],this.leaveSession?.(),this.leaveSession=null}},eA=2e3,tA=()=>typeof window<`u`&&window.isSecureContext===!1,nA=50,rA=class{deps;recorder;player;mode=`idle`;pressed=!1;disposed=!1;uploads=0;toldAboutSound=!1;abort=null;poll=null;unsubscribe;constructor(e){this.deps=e;let t=()=>this.recorderFailed();this.recorder=e.recorder??e.makeRecorder?.(t)??new $k({maxMs:6e4,onLimit:()=>void this.pressEnd(),onError:t}),this.player=e.player??new Jk,this.unsubscribe=this.player.onChange(e=>{this.mode!==`listening`&&this.mode!==`transcribing`&&this.setMode(e?`speaking`:`idle`)})}async pressStart(){if(!(this.pressed||this.disposed)){if(!this.deps.available()){this.alert(`warn`,`Voice is not available. Run: friend voice setup`);return}if(!(this.deps.supported?.()??$k.supported())){this.alert(`warn`,tA()?`This page is not secure, so the browser blocks the microphone. On the PC run: friend lan https on, restart Friend, and open the https:// address.`:`This browser cannot record audio here (use localhost or HTTPS).`);return}this.pressed=!0,this.player.unlock(),this.player.playing()&&(this.deps.send({type:`voice.interrupt`}),this.player.stop());try{await this.recorder.start()}catch(e){this.pressed=!1,this.alert(`error`,e.message),this.setMode(`idle`);return}if(!this.pressed){this.recorder.cancel(),this.setMode(`idle`);return}this.setMode(`listening`)}}async pressEnd(){if(!this.pressed||(this.pressed=!1,!this.recorder.active))return;let e=await this.recorder.stop();if(e.size<eA){this.alert(`info`,`Hold the key a little longer while you speak.`),this.setMode(`idle`);return}this.setMode(`transcribing`);let t=new AbortController;this.abort=t,this.uploads++;try{let{text:n}=await this.deps.post(e,t.signal);n.trim()||this.alert(`info`,`I didn't catch that.`)}catch(e){e.name!==`AbortError`&&this.alert(`error`,e.message)}finally{this.uploads--,this.abort===t&&(this.abort=null),this.settle()}}blur(){this.pressed&&(this.pressed=!1,this.recorder.cancel(),this.setMode(`idle`))}handleServer(e){if(e.type!==`audio.chunk`)return this.player.stop();this.player.enqueue(e),!this.toldAboutSound&&this.player.locked?.()&&(this.toldAboutSound=!0,this.deps.dispatch({type:`alert.add`,level:`info`,text:`Sound is blocked by the browser. Click or press a key once anywhere on the page to hear me.`}))}unlock(){this.player.unlock()}dispose(){this.disposed=!0,this.pressed=!1,this.stopPolling(),this.abort?.abort(),this.recorder.cancel(),this.player.stop(),this.player.dispose?.(),this.unsubscribe()}recorderFailed(){this.pressed=!1,this.recorder.cancel(),this.alert(`error`,`The microphone stopped working.`),this.setMode(`idle`)}settle(){this.uploads>0||this.mode!==`transcribing`||this.setMode(this.player.playing()?`speaking`:`idle`)}setMode(e){this.disposed||(this.mode=e,this.deps.dispatch({type:`voice.mode`,mode:e}),e===`listening`||e===`speaking`?this.startPolling():this.stopPolling())}startPolling(){this.stopPolling(),this.poll=setInterval(()=>{let e=this.mode===`listening`?this.recorder.level():this.player.level();this.deps.dispatch({type:`voice.level`,level:e})},nA)}stopPolling(){this.poll&&clearInterval(this.poll),this.poll=null}alert(e,t){this.disposed||this.deps.dispatch({type:`alert.add`,level:e,text:t})}};function iA(e){let[t,n]=(0,l.useReducer)(MD,ED),r=(0,l.useRef)(null),i=(0,l.useRef)(null),a=(0,l.useRef)(null),o=(0,l.useRef)(null),[s,c]=(0,l.useState)(!1),u=(0,l.useRef)(e);u.current=e;let d=(0,l.useRef)(t);d.current=t,(0,l.useEffect)(()=>{let e=TD();r.current=e;let t=new rA({send:t=>e.send(t),dispatch:e=>n(e),post:gk,available:()=>d.current.voice.available});i.current=t;let s=new Ck({makeListener:e=>new Hk(e),wake:_k,command:gk,mode:()=>d.current.voice.mode,chime:yk,dispatch:e=>n(e)});o.current=s;let l=new BD({send:t=>e.send(t),dispatch:e=>n(e),enabled:()=>d.current.camera.enabled,upload:async(e,t)=>{let n=await fetch(`/api/camera/frame/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`image/jpeg`},body:t});if(!n.ok)throw Error(`upload failed (${n.status})`)}});a.current=l;let f=new dk({send:t=>e.send(t),dispatch:e=>n(e),upload:async(e,t)=>{let n=await fetch(`/api/screen/frame/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`image/jpeg`},body:t});if(!n.ok)throw Error(`upload failed (${n.status})`)}}),p=e.onMessage(e=>{n(e);let r=e?.type,i=e?.id;(r===`camera.request`||r===`camera.cancel`)&&typeof i==`string`&&l.handle({type:r,id:i}),(r===`screen.request`||r===`screen.cancel`)&&typeof i==`string`&&f.handle({type:r,id:i}),r===`audio.duck`&&gE.set(e.level??1),(r===`audio.chunk`||r===`audio.stop`)&&t.handleServer(e)}),m=e.onState(e=>{n({type:`conn`,value:e}),e!==`open`&&gE.set(1,0),e===`unauthorized`&&u.current(),e===`elsewhere`&&(s.disable(),c(!1),t.blur(),l.dispose(),f.dispose())});return()=>{p(),m(),s.disable(),o.current=null,t.dispose(),l.dispose(),f.dispose(),e.close(),i.current=null,a.current=null,r.current=null}},[]),(0,l.useEffect)(()=>{t.camera.enabled||a.current?.dispose()},[t.camera.enabled]),(0,l.useEffect)(()=>{o.current?.sync()},[t.voice.mode]);let f=(0,l.useCallback)(async e=>{let t=o.current;if(t){e?await t.enable():t.disable(),c(t.enabled);try{localStorage.setItem(`friend.handsFree`,t.enabled?`1`:`0`)}catch{}}},[]),p=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!p.current&&t.voice.available){p.current=!0;try{localStorage.getItem(`friend.handsFree`)===`1`&&Hk.supported()&&f(!0)}catch{}}},[t.voice.available,f]);let m=(0,l.useMemo)(()=>({on:s,supported:Hk.supported(),toggle:()=>void f(!o.current?.enabled)}),[s,f]),h=(0,l.useCallback)(e=>r.current?.send(e),[]);return pk(t.voice.mode,h),{state:t,send:h,dispatch:(0,l.useCallback)(e=>n(e),[]),voice:(0,l.useMemo)(()=>({pressStart:()=>void i.current?.pressStart(),pressEnd:()=>void i.current?.pressEnd(),blur:()=>i.current?.blur(),unlock:()=>i.current?.unlock()}),[]),handsFree:m,useHere:(0,l.useCallback)(()=>r.current?.takeOver(),[])}}var aA={401:`Please sign in again.`,403:`Incorrect PIN.`,413:`That recording was too long.`,429:`Too many attempts. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function oA(e,t){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||aA[n.status]||`The request failed (${n.status}).`)}return await n.json()}var sA=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),cA={state:()=>oA(`/api/voice/enroll`,{}),sample:e=>oA(`/api/voice/enroll/sample`,{method:`POST`,headers:{"content-type":e.type||`audio/webm`},body:e}),finish:e=>oA(`/api/voice/enroll/finish`,sA(`POST`,{pin:e})),cancel:async()=>{await oA(`/api/voice/enroll/cancel`,sA(`POST`,{}))},remove:async e=>{await oA(`/api/voice/enroll`,sA(`DELETE`,{pin:e}))}},lA=[`Friend, good evening. It is a pleasant day to get things done.`,`Open my projects and show me what changed today.`,`My voice is my key, so please remember it well.`,`Check the weather and read me the latest headlines.`,`Always protect the boss, and never trust a stranger.`],uA=15e3;function dA({api:e=cA,createRecorder:t=e=>new $k(e),onClose:n,who:r}){let[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),[f,m]=(0,l.useState)(`record`),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(``),C=(0,l.useRef)(!0),w=(0,l.useRef)(null);(0,l.useEffect)(()=>(C.current=!0,e.state().then(e=>{C.current&&(a(e),s(e.samples))}).catch(e=>C.current&&b(e.message)),()=>{C.current=!1,w.current?.cancel(),w.current=null}),[e]);let E=(0,l.useCallback)(async()=>{let t=w.current;if(t){w.current=null,g(!1),v(!0);try{let n=await t.stop(),r=await e.sample(n);if(!C.current)return;s(r.count),u(r.note)}catch(e){C.current&&b(e.message)}finally{C.current&&v(!1)}}},[e]),D=async()=>{b(null),u(null);let e=t({maxMs:uA,onLimit:()=>void E(),onError:()=>{w.current=null,C.current&&(g(!1),b(`The microphone stopped working. Try again.`))}});try{await e.start()}catch(e){C.current&&b(e.message);return}if(!C.current)return e.cancel();w.current=e,g(!0)},O=async e=>{b(null),v(!0);try{await e()}catch(e){C.current&&b(e.message)}finally{C.current&&(v(!1),S(``))}},k=async()=>{w.current?.cancel(),w.current=null,await e.cancel().catch(()=>{}),n()},A=i?.min??3,j=o%lA.length,ee=o<lA.length?`Phrase ${o+1} of ${lA.length}`:`Extra recording (${o} so far)`;return(0,p.jsxs)(`div`,{className:`approval enroll glass`,role:`dialog`,"aria-label":`Voice enrollment`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:r?`Teach Friend ${r}'s voice`:`Teach Friend your voice`})}),f===`record`&&(0,p.jsxs)(p.Fragment,{children:[!r&&i?.enrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Your voice is already saved. Saving a new one replaces it.`}),r&&(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Hand the device to `,r,`. `,r,` reads each sentence aloud, close to the microphone, in a quiet room.`]}),(0,p.jsxs)(`p`,{className:`auth-note`,children:[ee,`. Press Record, read this aloud in a quiet room, then press Stop.`]}),(0,p.jsx)(`pre`,{className:`approval-summary`,"data-testid":`enroll-phrase`,style:{whiteSpace:`pre-wrap`},children:lA[j]}),(0,p.jsxs)(`div`,{role:`status`,className:`auth-note`,children:[o,` recorded`,o>=A?` — enough to save`:` — at least ${A} needed`,`.`,c?` ${c}`:``]}),y&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:y}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[h?(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>void E(),children:`Stop`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:_||!i||o>=(i?.max??8),onClick:()=>void D(),children:_?`Uploading…`:`Record`}),(0,p.jsx)(`button`,{type:`button`,style:d,disabled:h||_||o<A,onClick:()=>m(`pin-save`),children:r?`Save ${r}'s voice`:`Save my voice`}),!r&&i?.enrolled&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:h||_,onClick:()=>m(`pin-delete`),children:`Delete my voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>void k(),children:`Cancel`})]})]}),(f===`pin-save`||f===`pin-delete`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:f===`pin-save`?r?`Enter your PIN to save ${r}'s voice.`:`Enter your PIN to save your voice.`:`Enter your PIN to delete your saved voice.`}),(0,p.jsx)(T,{pin:x,onChange:S,onSubmit:f===`pin-save`?()=>!_&&void O(async()=>{await e.finish(x),C.current&&m(`saved`)}):void 0}),y&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:y}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[f===`pin-save`?(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:_||x.length<6,onClick:()=>void O(async()=>{await e.finish(x),C.current&&m(`saved`)}),children:`Save`}):(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:_||x.length<6,onClick:()=>void O(async()=>{await e.remove(x),C.current&&m(`deleted`)}),children:`Delete`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{S(``),b(null),m(`record`)},children:`Back`})]})]}),(f===`saved`||f===`deleted`)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:f===`saved`?r?`${r}'s voice is saved. From now on I will know when ${r} is talking.`:`Your voice is saved. From now on I will tell you apart from other speakers.`:`Your voice was deleted. Every voice is treated as yours until you enroll again.`}),(0,p.jsx)(`div`,{className:`approval-actions`,children:(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,onClick:n,children:`Done`})})]})]})}var fA=new Set([`INPUT`,`TEXTAREA`,`SELECT`,`BUTTON`,`A`,`SUMMARY`]),pA=new Set([`button`,`checkbox`,`switch`,`tab`,`menuitem`,`link`,`radio`,`option`,`textbox`,`combobox`,`slider`]),mA=e=>e instanceof HTMLElement&&(fA.has(e.tagName)||e.isContentEditable||pA.has(e.getAttribute(`role`)??``)),hA=e=>e.code===`Space`||e.key===` `;function gA(e){let t=(0,l.useRef)(e);t.current=e,(0,l.useEffect)(()=>{let e=!1,n=n=>{!hA(n)||n.ctrlKey||n.metaKey||n.altKey||mA(n.target)||mA(document.activeElement)||(n.preventDefault(),!(n.repeat||e)&&(e=!0,t.current.pressStart()))},r=n=>{hA(n)&&e&&(e=!1,n.preventDefault(),t.current.pressEnd())},i=()=>{e=!1,t.current.blur()},a=()=>{document.hidden&&i()};return window.addEventListener(`keydown`,n),window.addEventListener(`keyup`,r),window.addEventListener(`blur`,i),document.addEventListener(`visibilitychange`,a),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`keyup`,r),window.removeEventListener(`blur`,i),document.removeEventListener(`visibilitychange`,a)}},[])}function _A(e){let t=(0,l.useRef)(e);t.current=e,(0,l.useEffect)(()=>{let e=()=>t.current.unlock(),n=[`pointerdown`,`keydown`,`touchend`];for(let t of n)window.addEventListener(t,e,{passive:!0});return()=>{for(let t of n)window.removeEventListener(t,e)}},[])}function vA({onUseHere:e}){return(0,p.jsx)(`div`,{className:`elsewhere`,role:`alertdialog`,"aria-labelledby":`elsewhere-title`,"data-testid":`elsewhere`,children:(0,p.jsxs)(`div`,{className:`elsewhere-card`,children:[(0,p.jsx)(`h2`,{id:`elsewhere-title`,children:`Friend is open in another window`}),(0,p.jsx)(`p`,{children:`Friend works in one window at a time. Click “Use here” to use it in this window instead; the other one will stop.`}),(0,p.jsx)(`button`,{type:`button`,className:`elsewhere-btn`,onClick:e,autoFocus:!0,children:`Use here`})]})})}function yA(e,t,n){let r=Math.max(100,Math.round(e)),i=Math.max(100,Math.round(t));return{width:r,height:i,kind:r<=599?`phone`:n||r<1024?`tablet`:`desktop`,orientation:i>r?`portrait`:`landscape`,touch:n}}var bA=()=>typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches;function xA(){return yA(window.innerWidth,window.innerHeight,bA())}var SA=(e,t)=>!!e&&e.width===t.width&&e.height===t.height&&e.kind===t.kind&&e.orientation===t.orientation&&e.touch===t.touch;function CA(e,t){let n=(0,l.useRef)(null),r=(0,l.useRef)(e);r.current=e,(0,l.useEffect)(()=>{if(t!==`open`){n.current=null;return}let e=()=>{let e=xA();SA(n.current,e)||(n.current=e,r.current({type:`ui.screen`,...e}))};e();let i=null,a=()=>{i&&clearTimeout(i),i=setTimeout(e,400)};return window.addEventListener(`resize`,a),window.addEventListener(`orientationchange`,a),()=>{i&&clearTimeout(i),window.removeEventListener(`resize`,a),window.removeEventListener(`orientationchange`,a)}},[t])}var wA={401:`Please sign in again.`,403:`Incorrect PIN.`,413:`That recording was too long.`,429:`Too many attempts. Wait a moment.`,503:`Voice is not available. Run: friend voice setup`};async function TA(e,t={}){let n;try{n=await fetch(e,t)}catch{throw Error(`Could not reach Friend. Check the connection.`)}if(!n.ok){let e=``;try{e=(await n.json()).error??``}catch{}throw Error(e||wA[n.status]||`The request failed (${n.status}).`)}return await n.json()}var EA=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),DA={overview:()=>TA(`/api/voice/people`),begin:e=>TA(`/api/voice/people/begin`,EA(`POST`,{name:e})),recording:{state:async()=>(await TA(`/api/voice/people`)).enrolling??{enrolled:!1,samples:0,min:3,max:8},sample:e=>TA(`/api/voice/people/sample`,{method:`POST`,headers:{"content-type":e.type||`audio/webm`},body:e}),finish:e=>TA(`/api/voice/people/finish`,EA(`POST`,{pin:e})),cancel:async()=>{await TA(`/api/voice/people/cancel`,EA(`POST`,{}))},remove:async()=>{}},removePerson:async(e,t)=>{await TA(`/api/voice/people/${e}`,EA(`DELETE`,{pin:t}))}};function OA({api:e=DA,createRecorder:t,onClose:n}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)({kind:`list`}),[s,c]=(0,l.useState)(``),[u,f]=(0,l.useState)(``),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(null),v=(0,l.useRef)(!0),y=(0,l.useCallback)(()=>{e.overview().then(e=>v.current&&i(e)).catch(e=>v.current&&_(e.message))},[e]);(0,l.useEffect)(()=>(v.current=!0,y(),()=>{v.current=!1}),[y]);let b=async()=>{_(null),h(!0);try{let t=await e.begin(s.trim());v.current&&o({kind:`record`,name:t.name})}catch(e){v.current&&_(e.message)}finally{v.current&&h(!1)}},x=async t=>{_(null),h(!0);try{if(await e.removePerson(t.id,u),!v.current)return;o({kind:`list`}),y()}catch(e){v.current&&_(e.message)}finally{v.current&&(h(!1),f(``))}};return a.kind===`record`?(0,p.jsx)(dA,{api:e.recording,who:a.name,...t?{createRecorder:t}:{},onClose:()=>{c(``),o({kind:`list`}),y()}}):(0,p.jsxs)(`div`,{className:`approval enroll glass`,role:`dialog`,"aria-label":`Family voices`,style:{pointerEvents:`auto`},children:[(0,p.jsx)(`div`,{className:`approval-head`,children:(0,p.jsx)(`span`,{className:`approval-title`,children:`Family voices`})}),a.kind===`list`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`auth-note`,children:`Friend knows your voice. Add the people at home, so it knows who is talking and answers them by name. They can chat and ask for the weather, but cannot use your PC or see your private things.`}),r&&!r.ownerEnrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`First teach Friend your own voice (Esc, then Enroll my voice).`}),r&&r.people.length===0&&r.ownerEnrolled&&(0,p.jsx)(`p`,{className:`auth-note`,children:`Nobody added yet.`}),r&&r.people.length>0&&(0,p.jsx)(`ul`,{className:`household-list`,"aria-label":`People Friend knows`,children:r.people.map(e=>(0,p.jsxs)(`li`,{className:`household-row`,children:[(0,p.jsx)(`span`,{children:e.name}),(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,onClick:()=>o({kind:`remove`,person:e}),"aria-label":`Remove ${e.name}`,children:`Remove`})]},e.id))}),r&&r.ownerEnrolled&&r.people.length<r.max&&(0,p.jsxs)(`label`,{className:`settings-field`,children:[(0,p.jsx)(`span`,{children:`Add a person`}),(0,p.jsx)(`input`,{value:s,maxLength:40,placeholder:`Name, for example Priya`,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s.trim()&&!m&&void b()})]}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[r&&r.ownerEnrolled&&r.people.length<r.max&&(0,p.jsx)(`button`,{type:`button`,style:d,className:`primary`,disabled:m||!s.trim(),onClick:()=>void b(),children:`Record their voice`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:n,children:`Close`})]})]}),a.kind===`remove`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`auth-note`,children:[`Enter your PIN to remove `,a.person.name,`’s voice. Friend will treat their voice as a stranger’s.`]}),(0,p.jsx)(T,{pin:u,onChange:f}),g&&(0,p.jsx)(`p`,{role:`alert`,className:`auth-error`,children:g}),(0,p.jsxs)(`div`,{className:`approval-actions`,children:[(0,p.jsx)(`button`,{type:`button`,style:d,className:`danger`,disabled:m||u.length<6,onClick:()=>void x(a.person),children:`Remove`}),(0,p.jsx)(`button`,{type:`button`,style:d,onClick:()=>{f(``),_(null),o({kind:`list`})},children:`Back`})]})]})]})}var kA=`▌▍▎▏█▓▒░<>/\\|+-=*#%&0123456789ABCDEF`;function AA(e,t,n=Math.random){let r=[...e];if(t>=1)return e;let i=Math.floor(r.length*Math.max(0,t));return r.map((e,t)=>t<i||e===` `?e:kA[Math.floor(n()*36)]).join(``)}var jA=e=>e.length===0?0:Math.min(24,Math.max(6,Math.ceil([...e].length/2)));function MA(e,t){let[n,r]=(0,l.useState)(e),i=(0,l.useRef)(e);return(0,l.useEffect)(()=>{if(!t||e===i.current){i.current=e,r(e);return}i.current=e;let n=jA(e);if(n===0){r(e);return}let a=0,o=setInterval(()=>{a++,r(AA(e,a/n)),a>=n&&clearInterval(o)},320/n);return()=>clearInterval(o)},[e,t]),n}function NA(e){let t=e.currentTarget,n=t.getBoundingClientRect(),r=document.createElement(`span`);r.className=`hud-ripple`;let i=Math.max(n.width,n.height)*2;r.style.width=r.style.height=`${i}px`,r.style.left=`${e.clientX-n.left-i/2}px`,r.style.top=`${e.clientY-n.top-i/2}px`,t.appendChild(r),r.addEventListener(`animationend`,()=>r.remove(),{once:!0}),setTimeout(()=>r.remove(),900)}function PA({items:e,animations:t,onAction:n}){let[r,i]=(0,l.useState)(null),a=(0,l.useRef)(void 0);if((0,l.useEffect)(()=>()=>clearTimeout(a.current),[]),e.length===0)return null;let o=e=>{t!==`off`&&(i(e.id),clearTimeout(a.current),a.current=setTimeout(()=>i(null),650)),n(e)};return(0,p.jsxs)(he,{id:`launcher`,label:`Quick launch`,wholeBox:!0,testId:`launcher`,className:`hud hud-launcher${t===`full`?` hud-boot`:``}`,children:[(0,p.jsx)(`div`,{className:`hud-kicker`,children:`Quick launch`}),(0,p.jsx)(`ul`,{className:`hud-stack`,children:e.map((e,n)=>(0,p.jsx)(`li`,{className:`hud-tab hud-cut${r===e.id?` engaged`:``}${t===`full`?` hud-boot`:``}`,style:{"--i":n+1},children:(0,p.jsxs)(`button`,{type:`button`,className:`hud-tab-main`,"aria-label":e.label,onPointerDown:t===`off`?void 0:NA,onClick:()=>o(e),children:[(0,p.jsx)(`span`,{className:`hud-icon`,"aria-hidden":`true`,children:e.icon}),(0,p.jsx)(`span`,{className:`hud-tab-label`,children:e.label}),(0,p.jsx)(`span`,{className:`hud-tab-engaged`,"aria-hidden":`true`,children:`ENGAGED`}),(0,p.jsx)(`span`,{className:`hud-sweep`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`hud-scan`,"aria-hidden":`true`})]})},e.id))})]})}var FA=(e,t=18)=>(0,p.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e}),IA=()=>FA((0,p.jsx)(`path`,{d:`M7 4.5v15l12-7.5z`,fill:`currentColor`})),LA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`rect`,{x:`6`,y:`4.5`,width:`4`,height:`15`,fill:`currentColor`}),(0,p.jsx)(`rect`,{x:`14`,y:`4.5`,width:`4`,height:`15`,fill:`currentColor`})]})),RA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M5 5v14l10-7z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M18 5v14`})]})),zA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M19 5v14L9 12z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M6 5v14`})]})),BA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M3 7h3.5c3 0 4 2 5.5 5s2.500 5 5.500 5H21`}),(0,p.jsx)(`path`,{d:`M3 17h3.5c1.500 0 2.500-.6 3.400-1.800M13.500 8.800C14.500 7.600 15.500 7 17 7h4`}),(0,p.jsx)(`path`,{d:`m18.500 4.500 2.500 2.500-2.500 2.500M18.500 14.500l2.500 2.500-2.500 2.500`})]})),VA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M17 3l3 3-3 3`}),(0,p.jsx)(`path`,{d:`M4 11V9a3 3 0 0 1 3-3h13M7 21l-3-3 3-3`}),(0,p.jsx)(`path`,{d:`M20 13v2a3 3 0 0 1-3 3H4`})]})),HA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M4 9.500v5h3.500L12 18.500v-13L7.500 9.500z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`M15.500 9a4 4 0 0 1 0 6M18 6.500a7.500 7.500 0 0 1 0 11`})]})),UA=()=>FA((0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M4 9.500v5h3.500L12 18.500v-13L7.500 9.500z`,fill:`currentColor`}),(0,p.jsx)(`path`,{d:`m16 9 5 6M21 9l-5 6`})]})),WA=()=>FA((0,p.jsx)(`path`,{d:`M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5`})),GA=()=>FA((0,p.jsx)(`path`,{d:`M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5`})),KA=()=>FA((0,p.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})),qA=()=>FA((0,p.jsx)(`path`,{d:`M9 18V6l10-2v12`}),22),JA=56,YA=()=>({bars:new Float32Array(JA),bass:0,left:0,right:0});function XA(e,t,n,r,i){let a=n?.82:.9;if(t&&n){t.getByteFrequencyData(i);let n=Math.min(i.length,96);for(let t=0;t<JA;t++){let r=Math.min(n-1,Math.floor((t/JA)**1.6*n));e.bars[t]=Math.max((i[r]??0)/255,e.bars[t]*a)}}else if(n)for(let t=0;t<JA;t++)e.bars[t]=Math.max(.12+.28*Math.abs(Math.sin(r/420+t*.55)*Math.cos(r/900+t*.21)),e.bars[t]*a);else for(let t=0;t<JA;t++)e.bars[t]=e.bars[t]*a;let o=0;for(let t=0;t<6;t++)o+=e.bars[t];e.bass=Math.min(1,o/6*1.15);let s=0,c=0;for(let t=0;t<JA/2;t++)s+=e.bars[t],c+=e.bars[t+JA/2];e.left=Math.min(1,s/(JA/2)*1.6),e.right=Math.min(1,c/(JA/2)*3.2)}function ZA({progress:e,playing:t,cover:n,analyser:r,levels:i,visualizer:a,animate:o,size:s}){let c=(0,l.useRef)(null),u=(0,l.useRef)(null),d=(0,l.useRef)(new Uint8Array(new ArrayBuffer(128)));(0,l.useEffect)(()=>{let e=c.current,n=e?.getContext(`2d`);if(!e||!n||!o)return;let l=0,f=Math.min(2,window.devicePixelRatio||1);e.width=e.height=Math.round(s*f);let p=getComputedStyle(e).getPropertyValue(`--accent`).trim()||`#3fd8ff`,m=e=>{if(XA(i,r,t,e,d.current),u.current?.style.setProperty(`--bass`,i.bass.toFixed(3)),n.setTransform(f,0,0,f,0,0),n.clearRect(0,0,s,s),a){let e=s/2,t=s*.335,r=s*.135;n.lineCap=`round`,n.lineWidth=Math.max(1.5,s/90);for(let a=0;a<JA;a++){let o=a/JA*Math.PI*2-Math.PI/2,s=i.bars[a],c=2+s*r;n.strokeStyle=p,n.globalAlpha=.35+s*.65,n.beginPath(),n.moveTo(e+Math.cos(o)*t,e+Math.sin(o)*t),n.lineTo(e+Math.cos(o)*(t+c),e+Math.sin(o)*(t+c)),n.stroke()}n.globalAlpha=1}(t||!i.bars.every(e=>e<.01)||a)&&(l=requestAnimationFrame(m))};return l=requestAnimationFrame(m),()=>cancelAnimationFrame(l)},[r,t,a,o,s,i]);let f=Math.max(0,Math.min(1,e))*100;return(0,p.jsxs)(`div`,{ref:u,className:`hud-dial${t?` playing`:``}`,style:{width:s,height:s},role:`img`,"aria-label":`Playback dial`,children:[(0,p.jsxs)(`svg`,{className:`hud-dial-svg`,viewBox:`0 0 200 200`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{className:`hud-dial-ticks`,cx:`100`,cy:`100`,r:`96`}),(0,p.jsx)(`circle`,{className:`hud-dial-track`,cx:`100`,cy:`100`,r:`88`}),(0,p.jsx)(`circle`,{className:`hud-dial-arc`,cx:`100`,cy:`100`,r:`88`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 100 100)`}),(0,p.jsx)(`circle`,{className:`hud-dial-inner`,cx:`100`,cy:`100`,r:`62`}),(0,p.jsxs)(`g`,{className:`hud-needle`,children:[(0,p.jsx)(`line`,{x1:`100`,y1:`100`,x2:`100`,y2:`14`}),(0,p.jsx)(`circle`,{cx:`100`,cy:`14`,r:`2.500`})]})]}),(0,p.jsx)(`canvas`,{ref:c,className:`hud-spectrum`,style:{width:s,height:s},"aria-hidden":`true`}),(0,p.jsx)(`div`,{className:`hud-cover`,style:n?{backgroundImage:`url("${n}")`}:void 0,children:!n&&(0,p.jsx)(qA,{})})]})}var QA=e=>{let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},$A=new Map,ej=e=>{let t=Su(e);return t&&t.source===`local`?t.id:null},tj=e=>Su(e)?.source===`spotify`,nj=e=>Su(e)?.source===`soundcloud`,rj=e=>Su(e)?.source===`audius`,ij={spotify:`Spotify`,soundcloud:`SoundCloud`,audius:`Audius`};function aj(e){let[t,n]=(0,l.useState)(e?$A.get(e)??!1:!1);return(0,l.useEffect)(()=>{if(!e)return n(!1);if($A.has(e))return n($A.get(e));let t=!0,r=new Image;r.onload=()=>{$A.set(e,!0),t&&n(!0)},r.onerror=()=>{$A.set(e,!1),t&&n(!1)};let i=ej(e);return i?(r.src=`/api/music/cover/${i}`,()=>{t=!1}):n(!1)},[e]),e&&t?`/api/music/cover/${ej(e)}`:null}async function oj(e,t){let n=await fetch(`/api/music/library?q=${encodeURIComponent(e)}&limit=${t}`);return n.ok?await n.json():{tracks:[],total:0}}function sj(){let[e,t]=(0,l.useState)(null);return(0,l.useEffect)(()=>{let e=!0;return fetch(`/api/music/sources`).then(e=>e.ok?e.json():null).then(n=>{let r={};for(let e of[`spotify`,`soundcloud`,`audius`]){let t=n?.sources?.find(t=>t.id===e)?.status;t&&(r[e]={connected:t.connected,needs:t.needs})}e&&n&&t(r)}).catch(()=>{}),()=>{e=!1}},[]),e}async function cj(e,t,n){let r=await fetch(`/api/music/search?q=${encodeURIComponent(t)}&source=${e}&limit=${n}`);if(!r.ok)return{tracks:[],total:0};let i=((await r.json()).tracks??[]).map(e=>({id:e.ref,title:e.title,artist:e.artist,album:e.album,durationSec:e.durationSec}));return{tracks:i,total:i.length}}var lj=e=>({id:e.id,title:e.title,artist:e.artist,album:e.album,durationSec:e.durationSec});function uj({levels:e,animate:t,side:n}){let r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!t)return;let i=0,a=r.current,o=()=>{if(a){let t=n===`left`?e.left:e.right,r=Math.round(t*12);a.querySelectorAll(`i`).forEach((e,t)=>e.classList.toggle(`on`,t<r))}i=requestAnimationFrame(o)};return i=requestAnimationFrame(o),()=>cancelAnimationFrame(i)},[e,t,n]),(0,p.jsx)(`div`,{ref:r,className:`hud-levels ${n}`,"aria-hidden":`true`,children:Array.from({length:12},(e,t)=>(0,p.jsx)(`i`,{},t))})}function dj({player:e,anim:t}){let{state:n,dispatch:r}=e,i=(0,l.useCallback)(async()=>{if(n.queue.length>0)return r({type:`resume`});let e=await oj(``,500);r({type:`play`,tracks:e.tracks.map(lj),mode:`replace`,...n.shuffle?{shuffle:!0}:{}})},[n.queue.length,n.shuffle,r]),a=e=>n=>{t!==`off`&&NA(n),e()};return(0,p.jsxs)(`div`,{className:`hud-controls`,role:`group`,"aria-label":`Player controls`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Shuffle`,"aria-pressed":n.shuffle,title:`Shuffle`,onClick:()=>r({type:`shuffle`}),children:(0,p.jsx)(BA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Previous track`,title:`Previous`,onPointerDown:a(()=>{}),onClick:()=>r({type:`previous`}),children:(0,p.jsx)(zA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn hud-btn-main`,"aria-label":n.playing?`Pause`:`Play`,title:n.playing?`Pause`:`Play`,onPointerDown:a(()=>{}),onClick:()=>n.playing?r({type:`pause`}):void i(),children:n.playing?(0,p.jsx)(LA,{}):(0,p.jsx)(IA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Next track`,title:`Next`,onPointerDown:a(()=>{}),onClick:()=>r({type:`next`}),children:(0,p.jsx)(RA,{})}),(0,p.jsxs)(`button`,{type:`button`,className:`hud-btn${n.repeat===`off`?``:` on`}`,"aria-label":`Repeat: ${n.repeat}`,title:`Repeat: ${n.repeat}`,onClick:()=>r({type:`repeat`,mode:n.repeat===`off`?`all`:n.repeat===`all`?`one`:`off`}),children:[(0,p.jsx)(VA,{}),n.repeat===`one`&&(0,p.jsx)(`sup`,{children:`1`})]})]})}function fj({player:e}){let{state:t,dispatch:n}=e,r=t.duration>0?t.position/t.duration*100:0;return(0,p.jsxs)(`div`,{className:`hud-timeline`,children:[(0,p.jsx)(`span`,{className:`hud-time`,children:QA(t.position)}),(0,p.jsx)(`input`,{type:`range`,className:`hud-range`,"aria-label":`Position`,min:0,max:Math.max(1,Math.floor(t.duration)),step:1,value:Math.min(Math.floor(t.position),Math.max(1,Math.floor(t.duration))),style:{"--fill":`${r}%`},disabled:t.duration<=0,onChange:e=>n({type:`seek`,seconds:Number(e.target.value)})}),(0,p.jsxs)(`span`,{className:`hud-time`,children:[`-`,QA(Math.max(0,t.duration-t.position))]})]})}function pj({player:e}){let{state:t,dispatch:n}=e;return(0,p.jsxs)(`div`,{className:`hud-volume`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":t.muted?`Unmute`:`Mute`,onClick:()=>n({type:`mute`}),children:t.muted||t.volume===0?(0,p.jsx)(UA,{}):(0,p.jsx)(HA,{})}),(0,p.jsx)(`input`,{type:`range`,className:`hud-range`,"aria-label":`Volume`,min:0,max:100,value:t.muted?0:t.volume,style:{"--fill":`${t.muted?0:t.volume}%`},onChange:e=>n({type:`volume`,level:Number(e.target.value)})})]})}function mj({player:e,anim:t}){let{state:n,dispatch:r}=e,[i,a]=(0,l.useState)(n.queue.length?`queue`:`library`),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(`folder`),[d,f]=(0,l.useState)(null),m=sj(),h=[`spotify`,`soundcloud`,`audius`].filter(e=>m?.[e]?.connected),g=c!==`folder`&&h.includes(c)?c:null,_=g?m?.[g]?.needs:null;(0,l.useEffect)(()=>{if(i!==`library`)return;let e=!0;if(g&&!o.trim()){f(null);return}let t=()=>g?cj(g,o.trim(),30):oj(o,100),n=setTimeout(()=>void t().then(t=>e&&f(t)),o?250:0);return()=>{e=!1,clearTimeout(n)}},[i,o,g]);let v=i===`queue`?n.queue.map((e,t)=>({track:e,index:t})):(d?.tracks??[]).map((e,t)=>({track:lj(e),index:t}));return(0,p.jsxs)(`div`,{className:`hud-playlist`,children:[(0,p.jsxs)(`div`,{className:`hud-tabs`,role:`tablist`,children:[[`queue`,`library`].map(e=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,className:`hud-chip${i===e?` on`:``}`,onClick:()=>a(e),children:e===`queue`?`Queue (${n.queue.length})`:`Library`},e)),i===`queue`&&n.queue.length>0&&(0,p.jsx)(`button`,{type:`button`,className:`hud-chip`,onClick:()=>r({type:`clear`}),children:`Clear`})]}),i===`library`&&h.length>0&&(0,p.jsx)(`div`,{className:`hud-tabs`,role:`tablist`,"aria-label":`Where to look`,children:[`folder`,...h].map(e=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":c===e,className:`hud-chip${c===e?` on`:``}`,onClick:()=>{u(e),f(null)},children:e===`folder`?`Folder`:ij[e]},e))}),i===`library`&&(0,p.jsx)(`input`,{className:`hud-search`,type:`search`,placeholder:`Search title, artist or album`,"aria-label":`Search the music`,value:o,onChange:e=>s(e.target.value)}),(0,p.jsxs)(`ul`,{className:`hud-list`,children:[v.length===0&&(0,p.jsx)(`li`,{className:`hud-empty`,children:i===`queue`?`The queue is empty.`:g&&!o.trim()?`Type to search ${ij[g]}.`:d?`No music matches.`:`Loading…`}),i===`library`&&g&&_&&(0,p.jsx)(`li`,{className:`hud-empty`,children:_}),v.map(({track:e,index:a},o)=>{let s=i===`queue`&&a===n.index;return(0,p.jsxs)(`li`,{className:`hud-tab hud-cut${s?` current`:``}${t===`full`?` hud-boot`:``}`,style:{"--i":Math.min(o,12)},children:[(0,p.jsxs)(`button`,{type:`button`,className:`hud-tab-main`,"aria-current":s?`true`:void 0,onPointerDown:t===`off`?void 0:NA,onClick:()=>r(i===`queue`?{type:`jump`,index:a}:{type:`play`,tracks:(d?.tracks??[]).map(lj),mode:`replace`,start:a}),children:[(0,p.jsx)(`span`,{className:`hud-tab-title`,children:e.title}),(0,p.jsxs)(`small`,{children:[e.artist||e.album,tj(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SPOTIFY`}),nj(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SOUNDCLOUD`}),rj(e.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`AUDIUS`})]})]}),i===`library`&&(0,p.jsx)(`button`,{type:`button`,className:`hud-mini`,"aria-label":`Add ${e.title} to the queue`,title:`Add to the queue`,onClick:()=>r({type:`play`,tracks:[e],mode:`add`}),children:`+`}),i===`queue`&&(0,p.jsx)(`button`,{type:`button`,className:`hud-mini`,"aria-label":`Remove ${e.title} from the queue`,title:`Remove`,onClick:()=>r({type:`remove`,index:a}),children:`×`})]},`${e.id}-${a}`)})]})]})}function hj({player:e,music:t,animations:n}){let{state:r,dispatch:i,current:a,blocked:o,notice:s,analyser:c,unlock:u}=e,d=(0,l.useMemo)(YA,[]),f=aj(a?.id),m=r.view===`full`,h=MA(a?.title??``,n===`full`);if(!t?.folderSet||r.view===`hidden`)return null;let g=r.duration>0?r.position/r.duration:0,_=n!==`off`;return(0,p.jsxs)(he,{id:`music`,label:`Music player`,wholeBox:!0,testId:`music`,className:`hud hud-music hud-cut ${m?`full`:`mini`}${r.playing?` playing`:``}${n===`full`?` hud-boot`:``}`,children:[(0,p.jsxs)(`header`,{className:`hud-music-head`,children:[(0,p.jsx)(`span`,{className:`hud-kicker`,children:`Media player`}),(0,p.jsxs)(`span`,{className:`hud-head-actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":m?`Smaller player`:`Bigger player`,title:m?`Smaller`:`Bigger`,onClick:()=>i({type:`view`,view:m?`mini`:`full`}),children:m?(0,p.jsx)(GA,{}):(0,p.jsx)(WA,{})}),(0,p.jsx)(`button`,{type:`button`,className:`hud-btn`,"aria-label":`Hide the player`,title:`Hide (the music keeps playing)`,onClick:()=>i({type:`view`,view:`hidden`}),children:(0,p.jsx)(KA,{})})]})]}),(0,p.jsxs)(`div`,{className:`hud-music-body`,children:[(0,p.jsxs)(`div`,{className:`hud-music-left`,children:[m&&(0,p.jsx)(uj,{levels:d,animate:_,side:`left`}),(0,p.jsx)(ZA,{progress:g,playing:r.playing,cover:f,analyser:c,levels:d,visualizer:t.visualizer,animate:_,size:m?250:112}),m&&(0,p.jsx)(uj,{levels:d,animate:_,side:`right`})]}),(0,p.jsxs)(`div`,{className:`hud-music-main`,children:[(0,p.jsxs)(`div`,{className:`hud-now`,"aria-live":`polite`,children:[(0,p.jsx)(`b`,{className:`hud-title`,children:a?h:`Nothing playing`}),(0,p.jsxs)(`small`,{className:`hud-sub`,children:[a?[a.artist,a.album].filter(Boolean).join(` — `):`Press play, or ask for some music.`,a&&tj(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SPOTIFY`}),a&&nj(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`SOUNDCLOUD`}),a&&rj(a.id)&&(0,p.jsx)(`em`,{className:`hud-source`,children:`AUDIUS`}),e.remote&&(0,p.jsx)(`em`,{className:`hud-source`,children:`THIS PC`})]})]}),(0,p.jsx)(fj,{player:e}),(0,p.jsx)(dj,{player:e,anim:n}),m&&(0,p.jsx)(pj,{player:e}),s&&(0,p.jsx)(`p`,{className:`hud-notice`,role:`status`,children:s}),o&&(0,p.jsx)(`button`,{type:`button`,className:`hud-unlock`,onClick:u,children:`Tap to enable sound`})]}),m&&(0,p.jsx)(mj,{player:e,anim:n})]})]})}var gj=/^spotify:/,_j=class{local;makeSpotify;active;spotify=null;listeners=new Map;wrapped=new Map;vol=1;mute=!1;pre=``;constructor(e,t){this.local=e,this.makeSpotify=t,this.active=e}get element(){return this.local}get error(){return this.active.error??null}wrap(e){let t=this.wrapped.get(e);return t||(t={local:()=>{this.active===this.local&&e()},spot:()=>{this.spotify&&this.active===this.spotify&&e()}},this.wrapped.set(e,t)),t}spot(){if(!this.spotify){let e=this.makeSpotify();e.volume=this.vol,e.muted=this.mute,e.preload=this.pre;for(let[t,n]of this.listeners)for(let r of n)e.addEventListener(t,this.wrap(r).spot);this.spotify=e}return this.spotify}dispose(){this.spotify?.dispose?.(),this.spotify=null,this.active=this.local}get src(){return this.active.src}set src(e){let t=gj.test(e)?this.spot():this.local;t===this.active?e===``&&this.active.pause():(this.active.pause(),this.active=t),this.active.src=e}get currentTime(){return this.active.currentTime}set currentTime(e){this.active.currentTime=e}get duration(){return this.active.duration}get paused(){return this.active.paused}get volume(){return this.vol}set volume(e){this.vol=e,this.local.volume=e,this.spotify&&(this.spotify.volume=e)}get muted(){return this.mute}set muted(e){this.mute=e,this.local.muted=e,this.spotify&&(this.spotify.muted=e)}get preload(){return this.pre}set preload(e){this.pre=e,this.local.preload=e,this.spotify&&(this.spotify.preload=e)}play(){return this.active.play()}pause(){this.active.pause()}addEventListener(e,t){let n=this.listeners.get(e);n||this.listeners.set(e,n=new Set),n.add(t);let r=this.wrap(t);this.local.addEventListener(e,r.local),this.spotify?.addEventListener(e,r.spot)}removeEventListener(e,t){this.listeners.get(e)?.delete(t);let n=this.wrap(t);this.local.removeEventListener(e,n.local),this.spotify?.removeEventListener(e,n.spot)}},vj=/^spotify:([A-Za-z0-9_-]{1,64})$/,yj=`Spotify Premium is needed to play on this screen.`;async function bj(){let e=await fetch(`/api/music/spotify/token`,{cache:`no-store`});if(!e.ok)throw Error(`Spotify is not connected.`);return(await e.json()).accessToken}function xj(){let e=window;return e.Spotify?Promise.resolve(e.Spotify):new Promise((t,n)=>{e.onSpotifyWebPlaybackSDKReady=()=>e.Spotify?t(e.Spotify):n(Error(`no sdk`));let r=document.createElement(`script`);r.src=`https://sdk.scdn.co/spotify-player.js`,r.async=!0,r.onerror=()=>n(Error(`blocked`)),document.head.appendChild(r)})}function Sj(e){let t=e.fetch??((...e)=>fetch(...e)),n=e.now??Date.now,r=new Map,i=null,a=null,o=null,s=null,c=!1,l=null,u=null,d=0,f=0,p=0,m=!0,h=1,g=!1,_,v=e=>{for(let t of r.get(e)??[])t()},y=()=>g?0:h,b=()=>{_&&clearInterval(_),_=void 0},x=()=>{_||=setInterval(()=>v(`timeupdate`),250)},S={error:null,preload:``,get src(){return s??``},set src(e){let t=vj.exec(e);c=e!==``&&!t,s=t?e:null,l=null,u=null,d=0,p=0,S.error=null,t||b()},get currentTime(){return m?d:d+(n()-f)/1e3},set currentTime(e){d=e,f=n(),i?.seek(Math.round(e*1e3)).catch(()=>{})},get duration(){return p},get paused(){return m},get volume(){return h},set volume(e){h=e,i?.setVolume(y()).catch(()=>{})},get muted(){return g},set muted(e){g=e,i?.setVolume(y()).catch(()=>{})},async play(){if(c||!s)throw Error(`That is not a Spotify track.`);let r=vj.exec(s),a=s,o=await T();if(s!==a)return;if(l===s){await i?.resume().catch(()=>{}),m=!1,f=n(),x();return}let u=await e.getToken().catch(()=>null);if(!u)throw C(`Spotify is not connected. Connect it in Plugins, Spotify.`);let d;try{d=await t(`https://api.spotify.com/v1/me/player/play?device_id=${encodeURIComponent(o)}`,{method:`PUT`,headers:{authorization:`Bearer ${u}`,"content-type":`application/json`},body:JSON.stringify({uris:[`spotify:track:${r[1]}`]})})}catch{throw C(`Friend could not reach Spotify right now.`)}if(d.status===403)throw C(yj);if(d.status===401)throw C(`Spotify sign-in has ended. Reconnect Spotify in Plugins, Spotify.`);if(d.status===404)throw C(`Spotify could not find this screen or that track.`);if(d.status===429)throw C(`Spotify is asking Friend to slow down. Try again in a minute.`);if(!d.ok)throw C(`Spotify could not play that.`);s===a&&(l=a,m=!1,f=n(),x())},pause(){m=!0,d+=(n()-f)/1e3,f=n(),b(),i?.pause().catch(()=>{})},dispose(){b();try{i?.disconnect()}catch{}i=null,a=null,s=null,l=null},addEventListener(e,t){let n=r.get(e);n||r.set(e,n=new Set),n.add(t)},removeEventListener(e,t){r.get(e)?.delete(t)}};function C(e){S.error=e,m=!0,b(),v(`error`);let t=Error(e),n=o;return o=null,n?.reject(t),t}function w(e){if(!e)return;d=e.position/1e3,f=n(),p=e.duration/1e3,m=e.paused,v(`timeupdate`),v(`loadedmetadata`),v(`durationchange`);let t=s?vj.exec(s)?.[1]:void 0;t&&e.paused&&e.position===0&&u!==s&&(e.track_window.previous_tracks??[]).some(e=>e.id===t)&&(u=s,b(),v(`ended`))}function T(){if(a)return Promise.resolve(a);if(o)return o.promise;let t,n,r=new Promise((e,r)=>{t=e,n=r}),s={promise:r,resolve:t,reject:n};o=s;let c=setTimeout(()=>{o===s&&C(`Spotify's player did not start. Check that this browser allows Spotify's player, then try again.`)},e.readyTimeoutMs??15e3),l=()=>clearTimeout(c);return r.then(l,l),(async()=>{try{if(!i){let t;try{t=await(e.loadSdk??xj)()}catch{o===s&&C(`Spotify's player could not be loaded. Check that nothing blocks sdk.scdn.co.`);return}let n=new t.Player({name:e.deviceName??`Friend`,volume:y(),getOAuthToken:t=>{e.getToken().then(t,()=>{})}});i=n,n.addListener(`ready`,(e=>{a=e.device_id;let t=o;o=null,t?.resolve(e.device_id)})),n.addListener(`not_ready`,(()=>{a=null})),n.addListener(`player_state_changed`,(e=>w(e))),n.addListener(`account_error`,(()=>void C(yj))),n.addListener(`authentication_error`,(()=>void C(`Spotify sign-in has ended. Reconnect Spotify in Plugins, Spotify.`))),n.addListener(`initialization_error`,(()=>void C(`Spotify's player does not work in this browser.`))),n.addListener(`playback_error`,(()=>void C(`Spotify could not play that.`)))}!await i.connect()&&o===s&&C(`Spotify's player could not connect.`)}catch{o===s&&C(`Spotify's player could not connect.`)}})(),r}return S}var Cj=e=>{let t=Su(e);return t?t.source===`local`?`/api/music/track/${t.id}`:t.source===`soundcloud`||t.source===`audius`?`/api/music/stream/${e}`:e:`/api/music/track/${e}`},wj=(e,t)=>Xu(e,t),Tj=`friend.music`,Ej=1e3,Dj=1.5,Oj=()=>{try{return JSON.parse(localStorage.getItem(Tj)??`{}`)}catch{return{}}},kj=e=>{try{localStorage.setItem(Tj,JSON.stringify({volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:e.view}))}catch{}};function Aj({music:e,cmd:t,send:n,connection:r,createAudio:i,createSpotify:a,remote:o=!1}){let[s,c]=(0,l.useReducer)(wj,void 0,()=>{let e=Oj();return Ku({volume:e.volume??70,shuffle:e.shuffle??!1,repeat:e.repeat??`all`,view:e.view??`mini`})}),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useRef)(!1),v=(0,l.useRef)(s);v.current=s;let y=(0,l.useRef)(!1),b=(0,l.useRef)(null),x=(0,l.useRef)(0),S=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!e||S.current)return;S.current=!0;let t=Oj();c({type:`volume`,level:t.volume??e.volume}),c({type:`repeat`,mode:t.repeat??e.repeat}),(t.shuffle??e.shuffle)&&c({type:`shuffle`,on:!0}),c({type:`view`,view:t.view??e.startView}),t.muted&&c({type:`mute`,on:!0})},[e]);let C=()=>{if(!g.current){let e=new _j(i?i():new Audio,a??(()=>Sj({getToken:bj})));e.preload=`auto`,g.current=e}return g.current},w=(0,l.useRef)(!1),T=(0,l.useCallback)(()=>{let e=g.current;if(e&&e.src){w.current=!0;try{let t=e.play();t&&typeof t.then==`function`?t.then(()=>{w.current=!1,d(!1)},()=>{w.current=!1;let e=g.current?.error??null;e?p(e):d(!0)}):(w.current=!1,d(!1))}catch{w.current=!1,d(!0)}E.current||O()}},[]),E=(0,l.useRef)(!1),D=(0,l.useRef)(null),O=()=>{let e=g.current,t=e instanceof _j?e.element:e,n=typeof window<`u`?window.AudioContext??window.webkitAudioContext:void 0;if(t&&n&&typeof t.play==`function`)try{let e=new n;D.current=e;let r=e.createMediaElementSource(t),i=e.createAnalyser();i.fftSize=256,i.smoothingTimeConstant=.82,r.connect(i),i.connect(e.destination),E.current=!0,h(i)}catch{E.current=!0}};(0,l.useEffect)(()=>{if(o)return;let e=C(),t=0,n=()=>{let n=Date.now();n-t<250||(t=n,c({type:`time`,position:e.currentTime||0,duration:Number.isFinite(e.duration)?e.duration:0}))},r=()=>c({type:`time`,position:e.currentTime||0,duration:Number.isFinite(e.duration)?e.duration:0}),i=()=>c({type:`ended`}),a=()=>{let t=e.error??null;p(t),c(t?{type:`pause`}:{type:`failed`})};return e.addEventListener(`timeupdate`,n),e.addEventListener(`loadedmetadata`,r),e.addEventListener(`durationchange`,r),e.addEventListener(`ended`,i),e.addEventListener(`error`,a),()=>{e.removeEventListener(`timeupdate`,n),e.removeEventListener(`loadedmetadata`,r),e.removeEventListener(`durationchange`,r),e.removeEventListener(`ended`,i),e.removeEventListener(`error`,a),e.pause(),D.current?.close().catch(()=>{}),D.current=null,e.dispose(),b.current=null,g.current=null,E.current=!1,h(null)}},[o]),(0,l.useEffect)(()=>{o&&c({type:`stop`})},[o]);let k=s.index>=0?s.queue[s.index]??null:null;(0,l.useEffect)(()=>{let e=g.current;if(o||!e)return;let t=k?.id??null;if(t!==b.current){if(b.current=t,!t){e.pause(),e.src=``;return}p(null),e.src=Cj(t),s.playing&&T()}},[k?.id,s.playing,T,o]),(0,l.useEffect)(()=>{let e=g.current;!o&&e&&e.src&&(s.playing&&e.paused&&!_.current&&!w.current?T():!s.playing&&!e.paused&&e.pause())},[s.playing,s.position,T,o]),(0,l.useEffect)(()=>{let e=g.current;e&&(e.volume=s.volume/100*gE.level,e.muted=s.muted)},[s.volume,s.muted]),(0,l.useEffect)(()=>gE.subscribe(e=>{let t=g.current;t&&(t.volume=v.current.volume/100*e)}),[]),(0,l.useEffect)(()=>{let e=g.current;e&&e.src&&Math.abs((e.currentTime||0)-s.position)>Dj&&(e.currentTime=s.position)},[s.position]),(0,l.useEffect)(()=>kj(s),[s.volume,s.muted,s.shuffle,s.repeat,s.view]),(0,l.useEffect)(()=>{if(!t||t.n===x.current)return;x.current=t.n;let e=Zu(t.command);e&&c(e)},[t]),(0,l.useEffect)(()=>{let e=()=>{y.current=!0,_.current&&T()};return window.addEventListener(`pointerdown`,e,{passive:!0}),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[T]),_.current=u;let A=(0,l.useRef)(0);return(0,l.useEffect)(()=>{if(r!==`open`||o)return;let e=()=>{let e=v.current,t=e.index>=0?e.queue[e.index]:void 0;A.current=Date.now(),n({type:`music.state`,state:{playing:e.playing,trackId:t?.id??null,title:t?.title??``,artist:t?.artist??``,album:t?.album??``,position:e.position,duration:e.duration,volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:e.view,queue:e.queue.slice(0,50).map(e=>({id:e.id,title:e.title.slice(0,200)})),index:e.index,active:(typeof document>`u`||document.visibilityState===`visible`)&&y.current}})};e();let t=setInterval(()=>s.playing&&Date.now()-A.current>=Ej&&e(),Ej);return()=>clearInterval(t)},[r,o,k?.id,s.playing,s.volume,s.muted,s.shuffle,s.repeat,s.view,s.queue.length,s.index]),(0,l.useEffect)(()=>{let e=typeof navigator<`u`?navigator.mediaSession:void 0;if(e&&!o)try{k&&typeof MediaMetadata<`u`&&(e.metadata=new MediaMetadata({title:k.title,artist:k.artist,album:k.album,artwork:[{src:`/api/music/cover/${k.id}`}]})),e.playbackState=s.playing?`playing`:k?`paused`:`none`,e.setActionHandler(`play`,()=>c({type:`resume`})),e.setActionHandler(`pause`,()=>c({type:`pause`})),e.setActionHandler(`previoustrack`,()=>c({type:`previous`})),e.setActionHandler(`nexttrack`,()=>c({type:`next`})),e.setActionHandler(`seekto`,e=>typeof e.seekTime==`number`&&c({type:`seek`,seconds:e.seekTime}))}catch{}},[k?.id,s.playing,o]),{remote:!1,state:s,dispatch:c,current:k,blocked:u,notice:f,analyser:m,unlock:T,audio:g}}function jj(e,t){if(!e)return{state:{queue:[],index:-1,playing:!1,position:0,duration:0,volume:70,muted:!1,shuffle:!1,repeat:`all`,view:t},current:null};let n=e.queue.map((t,n)=>n===e.index?{id:t.id,title:e.title||t.title,artist:e.artist,album:e.album,durationSec:e.duration>0?e.duration:null}:{id:t.id,title:t.title,artist:``,album:``,durationSec:null});return{state:{queue:n,index:e.index,playing:e.playing,position:e.position,duration:e.duration,volume:e.volume,muted:e.muted,shuffle:e.shuffle,repeat:e.repeat,view:t},current:e.index>=0?n[e.index]??null:null}}function Mj({local:e,host:t,send:n}){let r=e.state.view,{state:i,current:a}=(0,l.useMemo)(()=>jj(t,r),[t,r]),o=e.dispatch,s=(0,l.useCallback)(e=>{if(e.type===`view`)return o(e);let t=Qu(e);t&&n({type:`music.remote`,command:t})},[o,n]);return(0,l.useMemo)(()=>({...e,remote:!0,state:i,dispatch:s,current:a,blocked:!1,notice:null,analyser:null,unlock:()=>{}}),[e,i,s,a])}function Nj(e){let t=new URLSearchParams(e).get(`music`);return t===`connected`?{level:`info`,text:`Spotify is connected. Ask Friend to play something.`}:t===`failed`?{level:`warn`,text:`Spotify did not connect. Open Plugins, Spotify and press Connect again.`}:null}function Pj({onSignedOut:e}){let{state:t,send:n,dispatch:r,voice:i,handsFree:a,useHere:o}=iA(e);gA(i),_A(i),CA(n,t.connection);let[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(void 0),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(be),C=e=>{U(e),S(e)},w=x===`orb`?We:xe,[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(0),[k,A]=(0,l.useState)(null),j=fe(t.view),ee=t.music?.output===`host`,M=Aj({music:t.music,cmd:t.musicCmd,send:n,connection:t.connection,remote:ee}),P=Mj({local:M,host:t.hostMusic,send:n}),F=ee?P:M,te=t.hud?.animations??`full`,I=e=>{let{type:i,value:a}=e.action;if(i===`url`)window.open(a,`_blank`,`noopener,noreferrer`);else if(i===`prompt`)n({type:`chat.send`,text:a});else if(i===`music`||i===`panel`&&a===`music`){if(!t.music?.folderSet){r({type:`alert.add`,level:`info`,text:`No music folder is chosen yet. Pick one in Settings, Widgets, and the player opens.`}),b(`widgets`);return}if(i===`panel`){j.toggle(`music`,!0),F.state.view===`hidden`&&F.dispatch({type:`view`,view:`mini`});return}let e=Zu({action:a});e&&F.dispatch(e)}else a===`plugins`?g(!0):a===`settings`?b(`model`):(a===`chat`||a===`tasks`)&&j.toggle(a,!0)},ne=(0,l.useMemo)(()=>s?{...t,objects:[],captions:``}:t,[s,t]),ie=(0,l.useRef)(!1);(0,l.useEffect)(()=>{ie.current||!t.voice.available||t.voice.enrolled||(ie.current=!0,r({type:`alert.add`,level:`info`,text:`Voice recognition is not set up. Press Esc, then Enroll my voice.`}))},[t.voice.available,t.voice.enrolled,r]);let oe=ae(),se=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(!oe||se.current||t.connection!==`open`)return;se.current=!0;let e=!1;try{e=localStorage.getItem(`friend.touchHint`)===`1`,localStorage.setItem(`friend.touchHint`,`1`)}catch{}e||r({type:`alert.add`,level:`info`,text:`Hold the round mic button to talk, or tap it once to start and again to send. The keyboard button types; the menu button opens settings.`})},[oe,t.connection,r]);let ce=t.uiOpen?.n??0,le=t.uiOpen?.integration;(0,l.useEffect)(()=>{ce!==0&&(v(le),g(!0))},[ce,le]);let ue=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(ue.current)return;ue.current=!0;let e=Nj(window.location.search);e&&(r({type:`alert.add`,level:e.level,text:e.text}),window.history.replaceState(null,``,window.location.pathname))},[r]);let de=(0,l.useRef)(!1);(0,l.useEffect)(()=>{de.current||t.connection!==`open`||(de.current=!0,fetch(`/api/history`).then(e=>e.ok?e.json():[]).then(e=>r({type:`chat.seed`,lines:e})).catch(()=>{}))},[t.connection,r]),(0,l.useEffect)(()=>{t.connection===`open`&&n({type:`ui.panels`,open:[...j.show.chat?[`chat`]:[],...j.show.tasks?[`tasks`]:[]]})},[t.connection,j.show.chat,j.show.tasks,n]);let R=(0,l.useRef)(!1);(0,l.useEffect)(()=>{t.viewKnown&&t.view===`minimal`&&!R.current&&(R.current=!0,r({type:`alert.add`,level:`info`,text:`The view is Minimal, so the status line and clock are hidden. Press Esc, then View, to bring them back.`}))},[t.viewKnown,t.view,r]);let z=e=>{ht.save({view:e}).catch(e=>r({type:`alert.add`,level:`warn`,text:e.message}))},pe=(0,l.useMemo)(()=>L({notify:e=>r({type:`alert.add`,level:`info`,text:e}),openSettings:()=>b(`model`),openLook:()=>b(`look`),openConnectors:()=>E(!0),openPlugins:()=>g(!0),openVoice:t.voice.available?()=>d(!0):null,muted:s,setMuted:c,cameraOn:t.camera.enabled,setCamera:e=>r({type:`camera.enable`,value:e}),clearScreen:()=>{for(let e of t.objects)n({type:`stage.event`,objectId:e.id,event:`dismiss`})},statusLine:()=>nt({connection:t.connection,deviceOnline:t.deviceOnline,approval:t.approval,voiceMode:t.voice.mode,busy:t.busy,activity:t.activity}).text,endSession:t=>{fetch(t===`lock`?`/api/lock`:`/api/logout`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).catch(()=>{}).finally(e)},panelOn:e=>j.show[e],setPanel:(e,t)=>j.toggle(e,t),view:t.view,setView:z,openHelp:A,resetLayout:()=>{B(),window.location.reload()}}),[r,n,s,e,j.show,j.toggle,t.view,t.voice.available,t.voice.mode,t.camera.enabled,t.objects,t.connection,t.deviceOnline,t.approval,t.busy,t.activity]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(SD,{state:ne,send:n,dispatch:r,voice:i,slash:pe,onMenu:()=>O(e=>e+1)}),(0,p.jsxs)(at,{approval:t.approval,challenge:t.challenge,cameraStream:t.camera.stream,alerts:t.alerts,connection:t.connection,deviceOnline:t.deviceOnline,voiceMode:t.voice.mode,busy:t.busy,activity:t.activity,showStatus:t.viewKnown&&j.show.status,showClock:t.viewKnown&&j.show.clock,profile:t.viewKnown&&j.show.profile?{ownerName:t.ownerName,speaker:t.speaker}:null,assistantName:t.assistantName,hud:t.hud,send:n,dispatch:r,children:[t.viewKnown&&j.show.chat&&(0,p.jsx)(ge,{lines:t.chat,live:t.chatLive,onSend:e=>n({type:`chat.send`,text:e}),onClose:()=>j.toggle(`chat`,!1)}),t.viewKnown&&j.show.tasks&&(0,p.jsx)(ve,{busy:t.busy,onClose:()=>j.toggle(`tasks`,!1)}),t.viewKnown&&j.show.launcher&&t.hud&&(0,p.jsx)(PA,{items:t.hud.launcher,animations:te,onAction:I}),t.viewKnown&&j.show.music&&(0,p.jsx)(hj,{player:F,music:t.music,animations:te}),u&&(0,p.jsx)(dA,{onClose:()=>d(!1)}),f&&(0,p.jsx)(OA,{onClose:()=>m(!1)}),h&&(0,p.jsx)($d,{variant:x===`orb`?`holo`:`classic`,..._?{initialConfigure:_}:{},onClose:()=>{g(!1),v(void 0)}}),y&&(0,p.jsx)(dS,{initialTab:y,variant:x===`orb`?`holo`:`classic`,onClose:()=>b(null)}),T&&(0,p.jsx)(N,{variant:x===`orb`?`holo`:`classic`,onClose:()=>E(!1)}),k&&(0,p.jsx)(re,{commands:k,onClose:()=>A(null)})]}),(0,p.jsx)(w,{voiceMode:t.voice.mode,busy:t.busy,onClassic:()=>C(`classic`),onOrb:()=>C(`orb`),muted:s,onToggleMute:()=>c(e=>!e),onSignedOut:e,voiceAvailable:t.voice.available,voiceEnrolled:t.voice.enrolled,onEnroll:()=>d(!0),onHousehold:()=>m(!0),handsFreeOn:a.on,onToggleHandsFree:a.supported?a.toggle:void 0,assistantName:t.assistantName,onPlugins:()=>g(!0),onSettings:e=>b(e??`model`),onConnectors:()=>E(!0),cameraOn:t.camera.enabled,onToggleCamera:()=>r({type:`camera.enable`,value:!t.camera.enabled}),chatOn:j.show.chat,onToggleChat:()=>j.toggle(`chat`),tasksOn:j.show.tasks,onToggleTasks:()=>j.toggle(`tasks`),musicOn:j.show.music,onToggleMusic:()=>j.toggle(`music`),launcherOn:j.show.launcher,onToggleLauncher:()=>j.toggle(`launcher`),view:t.view,onView:z,openRequest:D}),t.connection===`elsewhere`&&(0,p.jsx)(vA,{onUseHere:o})]})}function Fj(){let[e,t]=(0,l.useState)(`loading`);return(0,l.useEffect)(()=>{let e=!0,n=n=>e&&t(n);return(async()=>{try{if(!(await(await fetch(`/api/state`)).json()).hasOwner)return n(`setup`);let e=await(await fetch(`/api/session`,{cache:`no-store`})).json();n(e.signedIn===!0?`stage`:`login`)}catch{n(`login`)}})(),()=>{e=!1}},[]),e===`loading`?(0,p.jsx)(`div`,{className:`boot`,"aria-busy":`true`}):e===`setup`?(0,p.jsx)(g,{onDone:()=>t(`login`)}):e===`login`?(0,p.jsx)(h,{onLoggedIn:()=>t(`stage`)}):(0,p.jsx)(Pj,{onSignedOut:()=>t(`login`)})}(0,u.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(l.StrictMode,{children:(0,p.jsx)(Fj,{})}));
|